我有一个状态栏,但如何让它发挥作用?
这段代码显示了一个状态栏。但是,当我单击按钮时,状态栏中并没有显示我已这样做。
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()
This code shows me a status bar. However when I click a button it does not say that I have done so in the status bar.
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()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要通过向状态栏推送消息来显式更新状态栏。该文档有一个简短的示例,展示了状态栏的工作原理:
尝试这部分,如果消息显示:请告诉我:
You need to explicitly update the statusbar by pushing a message to it. The documentation has a brief example showing how the statusbar works:
Try this part, and let me know if the message shows:
这又如何呢?
What about this?