-
-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widget IDs are not cleared when a window closes #2514
Comments
Thanks for the report. If you're able to provide actual code for a minimal reproduction example, rather than a "word description" of the problem, that would be a lot more helpful for debugging purposes, as it guarantees we're looking at the same problem you are. |
The repro is something along the lines: import toga
class SendsDialog(toga.Window):
def __init__(self, device_id, input_id):
super().__init__(title="Edit Sends", size=(400, 200))
self.sends_content = toga.Box()
self.input = input_id
self.device = device_id
self.content = self.sends_content
def build(self):
path = f"/devices/0/inputs/0/sends/0/Gain/value"
sendname = "AUX 1"
val = -144.0
default = -144.0
min = -144.0
max = 12.0
label = toga.Label(f"{sendname} Gain")
edit = toga.NumberInput(id=path, step=1.0, min=min, max = max, value = val if val is not None else default, on_change=self.on_prop_float_change)
self.sends_content.add(label)
self.sends_content.add(edit)
self.sends_content.add(toga.Button("&Close", on_press=self.close_window))
async def on_prop_float_change(self, widget, *args, **kwargs):
pass # Do nothing
def close_window(self, widget, *args, **kwargs):
self.close()
class Repro(toga.App):
def startup(self):
self.on_exit = self.handle_exit
self.main_window = toga.MainWindow(title=f"{self.formal_name} [Loading]")
self.main_container = toga.Box(
style=Pack(direction=COLUMN, padding=10),
)
self.sends_btn = toga.Button("&Sends", on_press=self.open_sends)
self.main_container.content.append(self.sends_btn)
self.main_window.content = self.main_container
self.main_window.show()
async def close_app(self, widget, **kwargs):
self.exit()
def open_sends(self, widget, *args, **kwargs):
dialog = SendsDialog(0, 0)
dialog.build()
dialog.show()
def main():
return Repro() |
A simplified reproducible example of the above would be:
The title should be changed to clarify that the bug is with widget IDs not with window IDs. |
@proneon267 Thanks for that simplification, I wasn't sure if I'd done it right. I've updated both the issue title and the original comment to specifically indicate that this occurred with widget IDs -- somehow I didn't notice that or my brain filtered it out :P |
No worries :) |
Describe the bug
When a window is created upon the click of a button or other widget in a main window, IDs of widgets within that sub-window are not cleared, causing window creation and displaying to fail when the window is closed and re-opened.
Steps to reproduce
KeyError: "There is already a widget with the id '/devices/0/inputs/0/sends/0/Gain/value'"
Expected behavior
Widget IDs should be cleared when the window is either closed, deleted, or otherwise ceases to exist.
Screenshots
No response
Environment
Logs
Additional context
No response
The text was updated successfully, but these errors were encountered: