Giter Club home page Giter Club logo

Comments (2)

v-ein avatar v-ein commented on May 27, 2024

The file dialog behaves much like a regular dpg.window (it's a window, after all). In particular, when you click OK or Cancel, it doesn't get deleted - instead, it gets hidden. This way you can query some properties from it or reuse the dialog widget later.

You can see it by adding the following line to your example:

dpg.show_item_registry()

Look at the File Dialogs section in the Item Registry.
image
You can even bring it back by clicking the Show button in the Item Registry.

So when you click the Load button in your examlpe second time, there's already a file dialog in the GUI with the tag "file_selector". DPG actually tells you that straight, before the first SystemError message:

Exception:
Error:     [1000]
Command:   add alias
Item:      0
Label:     Not found
Item Type: Unknown
Message:   Alias already exists

The same would happen if you were creating a dpg.window that way. When the window is closed, it remains hidden until you delete it explicitly with dpg.delete_item().

It is perfectly normal to use a tag with dpg.file_dialog, as long as your code manages the item lifetime properly:

  • Either delete the file dialog after OK/Cancel and re-create each time,
  • or create it once (probably before first use) and then use dpg.show("file_selector") instead of creating the file dialog again.

from dearpygui.

whitews avatar whitews commented on May 27, 2024

Hi Vladimir,

Thanks for the explanation. That logic and message is what made me try removing the tag to see if it fixes the problem. I get that is how it works, but the documentation doesn't mention this and the example there uses a tag without managing the dialog.

In any other GUI library I've used, I don't recall dialog windows having to managed this way. Just my opinion, but this feels like an implementation detail that should be handled in the library itself. It is nice that it would be an option to keep an instance of the dialog and show / hide it manually, but again, maybe something that should be handled automatically by default.

Also, I found in debug mode it crashes the whole program. In normal running mode, it emits the error I posted but the app remains open and an additional file dialog is opened (if the first one wasn't closed).

from dearpygui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.