http://python-gtk-3-tutorial.readthedocs.io/en/latest/install.html
Last active
March 29, 2017 00:02
-
-
Save nenodias/8f9b789ceaf67dd5ccfb0ae4482a98f9 to your computer and use it in GitHub Desktop.
GTK Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!-- Generated with glade 3.19.0 --> | |
| <interface> | |
| <requires lib="gtk+" version="3.12"/> | |
| <object class="GtkApplicationWindow" id="window1"> | |
| <property name="can_focus">False</property> | |
| <child> | |
| <object class="GtkLayout" id="layout1"> | |
| <property name="visible">True</property> | |
| <property name="can_focus">False</property> | |
| <child> | |
| <object class="GtkButton" id="button1"> | |
| <property name="label" translatable="yes">OK</property> | |
| <property name="width_request">99</property> | |
| <property name="height_request">80</property> | |
| <property name="visible">True</property> | |
| <property name="can_focus">True</property> | |
| <property name="receives_default">True</property> | |
| <signal name="clicked" handler="onButtonPressed" swapped="no"/> | |
| </object> | |
| <packing> | |
| <property name="x">160</property> | |
| </packing> | |
| </child> | |
| <child> | |
| <object class="GtkEntry" id="entry1"> | |
| <property name="width_request">100</property> | |
| <property name="height_request">80</property> | |
| <property name="visible">True</property> | |
| <property name="can_focus">True</property> | |
| </object> | |
| <packing> | |
| <property name="x">125</property> | |
| <property name="y">100</property> | |
| </packing> | |
| </child> | |
| </object> | |
| </child> | |
| </object> | |
| </interface> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """MODULO.""" | |
| import gi | |
| gi.require_version('Gtk', '3.0') | |
| from gi.repository import Gtk | |
| builder = Gtk.Builder() | |
| builder.add_from_file("exemplo.glade") | |
| window = builder.get_object("window1") | |
| entry1 = builder.get_object("entry1") | |
| def hello(button): | |
| """Click Handler.""" | |
| print("Que isso") | |
| value = entry1.get_text() | |
| print(value) | |
| handlers = { | |
| "onDeleteWindow": Gtk.main_quit, | |
| "onButtonPressed": hello | |
| } | |
| builder.connect_signals(handlers) | |
| window.show_all() | |
| Gtk.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gi | |
| gi.require_version('Gtk', '3.0') | |
| from gi.repository import Gtk | |
| class MyWindow(Gtk.Window): | |
| def __init__(self): | |
| Gtk.Window.__init__(self, title="Hello World") | |
| self.button = Gtk.Button(label="Click Here") | |
| self.button.connect("clicked", self.on_button_clicked) | |
| self.add(self.button) | |
| def on_button_clicked(self, widget): | |
| print("Hello World") | |
| win = MyWindow() | |
| win.connect("delete-event", Gtk.main_quit) | |
| win.show_all() | |
| Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment