作成したボタンのコレクションがあり、ボタンが押されたときにボタンの色を変更する必要があります。現在、デフォルトの色が設定されています (灰色 = 非アクティブ、水色 = アクティブ):
しかし、アクティブの色を赤に変更したいです。
これが私のボタンクラスです:
class ButtonClass(wx.Panel):
def __init__(self, parent, name, id):
wx.Panel.__init__(self, parent)
self.name = name
self.taskid = id
self.button = wx.ToggleButton(self, 1, size=(50, 50))
self.button.SetLabel('Start')
self.mainSizer = wx.BoxSizer(wx.HORIZONTAL)
self.mainSizer.Add(self.button)
self.Bind(wx.EVT_TOGGLEBUTTON, self.toggledbutton, self.button)
# Where the buttons change state
def toggledbutton(self, event):
# Active State
if self.button.GetValue() == True:
self.button.SetLabel('Stop')
# Inactive State
if self.button.GetValue() == False:
self.button.SetLabel('Start')
self.button.SetColour
、を使用してみましたがself.button.SetBackgroundColour
、self.button.SetForegroundColour
すべてうまくいきませんでした。wxpython 内でこれを達成する方法はありますか?