a working quit button wow how advanced

This commit is contained in:
Lynne Megido 2020-08-21 21:08:18 +10:00
parent 765f148805
commit 03376ffd7f
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
3 changed files with 16 additions and 9 deletions

View file

@ -69,8 +69,22 @@ class BuypeebApp:
self.settings.save() self.settings.save()
self.app.quit() self.app.quit()
def msgBox(self, title, text, form = Gtk.MessageType.WARNING):
msgbox = Gtk.MessageDialog(self.window, 0, form, Gtk.ButtonsType.OK, title)
msgbox.format_secondary_text(text)
response = msgbox.run()
msgbox.destroy()
return response
def btnAddClicked(self, widget): def btnAddClicked(self, widget):
pass self.msgBox("good job", "succkeess")
def btnQuitClicked(self, widget):
prompt = Gtk.MessageDialog(self.window, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, "Really quit?")
prompt.format_secondary_text("Are you sure you want to quit buypeeb?")
response = prompt.run()
if response:
self.shutdown(self)
if __name__ == '__main__': if __name__ == '__main__':
app = BuypeebApp() app = BuypeebApp()

View file

@ -12,12 +12,5 @@ def get_exchange_rate():
except: except:
return 76.15 return 76.15
def msgBox(title, text, form = Gtk.MessageType.WARNING):
msgbox = Gtk.MessageDialog(app.window, 0, form, Gtk.ButtonsType.OK, title)
msgbox.format_secondary_text(text)
response = msgbox.run()
msgbox.destroy()
return response
def rmatch(pattern, string): def rmatch(pattern, string):
return re.match(pattern, string) != None return re.match(pattern, string) != None

View file

@ -322,10 +322,10 @@
<object class="GtkToolButton"> <object class="GtkToolButton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="action_name">app.shutdown</property>
<property name="label" translatable="yes">Quit</property> <property name="label" translatable="yes">Quit</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-quit</property> <property name="stock_id">gtk-quit</property>
<signal name="clicked" handler="btnQuitClicked" swapped="no"/>
<accelerator key="q" signal="clicked" modifiers="GDK_CONTROL_MASK"/> <accelerator key="q" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
</object> </object>
<packing> <packing>