Problem with Platebuttons

I got this problem when using platebuttons.
I have a panel with a sizer and the sizer got the platebutton. But when I
click left mouse button on the panel (not on the button) the button gets
highlighted! Is this bug in the platebuttons or bug in my code? :slight_smile:

so in the example there's two panels with buttons, when app starts for some
reason first button is highlighted already, but hover the mouse above it
first, then press on the lower panel, and then upper panel, then lower...
and you will see that pressing only the panel highlight the button :frowning:

as a bonus bug the example code crash when you close it, have no idea why,
but that's not happening in my main program, so don't wonder too much about
that :wink:

see the code in http://pastebin.com/f7bed6246
or below:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import wx
import wx.lib.platebtn as platebtn

class MyFrame(wx.Frame):
聽聽聽def __init__(self):
聽聽聽聽聽聽wx.Frame.__init__(self, None, id=-1, title="test", size=(320,100))

聽聽聽聽聽聽main_panel = wx.Panel(self, -1)

聽聽聽聽聽聽#button 1 & panel & sizer
聽聽聽聽聽聽panel2 = wx.Panel(main_panel, -1)
聽聽聽聽聽聽panel2.SetBackgroundColour("#FFFF00")
聽聽聽聽聽聽button = platebtn.PlateButton(panel2, id_=wx.ID_ANY, label="Button 1",
style=platebtn.PB_STYLE_SQUARE)

聽聽聽聽聽聽button_sizer = wx.BoxSizer(wx.VERTICAL)
聽聽聽聽聽聽button_sizer.Add(button, 0, wx.RIGHT|wx.ALIGN_RIGHT, 10)
聽聽聽聽聽聽panel2.SetSizer(button_sizer)
聽聽聽聽聽聽panel2.SetAutoLayout(True)

聽聽聽聽聽聽#button 2 & panel & sizer
聽聽聽聽聽聽panel3 = wx.Panel(main_panel, -1)
聽聽聽聽聽聽panel3.SetBackgroundColour("#FFFFFF")
聽聽聽聽聽聽button2 = platebtn.PlateButton(panel3, id_=wx.ID_ANY, label="Button
2", style=platebtn.PB_STYLE_SQUARE)

聽聽聽聽聽聽button_sizer2 = wx.BoxSizer(wx.VERTICAL)
聽聽聽聽聽聽button_sizer2.Add(button2, 0, wx.RIGHT|wx.ALIGN_RIGHT, 10)
聽聽聽聽聽聽panel3.SetSizer(button_sizer)
聽聽聽聽聽聽panel3.SetAutoLayout(True)

聽聽聽聽聽聽sizer = wx.BoxSizer(wx.VERTICAL)
聽聽聽聽聽聽sizer.Add(panel2, 0, wx.EXPAND)
聽聽聽聽聽聽sizer.Add(panel3, 0, wx.EXPAND)

聽聽聽聽聽聽main_panel.SetAutoLayout(True)
聽聽聽聽聽聽main_panel.SetSizer(sizer)
聽聽聽聽聽聽main_panel.Layout()

app = wx.PySimpleApp()
MyFrame().Show()
app.MainLoop()

路路路

--
View this message in context: http://www.nabble.com/Problem-with-Platebuttons-tp20832417p20832417.html
Sent from the wxPython-users mailing list archive at Nabble.com.

kewlar wrote:

as a bonus bug the example code crash when you close it, have no idea why,
but that's not happening in my main program, so don't wonder too much
about that :wink:

please use this updated code instead original :

panel3 was using the same sizer as panel2 and that's why it was crashing...
but that wasn't my main problem here anyway.

路路路

--
View this message in context: http://www.nabble.com/Problem-with-Platebuttons-tp20832417p20832519.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Hello,

When you click on a panel a child control that AcceptsFocus is given the focus by the panel, the PlateButton shows its highlighted state when it has the focus.

If you want to override this behavior you can do as follows.

class myPlateButton(platebtn.PlateButton):
  def __init__(self, ...):
    platebtn.PlateButton.__init__(self, ...)

  def AcceptsFocus(self):
    return False

Cody

路路路

On Dec 4, 2008, at 6:32 AM, kewlar wrote:

kewlar wrote:

as a bonus bug the example code crash when you close it, have no idea why,
but that's not happening in my main program, so don't wonder too much
about that :wink:

please use this updated code instead original :
http://pastebin.com/f70a43acd

panel3 was using the same sizer as panel2 and that's why it was crashing...
but that wasn't my main problem here anyway.
--
View this message in context: http://www.nabble.com/Problem-with-Platebuttons-tp20832417p20832519.html
Sent from the wxPython-users mailing list archive at Nabble.com.

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Thanks it worked with the panels. I had also another focus problem, if I did
click on the button and then minimize window to taskbar and then maximize it
(couldn't reproduce this with the example code) the platebutton got focus,
so I added this:
def SetFocus(self): return False
which solved that :slight_smile:

Cody Precord wrote:

路路路

Hello,

When you click on a panel a child control that AcceptsFocus is given
the focus by the panel, the PlateButton shows its highlighted state
when it has the focus.

If you want to override this behavior you can do as follows.

class myPlateButton(platebtn.PlateButton):
  def __init__(self, ...):
    platebtn.PlateButton.__init__(self, ...)

  def AcceptsFocus(self):
    return False

Cody

--
View this message in context: http://www.nabble.com/Problem-with-Platebuttons-tp20832417p20848370.html
Sent from the wxPython-users mailing list archive at Nabble.com.