PyAuiTabArt (?)

Hi All,

    I have given a shot at my old implementation of custom
PyAuiTabArts and there is something I do not understand. I attach a
very simple implementation of one of them, which shows the following:

- GetTabSize gets called correctly in the derived class;
- DrawBackground, DrawTab, GetBestTabCtrlSize, DrawButton (and
possibly others) are never called in the derived class.

All this means is, while I am able to change the tabs width and
height, I can't custom-draw them as the relevant methods are never
called. I have looked at the aui.i and aui_wrap.cpp files and I can't
see anything wrong, so either my Python code is wrong or my knowledge
of this woodoo-magic-SWIG is too poor for me to understand.

Also, as a side request, would it be possible to make available the
following virtual methods:

- ShowDropDown
- SetFlags
- GetIndentSize

Which are marked as "TODO" in the aui.i and aui_wrap.cpp files?

Thank you for your suggestions.

Andrea.

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

PyAUITabArts2.py (5.16 KB)

Andrea Gavana wrote:

Hi All,

    I have given a shot at my old implementation of custom
PyAuiTabArts and there is something I do not understand. I attach a
very simple implementation of one of them, which shows the following:

- GetTabSize gets called correctly in the derived class;
- DrawBackground, DrawTab, GetBestTabCtrlSize, DrawButton (and
possibly others) are never called in the derived class.

All this means is, while I am able to change the tabs width and
height, I can't custom-draw them as the relevant methods are never
called. I have looked at the aui.i and aui_wrap.cpp files and I can't
see anything wrong, so either my Python code is wrong or my knowledge
of this woodoo-magic-SWIG is too poor for me to understand.

I'll take a closer look at it this evening.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Andrea Gavana wrote:

Hi All,

    I have given a shot at my old implementation of custom
PyAuiTabArts and there is something I do not understand. I attach a
very simple implementation of one of them, which shows the following:

- GetTabSize gets called correctly in the derived class;
- DrawBackground, DrawTab, GetBestTabCtrlSize, DrawButton (and
possibly others) are never called in the derived class.

All this means is, while I am able to change the tabs width and
height, I can't custom-draw them as the relevant methods are never
called. I have looked at the aui.i and aui_wrap.cpp files and I can't
see anything wrong, so either my Python code is wrong or my knowledge
of this woodoo-magic-SWIG is too poor for me to understand.

Also, as a side request, would it be possible to make available the
following virtual methods:

- ShowDropDown
- SetFlags
- GetIndentSize

Which are marked as "TODO" in the aui.i and aui_wrap.cpp files?

I've got another preview build in progress that should take care of all these issues. The main issue was that Clone wasn't virtualized so the copy that AUI made of the art object wasn't making a clone of the Python class. I didn't virtualize ShowDropDown and GetBestTabCtrlSize because I don't have a good way yet to wrap the wxAuiNotebookPageArray type, but everything else has been done. Here is my test class that shows what methods can be overridden, what their parameters are, and what the return values are expected to be. Can you make a good sample from this?

class MyAuiTabArt(wx.aui.PyAuiTabArt):

     def __init__(self):
         print "__init__"
         wx.aui.PyAuiTabArt.__init__(self)

     def Clone(self):
         print "Clone"
         art = MyAuiTabArt()
         art.SetNormalFont(self.GetNormalFont())
         art.SetSelectedFont(self.GetSelectedFont())
         art.SetMeasuringFont(self.GetMeasuringFont())
         return art

     def DrawBackground(self, dc, wnd, rect):
         print "DrawBackground"
         wx.aui.PyAuiTabArt.DrawBackground(self, dc, wnd, rect)

     def DrawTab(self, dc, wnd, page, in_rect, close_button_state):
         print "DrawTab"
         tab_rect, button_rect, x_extent = \
                   wx.aui.PyAuiTabArt.DrawTab(self, dc, wnd, page,
                                              in_rect, close_button_state)
         return tab_rect, button_rect, x_extent

     def DrawButton(self, dc, wnd, in_rect, bitmap_id, button_state, orientation):
         print "DrawButton"
         out_rect = wx.aui.PyAuiTabArt.DrawButton(
             self, dc, wnd, in_rect, bitmap_id, button_state, orientation)
         return out_rect

     def GetTabSize(self, dc, wnd, caption, bitmap, active, close_button_state):
         print "GetTabSize"
         size, x_extent = wx.aui.PyAuiTabArt.GetTabSize(
             self, dc, wnd, caption, bitmap, active, close_button_state)
         return size, x_extent

     def SetSizingInfo(self, tab_ctrl_size, tab_count):
         print "SetSizingInfo"
         wx.aui.PyAuiTabArt.SetSizingInfo(self, tab_ctrl_size, tab_count)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

