Python & PyGTK Programming
here, I want to introduce to you about Python with PyGTK programming. PyGTK is used for creating GUI. I want to make scripts which have Graphical User Interface. This will make it easier for beginners to learn about Linux.

Here is the sample of the source code:


# Print the input in Entry Text into the Terminal

import pygtk


import gtk

def topingTombol(parent, iconFile, labelText):

kotak1 = gtk.HBox(False, 0)

icon = gtk.Image()


label = gtk.Label(labelText)

kotak1.pack_start(icon, False, False, 3)

kotak1.pack_start(label, False, False, 3)

return kotak1

class Cetak:

def tekan_enter(self, widget, entry):

masukan_teks = entry.get_text()

print "Isian Kotak Teks: %s\n" % masukan_teks

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


return False

def __init__(self):

self.jendela = gtk.Window(gtk.WINDOW_TOPLEVEL)

self.jendela.set_default_size(600, 400)

self.jendela.set_title("Cetak Entry Teks")

self.jendela.connect('destroy', lambda w: gtk.main_quit())

label1 = gtk.Label()

label1.set_text("Nama: ")

label1.set_size_request(100, 30)

kotakTeks = gtk.Entry()


kotakTeks.connect("activate", self.tekan_enter, kotakTeks)

kotakTeks.set_size_request(100, 30)

tombol1 = gtk.Button()

tombol1.connect("clicked", self.keluar, "Tutup")

tombol1.set_tooltip_text("Tutup Jendela")

kotak1 = topingTombol(self.jendela, "Close.png", "Tutup")


tombol1.set_size_request(100, 50)

fixed = gtk.Fixed()

fixed.put(label1, 10, 30)

fixed.put(kotakTeks, 90, 30)

fixed.put(tombol1, 50, 90)



def main(self):


return 0

if __name__ == "__main__":

Jendela = Cetak()


double learn
english language and python language Big Grin \m/ \m/

The picture of that script when it is running:

[Image: test1cp.png]

you also can find that script on Github, here is the url:

[#url=] [#/url]

(05-09-2013, 08:03 PM)abdilahrf Wrote: double learn
english language and python language Big Grin \m/ \m/

yes, it is.

good for start :-bd

really good bro, but next you can use source code highlighting... because python indentation.

good bro .... with this, we can build anything using GUI ... nice one ..
FOLLOW @DutaLinux
for more question and sharing about security and Opensource only

may I ask you? I didn't understand with this syntax :
if __name__ == "__main__":

can you explain to me, please?

Nice share om @stevennathaniel, i've been waiting tutorial like this. Thanks you om .. :v

@root31, in my knowledge, you have knowledge more in python language, please share in here .. :v

Nothing Impossible | Learn, Understand, Share | We Are Staff of Expert Zone Technology

just ngintips bro....!!!!!!Smile)Smile)Smile)
The Wolf

i wanna be a python now #LOL ckckckckc

Users browsing this thread: 1 Guest(s)