Controls in tabs?

Hello everyone. I was wondering if there was any way to get controls/buttons on the side of a tab group, like the attached example (from Eclipse). Switching between tabs would switch the buttons. This would be especially nice in an AuiNotebook.

I ask this because some of the tabs in our program have behavior associated with them that other tabs do not and:
   1) I don't want to clutter the top toolbar with all of the possible actions
   2) I don't want to have to worry about enabling/disabling the appropriate buttons each time a tab is switched, or worry about handling invalid actions.

I doubt this is possible but it doesn't hurt to ask I suppose, and maybe some other people will think it is neat and want to develop it. If it isn't possible, what is the best way to accomplish what I want, as this must be a somewhat common issue?

Thanks,
Mike

tabcontrols.PNG

I’m interested. This is purely specualtion based on the documentation: The AUINotebook has a SetArtProvider method that sets the art provider (wx.AuiTabArt) to be used by the notebook.
The class wx.AuiTabArt provides for drawing tabs and buttons. Maybe it’s possible to create your own AuiTabArt subclass that draws additional buttons?

Cheers, Frank

···

2007/1/24, Rooney, Mike (ext. 324) mxr@qvii.com:

Hello everyone. I was wondering if there was any way to get controls/buttons on the side of a tab group, like the attached example (from Eclipse). Switching between tabs would switch the buttons. This would be especially nice in an AuiNotebook.

I ask this because some of the tabs in our program have behavior associated with them that other tabs do not and:

  1. I don’t want to clutter the top toolbar with all of the possible actions
  2. I don’t want to have to worry about enabling/disabling the appropriate buttons each time a tab is switched, or worry about handling invalid actions.

I doubt this is possible but it doesn’t hurt to ask I suppose, and maybe some other people will think it is neat and want to develop it. If it isn’t possible, what is the best way to accomplish what I want, as this must be a somewhat common issue?

Hi All,

<snip>
<snap>

I'm interested. This is purely specualtion based on the documentation: The
AUINotebook has a SetArtProvider method that sets the art provider
(wx.AuiTabArt) to be used by the notebook. The class wx.AuiTabArt provides
for drawing tabs and buttons. Maybe it's possible to create your own
AuiTabArt subclass that draws additional buttons?

I believe it can be done. I see only a couple of issues, which I am
not sure can be addressed directly in Python (maybe we would have to
hack the C++ code, God save us):

1) wx.AuiTabArt: can it be easily subclassed and customized in Python?
2) The controls drawn on the tab area should have their own space
reserved (i.e., avoiding the tabs to jump over the controls covering
their reserved area).

I have no idea if both these things can be accomplished... maybe Robin
can share some thoughts. If it ends up in being impossible (directly
in Python, I mean), I would say that the best option left is to hack
FlatNotebook. You will lose the docking capability, however :frowning:

Just my 2c.

Andrea.

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

···

On 1/24/07, Frank Niessink wrote:

1) wx.AuiTabArt: can it be easily subclassed and customized in Python?

Unless I am just making some silly mistake, I think this is an issue. Looking at the class, it appears I would just want to implement a DrawTab and perhaps DrawButton. However, in my initial attempts I get this nice error:

  File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\aui.py", line 1106, in __init__
    def __init__(self): raise AttributeError, "No constructor defined"
AttributeError: No constructor defined

That was when I created a subclass and tried to instantiate it. Then for the heck of it I just tried to do notebook.SetArtProvider(AuiTabArt()), and that gave me the same error. Is this something dumb I am doing, is this just that the binding for the constructor was not created, or is it something more complicated?

Yes, I am getting exactly the same... uhm, might it be that
wx.AuiTabArt is like wx.RendererNative? No contructor defined... but
in wxWidgets there is the constructor:

···

On 1/24/07, Rooney, Mike (ext. 324) <mxr@qvii.com> wrote:

>1) wx.AuiTabArt: can it be easily subclassed and customized in Python?

