[Tutor] 2 Combo Boxes! What was I thinking?
Liam Clarke
ml.cyresse at gmail.com
Sat May 6 16:20:51 CEST 2006
Hi John,
I'm going to take a wild stab... (but as Kent said, wxPython or pyGTK?)
Combo3.child.append_text("Mon")
Okay, so, the DeprecationWarning you need to pay attention to, but
that aside, according to the pyGTK docs:
http://www.pygtk.org/pygtk2reference/class-gtkcomboboxentry.html#function-gtk--combo-box-entry-new-text
What you want to try is
comboboxthing = gtk.combo_box_new_text()
combobox.append_text("Option 1")
combobox.append_text("Option 2")
Regards,
Liam Clarke
On 5/7/06, Kent Johnson <kent37 at tds.net> wrote:
> John CORRY wrote:
> > I have set up a GUI which has amongst other widgets two combo boxes. I
> > am using:
> >
> > PythonCard version: 0.8.1
> > wxPython version: 2.6.1.0
> > Python version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit
> > (Intel)]
> >
> > Platform: win32
> >
> > Glade 2
>
> From your code it looks like you are using pyGTK and Glade, not
> PythonCard and wxPython. I don't have the answer to your question but it
> might help to get the question right :-)
>
> Kent
>
> >
> >
> >
> > I started by setting up comboboxentry2 to accept two settings in its
> > drop down list. (open + closed). This worked fine. Code below:
> >
> >
> >
> > self.wTree = gtk.glade.XML ("phonelog.glade", "window1")
> >
> > dic={"on_window1_destroy" : self.quit, }
> >
> > self.wTree.signal_autoconnect (dic)
> >
> >
> >
> > combo1 = self.wTree.get_widget("comboboxentry2")
> >
> >
> >
> >
> >
> > combo1.append_text("Open")
> >
> > combo1.append_text("Closed")
> >
> > combo1.set_active(0)
> >
> > combo1.connect("changed", self.callback2, combo1)
> >
> >
> >
> > My problems started when I went to set up comboboxentry3. I used the
> > following code:
> >
> >
> >
> >
> >
> > self.wTree = gtk.glade.XML ("phonelog.glade", "window1")
> >
> > dic={"on_window1_destroy" : self.quit, }
> >
> > self.wTree.signal_autoconnect (dic)
> >
> >
> >
> >
> >
> > combo3 = self.wTree.get_widget("comboboxentry3")
> >
> > combo3.connect("changed", self.callback3, "comboboxentry3")
> >
> >
> >
> > combo3.append_text ("Mon")
> >
> > combo3.append_text ("Tue")
> >
> >
> >
> > combo1 = self.wTree.get_widget("comboboxentry2")
> >
> > combo1.append_text("Open")
> >
> > combo1.append_text("Closed")
> >
> > combo1.set_active(0)
> >
> > combo1.connect("changed", self.callback2, combo1)
> >
> >
> >
> >
> >
> > I got the following error:
> >
> >
> >
> > Gtkwarning: gtk_combo_box_append_text: assertion
> > GTK_IS_LIST_STORE(Combobox->Priv->Model)
> >
> > Failed
> >
> > Combo3.append_text("Mon")
> >
> > Gtkwarning: gtk_combo_box_append_text: assertion
> > GTK_IS_LIST_STORE(Combobox->Priv->Model)
> >
> > Failed
> >
> > Combo3.append_text("Tue")
> >
> >
> >
> > I then tried the code:
> >
> >
> >
> > self.wTree = gtk.glade.XML ("phonelog.glade", "window1")
> >
> > dic={"on_window1_destroy" : self.quit, }
> >
> > self.wTree.signal_autoconnect (dic)
> >
> >
> >
> >
> >
> > combo3 = self.wTree.get_widget("comboboxentry3")
> >
> > combo3.connect("changed", self.callback3, "comboboxentry3")
> >
> >
> >
> > combo3.child.append_text ("Mon")
> >
> > combo3.child.append_text ("Tue")
> >
> >
> >
> > combo1 = self.wTree.get_widget("comboboxentry2")
> >
> > combo1.append_text("Open")
> >
> > combo1.append_text("Closed")
> >
> > combo1.set_active(0)
> >
> > combo1.connect("changed", self.callback2, combo1)
> >
> >
> >
> > I get the following error message:
> >
> >
> >
> > DeprecationWarning: use GtkEditable.insert_text
> >
> > Combo3.child.append_text("Mon")
> >
> > DeprecationWarning: use GtkEditable.insert_text
> >
> > Combo3.child.append_text("Tue")
> >
> >
> >
> > The combobox3 is populated on the GUI but instead of being a drop down
> > list it appears as a string on one line and looks like this:
> >
> > MonTue
> >
> >
> >
> > I have to confess I am not really sure what I am doing. I just guessed
> > at putting the child command in. It gets me close but not close
> > enough. Can anyone tell me what I am doing wrong or explain what
> > happens when you put two combo boxes on the one GUI?
> >
> >
> >
> > Any help greatly appreciated.
> >
> >
> >
> > Thanks,
> >
> >
> >
> > John.
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list