wx.checkbox and wx.combo.comboctrl

Hi,

I would like to combine with wx.combo.comboctrl and wx.checkbox to realize a function like wx.combobox with multi-selection.

I am not sure how to do that, need help!

or will wx.popwindow + wx.checkbox combination be a better choice?

Regards!

zhengqing(Forrest)

Perhaps ComboCtrl with a CheckListBox popup, or with a wx.ListCtrl plus CheckListCtrlMixin if you need more than one column.

···

On 8/29/12 11:08 PM, zhengqing wrote:

Hi,
    I would like to combine with wx.combo.comboctrl and wx.checkbox to
realize a function like wx.combobox with multi-selection.
    I am not sure how to do that, need help!
    or will wx.popwindow + wx.checkbox combination be a better choice?

--
Robin Dunn
Software Craftsman

Hi Robin,

Thanks!

That works very well, but somehow the checklistbox size is lot control.

please help!

Thank you very much!

zhengqing(Forrest)

ChecklistboxComboCtrl.py (1.18 KB)

···

On Thursday, August 30, 2012 10:34:21 AM UTC-7, Robin Dunn wrote:

On 8/29/12 11:08 PM, zhengqing wrote:

Hi,
I would like to combine with wx.combo.comboctrl and wx.checkbox to
realize a function like wx.combobox with multi-selection.
I am not sure how to do that, need help!
or will wx.popwindow + wx.checkbox combination be a better choice?

Perhaps ComboCtrl with a CheckListBox popup, or with a wx.ListCtrl plus
CheckListCtrlMixin if you need more than one column.


Robin Dunn
Software Craftsman
http://wxPython.org

Sorry, I don't understand your question.

···

On 8/30/12 6:03 PM, zhengqing wrote:

Hi Robin,
     Thanks!
     That works very well, but somehow the checklistbox size is lot control.
     please help!

--
Robin Dunn
Software Craftsman

Sorry!

I mean I can’t control the size of the checklistbox in combo control, no matter how I set the size.

And in the function bellow:
        def Create(self, parent):
self.checklistbox

what is self and parent?

cc = wx.combo.ComboCtrl(self, size = (250, -1))
tcp = CheckboxComboPopup()
cc.SetPopupControl(tcp)


It looks like checklistbox is not attribute of cc and tcp, how can I add items, I tried create a method for adding new items, but it doesn't work?

def Additems(self, list):

# list = ['zeor', 'one']

for item in list:

self.checklistbox.append(item)

tcp.Additems(list)

And this doesn't work!

Please help!

Regards!

zhengqing(Forrest)

<details class='elided'>
<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>

On Saturday, September 1, 2012 3:11:19 PM UTC-7, Robin Dunn wrote:
> On 8/30/12 6:03 PM, zhengqing wrote:
> 
> > Hi Robin,
> 
> >      Thanks!
> 
> >      That works very well, but somehow the checklistbox size is lot control.
> 
> >      please help!
> 
> 
> 
> Sorry, I don't understand your question.
> 
> 
> 
> 
> 
> --
> Robin Dunn
> 
> Software Craftsman
> 
> [http://wxPython.org](http://wxPython.org)
> 
> 
>

</details>

Sorry!
I mean I can't control the size of the checklistbox in combo control, no
matter how I set the size.

And in the function bellow:

      def Create(self, parent):
         self.checklistbox

what is self and parent?

Like usual self is an instance of the class that the method is a member of, in this case the ComboPopup. Parent is the widget that should be used as the parent of the widget that is created.

cc = wx.combo.ComboCtrl(self, size = (250, -1))
tcp = CheckboxComboPopup()
cc.SetPopupControl(tcp)

It looks like checklistbox is not attribute of cc and tcp,

The Create method is not called until after the SetPopupControl method above, so checklistbox does not exist until then. But after that point in the code you should be able to use checklistbox (or call a method that uses it) without problems.

···

On 9/1/12 9:56 PM, zhengqing wrote:

--
Robin Dunn
Software Craftsman

Thank you very much! problem solved!

Then another problem is that I can’t set the size as shown in the figure.

how to make the size to fit the number of checkbox?

Thanks!

···

On Monday, September 3, 2012 12:16:20 PM UTC-7, Robin Dunn wrote:

On 9/1/12 9:56 PM, zhengqing wrote:

Sorry!
I mean I can’t control the size of the checklistbox in combo control, no
matter how I set the size.

And in the function bellow:

  def Create(self, parent):
     self.checklistbox

what is self and parent?

Like usual self is an instance of the class that the method is a member
of, in this case the ComboPopup. Parent is the widget that should be
used as the parent of the widget that is created.

cc = wx.combo.ComboCtrl(self, size = (250, -1))
tcp = CheckboxComboPopup()
cc.SetPopupControl(tcp)

It looks like checklistbox is not attribute of cc and tcp,

The Create method is not called until after the SetPopupControl method
above, so checklistbox does not exist until then. But after that point
in the code you should be able to use checklistbox (or call a method
that uses it) without problems.


Robin Dunn
Software Craftsman
http://wxPython.org

Do you override the GetAdjustedSize method in your ComboPopup class?

···

On 9/3/12 6:56 PM, zhengqing wrote:

Thank you very much! problem solved!
Then another problem is that I can't set the size as shown in the figure.
how to make the size to fit the number of checkbox?

--
Robin Dunn
Software Craftsman

http://docs.wxwidgets.org/trunk/classwx_combo_popup.html#ae8ff1d6570b177c2c6b7a101035cf2ff

···

On 9/4/12 9:30 PM, zhengqing wrote:

Hi Robin,
     no, I didn't. From the Demo, I can't tell when this method was
called, and what is the function of this method.
     Now I add this method into the class, but still don't know how it
works, and where those parameter comes from, how to set those
parameters, and when this method was called.

     def GetAdjustedSize(self, minWidth, prefHeight, maxHeight):
         return wx.Size(minWidth, min(150, maxHeight))

     Please help if I would like to learn more about wxpython.

--
Robin Dunn
Software Craftsman