wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.32k stars 516 forks source link

Radio Toolbar Buttons behave as Toggle if Toolbar is Vertical #850

Open itsayellow opened 6 years ago

itsayellow commented 6 years ago

Operating system: Macos 10.13.4 wxPython version: 4.0.1 Stock or custom build: Stock (pip3) Python version: 3.6.5 Stock or custom build: Stock (homebrew)

Description of the problem:

Somehow radio buttons don't seem to work properly in a vertical toolbar.

In the following script, when the toolbar is created as a TB_HORIZONTAL toolbar, the radio buttons behave as expected: i.e. a click on one button, deselects another selected button.

However, when the toolbar is created as TB_VERTCIAL (by changing the TBFLAGS) the buttons all misbehave, acting instead as toggle buttons.

#!/usr/bin/env python3

import wx

#TBFLAGS = wx.TB_HORIZONTAL
TBFLAGS = wx.TB_VERTICAL

class MainWindow(wx.Frame):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.SetSize((800, 600))

        tb = self.CreateToolBar( TBFLAGS )
        tsize = (32,32)
        hd_bmp =  wx.ArtProvider.GetBitmap(wx.ART_HARDDISK, wx.ART_TOOLBAR, tsize)
        flop_bmp =  wx.ArtProvider.GetBitmap(wx.ART_FLOPPY, wx.ART_TOOLBAR, tsize)
        cd_bmp =  wx.ArtProvider.GetBitmap(wx.ART_CDROM, wx.ART_TOOLBAR, tsize)
        tb.SetToolBitmapSize(tsize)
        tool = tb.AddRadioTool( wx.ID_ANY, "Radio0", hd_bmp,
                shortHelp="Radio 0")
        tool = tb.AddRadioTool(wx.ID_ANY, "Radio1", flop_bmp,
                shortHelp="Radio 1")
        tool = tb.AddRadioTool(wx.ID_ANY, "Radio2", cd_bmp,
                shortHelp="Radio 2")
        tb.Realize()

        self.Show(True)

def main():
    my_app = wx.App()
    main_win = MainWindow(None)
    my_app.MainLoop()

if __name__ == '__main__':
    main()
RobinD42 commented 6 years ago

It doesn't look like anything can be done about this in wxPython. Please check https://trac.wxwidgets.org and create a ticket there for it if one doesn't already exist.

itsayellow commented 6 years ago

https://trac.wxwidgets.org/ticket/18178

Sorry I took so long!