Unless I am just making some silly mistake, I think this is an issue. Looking at the class, it appears I would just want to implement a DrawTab and perhaps DrawButton. However, in my initial attempts I get this nice error:

File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\aui.py", line 1106, in __init__
   def __init__(self): raise AttributeError, "No constructor defined"
AttributeError: No constructor defined

---------------------------------------
wxAuiTabArt::wxAuiTabArt
wxAuiTabArt()

Constructor.
---------------------------------------

I am blind, or there is no binding for the constructor. Most likely
the first. :frowning:
It's a pity, I was thinking exactly the same as you, Mike, today: it
would be nice to hack it and get some fancy art provider for the tabs.
Waiting for wxPython's Father... :smiley:

Andrea.

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

Yes, I am *really* blind:

aui.py, line 1103:

class AuiTabArt(object):
    """Proxy of C++ AuiTabArt class"""
    thisown = property(lambda x: x.this.own(), lambda x, v:
x.this.own(v), doc='The membership flag')
    def __init__(self): raise AttributeError, "No constructor defined"

Hahahaha. :-(((((((((((( ( :-(((((( ) ^Inf

···

On 1/24/07, Andrea Gavana <andrea.gavana@gmail.com> wrote:

On 1/24/07, Rooney, Mike (ext. 324) <mxr@qvii.com> wrote:
> >1) wx.AuiTabArt: can it be easily subclassed and customized in Python?
>
> Unless I am just making some silly mistake, I think this is an issue. Looking at the class, it appears I would just want to implement a DrawTab and perhaps DrawButton. However, in my initial attempts I get this nice error:
>
> File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\aui.py", line 1106, in __init__
> def __init__(self): raise AttributeError, "No constructor defined"
> AttributeError: No constructor defined
>

Yes, I am getting exactly the same... uhm, might it be that
wx.AuiTabArt is like wx.RendererNative? No contructor defined... but
in wxWidgets there is the constructor:

---------------------------------------
wxAuiTabArt::wxAuiTabArt
wxAuiTabArt()

Constructor.
---------------------------------------

I am blind, or there is no binding for the constructor. Most likely
the first. :frowning:
It's a pity, I was thinking exactly the same as you, Mike, today: it
would be nice to hack it and get some fancy art provider for the tabs.
Waiting for wxPython's Father... :smiley:

Andrea.

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

--
Andrea.

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

I have tried to rebuild wxAuiTabArt, and I managed to get:

Traceback (most recent call last):
  File "D:\MyProjects\AuiTabArt.py", line 619, in <module>
    panel = TestPanel(frame)
  File "D:\MyProjects\AuiTabArt.py", line 603, in __init__
    self.nb.SetArtProvider(MyTabArt())
  File "C:\Python25\Lib\site-packages\wx-2.8-msw-ansi\wx\aui.py", line 1365, in
SetArtProvider
    return _aui.AuiNotebook_SetArtProvider(*args, **kwargs)
TypeError: in method 'AuiNotebook_SetArtProvider', expected argument 2 of type '
wxAuiTabArt *'

:-(( . So, there is no constructor and SetArtProvider doesn't accept
anything but a subclass of wxAuiTabArt. I am giving up :wink:

Andrea.

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

Andrea Gavana wrote:

Hi All,

<snip>
<snap>

I'm interested. This is purely specualtion based on the documentation: The
AUINotebook has a SetArtProvider method that sets the art provider
(wx.AuiTabArt) to be used by the notebook. The class wx.AuiTabArt provides
for drawing tabs and buttons. Maybe it's possible to create your own
AuiTabArt subclass that draws additional buttons?

I believe it can be done. I see only a couple of issues, which I am
not sure can be addressed directly in Python (maybe we would have to
hack the C++ code, God save us):

1) wx.AuiTabArt: can it be easily subclassed and customized in Python?

I've written the wrappers for it, but I've never tried them so I don't know if I left anything out or implemented them all correctly.

2) The controls drawn on the tab area should have their own space
reserved (i.e., avoiding the tabs to jump over the controls covering
their reserved area).

This I don't know, but I doubt that it would expect anything extra to be drawn there and so will use that space if it needs to...

···

On 1/24/07, Frank Niessink wrote:

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

Rooney, Mike (ext. 324) wrote:

1) wx.AuiTabArt: can it be easily subclassed and customized in Python?

Unless I am just making some silly mistake, I think this is an issue. Looking at the class, it appears I would just want to implement a DrawTab and perhaps DrawButton. However, in my initial attempts I get this nice error:

  File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\aui.py", line 1106, in __init__
    def __init__(self): raise AttributeError, "No constructor defined"
AttributeError: No constructor defined

You need to derive a class from PyAuiTabArt to get the one that knows how to reflect calls to its virtual C++ methods to Python methods.

···

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

:-(( . So, there is no constructor and SetArtProvider doesn't accept
anything but a subclass of wxAuiTabArt. I am giving up :wink:

I tried Robin's suggestion of using PyAuiTabArt instead but still got the same error, have you given it a try?

Also, if you have made it that far, isn't there some way to trick it? If you are providing all the functions it expects it should be fine. I don't know exactly how it is doing the check, but if you do:

  MyTabArtProvider.__bases__ = (AuiTabArt,)

that seems to fool isinstance and issubclass. However it still says it expected argument 2 of type 'wxAuiTabArt *', so it doesn't seem to fix it. Any ideas on how it is checking the type, so that perhaps we could fool it? Or maybe there is a better solution?

Trying to fool it like this won't work, and if it did it would result
in crashes, because even when you subclass in Python there's still a
C++ wxAuiTabArt * class down there somewhere, and that gets passed to
C++ wxAUI functions. A pure python class mocked up to look right from
Python won't fool the C++ code.

···

On 1/25/07, Rooney, Mike (ext. 324) <mxr@qvii.com> wrote:

>:-(( . So, there is no constructor and SetArtProvider doesn't accept
>anything but a subclass of wxAuiTabArt. I am giving up :wink:

I tried Robin's suggestion of using PyAuiTabArt instead but still got the same error, have you given it a try?

Also, if you have made it that far, isn't there some way to trick it? If you are providing all the functions it expects it should be fine. I don't know exactly how it is doing the check, but if you do:

        MyTabArtProvider.__bases__ = (AuiTabArt,)

that seems to fool isinstance and issubclass. However it still says it expected argument 2 of type 'wxAuiTabArt *', so it doesn't seem to fix it. Any ideas on how it is checking the type, so that perhaps we could fool it? Or maybe there is a better solution?

I think this class (and the dock art one) aren't wrapped correctly,
theres no swiginit or new functions for them exported from _aui.pyd.

···

On 1/24/07, Robin Dunn <robin@alldunn.com> wrote:

Rooney, Mike (ext. 324) wrote:
>> 1) wx.AuiTabArt: can it be easily subclassed and customized in Python?
>
> Unless I am just making some silly mistake, I think this is an issue. Looking at the class, it appears I would just want to implement a DrawTab and perhaps DrawButton. However, in my initial attempts I get this nice error:
>
> File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\aui.py", line 1106, in __init__
> def __init__(self): raise AttributeError, "No constructor defined"
> AttributeError: No constructor defined

You need to derive a class from PyAuiTabArt to get the one that knows
how to reflect calls to its virtual C++ methods to Python methods.

Hi Mike,

>:-(( . So, there is no constructor and SetArtProvider doesn't accept
>anything but a subclass of wxAuiTabArt. I am giving up :wink:

I tried Robin's suggestion of using PyAuiTabArt instead but still got the same error, have you given it a try?

Yes, I have tried also PyAuiTabArt, with exactly the same results as
yours :frowning: . It is not "subclassable". And I also tried to fool the C++
implementation exactly like you, but got the same results. Have you
got mind-reading skills? :wink:

Andrea.

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

···

On 1/25/07, Rooney, Mike (ext. 324) <mxr@qvii.com> wrote:

Can't re-swig and test from here, but I think its as simple as
PyAuiTabArt and PyAuiDockArt missing public: visibility for ctor and
methods?

···

On 1/25/07, Chris Mellon <arkanes@gmail.com> wrote:

On 1/24/07, Robin Dunn <robin@alldunn.com> wrote:
> Rooney, Mike (ext. 324) wrote:
> >> 1) wx.AuiTabArt: can it be easily subclassed and customized in Python?
> >
> > Unless I am just making some silly mistake, I think this is an issue. Looking at the class, it appears I would just want to implement a DrawTab and perhaps DrawButton. However, in my initial attempts I get this nice error:
> >
> > File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\aui.py", line 1106, in __init__
> > def __init__(self): raise AttributeError, "No constructor defined"
> > AttributeError: No constructor defined
>
> You need to derive a class from PyAuiTabArt to get the one that knows
> how to reflect calls to its virtual C++ methods to Python methods.
>

I think this class (and the dock art one) aren't wrapped correctly,
theres no swiginit or new functions for them exported from _aui.pyd.

Can't re-swig and test from here, but I think its as simple as
PyAuiTabArt and PyAuiDockArt missing public: visibility for ctor and
methods?

That would be nice. If this is the case and someone is able to "re-swig", would it just be a matter of dropping some replacement files in to get this to work?

If I am correct (and I've already been wrong 3 times in a row this
morning, so no promises) then simply adding public: to the class
declarations in aui.i, then re-running SWIG and rebuilding wxPython
will fix it. If someone does this, the end result will be new _aui.pyd
and aui.py files, which could be dropped into your existing wxPython
install.

There are also 2 definitions for the wxPyAuiTabArt class, which is odd
and as I understand it shouldn't compile, so that might be a problem
too.

···

On 1/25/07, Rooney, Mike (ext. 324) <mxr@qvii.com> wrote:

>Can't re-swig and test from here, but I think its as simple as
>PyAuiTabArt and PyAuiDockArt missing public: visibility for ctor and
>methods?

That would be nice. If this is the case and someone is able to "re-swig", would it just be a matter of dropping some replacement files in to get this to work?

Chris Mellon wrote:

···

On 1/25/07, Chris Mellon <arkanes@gmail.com> wrote:

On 1/24/07, Robin Dunn <robin@alldunn.com> wrote:
> Rooney, Mike (ext. 324) wrote:
> >> 1) wx.AuiTabArt: can it be easily subclassed and customized in Python?
> >
> > Unless I am just making some silly mistake, I think this is an issue. Looking at the class, it appears I would just want to implement a DrawTab and perhaps DrawButton. However, in my initial attempts I get this nice error:
> >
> > File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\aui.py", line 1106, in __init__
> > def __init__(self): raise AttributeError, "No constructor defined"
> > AttributeError: No constructor defined
>
> You need to derive a class from PyAuiTabArt to get the one that knows
> how to reflect calls to its virtual C++ methods to Python methods.
>

I think this class (and the dock art one) aren't wrapped correctly,
theres no swiginit or new functions for them exported from _aui.pyd.

Can't re-swig and test from here, but I think its as simple as
PyAuiTabArt and PyAuiDockArt missing public: visibility for ctor and
methods?

Yep, it's just the missing little "public" keyword in a couple places. Oops.

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

Chris Mellon wrote:

There are also 2 definitions for the wxPyAuiTabArt class, which is odd
and as I understand it shouldn't compile, so that might be a problem
too.

One is for C++ and is compiled as part of the generated code, and one is for SWIG to tell it what to generate for the wrappers.

···

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