From 6d88cd2cedded8b015ddab9c4379685665a32a50 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Tue, 2 Apr 2024 17:29:59 -0400 Subject: [PATCH] app: add a dialog popup, and a quit button Signed-off-by: Vincent Batts --- src/helloworld/app.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/helloworld/app.py b/src/helloworld/app.py index 9b15d9b..d88b4fe 100644 --- a/src/helloworld/app.py +++ b/src/helloworld/app.py @@ -20,20 +20,36 @@ class HelloWorld(toga.App): name_box.add(name_label) name_box.add(self.name_input) - button = toga.Button( + hello_button = toga.Button( "Say Hello!", on_press=self.say_hello, style=Pack(padding=5) ) + + quit_button = toga.Button( + "Quit", + on_press=self.quit, + style=Pack(padding=5) + ) + main_box.add(name_box) - main_box.add(button) + main_box.add(hello_button) + main_box.add(quit_button) self.main_window = toga.MainWindow(title=self.formal_name) self.main_window.content = main_box self.main_window.show() + def quit(self, widget): + if self.on_exit is not None: + self.on_exit() + self.exit() + def say_hello(self, widget): - print(f"Hello, {self.name_input.value}") + self.main_window.info_dialog( + f"Hello, {self.name_input.value}", + "sup dawg!" + ) def main():