app: add a dialog popup, and a quit button
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
cb311a9b76
commit
6d88cd2ced
1 changed files with 19 additions and 3 deletions
|
@ -20,20 +20,36 @@ class HelloWorld(toga.App):
|
||||||
name_box.add(name_label)
|
name_box.add(name_label)
|
||||||
name_box.add(self.name_input)
|
name_box.add(self.name_input)
|
||||||
|
|
||||||
button = toga.Button(
|
hello_button = toga.Button(
|
||||||
"Say Hello!",
|
"Say Hello!",
|
||||||
on_press=self.say_hello,
|
on_press=self.say_hello,
|
||||||
style=Pack(padding=5)
|
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(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 = toga.MainWindow(title=self.formal_name)
|
||||||
self.main_window.content = main_box
|
self.main_window.content = main_box
|
||||||
self.main_window.show()
|
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):
|
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():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue