WxPython 更新框架以显示按钮
我是 wx 小部件的新手。我正在尝试制作一个 GUI,其中必须根据某些条件显示某些按钮。问题是,当我在 Frame.show() 之后创建这个新按钮时,该按钮不可见,直到我将鼠标悬停在按钮应该所在的位置上。我尝试了 Frame.Refresh() 但这不起作用。
self.button = wx.Button(panel, 1, 'Delete', (230, 120))
self.Bind(wx.EVT_BUTTON, self.delSong, self.button)
self.button2 = wx.Button(panel, 3, 'Refresh', (130, 120))
self.Bind(wx.EVT_BUTTON, self.shelving, self.button2)
self.button.Disable()
self.button2.Enable()
self.button3 = wx.Button(panel, 1, 'Exit', (230, 120))
self.Bind(wx.EVT_BUTTON, self.close, self.button3)
self.button3.Hide()
self.Show()
try:
fooo
except KeyError:
self.button.Destroy()
self.button3.Show()
我在这里想做的是删除按钮并显示button3。但如果出现异常,button3 不会显示在框架中。还有什么东西可以刷新框架吗?
I am new to wx widgets. I am trying to make a GUI in which I have to show certain buttons based on certain conditions. The problem is that when I create this new button after Frame.show() The button is not visible until I take the mouse over the place the button is supposed to be. I tried Frame.Refresh() But that isn't working.
self.button = wx.Button(panel, 1, 'Delete', (230, 120))
self.Bind(wx.EVT_BUTTON, self.delSong, self.button)
self.button2 = wx.Button(panel, 3, 'Refresh', (130, 120))
self.Bind(wx.EVT_BUTTON, self.shelving, self.button2)
self.button.Disable()
self.button2.Enable()
self.button3 = wx.Button(panel, 1, 'Exit', (230, 120))
self.Bind(wx.EVT_BUTTON, self.close, self.button3)
self.button3.Hide()
self.Show()
try:
fooo
except KeyError:
self.button.Destroy()
self.button3.Show()
What I want to do here is to remove the button and show button3. But In case of the exception the button3 is not displayed in the frame. Is there something else that refreshes the frame ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能只需要调用 Frame 的 Layout() 方法。这就是我在插入或删除小部件时所做的事情。我还建议学习调整器,因为它们对于自动调整尺寸和定位非常方便。
You probably just need to call the Frame's Layout() method. That's what I do when I insert or remove a widget. I also recommend learning sizers as they are very handy for automatic sizing and positioning.