Bug in wx.CheckListBox that damages all manu's wx.ITEM_RADIO

Hi,

I just saw that whenever a wx.CheckListBox is created with choises (not []), or when using the “.Set” function for wx.CheckListBox - all the icons for wx.ITEM_RADIO in menus disappear (the black circle saying which item is selected). It only affect menus that havn’t been created yet.

Even when selecting a new item in the menu the black circle doesn’t reappear.

Don’t know how the wx.CheckListBox is related to wx.Menu …

If anyone can help fixing this please let me know.

Thanks.

Tested under win32.

The following is a sample app for reproducing the problem.

···

import wx
import sys
“”" A Class for reproducing a bug when using a non-empty wx.CheckListBox
- All Radio check items are damaged, the icon for the selected item disappears.
Tested under win32 (Windows XP)"""

class TestCheckListBox(wx.Panel):
def init(self, parent):
wx.Panel.init(self, parent, -1)
colSizer = wx.BoxSizer(wx.VERTICAL)
# The list Box
self.listbox1 = wx.CheckListBox
( self, -1, choices=[], style=wx.LB_HSCROLL )
colSizer.Add(self.listbox1, 0)

This is the line that causes the problems,

    # Either that, or setting the choices parameter in the wx.CheckListBox not to [].
    # Both cause the same problem
    # Comment this line and see how everything works well

    self.listbox1.Set( ["test1", "test2"] )

    # A Simple right click menu for reproducing the disappearance of Radio-tool item bitmaps (the balck circle)
    # The bug also affects radio tools in Application menu.
    # It seems like all the menues that have been created after using self.listbox1.Set got damaged
    txt = wx.StaticText(self, -1, "Right Click Here!")
    colSizer.Add(txt, 0)
    txt.Bind(wx.EVT_RIGHT_UP, self.showMenu)
    self.SetSizer(colSizer)

    self.SetAutoLayout(True)
   
    self.chosen = 0
    self.popupmenu = False
   
def makePopupMenu(self):
    self.popupmenu = wx.Menu()       
    self.popupmenu.Append

(666, “Option1”, “Option1”, wx.ITEM_RADIO)
self.popupmenu.Append(667, “Option2”, “Option2”, wx.ITEM_RADIO)
self.popupmenu.Append(668, “Option3”, “Option3”, wx.ITEM_RADIO)
self.Bind(wx.EVT_MENU, self.onChangeOption, id = 666, id2 = 668)

def showMenu(self, event):
    if not self.popupmenu:
        self.makePopupMenu()
    self.popupmenu.Check(self.chosen + 666, True)
    self.PopupMenuXY(self.popupmenu, -1, -1)

def onChangeOption(self, event):
self.chosen = event.GetId() - 666
print "Chosen: ", self.chosen
event.Skip()

class TestFrame(wx.Frame):

def init(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE ):

wx.Frame.init(self, parent, id, title, size=size, style=style)

self.win = TestCheckListBox(self)

def main(argv=None):
if argv is None:
argv = sys.argv

app = wx.PySimpleApp()
f = TestFrame(None, -1, “CheckListBox Bug Test”,wx.Size(500,300))
f.Show()
app.MainLoop()

if name == ‘main’:
main()


Yes, I can reproduce your problem.

Strange (I use 2.6.2.1 and Windows Xp)

If I move following lines before the setting of the checkboxes,
then it works:

        self.listbox1 = wx.CheckListBox( self, -1, choices=[], style=wx.LB_HSCROLL )
        colSizer.Add(self.listbox1, 0)

#here I moved the creation
#it seems like the popupmenu must be created before
        self.popupmenu = False
        if not self.popupmenu:
            self.makePopupMenu()

        # This is the line that causes the problems,
        # Either that, or setting the choices parameter in thewx.CheckListBox not to [].
        # Both cause the same problem
        # Comment this line and see how everything works well
        self.listbox1.Set( ["test1", "test2"] )

There must be some bug!

···

On Mon, 8 May 2006 23:12:40 +0200, "roee88 shlomo" <roee88@gmail.com> wrote:

Hi,
I just saw that whenever a wx.CheckListBox is created with choises (not []),
or when using the ".Set" function for wx.CheckListBox - all the icons for
wx.ITEM_RADIO in menus disappear (the black circle saying which item is
selected). It only affect menus that havn't been created yet.
Even when selecting a new item in the menu the black circle doesn't
reappear.
Don't know how the wx.CheckListBox is related to wx.Menu ...
If anyone can help fixing this please let me know.
Thanks.

Tested under win32.
The following is a sample app for reproducing the problem.

--

Franz Steinhaeusler

I’m curious if its a bug in wxPython bug or it’s a wxWidgets bug.

Any idea who is the one that the bug should be reported to?

Creating the menu before the checklistbox does by-pass the bug, but big applications use dynamic menus so creating the menu at startup may not always be possible.

···

On 5/11/06, Franz Steinhaeusler franz.steinhaeusler@gmx.at wrote:

On Mon, 8 May 2006 23:12:40 +0200, “roee88 shlomo” <roee88@gmail.com > > wrote:

Hi,
I just saw that whenever a wx.CheckListBox is created with choises (not []),
or when using the “.Set” function for wx.CheckListBox - all the icons for
wx.ITEM_RADIO
in menus disappear (the black circle saying which item is
selected). It only affect menus that havn’t been created yet.
Even when selecting a new item in the menu the black circle doesn’t
reappear.

Don’t know how the wx.CheckListBox is related to wx.Menu …
If anyone can help fixing this please let me know.
Thanks.

Tested under win32.
The following is a sample app for reproducing the problem.

Yes, I can reproduce your problem.

Strange (I use 2.6.2.1 and Windows Xp)

If I move following lines before the setting of the checkboxes,
then it works:

   self.listbox1 = wx.CheckListBox( self, -1, choices=[], style=wx.LB_HSCROLL )
   colSizer.Add(self.listbox1, 0)

#here I moved the creation
#it seems like the popupmenu must be created before
self.popupmenu
= False
if not self.popupmenu:
self.makePopupMenu()

   # This is the line that causes the problems,
   # Either that, or setting the choices parameter in thewx.CheckListBox not to [].

   # Both cause the same problem
   # Comment this line and see how everything works well
   self.listbox1.Set( ["test1", "test2"] )

There must be some bug!

Franz Steinhaeusler


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Huh... That would explain my recent problems with radio items in the
menus. I managed to work around it by using check items and liberal
"clear everything, check the item that was clicked on" behavior. Quite
a pain, but I got it working. It would be better if the radio items
were fixed instead.

- Josiah

···

Franz Steinhaeusler <franz.steinhaeusler@gmx.at> wrote:

On Mon, 8 May 2006 23:12:40 +0200, "roee88 shlomo" <roee88@gmail.com> wrote:
>Hi,
>I just saw that whenever a wx.CheckListBox is created with choises (not []),
>or when using the ".Set" function for wx.CheckListBox - all the icons for
>wx.ITEM_RADIO in menus disappear (the black circle saying which item is
>selected). It only affect menus that havn't been created yet.
>Even when selecting a new item in the menu the black circle doesn't
>reappear.
>Don't know how the wx.CheckListBox is related to wx.Menu ...
>If anyone can help fixing this please let me know.
>Thanks.
>
>Tested under win32.
>The following is a sample app for reproducing the problem.

I'm curious if its a bug in wxPython bug or it's a wxWidgets bug.
Any idea who is the one that the bug should be reported to?

I would say wiWidgets specific.

Creating the menu before the checklistbox does by-pass the bug, but big
applications use dynamic menus so creating the menu at startup may not
always be possible.

Yes, your are right.

···

On Thu, 11 May 2006 19:35:08 +0200, "roee88 shlomo" <roee88@gmail.com> wrote:

--

Franz Steinhaeusler