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!