Created
March 28, 2015 11:55
-
-
Save movEAX/4ac04c7f777436522c5e to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python | |
""" | |
Building (Python3.4): | |
> cython --embed window.pyx | |
> gcc -I/usr/include/python3.4m -o window -lpython3.4m -lpthread -lm -lutil -ldl | |
""" | |
#------------------------------------------------------------------------------ | |
# Imports | |
#------------------------------------------------------------------------------ | |
import logging | |
from gi.repository import Gtk | |
#------------------------------------------------------------------------------ | |
# Hello World GTK | |
#------------------------------------------------------------------------------ | |
class HelloWorld: | |
def hello(self, widget, data=None): | |
logging.info("Hello World") | |
def delete_event(self, widget, event, data=None): | |
logging.info("delete event occured") | |
return False | |
def destroy(self, widget, data=None): | |
Gtk.main_quit() | |
def __init__(self): | |
# -------------------------------------------------------------------- | |
self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL) | |
self.window.connect("delete_event", self.delete_event) | |
self.window.connect("destroy", self.destroy) | |
self.window.set_border_width(10) | |
# -------------------------------------------------------------------- | |
self.button = Gtk.Button("Hello world") | |
self.button.connect("clicked", self.hello, None) | |
self.button.connect_object("clicked", Gtk.Widget.destroy, self.window) | |
# -------------------------------------------------------------------- | |
self.window.add(self.button) | |
self.button.show() | |
self.window.show() | |
def main(self): | |
Gtk.main() | |
if __name__ == "__main__": | |
logging.basicConfig(level=logging.INFO) | |
HelloWorld().main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment