[root@dywHome2 ~]# [root@deyu ~]# yum install glade3
圖形界面 Applications->Programming->Glade Interface Designer 文字界面 [dywang@deyu glade]$ glade-3
1. table1 Rows: 5 -> 6 2. insert ok button in table1 (0,5) 3. rename ok button Label and Name to Sqrt 4. set Sqrt button clicked Signals to on_Sqrt_clicked 5. vim calculatorglade.py # coding: utf-8 import sys import math # 匯入數學模組 try: import pygtk pygtk.require('2.0') except: pass .... omission .... class Calculator: .... omission .... "on_Add_clicked" : self.displayAdd, "on_Sqrt_clicked" : self.displaySqrt, # 定義sqrt按鈕接受函式 .... omission .... if operator == 'Sqrt': self.firstOperand = self.wTree.get_widget("displayText").get_text() result = math.sqrt(float(self.firstOperand)) self.wTree.get_widget("displayText").set_text(str(result)) .... omission .... def displaySqrt(self,widget): #定義displaySqrt函式 self.compute("Sqrt")
[dywang@deyu glade]$ python calculatorglade.py