Phoenix - AquaButton and EVT_UPDATE_UI

Hi,

I noticed that the button is not refreshing when I do below, so I added the last line in the handler. Now the problem does only show if I use wx.lib.agw.aquabutton.

Any tip of what needs to change in AquaButton to do the refresh automatically?

Werner

         self.importwine.Bind(wx.EVT_UPDATE_UI, self.onUpdateUIImportwine)

     def onUpdateUIImportwine(self, evt): #pylint: disable=W0613
         """Set import wine button state"""
         if self._vinoSel:
             evt.Enable(True)
         else:
             evt.Enable(False)
         evt.GetEventObject().Refresh()

Werner wrote:

Hi,

I noticed that the button is not refreshing when I do below, so I added
the last line in the handler. Now the problem does only show if I use
wx.lib.agw.aquabutton.

Any tip of what needs to change in AquaButton to do the refresh
automatically?

Try overriding DoEnable in AquaButton with something like this:

def DoEnable(self, enable):
     wasEnabled = self.IsEnabled()
     super(AquaButton, self).DoEnable(enable)
     if self.IsEnabled() != wasEnabled:
         self.Refresh()

···

--
Robin Dunn
Software Craftsman

I can only get it to work like this:
     def DoEnable(self, enable):
         """
         Overridden base class virtual.

         Need to Refresh if Enable state changed.
         """
         self.Refresh()

It looks like the enable state is already changed by the time DoEnable is called.

Does this make sense?

Werner

···

On 2/26/2015 20:37, Robin Dunn wrote:

Werner wrote:

Hi,

I noticed that the button is not refreshing when I do below, so I added
the last line in the handler. Now the problem does only show if I use
wx.lib.agw.aquabutton.

Any tip of what needs to change in AquaButton to do the refresh
automatically?

Try overriding DoEnable in AquaButton with something like this:

def DoEnable(self, enable):
    wasEnabled = self.IsEnabled()
    super(AquaButton, self).DoEnable(enable)
    if self.IsEnabled() != wasEnabled:
        self.Refresh()