GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Jul 25, 2014 10:38 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PyGTK ComboBox Not Visible
PostPosted: Mon Mar 31, 2014 1:03 am 
Offline
Familiar Face

Joined: Sat Jun 16, 2012 2:20 am
Posts: 5
Hello

I have a very simple PyGTK application that contains 1 widget - a ComboBox. For some reason the ComboBox is not visible when I run my python script. The main window is visible just not the ComboBox. Note I have successfully determined that the ComboBox exists and I have added it to the main window (added the widget to a box then added that to the main window).

How can I get my ComboBox to appear?


Code:
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()


Top
 Profile  
 
 Post subject: Re: PyGTK ComboBox Not Visible
PostPosted: Mon Mar 31, 2014 5:34 am 
Offline
Familiar Face

Joined: Sat Jun 16, 2012 2:20 am
Posts: 5
Solved:

I forgot to call .show()

Code:
combobox..show()


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group