agw.aui and wx.InfoBar - can't get them to play nicely

I changed the demo, see attached to add an InfoBar to the bottom - search for AddInfoBar.

When it is shown it does not size correctly, i.e. button is not shown and one dismisses it does not hide completely.

Does anyone see what I am doing wrong?

Werner

AUI.py (133 KB)

Hi Werner,

I changed the demo, see attached to add an InfoBar to the bottom - search
for AddInfoBar.

When it is shown it does not size correctly, i.e. button is not shown and
one dismisses it does not hide completely.

Does anyone see what I am doing wrong?

Nothing wrong that I can see. I don't know that much about wx.InfoBar,
but from my understanding of this documentation:

http://docs.wxwidgets.org/trunk/classwx_info_bar.html#ab2ce2964b330eb742af11b9226616e56

void wxInfoBar::Dismiss()
Hide the info bar window.

This method hides the window and lays out the parent window to account
for its disappearance (unlike a simple Hide()).

wx.InfoBar will not play nicely with the layout mechanism of AUI (at
least the Python version of it, did you try with wx.aui?). The problem
is wx.InfoBar should not touch the parent layout if it is managed by
AUI, it should simply disappear. I am not sure if this is the actual
problem or, even if it is, if there is a way to tell wx.InfoBar to
stop messing up with parent's layouts. Maybe Robin will have a better
explanation.

Of course, you can also contact Vadim (the creator of wx.InfoBar, as
far as I remember) via wx-users, maybe he could explain what we might
do to make AUI and wx.InfoBar play nicely together.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 10 March 2012 11:21, werner wrote:

I think I got a work around.

I had:
wx.Frame
- aui
-- notebooks etc
-- infobar

Changed to:
sc.SizedFrame
- sc.SizedPanel
--- aui
----- notebooks etc
- infobar

In other words, aui does no longer manage the InfoBar and use an additional panel which aui manages.

Works for me for the moment.

Obviously it would still be nice to have an InfoBar in an aui controlled panel/frame, but will wait until we get Robin's insight on how to go about that.

Werner

···

On 10/03/2012 23:06, Andrea Gavana wrote:

Hi Werner,

On 10 March 2012 11:21, werner wrote:

I changed the demo, see attached to add an InfoBar to the bottom - search
for AddInfoBar.

When it is shown it does not size correctly, i.e. button is not shown and
one dismisses it does not hide completely.

Does anyone see what I am doing wrong?

Nothing wrong that I can see. I don't know that much about wx.InfoBar,
but from my understanding of this documentation:

wxWidgets: wxInfoBar Class Reference

void wxInfoBar::Dismiss()
Hide the info bar window.

This method hides the window and lays out the parent window to account
for its disappearance (unlike a simple Hide()).

wx.InfoBar will not play nicely with the layout mechanism of AUI (at
least the Python version of it, did you try with wx.aui?). The problem
is wx.InfoBar should not touch the parent layout if it is managed by
AUI, it should simply disappear. I am not sure if this is the actual
problem or, even if it is, if there is a way to tell wx.InfoBar to
stop messing up with parent's layouts. Maybe Robin will have a better
explanation.

Of course, you can also contact Vadim (the creator of wx.InfoBar, as
far as I remember) via wx-users, maybe he could explain what we might
do to make AUI and wx.InfoBar play nicely together.

Hi Werner,

Hi Werner,

I changed the demo, see attached to add an InfoBar to the bottom - search
for AddInfoBar.

When it is shown it does not size correctly, i.e. button is not shown and
one dismisses it does not hide completely.

Does anyone see what I am doing wrong?

Nothing wrong that I can see. I don't know that much about wx.InfoBar,
but from my understanding of this documentation:

wxWidgets: wxInfoBar Class Reference

void wxInfoBar::Dismiss()
Hide the info bar window.

This method hides the window and lays out the parent window to account
for its disappearance (unlike a simple Hide()).

wx.InfoBar will not play nicely with the layout mechanism of AUI (at
least the Python version of it, did you try with wx.aui?). The problem
is wx.InfoBar should not touch the parent layout if it is managed by
AUI, it should simply disappear. I am not sure if this is the actual
problem or, even if it is, if there is a way to tell wx.InfoBar to
stop messing up with parent's layouts. Maybe Robin will have a better
explanation.

Of course, you can also contact Vadim (the creator of wx.InfoBar, as
far as I remember) via wx-users, maybe he could explain what we might
do to make AUI and wx.InfoBar play nicely together.

I think I got a work around.

I had:
wx.Frame
- aui
-- notebooks etc
-- infobar

Changed to:
sc.SizedFrame
- sc.SizedPanel
--- aui
----- notebooks etc
- infobar

In other words, aui does no longer manage the InfoBar and use an additional
panel which aui manages.

Works for me for the moment.

Obviously it would still be nice to have an InfoBar in an aui controlled
panel/frame, but will wait until we get Robin's insight on how to go about
that.

One thing I am almost about to try is to run your demo with my Python
version of wx.InfoBar (I have translated it from C++) and see if
anything changes by modifying the Dismiss() method to handle a
particular case where the wx.InfoBar parent is managed by AUI or
wx.aui.

Then the next question would be: if I can make it work, is there any
interest in having a pure-Python "PyInfoBar" version of wx.InfoBar in
wx.lib.agw? Or is it just a redundant waste of time and disk space in
the wxPython installation?

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 12 March 2012 11:45, werner wrote:

On 10/03/2012 23:06, Andrea Gavana wrote:

On 10 March 2012 11:21, werner wrote:

On 12/03/2012 12:13, Andrea Gavana wrote::slight_smile:
...

One thing I am almost about to try is to run your demo with my Python
version of wx.InfoBar (I have translated it from C++) and see if
anything changes by modifying the Dismiss() method to handle a
particular case where the wx.InfoBar parent is managed by AUI or
wx.aui.

Then the next question would be: if I can make it work, is there any
interest in having a pure-Python "PyInfoBar" version of wx.InfoBar in
wx.lib.agw? Or is it just a redundant waste of time and disk space in
the wxPython installation?

If it is an issue with wx.InfoBar I think it should get fixed in the C++ code and not duplicate the effort in a PyInfoBar version. But if the C++ code isn't getting fixed then I would very much like to see a py version of it as I think InfoBar is a nice way of informing the user about issues without getting in the way (MessageDialog) but still be much more obvious then the StatusBar.

Werner

Hi Werner,

On 12/03/2012 12:13, Andrea Gavana wrote::slight_smile:
...

One thing I am almost about to try is to run your demo with my Python
version of wx.InfoBar (I have translated it from C++) and see if
anything changes by modifying the Dismiss() method to handle a
particular case where the wx.InfoBar parent is managed by AUI or
wx.aui.

Then the next question would be: if I can make it work, is there any
interest in having a pure-Python "PyInfoBar" version of wx.InfoBar in
wx.lib.agw? Or is it just a redundant waste of time and disk space in
the wxPython installation?

If it is an issue with wx.InfoBar I think it should get fixed in the C++
code and not duplicate the effort in a PyInfoBar version. But if the C++
code isn't getting fixed then I would very much like to see a py version of
it as I think InfoBar is a nice way of informing the user about issues
without getting in the way (MessageDialog) but still be much more obvious
then the StatusBar.

OK, I managed to make it work on the pure-Python version of
wx.InfoBar, without the need of using any aui_manager.Update() or
whatever from the developer. Everything is handled inside PyInfoBar,
so I would say it is a limitation of the C++ code (unless the C++
wx.InfoBar it works with the C++ version of wx.aui, in which case the
wx-devs could simply tell us to shut up...).

This is the fix I had to add to PyInfoBar to make it work with AUI:

ORIGINAL (translated from C++):

    def DoHide(self):

        self.HideWithEffect(self.GetHideEffect(), self.GetEffectDuration())

NEW:

    def DoHide(self):

        self.HideWithEffect(self.GetHideEffect(), self.GetEffectDuration())

        handler = self.GetParent().GetEventHandler()

        if not isinstance(handler, framemanager.AuiManager):
            self.UpdateParent()
        else:
            pane = handler.GetPane(self)
            pane.Show(False)
            handler.Update()

I don't think it would be much of a problem to fix the C++ version,
but unfortunately even if the wx-devs fix it, the C++ version of
wx.InfoBar knows nothing about the AGW AUI Python version, so I guess
we will still be more or less in the same boat (unless I am missing
something obvious here...).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 12 March 2012 14:10, werner wrote:

You're not missing anything. There isn't a clean or easy way to get the C++ code to know what Python objects are being used, or even that Python is there at all. However in Phoenix it will be possible to properly override at least the Dismiss method in a Python class derived from wx.InfoBar, so the special handling for agw.aui could be done that way.

In the meantime you could probably do it from a wx.EVT_SHOW handler bound to the infobar. Check event.GetShow() to know if it is being shown or hidden.

···

On 3/12/12 7:25 AM, Andrea Gavana wrote:

I don't think it would be much of a problem to fix the C++ version,
but unfortunately even if the wx-devs fix it, the C++ version of
wx.InfoBar knows nothing about the AGW AUI Python version, so I guess
we will still be more or less in the same boat (unless I am missing
something obvious here...).

--
Robin Dunn
Software Craftsman

I don't think it would be much of a problem to fix the C++ version,
but unfortunately even if the wx-devs fix it, the C++ version of
wx.InfoBar knows nothing about the AGW AUI Python version, so I guess
we will still be more or less in the same boat (unless I am missing
something obvious here...).

You're not missing anything. There isn't a clean or easy way to get the C++
code to know what Python objects are being used, or even that Python is
there at all. However in Phoenix it will be possible to properly override
at least the Dismiss method in a Python class derived from wx.InfoBar, so
the special handling for agw.aui could be done that way.

OK then, for the moment I have added the pure-Python implementation of
InfoBar to AGW, I'll take it out from AGW as soon as this (and another
bug, see later) gets somehow fixed.

As for the other bug, I have found that if you click on the "Add
Button" button in the demo *while the wx.InfoBar is shown*, the layout
gets messed up. This is because AddButton should check the status of
wx.InfoBar itself and, if it is shown, it should call UpdateParent.

In the meantime you could probably do it from a wx.EVT_SHOW handler bound to
the infobar. Check event.GetShow() to know if it is being shown or hidden.

I have tried this approach on Werner's sample, but I only got hard
Python crashes on Windows Vista and 7, latest wxPython version...
Maybe I am just doing it wrong.

Anyway, the pure-Python AGW version adds the ability to have bitmaps
on the buttons added via "AddButton" and solves the 2 problems
mentioned in this thread. If you use AuiManager and the InfoBar is a
direct child of the managed window, you don't need to call
AuiManager.Update or anything, everything should be taken care of in
the Dismiss() and ShowMessage() methods of the AGW InfoBar.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 12 March 2012 16:59, Robin Dunn wrote:

On 3/12/12 7:25 AM, Andrea Gavana wrote:

Hi Andrea,

I am finally getting around to give this a try, I get the following exception which I fixed by changing around line 456 in infobar.py from:

         siblings = sizer.GetChildren()

         if siblings[0].GetWindow() == self:
             return BarPlacement_Top
         elif siblings[-1].GetWindow()== self:
             return BarPlacement_Bottom

to:

         siblings = sizer.GetChildren()
         lSib = len(siblings)-1

         if siblings[0].GetWindow() == self:
             return BarPlacement_Top
         elif siblings[lSib].GetWindow()== self:
             return BarPlacement_Bottom

Werner

ValueError: in method 'SizerItemList___getitem__', expected argument 2 of type 'size_t'
File "c:\dev\twcbv4\twcbsrc\controllers\app_cb.py", line 575, in <module>
   app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 8651, in MainLoop
   wx.PyApp.MainLoop(self)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 7943, in MainLoop
   return _core_.PyApp_MainLoop(*args, **kwargs)
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 960, in onOLVItemSelected
   self.loadItemData(self._lastItemPkey)
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 724, in loadItemData
   self.view.InitDialog()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 10511, in InitDialog
   return _core_.Window_InitDialog(*args, **kwargs)
File "c:\dev\twcbv4\twcbsrc\controllers\validators.py", line 600, in TransferToWindow
   self.theCallback()
File "c:\dev\twcbv4\twcbsrc\controllers\pane_ExternalList.py", line 153, in showFirstImage
   self._controller.paneImage.showImage(items[0].filename)