I've got another preview build in progress that should take care of all
these issues. The main issue was that Clone wasn't virtualized so the copy
that AUI made of the art object wasn't making a clone of the Python class.
I didn't virtualize ShowDropDown and GetBestTabCtrlSize because I don't
have a good way yet to wrap the wxAuiNotebookPageArray type, but everything
else has been done. Here is my test class that shows what methods can be
overridden, what their parameters are, and what the return values are
expected to be. Can you make a good sample from this?

I can probably do something better: I have designed a number of tab
arts, namely Visual Studio 2005, Visual Studio 2008, Firefox 2 styles
and I am currently writing the Google Chrome style tabs. If you can
wait a couple of days (assuming that my wife will not deliver our
first child in the meantime :smiley: ) I can put these TabArts in
wx.lib.agw and create a nice demo.

BTW, the Main.py demo has a small bug (which I introduced :frowning: ). The
method GetOriginalFileName should have this line of code added:

return ""

at the end of the method. Sorry about that... do you want me to commit
the change in SVN?

Andrea.

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

···

On Mon, Feb 9, 2009 at 5:31 AM, Robin Dunn wrote:

Andrea Gavana wrote:

Hi Robin,

I've got another preview build in progress that should take care of all
these issues. The main issue was that Clone wasn't virtualized so the copy
that AUI made of the art object wasn't making a clone of the Python class.
I didn't virtualize ShowDropDown and GetBestTabCtrlSize because I don't
have a good way yet to wrap the wxAuiNotebookPageArray type, but everything
else has been done. Here is my test class that shows what methods can be
overridden, what their parameters are, and what the return values are
expected to be. Can you make a good sample from this?

I can probably do something better: I have designed a number of tab
arts, namely Visual Studio 2005, Visual Studio 2008, Firefox 2 styles
and I am currently writing the Google Chrome style tabs. If you can
wait a couple of days (assuming that my wife will not deliver our
first child in the meantime :smiley: ) I can put these TabArts in
wx.lib.agw and create a nice demo.

Sounds good.

BTW, the Main.py demo has a small bug (which I introduced :frowning: ). The
method GetOriginalFileName should have this line of code added:

return ""

at the end of the method. Sorry about that... do you want me to commit
the change in SVN?

Sure, go ahead. Be sure to make the change in the trunk version too.

···

On Mon, Feb 9, 2009 at 5:31 AM, Robin Dunn wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Andrea Gavana wrote:

Hi Robin,
I can probably do something better: I have designed a number of tab
arts, namely Visual Studio 2005, Visual Studio 2008, Firefox 2 styles
and I am currently writing the Google Chrome style tabs. If you can
wait a couple of days (assuming that my wife will not deliver our
first child in the meantime :smiley: ) I can put these TabArts in
wx.lib.agw and create a nice demo.

Sounds good.

Ok, I have implemented the notebook arts I described in the last post.
There is a small problem, though: in aui.i, it seems that the SetFlags
method for PyAuiTabArt is not wrapped yet, so every time
wx.aui.AuiNotebook calls SetFlags on the PyAuiTabArts I can't set the
flags for the tab arts and so I can't correctly draw the tabs (these
flags are tipically like wx.aui.AUI_NB_WINDOWLIST_BUTTON,
wx.aui.AUI_NB_BOTTOM, wx.aui.AUI_NB_TAB_FIXED_WIDTH and so on). I can
access these flags by passing the notebook itself as an __init__
argument to my PyAuiTabArts, but it is ugly and it's not consistent
with the C++ classes wx.aui.AuiDefaultTabArt and
wx.aui.AuiSimpleTabArt.

