用 python 寫 GTK 比用 C 寫省下許多繁瑣的功夫 (其實寫什麼都很省事)
先安裝這些東西:
- gtk-dev-2.12.9-win32-2.exe
- gtkmm-win32-runtime-2.10.11-1.exe
- pygobject-2.14.1-1.win32-py2.5.exe
- pygtk-2.12.1-2.win32-py2.5.exe
- pycairo-1.4.12-1.win32-py2.5.exe (為了出一些 Fancy 的圖)
glade 拖拉產生的描述檔於程式中載入:
import sys
import gtk
import gtk.glade
import pygtk
class FisApp:
def __init__(self):
glade = sys.path[0] + "/" + "FIS.glade"
name = "winFis"
self.wTree = gtk.glade.XML(glade, name)
self.win = self.wTree.get_widget(name)
dic = { "on_tbExit_clicked" : self.on_tbExit_clicked,
"on_winFis_destroy" :(gtk.main_quit)
}
self.wTree.signal_autoconnect(dic)
self.win.show_all()
##### My CALLBACKS #####
def on_tbExit_clicked(self, widget):
print 'test'
gtk.main_quit()
if __name__ == '__main__':
app = FisApp()
gtk.main()
可以開始做正事啦 :)
沒有留言:
張貼留言