HI,
I’ve been trying to get ButtonPanel to work and so far no luck. Below is my attempt
at a simple frame with a panel on it, and then a ButtonPanel on that. I just made a
frame, put a panel on it, put a panel on that panel, then changed it to a ButtonPanel.
I also included the SetProperties function from the ButtonPanel demo.
But when I run it, I only see the frame with the first panel, not the ButtonPanel.
What am I missing?
Thanks.
···
import wx
import wx.lib.buttonpanel as bp
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1PANEL1, wxID_FRAME1PANEL2,
] = [wx.NewId() for _init_ctrls in range(3)]
class Frame1(
wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don’t edit
wx.Frame.init(self, id=wxID_FRAME1, name=’’, parent=prnt,
pos=wx.Point(66, 87), size=wx.Size
(400, 489),
style=wx.DEFAULT_FRAME_STYLE, title=‘Frame1’)
self.SetClientSize(wx.Size(392, 455))
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(392, 455),
style=wx.TAB_TRAVERSAL)
self.panel1.SetBackgroundColour(wx.Colour(44, 211, 142))
self.alignment = bp.BP_ALIGN_LEFT
self.style = bp.BP_USE_GRADIENT
self.panel2 = bp.ButtonPanel(self.panel1, -1, "A Simple Test & Demo",
style=self.style, alignment=
self.alignment)
self.SetProperties()
def SetProperties(self):
# Sets the colours for the two demos: called only if the user didn't
# modify the colours and sizes using the Settings Panel
bpArt = self.panel2.GetBPArt()
if self.style & bp.BP_USE_GRADIENT:
# set the color the text is drawn with
bpArt.SetColor(bp.BP_TEXT_COLOR, wx.WHITE)
# These default to white and whatever is set in the system
# settings for the wx.SYS_COLOUR_ACTIVECAPTION. We'll use
# some specific settings to ensure a consistent look for the
# demo.
bpArt.SetColor(bp.BP_BORDER_COLOR, wx.Colour(120,23,224))
bpArt.SetColor(bp.BP_GRADIENT_COLOR_FROM, wx.Colour(60,11,112))
bpArt.SetColor(bp.BP_GRADIENT_COLOR_TO
, wx.Colour(120,23,224))
bpArt.SetColor(bp.BP_BUTTONTEXT_COLOR, wx.Colour(70,143,255))
bpArt.SetColor(bp.BP_SEPARATOR_COLOR,
bp.BrightenColour(wx.Colour(60, 11, 112), 0.85))
bpArt.SetColor(bp.BP_SELECTION_BRUSH_COLOR, wx.Color(225, 225, 255))
bpArt.SetColor(bp.BP_SELECTION_PEN_COLOR, wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVECAPTION))
else:
background = self.panel2.GetBackgroundColour()
bpArt.SetColor(bp.BP_TEXT_COLOR, wx.BLUE)
bpArt.SetColor(bp.BP_BORDER_COLOR,
bp.BrightenColour
(background, 0.85))
bpArt.SetColor(bp.BP_SEPARATOR_COLOR,
bp.BrightenColour(background, 0.85))
bpArt.SetColor(bp.BP_BUTTONTEXT_COLOR, wx.BLACK)
bpArt.SetColor
(bp.BP_SELECTION_BRUSH_COLOR, wx.Colour(242, 242, 235))
bpArt.SetColor(bp.BP_SELECTION_PEN_COLOR, wx.Colour(206, 206, 195))
self.panel2.SetStyle(self.style)
def __init__(self, parent):
self._init_ctrls(parent)