BTW, I have been a bit disappointed (if this is the correct word
expressing my feelings) by the attitude towards patches/modifications
to wxAUI in the C++ code (see the Trac and the wxForum), so I took a
couple of hours and I have re-implemented in pure Python
wx.aui.AuiNotebook and wx.aui.AuiToolBar (with all the
patches/optimizations/improvements proposed so far to these classes).
The result is in the screenshot attached (with Chrome style tabs).

Now, I don't know if having a pure-Python implementation of these
classes would be of any use in wxPython, but I did it mostly to add to
wx.aui.AuiNotebook the ability of adding more buttons to the right, as
asked in this thread:

http://lists.wxwidgets.org/pipermail/wxpython-users/2007-January/060451.html

And the ability of hiding/showing tabs when only 1 tab is present (a
la FlatNotebook) plus all other FlatNotebook functionalities (if
required, they are currently not implemented). So, basically, we would
have a wx.aui.AuiNotebook with all the goodies of wxAUI and
FlatNotebook coming together.

As I wasn't able to make wx.aui.AuiToolBar run, I converted the C++
code to wxPython, and it's working very well. This, in turn, will
allow us to create customized AuiToolBarArts and adding features
indipendently from the development (or lack of it) of wxAUI.

Lastly, scanning the wxWidgets wxForum, I found so many request for
patches integration and improvements in the wxAUI framemanager main
class that I am starting to wonder if I should just resuscitate my
PyAUI project and updating it to the latest wxAUI in wxWidgets trunk,
before adding the patches mentioned in the wxForum: at that point, I
will just scrap the C++ version of wxAUI and I will just use the
pure-Python one.

Sorry for the rant :smiley:

Andrea.

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

···

On Mon, Feb 9, 2009 at 5:10 PM, Robin Dunn wrote:

Andrea Gavana wrote:

Hi Robin,

Andrea Gavana wrote:

Hi Robin,
I can probably do something better: I have designed a number of tab
arts, namely Visual Studio 2005, Visual Studio 2008, Firefox 2 styles
and I am currently writing the Google Chrome style tabs. If you can
wait a couple of days (assuming that my wife will not deliver our
first child in the meantime :smiley: ) I can put these TabArts in
wx.lib.agw and create a nice demo.

Sounds good.

Ok, I have implemented the notebook arts I described in the last post.
There is a small problem, though: in aui.i, it seems that the SetFlags
method for PyAuiTabArt is not wrapped yet, so every time
wx.aui.AuiNotebook calls SetFlags on the PyAuiTabArts I can't set the
flags for the tab arts and so I can't correctly draw the tabs (these
flags are tipically like wx.aui.AUI_NB_WINDOWLIST_BUTTON,
wx.aui.AUI_NB_BOTTOM, wx.aui.AUI_NB_TAB_FIXED_WIDTH and so on). I can
access these flags by passing the notebook itself as an __init__
argument to my PyAuiTabArts, but it is ugly and it's not consistent
with the C++ classes wx.aui.AuiDefaultTabArt and
wx.aui.AuiSimpleTabArt.

I didn't virtualize SetFlags because I added a GetFlags so you can fetch the value that was set with the base class's SetFlags at any time. With that ability is there still any situation where you would need to override SetFlags?

BTW, I have been a bit disappointed (if this is the correct word
expressing my feelings) by the attitude towards patches/modifications
to wxAUI in the C++ code (see the Trac and the wxForum),

So have I. Ben was originally really excited about extending and maintaining AUI in wx, and the "honor" of having it chosen to be included in the core library, etc. Then the time he spent on it evaporated, even though it is an important part of his work project, and nobody has felt comfortable enough with it to step forward and take over.

so I took a
couple of hours and I have re-implemented in pure Python
wx.aui.AuiNotebook and wx.aui.AuiToolBar (with all the
patches/optimizations/improvements proposed so far to these classes).
The result is in the screenshot attached (with Chrome style tabs).

Now, I don't know if having a pure-Python implementation of these
classes would be of any use in wxPython, but I did it mostly to add to
wx.aui.AuiNotebook the ability of adding more buttons to the right, as
asked in this thread:

http://lists.wxwidgets.org/pipermail/wxpython-users/2007-January/060451.html

