-
Beginner, here: Trying to pass an object (doc) to a call back function (new_figure_callback), that is supposed to contain some UUID of interest (doc.win), but somehow, I cannot use it within the call back function. Hints, please. Below, please find minimal test program and error message. Test programs:
Error message:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The problem is that you are calling So you could just switch over to def new_doc_callback():
doc = Document()
with dpg.window(label="New doc", width=800, height=600) as window:
doc.win = window
dpg.add_button(label="New Figure", callback=new_figure_callback, user_data=doc, parent=doc.win) Note that the official documentation for the two functions states that |
Beta Was this translation helpful? Give feedback.
The problem is that you are calling
dpg.window()
instead ofdpg.add_window()
. If you check the type of the value returned by each of those functions, then you would see that the former returns something like<contextlib._GeneratorContextManager object at 0x7f5cda637910>
whereas the latter returns an integer (i.e. the ID that you are looking for).So you could just switch over to
dpg.add_window()
. If you absolutely wanted to usedpg.window()
, then you could do something like: