Python & PyGTK Programming - Printable Version +- Indonesian Back|Track Team (https://www.indonesianbacktrack.or.id/forum) +-- Forum: Community Zone (https://www.indonesianbacktrack.or.id/forum/forum-167.html) +--- Forum: International Community (https://www.indonesianbacktrack.or.id/forum/forum-89.html) +--- Thread: Python & PyGTK Programming (/thread-4537.html) |
Python & PyGTK Programming - stevennathaniel - 05-09-2013 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: #!/usr/bin/python # Print the input in Entry Text into the Terminal import pygtk pygtk.require('2.0') import gtk def topingTombol(parent, iconFile, labelText): kotak1 = gtk.HBox(False, 0) icon = gtk.Image() icon.set_from_file(iconFile) label = gtk.Label(labelText) kotak1.pack_start(icon, False, False, 3) kotak1.pack_start(label, False, False, 3) icon.show() label.show() 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): gtk.main_quit() 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.set_max_length(50) 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.add(kotak1) tombol1.set_size_request(100, 50) fixed = gtk.Fixed() fixed.put(label1, 10, 30) fixed.put(kotakTeks, 90, 30) fixed.put(tombol1, 50, 90) self.jendela.add(fixed) self.jendela.show_all() def main(self): gtk.main() return 0 if __name__ == "__main__": Jendela = Cetak() Jendela.main() RE: Python & PyGTK Programming - abdilahrf - 05-09-2013 double learn english language and python language \m/ \m/ RE: Python & PyGTK Programming - stevennathaniel - 05-09-2013 The picture of that script when it is running: you also can find that script on Github, here is the url: [#url=https://github.com/balikpapan/antarmuka1/blob/disk1/Test/Test6.py] https://github.com/balikpapan/antarmuka1/blob/disk1/Test/Test6.py [#/url] (05-09-2013, 08:03 PM)abdilahrf Wrote: double learn yes, it is. RE: Python & PyGTK Programming - mywisdom - 06-16-2013 good for start :-bd RE: Python & PyGTK Programming - gunslinger_ - 06-17-2013 really good bro, but next you can use source code highlighting... because python indentation. RE: Python & PyGTK Programming - zee eichel - 07-23-2013 good bro .... with this, we can build anything using GUI ... nice one .. RE: Python & PyGTK Programming - root31 - 07-23-2013 may I ask you? I didn't understand with this syntax : if __name__ == "__main__": can you explain to me, please? RE: Python & PyGTK Programming - ino_ot - 07-24-2013 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 RE: Python & PyGTK Programming - m4k4ss4rh4ck3r - 07-25-2013 just ngintips bro....!!!!!!))) RE: Python & PyGTK Programming - mulher - 09-15-2013 i wanna be a python now #LOL ckckckckc |