And the ability of hiding/showing tabs when only 1 tab is present (a
la FlatNotebook) plus all other FlatNotebook functionalities (if
required, they are currently not implemented). So, basically, we would
have a wx.aui.AuiNotebook with all the goodies of wxAUI and
FlatNotebook coming together.

As I wasn't able to make wx.aui.AuiToolBar run, I converted the C++
code to wxPython, and it's working very well. This, in turn, will
allow us to create customized AuiToolBarArts and adding features
indipendently from the development (or lack of it) of wxAUI.

Lastly, scanning the wxWidgets wxForum, I found so many request for
patches integration and improvements in the wxAUI framemanager main
class that I am starting to wonder if I should just resuscitate my
PyAUI project and updating it to the latest wxAUI in wxWidgets trunk,
before adding the patches mentioned in the wxForum: at that point, I
will just scrap the C++ version of wxAUI and I will just use the
pure-Python one.

I've actually been wondering the same thing (or more accurately, I've been regretting my encouraging you to abandon it in favor of the C++ version.) It seems a shame to duplicate the effort and have two versions of the same thing, but with your track record compared to Ben's it's getting easier to overlook that issue.

···

On Mon, Feb 9, 2009 at 5:10 PM, Robin Dunn wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hello,

···

On Fri, Feb 13, 2009 at 9:12 AM, Andrea Gavana andrea.gavana@gmail.com wrote:

Now, I don’t know if having a pure-Python implementation of these
classes would be of any use in wxPython, but I did it mostly to add to

wx.aui.AuiNotebook the ability of adding more buttons to the right, as
asked in this thread:

http://lists.wxwidgets.org/pipermail/wxpython-users/2007-January/060451.html

And the ability of hiding/showing tabs when only 1 tab is present (a
la FlatNotebook) plus all other FlatNotebook functionalities (if
required, they are currently not implemented). So, basically, we would
have a wx.aui.AuiNotebook with all the goodies of wxAUI and

FlatNotebook coming together.

Nice, I could definitely use this. If you have something working I am more than happy to check it out on osx and make any necessary fixes (if any).

I have held back from using the auinotebook mostly because of appearance issues on osx.

Sorry for the hijack, but think I could talk you into converting the DynamicSashWindow to python too :wink: I was planning to fix it to use RenderNative so that I could use that control on osx without it looking way out of place but it would be much nicer to have a python version to work with. (its also been moved to wxCode for 2.9 so it will no longer be in the core library anymore).

Thanks,

Cody

Hi Andrea, et al.

···

2009/2/13 Andrea Gavana <andrea.gavana@gmail.com>:

Lastly, scanning the wxWidgets wxForum, I found so many request for
patches integration and improvements in the wxAUI framemanager main
class that I am starting to wonder if I should just resuscitate my
PyAUI project and updating it to the latest wxAUI in wxWidgets trunk,
before adding the patches mentioned in the wxForum: at that point, I
will just scrap the C++ version of wxAUI and I will just use the
pure-Python one.

If you haven't done so yourself I hereby offer to implement saving of
AUI notebook perspectives in PyAUI. That is the feature I have been
missing most in AUI.

Cheers, Frank

Hi All,

Andrea Gavana wrote:

Ok, I have implemented the notebook arts I described in the last post.
There is a small problem, though: in aui.i, it seems that the SetFlags
method for PyAuiTabArt is not wrapped yet, so every time
wx.aui.AuiNotebook calls SetFlags on the PyAuiTabArts I can't set the
flags for the tab arts and so I can't correctly draw the tabs (these
flags are tipically like wx.aui.AUI_NB_WINDOWLIST_BUTTON,
wx.aui.AUI_NB_BOTTOM, wx.aui.AUI_NB_TAB_FIXED_WIDTH and so on). I can
access these flags by passing the notebook itself as an __init__
argument to my PyAuiTabArts, but it is ugly and it's not consistent
with the C++ classes wx.aui.AuiDefaultTabArt and
wx.aui.AuiSimpleTabArt.

I didn't virtualize SetFlags because I added a GetFlags so you can fetch the
value that was set with the base class's SetFlags at any time. With that
ability is there still any situation where you would need to override
SetFlags?

Uhm, I didn't try with GetFlags, but I'll do it soon and I'll let you
know. In any case, if we are going to use the pure-Python version of
wxAUI there will be no need of wrapping this method (or other
methods).

As I wasn't able to make wx.aui.AuiToolBar run, I converted the C++
code to wxPython, and it's working very well. This, in turn, will
allow us to create customized AuiToolBarArts and adding features
indipendently from the development (or lack of it) of wxAUI.

Lastly, scanning the wxWidgets wxForum, I found so many request for
patches integration and improvements in the wxAUI framemanager main
class that I am starting to wonder if I should just resuscitate my
PyAUI project and updating it to the latest wxAUI in wxWidgets trunk,
before adding the patches mentioned in the wxForum: at that point, I
will just scrap the C++ version of wxAUI and I will just use the
pure-Python one.

I've actually been wondering the same thing (or more accurately, I've been
regretting my encouraging you to abandon it in favor of the C++ version.)
It seems a shame to duplicate the effort and have two versions of the same
thing, but with your track record compared to Ben's it's getting easier to
overlook that issue.

I understand. Well, let's summarize where I am at the moment:

- wx.aui.AuiToolBar is fully re-implemented in pure-Python, with all
the patches and bug report submitted already fixed in it;
- wx.aui.AuiNotebook is fully re-implemented in pure-Python, with all
the patches and bug report submitted already fixed in it, plus some
more enhancements;
- I am currently revamping PyAUI to bring it up-to-date with the
latest wxAUI. Then, I will implement all the patches and improvements
mentioned in wxForum, unless something very low-level
platform-specific C++-only thing interrupts me (but that may be
overcome using ctypes and friends)

It's a shame wxAUI gets so little attention by wx-devs (or wx-devs
with enough knowledge of wxAUI): it's a great layout management
library and the possibilities to extend it are almost limitless. Apart
of the wxForum patches, I have some many ideas on how to improve it
that I need to start writing them down or I will forget them.

Anyway, if you want me to go ahead with the pure-Python
implementation, where should I put it once I finish? Do you prefer it
to live in the wxPython SVN or should I set up a google-code project
(or similar)?

Cody Precord wrote:
Nice, I could definitely use this. If you have something working I am more than happy to check it out on osx and make any
necessary fixes (if any).

I will ask for your help as soon as I finish bringing PyAUI
up-to-date, as I can't really test anything on a Mac.

Sorry for the hijack, but think I could talk you into converting the DynamicSashWindow to python too :wink: I was planning to fix it to use
RenderNative so that I could use that control on osx without it looking way out of place but it would be much nicer to have a python
version to work with. (its also been moved to wxCode for 2.9 so it will no longer be in the core library anymore).

Than will not be a problem. With my magic scripts I believe I can do
that in a couple of hours, unless very low-level C++-specific code is
there (see above). In any case, let me finish with PyAUI and I'll come
back to you.

Frank Niessink wrote:
If you haven't done so yourself I hereby offer to implement saving of
AUI notebook perspectives in PyAUI. That is the feature I have been
missing most in AUI.

That would be nice, and for sure you are the most qualified person for
the job, recalling the implementation of TreeMixin and friends.

Andrea.

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

···

On Fri, Feb 13, 2009 at 6:24 PM, Robin Dunn wrote:

OK, just let me (us) know where the source code is and I'll start hacking.

Cheers, Frank

···

2009/2/14 Andrea Gavana <andrea.gavana@gmail.com>:

Frank Niessink wrote:
If you haven't done so yourself I hereby offer to implement saving of
AUI notebook perspectives in PyAUI. That is the feature I have been
missing most in AUI.

That would be nice, and for sure you are the most qualified person for
the job, recalling the implementation of TreeMixin and friends.

Andrea Gavana wrote:

Anyway, if you want me to go ahead with the pure-Python
implementation, where should I put it once I finish? Do you prefer it
to live in the wxPython SVN or should I set up a google-code project
(or similar)?

Let's put it in the wxPython SVN, but not in the agw package for now since that package is automatically pulled into the wx.lib tree. So maybe something like http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/AGW/aui. Then once it has had some people testing and using it for a while we can move it into the agw package.

Thanks for all your work!

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!