Files
foundations-of-pygtk-develo…/Containers/Showing_And_Hiding_Widgets.py
2019-01-02 14:53:58 -05:00

36 lines
1019 B
Python

#!/usr/bin/python3
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class AppWindow(Gtk.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_border_width(10)
self.set_size_request(200, 100)
expander = Gtk.Expander.new_with_mnemonic("Click _Me For More!")
label = Gtk.Label.new ("Hide me or show me,\nthat is your choice.")
expander.add(label)
expander.set_expanded(True)
self.add(expander)
class Application(Gtk.Application):
def __init__(self, *args, **kwargs):
super().__init__(*args, application_id="org.example.myapp",
**kwargs)
self.window = None
def do_activate(self):
if not self.window:
self.window = AppWindow(application=self, title="Hello World!")
self.window.show_all()
self.window.present()
if __name__ == "__main__":
app = Application()
app.run(sys.argv)