此代碼顯示我一個狀態欄。但是,當我點擊一個按鈕時,並沒有說我已經在狀態欄中這樣做了。我有一個狀態欄,但我如何使它工作?
import pygtk
pygtk.require('2.0')
import gtk
import subprocess
class Example:
def __init__(self):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_size_request(400, 500)
window.set_title("GTK Menu")
window.connect("delete_event",
lambda w,e: gtk.main_quit())
vbox = gtk.VBox(False, 0)
window.add(vbox)
vbox.show()
button = gtk.Button("Write")
button.connect("clicked", self.clicked_Write)
vbox.pack_end(button, True, True, 2)
button.show()
button2 = gtk.Button("Draw")
button2.connect("clicked", self.clicked_Scrible)
vbox.pack_end(button2, True, True, 2)
button2.show()
button3 = gtk.Button("Final Test")
button3.connect("clicked", self.clicked_Final)
vbox.pack_end(button3, True, True, 2)
button3.show()
button4 = gtk.Button("Helloworld")
button4.connect("clicked", self.clicked_Hello)
vbox.pack_end(button4, True, True, 2)
button4.show()
button5 = gtk.Button("Facebook")
button5.connect("clicked", self.clicked_Facebook)
vbox.pack_end(button5, True, True, 2)
button5.show()
# Add status bar to vbox
self.statusbar = gtk.Statusbar()
vbox.pack_start(self.statusbar, False, False, 0)
window.show_all()
def clicked_Write(self, widget):
subprocess.Popen(["python", "Helloworld.py"])
def clicked_Scrible(self, widget):
subprocess.Popen(["python", "scrible.py"])
def clicked_Final(self, widget):
subprocess.Popen(["python", "Final.py"])
def clicked_Hello(self, widget):
subprocess.Popen(["python", "Helloword.py"])
def clicked_Facebook(self, widget):
subprocess.Popen(["python", "facebookfinal.py"])
def main(self):
gtk.main()
return 0
Example().main()
請確保格式化您的代碼示例。 – zeekay 2011-05-08 18:06:55