File "c:\dev\twcbv4\twcbsrc\controllers\pane_Image.py", line 76, in showImage
   pub.sendMessage(pTopics.statusText, msg="")
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\publisher.py", line 30, in sendMessage
   topicObj.publish(**kwargs)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\publishermixin.py", line 24, in publish
   self._publish(msgKwargs)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\topicobj.py", line 340, in _publish
   self.__sendMessage(data, self, iterState)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\topicobj.py", line 359, in __sendMessage
   self._mix_callListener(listener, data, iterState)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\publishermixin.py", line 64, in _mix_callListener
   listener(iterState.filteredArgs, self, msgKwargs)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\listenerimpl.py", line 27, in __call__
   cb(**kwargs)
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 136, in listenerInfoBar
   self.doInfoBarDismiss()
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 122, in doInfoBarDismiss
   self.info.Dismiss()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py", line 653, in Dismiss
   self.DoHide()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py", line 553, in DoHide
   self.HideWithEffect(self.GetHideEffect(), self.GetEffectDuration())
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py", line 519, in GetHideEffect
   placement = self.GetBarPlacement()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py", line 460, in GetBarPlacement
   elif siblings[-1].GetWindow()== self:
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 13993, in __getitem__
   return _core_.SizerItemList___getitem__(*args, **kwargs)

Hi Werner,

Hi Andrea,

I am finally getting around to give this a try, I get the following
exception which I fixed by changing around line 456 in infobar.py from:

   siblings = sizer\.GetChildren\(\)

   if siblings\[0\]\.GetWindow\(\) == self:
       return BarPlacement\_Top
   elif siblings\[\-1\]\.GetWindow\(\)== self:
       return BarPlacement\_Bottom

to:

   siblings = sizer\.GetChildren\(\)
   lSib = len\(siblings\)\-1

   if siblings\[0\]\.GetWindow\(\) == self:
       return BarPlacement\_Top
   elif siblings\[lSib\]\.GetWindow\(\)== self:
       return BarPlacement\_Bottom

Werner

ValueError: in method 'SizerItemList___getitem__', expected argument 2 of
type 'size_t'
File "c:\dev\twcbv4\twcbsrc\controllers\app_cb.py", line 575, in <module>
app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 8651, in
MainLoop
wx.PyApp.MainLoop(self)
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 7943, in
MainLoop
return _core_.PyApp_MainLoop(*args, **kwargs)
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 960, in
onOLVItemSelected
self.loadItemData(self._lastItemPkey)
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 724, in loadItemData
self.view.InitDialog()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 10511,
in InitDialog
return _core_.Window_InitDialog(*args, **kwargs)
File "c:\dev\twcbv4\twcbsrc\controllers\validators.py", line 600, in
TransferToWindow
self.theCallback()
File "c:\dev\twcbv4\twcbsrc\controllers\pane_ExternalList.py", line 153, in
showFirstImage
self._controller.paneImage.showImage(items[0].filename)
File "c:\dev\twcbv4\twcbsrc\controllers\pane_Image.py", line 76, in
showImage
pub.sendMessage(pTopics.statusText, msg="")
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\publisher.py",
line 30, in sendMessage
topicObj.publish(**kwargs)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\publishermixin.py",
line 24, in publish
self._publish(msgKwargs)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\topicobj.py",
line 340, in _publish
self.__sendMessage(data, self, iterState)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\topicobj.py",
line 359, in __sendMessage
self._mix_callListener(listener, data, iterState)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\publishermixin.py",
line 64, in _mix_callListener
listener(iterState.filteredArgs, self, msgKwargs)
File
"c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\pubsub\core\kwargs\listenerimpl.py",
line 27, in __call__
cb(**kwargs)
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 136, in
listenerInfoBar
self.doInfoBarDismiss()
File "c:\dev\twcbv4\twcbsrc\controllers\base.py", line 122, in
doInfoBarDismiss
self.info.Dismiss()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py",
line 653, in Dismiss
self.DoHide()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py",
line 553, in DoHide
self.HideWithEffect(self.GetHideEffect(), self.GetEffectDuration())
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py",
line 519, in GetHideEffect
placement = self.GetBarPlacement()
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\lib\agw\infobar.py",
line 460, in GetBarPlacement
elif siblings[-1].GetWindow()== self:
File "c:\Python27\Lib\site-packages\wx-2.9.3-msw\wx\_core.py", line 13993,
in __getitem__
return _core_.SizerItemList___getitem__(*args, **kwargs)

