Write a Python script that creates a button with the text "Hello World" - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Monday, March 2, 2015

Write a Python script that creates a button with the text "Hello World"

Write a Python script that creates a button with the text "Hello World".

Objective

1.  Get started with GTK+.

2.  Learn to create widgets and associate callbacks.

Required Reading

   Getting Started and Movin On sections of the PyGTK 2.0 Tutorial  [http://www.pygtk.org/  pygtk2tutorial/index.html]

   ComboBox Widget section of the PyGTK 2.0 Tutorial  [http://www.pygtk.org/pygtk2tutorial/  index.html

import pygtk pygtk.require('2.0') import gtk

class HelloWorld:

def __init__(self):

self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_border_width(5)

self.button = gtk.Button("Hello World!") self.window.add(self.button) self.window.show_all()

def main(self): gtk.main()


if __name__ == "__main__": hello = HelloWorld() hello.main()

No comments:

Post a Comment