GUI Using Python PyGTK and Glade A. Jai Sathish Kumar - - PowerPoint PPT Presentation

gui using python pygtk and glade
SMART_READER_LITE
LIVE PREVIEW

GUI Using Python PyGTK and Glade A. Jai Sathish Kumar - - PowerPoint PPT Presentation

Pycon India 2009,IISc GUI Using Python PyGTK and Glade A. Jai Sathish Kumar S.Rajeswari sathishavadi@gmail.com sraji.me@gmail.com PyFLTK Pygame Pyglet PythonCard PyGTK PySide PyQt


slide-1
SLIDE 1

Pycon India 2009,IISc

GUI Using Python – PyGTK and Glade

  • A. Jai Sathish Kumar S.Rajeswari

sathishavadi@gmail.com sraji.me@gmail.com

slide-2
SLIDE 2
slide-3
SLIDE 3

PyFLTK Pygame Pyglet PythonCard PyGTK PySide PyQt TkInter wxPython

slide-4
SLIDE 4

No Standard

GUI Tool available

slide-5
SLIDE 5

There are some factors that decides the GUI tool

slide-6
SLIDE 6

Money

slide-7
SLIDE 7

OR

Linux User Windows User

slide-8
SLIDE 8

Linux and Windows User

slide-9
SLIDE 9

A GNOME User

slide-10
SLIDE 10

A KDE User

slide-11
SLIDE 11

What is PyGTK ?

slide-12
SLIDE 12

+

slide-13
SLIDE 13

Y

PyGTK

slide-14
SLIDE 14

Easy to create your own GUI

slide-15
SLIDE 15

PyGTK is Free Open Source Software

slide-16
SLIDE 16

PyGTK supports Multiplatform Applications

slide-17
SLIDE 17

What is GTK ?

slide-18
SLIDE 18

GTK (GIMP ToolKit)

slide-19
SLIDE 19

Library for creating Graphical User Interfaces

slide-20
SLIDE 20

PyGTK Programming Basics

slide-21
SLIDE 21

Import required Libraries

slide-22
SLIDE 22

Create a Window

slide-23
SLIDE 23

Pack Widgets into it

slide-24
SLIDE 24

Set Appropriate Signals to Widgets

slide-25
SLIDE 25

Connect Signals to Callback Functions

slide-26
SLIDE 26

Uses main loop to start GTK+ event processing loop

slide-27
SLIDE 27

Putting it all together

import pygtk pygtk.require('2.0') import gtk #import libraries class WelcomeMsg: def __init__(self): window = gtk.Window() #create a window window.set_title("Welcome") window.set_border_width(10) window.set_size_request(200,100) window.connect("destroy", self.quit) vbox = gtk.VBox() window.add(vbox) button = gtk.Button("Press Me !") button.connect("clicked",self.printMessage,"Welcome To Pycon India 2009,IISc") vbox.pack_start(button,True,True,0) #pack widgets

slide-28
SLIDE 28

button = gtk.Button("Close") button.connect("clicked",self.quit) #connect signals to callback vbox.pack_start(button,True,True,5) window.show_all() def printMessage(self,widget,data): #callback function print data def quit(self,widget): #callback function gtk.main_quit() def main(self): gtk.main() #main loop if __name__ == "__main__": p = WelcomeMsg() p.main()

slide-29
SLIDE 29

Run in the terminal python filename.py

slide-30
SLIDE 30

END of PyGTK

slide-31
SLIDE 31

WELCOME To GLADE

slide-32
SLIDE 32

GLADE

slide-33
SLIDE 33

What is Glade ?

slide-34
SLIDE 34

A User Interface Designer

slide-35
SLIDE 35

G L A D E

slide-36
SLIDE 36

Rapid Application Development Tool

slide-37
SLIDE 37

Used in Many Programming Languages

slide-38
SLIDE 38
slide-39
SLIDE 39

User Interfaces are stored in XML format

slide-40
SLIDE 40

GLADE GUI Designing

slide-41
SLIDE 41

A Drag & Drop Interface

slide-42
SLIDE 42

Design starts by adding

  • i. Top Levels
  • ii. Containers
  • iii. Controls and Displays
slide-43
SLIDE 43

Top Levels

slide-44
SLIDE 44
slide-45
SLIDE 45

Containers

slide-46
SLIDE 46
slide-47
SLIDE 47

Controls and Displays

slide-48
SLIDE 48
slide-49
SLIDE 49
slide-50
SLIDE 50

Set the glade file

def __init__(self): self.gladefile = "glade file name" self.wTree = gtk.glade.XML(self.gladefile)

slide-51
SLIDE 51

Create a dictionary and Connect it

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

slide-52
SLIDE 52

Resources

slide-53
SLIDE 53

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

slide-54
SLIDE 54

http://www.pygtk.org/

slide-55
SLIDE 55

http://glade.gnome.org/

slide-56
SLIDE 56
  • Mailing list
  • IRC
  • Forums
slide-57
SLIDE 57
slide-58
SLIDE 58
slide-59
SLIDE 59
slide-60
SLIDE 60

We thank and

for pictures