本章節主要圍繞Deepin 剪取工具中都引用module 來慢慢學習吧,基本技術概念決定上層建築嘛,希望不要被噴。
PyGTK是Deepin中用來組建GUI這一塊都基本工具,說是樓房都地基一點都不為怪,截圖都視窗就是這個東東建起來的。
pygtk是其中最常用到的module之一,教程如下:
http://www.pygtk.org/pygtk2tutorial/index.html
#!/usr/bin/env python#example pygtk_test.pyimport pygtkpygtk.require('2.0')import gtkclass Base: def destroy(self): '''Destroy window''' gtk.main_quit() def hello(self, widget, data): '''print some data''' print 'Hello' + data + ' this is a button click() test' def delete_event(self, widget, event, data=None): print "delete event occurred" return False def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) handler1 = self.window.connect("destroy", self.destroy) print "handler1 is :%d" % handler1 self.window.set_title("PyGTK Test Window") self.window.set_default_size(200, 200) self.window.set_border_width(100) self.window.set_position(gtk.WIN_POS_CENTER) self.button1 = gtk.Button() self.button2 = gtk.Button() self.button1.set_label('label1') self.button2.set_label('label2') handler2 = self.button1.connect("clicked", self.hello, "PyGTK") print "handler2 is:%d" % handler2 self.button1.connect_object("clicked", gtk.Widget.destroy, self.window) self.button1.disconnect(handler2) self.box1 = gtk.HBox(False, 0) self.window.add(self.box1) self.box1.pack_start(self.button1, True, True, 0) self.button1.show() self.box1.pack_start(self.button2, True, True, 0) self.button2.show() self.box1.show() self.window.show() def main(self): gtk.main() print __name__if __name__ == "__main__": base = Base() base.main()