Thank you for the patch... I'll apply it when I get back home. On a
related note, there still are 3 unresolved issues for the wxWidgets
C++ wx.InfoBar implementation:

1) wx.InfoBar does not account for layout managers like wx.aui or
wx.lib.agw.aui;
2) The wx.InfoBar layout is screwed up if you add a button while the
infobar is shown (see the demo);
3) Very long messages do not get wrapped, they simply go on
horizontally until they disappear.

I suppose I should enter one (more?) bug reports on wxTrac about those
issues... Robin, do you think a single bug report should do or do I
have to open one per issue?

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 21 March 2012 15:26, werner wrote:

Hi Andrea,

...

Thank you for the patch... I'll apply it when I get back home.

Great.

  On a
related note, there still are 3 unresolved issues for the wxWidgets
C++ wx.InfoBar implementation:

1) wx.InfoBar does not account for layout managers like wx.aui or
wx.lib.agw.aui;
2) The wx.InfoBar layout is screwed up if you add a button while the
infobar is shown (see the demo);
3) Very long messages do not get wrapped, they simply go on
horizontally until they disappear.

That and the auto handling of lib.agw.aui are the reasons for me to use your version.

Werner

P.S.
Will try the Persist change in a little bit and report back.

···

On 21/03/2012 16:16, Andrea Gavana wrote:

One per issue would be best.

···

On 3/21/12 8:16 AM, Andrea Gavana wrote:

Thank you for the patch... I'll apply it when I get back home. On a
related note, there still are 3 unresolved issues for the wxWidgets
C++ wx.InfoBar implementation:

1) wx.InfoBar does not account for layout managers like wx.aui or
wx.lib.agw.aui;
2) The wx.InfoBar layout is screwed up if you add a button while the
infobar is shown (see the demo);
3) Very long messages do not get wrapped, they simply go on
horizontally until they disappear.

I suppose I should enter one (more?) bug reports on wxTrac about those
issues... Robin, do you think a single bug report should do or do I
have to open one per issue?

--
Robin Dunn
Software Craftsman

Hi Werner,

···

On 21 March 2012 17:14, werner wrote:

Hi Andrea,

On 21/03/2012 16:16, Andrea Gavana wrote:
...

Thank you for the patch... I'll apply it when I get back home.

Great.

On a
related note, there still are 3 unresolved issues for the wxWidgets
C++ wx.InfoBar implementation:

1) wx.InfoBar does not account for layout managers like wx.aui or
wx.lib.agw.aui;
2) The wx.InfoBar layout is screwed up if you add a button while the
infobar is shown (see the demo);
3) Very long messages do not get wrapped, they simply go on
horizontally until they disappear.

That and the auto handling of lib.agw.aui are the reasons for me to use your
version.

Patch applied in SVN, thank you!

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

Done:

http://trac.wxwidgets.org/ticket/14120
http://trac.wxwidgets.org/ticket/14121
http://trac.wxwidgets.org/ticket/14122

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 21 March 2012 18:03, Robin Dunn wrote:

On 3/21/12 8:16 AM, Andrea Gavana wrote:

Thank you for the patch... I'll apply it when I get back home. On a
related note, there still are 3 unresolved issues for the wxWidgets
C++ wx.InfoBar implementation:

1) wx.InfoBar does not account for layout managers like wx.aui or
wx.lib.agw.aui;
2) The wx.InfoBar layout is screwed up if you add a button while the
infobar is shown (see the demo);
3) Very long messages do not get wrapped, they simply go on
horizontally until they disappear.

I suppose I should enter one (more?) bug reports on wxTrac about those
issues... Robin, do you think a single bug report should do or do I
have to open one per issue?

One per issue would be best.

Hi Andrea,

One more thing, I noticed in a few situations that I needed to do a Refresh, maybe add

         parent.Refresh()

to the UpdateParent method?

Werner

Hi Werner,

···

On 22 March 2012 19:59, werner wrote:

Hi Andrea,

One more thing, I noticed in a few situations that I needed to do a Refresh,
maybe add

   parent\.Refresh\(\)

to the UpdateParent method?

Done in the latest SVN version.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/