0% found this document useful (0 votes)
14 views1 page

Interface

This Python code creates a simple GUI application with one button that prints 'Hello World' when clicked, by importing the pygtk and gtk modules, defining a HelloWorld class with methods to initialize a window with a button, connect a click handler to the button, and print when clicked, and instantiating and running the application.

Uploaded by

Tavo Maloso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Interface

This Python code creates a simple GUI application with one button that prints 'Hello World' when clicked, by importing the pygtk and gtk modules, defining a HelloWorld class with methods to initialize a window with a button, connect a click handler to the button, and print when clicked, and instantiating and running the application.

Uploaded by

Tavo Maloso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import pygtk

pygtk.require('2.0')
import gtk

class HelloWorld:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.button = gtk.Button("Hello World")
self.button.connect("clicked", self.say_hello, None)
self.window.add(self.button)
self.button.show()
self.window.show()

def main(self):
gtk.main()

def say_hello(self, widget, data=None):


print "Hello World"

hello = HelloWorld()
hello.main()

You might also like