我的应用程序有2个框架。我可以通过按下第一帧上的按钮自由地从第一帧切换到第二帧。由于某些原因,当我加载第二帧,EVT_BUTTON,我绑定到它的一个按钮触发器。更糟糕的是,当我在第二帧中点击它时,它不会触发。我是python和wx库的新手,但到目前为止,它是相当简单的,现在我有点卡住了。
class ItemInfo(wx.Frame):
def __init__(self, parent, item, *args):
super(ItemInfo, self).__init__(parent)
self.Centre()
# self.Size = wx.Size(500, 900)
self.current_item = self.find_current_item(item)
#I skipped several boxsizers in this snipped
test_button = wx.Button(self, label="Test")
self.Bind(wx.EVT_BUTTON, self.show_current_item_stats(), test_button)
button_sizer = wx.BoxSizer(wx.HORIZONTAL)
button_sizer.Add(test_button, wx.ID_ANY, wx.ALIGN_CENTER)
self.main_sizer = wx.BoxSizer(wx.VERTICAL)
self.main_sizer.Add(button_sizer, wx.ID_ANY, wx.EXPAND)
self.SetSizer(self.main_sizer)
def show_current_item_stats(self):
self.current_item.stat_bonuses["Strength"] += 510
self.current_item_strength_bonus.SetLabel(f"Strength: {self.current_item.stat_bonuses['Strength']}")
'''发布于 2019-08-30 16:56:17
看起来我不小心通过添加()调用了函数,而不是仅仅绑定它。愚蠢的我+)
https://stackoverflow.com/questions/57713300
复制相似问题