WxPython Updating Frame to show buttons
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开发者_如何学Python.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 ?
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.
精彩评论