[wxPython] Can somebody please help me with this: Combobox on windows

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Can somebody please help me with this: Combobox on windows

Johann Spies-4
Sorry to bother you with the same question of three days ago but I still
do not have solution:

When I use combobox on Linux the default value appears in the entry field
as it should.  However in Windows, the entryfield appears as an empty
field. This is causing problems on an entryform for data where another
field is dependent on the value in the combobox.

I am using exactly the same code and data in both cases.  

How can I correct it?

Johann
 --------------------------------------------------------------------------
| Johann Spies                                 Windsorlaan 19              |
| [hidden email]                3201 Pietermaritzburg             |
| Tel/Faks Nr. +27 331-46-1310       Suid-Afrika (South Africa)  |
 --------------------------------------------------------------------------

     "And whatsoever ye shall ask in my name, that will I
      do, that the Father may be glorified in the Son."    
                                          John 14:13



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Can somebody please help me with this: Combobox on windows

Robin Dunn
> Sorry to bother you with the same question of three days ago but I still
> do not have solution:
>
> When I use combobox on Linux the default value appears in the entry field
> as it should.  However in Windows, the entryfield appears as an empty
> field. This is causing problems on an entryform for data where another
> field is dependent on the value in the combobox.


Sorry, I have been away from the project for a few days working on something
else.  I will look into it this evening.

Robin



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Can somebody please help me with this: Combobox on windows

Paul Sokolovsky-4
In reply to this post by Johann Spies-4
Hello Johann,

Johann Spies <[hidden email]> wrote:

JS> Sorry to bother you with the same question of three days ago but I still
JS> do not have solution:

JS> When I use combobox on Linux the default value appears in the entry field
JS> as it should.  However in Windows, the entryfield appears as an empty
JS> field. This is causing problems on an entryform for data where another
JS> field is dependent on the value in the combobox.

JS> I am using exactly the same code and data in both cases.

JS> How can I correct it?

    Very easy, I guess - explicitly use .SetSelection(0) . By the way,
Windows' behaviour is not entirely incorrect - [some] users tend to
hit buttons without thinking, and having underspecified default value
asks them to be little more aware.

    Other thing bothers me - by some reason .SetSelection doesn't call
EVT_COMBOBOX() handler. I'd find it more natural if it called.



JS> Johann





Best regards,
 Paul                            mailto:[hidden email]



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Can somebody please help me with this: Combobox on windows

Robin Dunn
In reply to this post by Johann Spies-4
> Sorry to bother you with the same question of three days ago but I still
> do not have solution:
>
> When I use combobox on Linux the default value appears in the entry field
> as it should.  However in Windows, the entryfield appears as an empty
> field. This is causing problems on an entryform for data where another
> field is dependent on the value in the combobox.
>
> I am using exactly the same code and data in both cases.
>
> How can I correct it?

How are you creating the wxComboBox?  Are you specifying a value in the 3rd
parameter or expecting the first item in the list to be selected?  This
works for me on MSW:

    wxComboBox(self, 500, "default value", wxPoint(80, 50),
               wxSize(95, -1), sampleList, wxCB_DROPDOWN)

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Can somebody please help me with this: Combobox on windows

Johann Spies-4
On Tue, 17 Aug 1999, Robin Dunn wrote:


> > When I use combobox on Linux the default value appears in the entry field
> > as it should.  However in Windows, the entryfield appears as an empty
> > field. This is causing problems on an entryform for data where another
> > field is dependent on the value in the combobox.

> How are you creating the wxComboBox?  Are you specifying a value in the 3rd
> parameter or expecting the first item in the list to be selected?  This
> works for me on MSW:
>
>     wxComboBox(self, 500, "default value", wxPoint(80, 50),
>                wxSize(95, -1), sampleList, wxCB_DROPDOWN)

This is the code I use:

                grootte = 35*9
                try:
                    n = self.data.afkortings.index(self.ouinhoud[veld])
                except:
                    n = 44
                dv = self.data.skolelys[n]
                self.lb= wxComboBox(self, id, dv, wxPoint(xafset,y_pos), wxSize(grootte, -1),self.data.skolelys, wxCB_READONLY)
       
I Linux the nth item in self.data.skolelys is shown in the entry field.
In Windows the field is blank.

Johann

 --------------------------------------------------------------------------
| Johann Spies                                 Windsorlaan 19              |
| [hidden email]                3201 Pietermaritzburg             |
| Tel/Faks Nr. +27 331-46-1310       Suid-Afrika (South Africa)  |
 --------------------------------------------------------------------------

     "And I say unto you, Ask, and it shall be given you;
      seek, and ye shall find; knock, and it shall be opened
      unto you."            Luke 11:9


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Can somebody please help me with this: Combobox on windows

