Deepin Linux Desktop, 剪取工具剖析(二) GTK pygtk__Linux

來源:互聯網
上載者:User

本章節主要圍繞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()


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.