Skip to content

Instantly share code, notes, and snippets.

@yukpiz yukpiz/python_gtk.py
Last active Aug 29, 2015

Embed
What would you like to do?
Using the gtk from Python.
import gtk
class GtkTutorial:
def __init__(self):
#GTK Window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_border_width(1)
self.window.set_title('Tutorial')
self.window.set_default_size(1024, 768)
self.window.connect('delete_event', self.destroy)
#GTK MessageDialog
self.message = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
self.message.set_markup('ok!')
#GTK Button
self.button = gtk.Button('Hello World')
self.button.connect('clicked', self.showMessage, None)
#GTK Drawing Area
self.drawingArea = gtk.DrawingArea()
self.drawingArea.set_size_request(10, 10)
self.window.add(self.drawingArea)
self.window.add(self.button)
self.button.show()
self.window.show()
def main(self):
gtk.main()
def destroy(self, widget, data=None):
gtk.main_quit()
def showMessage(self, widget, event, data=None):
self.message.run()
tutorial = GtkTutorial()
tutorial.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.