0
我有一個非常簡單的PyGTK應用程序,它包含1個小部件 - 一個ComboBox。出於某種原因,當我運行我的Python腳本時,ComboBox不可見。主窗口是可見的,而不是ComboBox。注意我已經成功地確定ComboBox存在,並且我已經將它添加到主窗口(將小部件添加到一個框然後將其添加到主窗口)。PyGTK ComboBox不可見
如何讓我的組合框出現?
import pygtk
pygtk.require('2.0')
import gtk
class MainApp:
def __init__(self):
self.encryptFile = True
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
main_box = gtk.VBox(True, 10)
client_store = gtk.ListStore(str)
self.clientFiles = ("a","b","c")
for f in self.clientFiles:
client_store.append([f])
combobox = gtk.ComboBox(client_store)
renderer_text = gtk.CellRendererText()
combobox.pack_start(renderer_text, True)
combobox.add_attribute(renderer_text, "text", 0)
combobox.set_size_request(200,25)
main_box.pack_start(combobox)
main_box.show()
self.window.add(main_box)
self.window.show()
def main(self):
gtk.main()
def delete_event(self, widget, event, data=None):
return False
def destroy(self, widget, data=None):
gtk.main_quit()
if __name__ == "__main__":
app = MainApp()
app.main()
感謝:D它的讚賞 – Mack