Robin Dunn
> > How are you creating the wxComboBox?  Are you specifying a value in the
3rd

> > parameter or expecting the first item in the list to be selected?  This
> > works for me on MSW:
> >
> >     wxComboBox(self, 500, "default value", wxPoint(80, 50),
> >                wxSize(95, -1), sampleList, wxCB_DROPDOWN)
>
> This is the code I use:
>
>                 grootte = 35*9
>                 try:
>     n = self.data.afkortings.index(self.ouinhoud[veld])
> except:
>     n = 44
> dv = self.data.skolelys[n]
>                 self.lb= wxComboBox(self, id, dv, wxPoint(xafset,y_pos),
wxSize(grootte, -1),self.data.skolelys, wxCB_READONLY)
>
> I Linux the nth item in self.data.skolelys is shown in the entry field.
> In Windows the field is blank.
>


Ah ha!  You're using the wxCB_READONLY flag.  In this case I believe wxMSW
is correct.  It makes no sense to add an item to the text edit field if it
can't be edited.  As far as the control is concerned, that value is not a
member of the list, but an alternate...

You are essentiually using the wxComboBox as a wxChoice in which case you
need to do as was previously suggested and add a self.lb.SetSelection(n).

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Can somebody please help me with this: Combobox on windows

Johann Spies-4
On Tue, 17 Aug 1999, Robin Dunn wrote:

> > dv = self.data.skolelys[n]
> >                 self.lb= wxComboBox(self, id, dv, wxPoint(xafset,y_pos),
> wxSize(grootte, -1),self.data.skolelys, wxCB_READONLY)
> >
> > I Linux the nth item in self.data.skolelys is shown in the entry field.
> > In Windows the field is blank.
> >
>
>
> Ah ha!  You're using the wxCB_READONLY flag.  In this case I believe wxMSW
> is correct.  It makes no sense to add an item to the text edit field if it
> can't be edited.  As far as the control is concerned, that value is not a
> member of the list, but an alternate...

I makes good sense in the context of the program.  The user should only be
allowed to select from the list and not to enter an entry from the
keyboard.  The list is to long to use wxChoice which does not appear to
have a scrolling function.

> You are essentiually using the wxComboBox as a wxChoice in which case you
> need to do as was previously suggested and add a self.lb.SetSelection(n).

Thanks. That solve the problem on Windows.  When I use
self.lb.SetSelection I get the following error on Linux:  

Gtk-CRITICAL **: file gtkoptionmenu.c: line 232
(gtk_option_menu_set_history): assertion `GTK_IS_OPTION_MENU
(option_menu)' failed.

Gtk-CRITICAL **: file gtkoptionmenu.c: line 160
(gtk_option_menu_get_menu): assertion `GTK_IS_OPTION_MENU (option_menu)'
failed.
Segmentation fault

This may be a bug.

Thanks again for the help.

Johann.



 --------------------------------------------------------------------------
| Johann Spies                                 Windsorlaan 19              |
| [hidden email]                3201 Pietermaritzburg             |
| Tel/Faks Nr. +27 331-46-1310       Suid-Afrika (South Africa)  |
 --------------------------------------------------------------------------

     "And I say unto you, Ask, and it shall be given you;
      seek, and ye shall find; knock, and it shall be opened
      unto you."            Luke 11:9




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Can somebody please help me with this: Combobox on windows

Robin Dunn
>
> Thanks. That solve the problem on Windows.  When I use
> self.lb.SetSelection I get the following error on Linux:
>
> Gtk-CRITICAL **: file gtkoptionmenu.c: line 232
> (gtk_option_menu_set_history): assertion `GTK_IS_OPTION_MENU
> (option_menu)' failed.
>
> Gtk-CRITICAL **: file gtkoptionmenu.c: line 160
> (gtk_option_menu_get_menu): assertion `GTK_IS_OPTION_MENU (option_menu)'
> failed.
> Segmentation fault
>
> This may be a bug.
>

Yep.  On wxMSW wxComboBox derives from wxChoice.  A while back there was a
problem with wxComboBox.SetSelection and so I commented it out and let it
default to wxChoice.SetSelection which was working.  Since there is a
heiarchical relationship betwen the classes it worked okay.

Unfortunatly on wxGTK wxComboBox derives directly from wxControl and so when
wxPython tries to call wxChoice.SetSelection with a wxComboBox it complains
about it and fails.  This has been fixed, but since wxGTK version uses the
default value you can in the short-term only call SetSelection on MSW.
Something like this:

    if wxPlatform == '__WXMSW__':
        self.lb.SetSelection(n)

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users