0% found this document useful (0 votes)
31 views60 pages

Pycon India 2009, Iisc: Gui Using Python - Pygtk and Glade

This document discusses various Python GUI frameworks and the Glade user interface designer. It provides an overview of PyGTK and how to create basic GUIs with PyGTK including importing libraries, creating windows and widgets, connecting signals to callbacks, and running the main loop. It also summarizes what Glade is and how it can be used for rapid GUI prototyping through drag and drop design in an XML format. Code examples are provided to illustrate basic PyGTK and Glade usage.

Uploaded by

Boon David
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
31 views60 pages

Pycon India 2009, Iisc: Gui Using Python - Pygtk and Glade

This document discusses various Python GUI frameworks and the Glade user interface designer. It provides an overview of PyGTK and how to create basic GUIs with PyGTK including importing libraries, creating windows and widgets, connecting signals to callbacks, and running the main loop. It also summarizes what Glade is and how it can be used for rapid GUI prototyping through drag and drop design in an XML format. Code examples are provided to illustrate basic PyGTK and Glade usage.

Uploaded by

Boon David
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 60

PyconIndia2009,IISc

GUIUsingPythonPyGTKandGlade
A.JaiSathishKumarS.Rajeswari
[email protected]
[email protected]

PyFLTKPygame

Pyglet

PythonCardPyGTK

PySide

PyQt

TkInter

wxPython

NoStandard

GUIToolavailable

Thereare
somefactors
thatdecides
theGUItool

Money

OR
LinuxUser

WindowsUser

LinuxandWindowsUser

AGNOMEUser

AKDEUser

What
is
PyGTK?

PyGTK

EasytocreateyourownGUI

PyGTKisFreeOpenSourceSoftware

PyGTKsupportsMultiplatformApplications

What
is
GTK?

GTK(GIMPToolKit)

Library
forcreating
GraphicalUserInterfaces

PyGTK
Programming
Basics

Import
required
Libraries

CreateaWindow

Pack
Widgetsintoit

Set
AppropriateSignals
to
Widgets

ConnectSignals
to
CallbackFunctions

Usesmainloop
tostart
GTK+event
processingloop

Puttingitalltogether
importpygtk
pygtk.require('2.0')
importgtk

#importlibraries

classWelcomeMsg:
def__init__(self):
window=gtk.Window()
window.set_title("Welcome")
window.set_border_width(10)
window.set_size_request(200,100)
window.connect("destroy",self.quit)

#createawindow

vbox=gtk.VBox()
window.add(vbox)

button=gtk.Button("PressMe!")
button.connect("clicked",self.printMessage,"WelcomeToPyconIndia
2009,IISc")
vbox.pack_start(button,True,True,0)
#packwidgets

button=gtk.Button("Close")
button.connect("clicked",self.quit)
vbox.pack_start(button,True,True,5)

#connectsignalstocallback

window.show_all()
defprintMessage(self,widget,data):
printdata

#callbackfunction

defquit(self,widget):
gtk.main_quit()

#callbackfunction

defmain(self):
gtk.main()

#mainloop

if__name__=="__main__":
p=WelcomeMsg()
p.main()

Runintheterminal
pythonfilename.py

ENDofPyGTK

WELCOME
To
GLADE

GLADE

What
is
Glade?

A
User
Interface
Designer

G
L
A
D
E

Rapid
Application
Development
Tool

UsedinMany
ProgrammingLanguages

User
Interfaces
arestored
in
XMLformat

GLADE
GUI
Designing

ADrag
&
Drop
Interface

Designstartsbyadding

i.TopLevels
ii.Containers
iii.ControlsandDisplays

TopLevels

Containers

Controls
and
Displays

Setthegladefile
def__init__(self):
self.gladefile="gladefilename"
self.wTree=gtk.glade.XML(self.gladefile)

Createadictionary
andConnectit
dic={
"on_mainWindow_destroy":gtk.main_quit,
}
self.wTree.signal_autoconnect(dic)

Resources

http://wiki.python.org/moin/GuiProgramming

http://www.pygtk.org/

http://glade.gnome.org/

Mailinglist
IRC
Forums

Wethank

forpictures

and

You might also like