[pygtk] ComboBox Behavior - End User Perspective
kurt at kbsymanzik.org
Wed Mar 21 18:42:21 WST 2007
Preben Randhol wrote:
> On Wed, 21 Mar 2007 16:05:36 +0800
> Kurt Symanzik <kurt at kbsymanzik.org> wrote:
>> I have a ComboBox that has no active rows when the application starts
>> which is accomplished with the set_active(-1) call in the init()
>> method. I have found that the user may select any row easy enough,
>> but it is baffling me how to get the ComboBox to allow the *end user*
>> to select no active row again. In other words, after making a
>> selection, I want to enable the user to choose "nothing" again
>> leaving a blank ComboBox as when the application started. I know
>> that I could add a button that the user could press that I could use
>> to set_active(-1) on the ComboBox, but that seems like a hack to me.
> Why don't you in stead have one row in the combobox which is the empty
> row? Say Row 1, so the user can choose this. Simple and easy to do.
I agree that that is an easy and clean solution in the simple scenario,
and maybe in my case too (I'll let you judge). In my code the
underlying base model supplies the data to a TreeView and this ComboBox.
There is a TreeModelFilter chained together that allows the ComboBox
to display unique values of a particular column in the base model. I am
using the ComboBox to give the user the option of filtering out what
gets displayed in the TreeView. When the ComboBox is empty, then all
rows are displayed in the TreeView. When the ComboBox contains a
selection, then only those rows that match that column in the model are
displayed in the TreeView. Thus, the need for the user to select
"nothing" in the ComboBox in order to have the TreeView display all rows
My main concern at this point is that I am correctly understanding the
ComboBox and associated widgets. Is the empty row solution the best, or
am I missing something else, or misunderstanding ComboBox, etc. It just
surprised me that the user could start with no row selected but never
get back to that original state. In other words, at one point the
ComboBox truly does display nothing and have nothing selected even
without an empty row in the underlying model. I would think that that
state could be reacquired by the user without having to "taint" the model.
Yet, if there is no other way, I could put an empty row in the
underlying model and then just hide it from the TreeView with a
TreeModelFilter (I am already using one anyway). If this is the
cleanest and best solution, then that will work.
Thanks for your input.
kurt at kbsymanzik.org
Skype id: ksymanzik
More information about the pygtk