Another stab (hopefully the last) at how to handle the delayed
initialization of the stock objects. Go ahead and create an uninitialized instance using __new__, and then just set the .this attribute when the app is initialized. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39350 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -120,13 +120,13 @@ source of the clipboard or DnD operation, and then you'll know which
|
|||||||
of the component data objects to use to access the data.
|
of the component data objects to use to access the data.
|
||||||
|
|
||||||
Changed how the stock objects (wx.RED, wx.RED_PEN, wx.RED_BRUSH, etc.)
|
Changed how the stock objects (wx.RED, wx.RED_PEN, wx.RED_BRUSH, etc.)
|
||||||
are initialized. They are now created after the wx.App has been
|
are initialized. They are now created as uninitialized instances
|
||||||
created, but before OnInit is called, so if you use any of these
|
using __new__. Then after the wx.App has been created, but before
|
||||||
objects before the wx.App is created you will need to adjust your
|
OnInit is called, the .this attribute of each obhect is initialized.
|
||||||
code. This was needed because of some delayed initialization
|
This was needed because of some delayed initialization functionality
|
||||||
functionality that was implemented in wxWidgets, but the end result is
|
that was implemented in wxWidgets, but the end result is cleaner for
|
||||||
cleaner for wxPython as well, and allowed me to remove some ugly code
|
wxPython as well, and allowed me to remove some ugly code previously
|
||||||
previously hidden under the covers.
|
hidden under the covers.
|
||||||
|
|
||||||
Added wx.StandardPaths.GetDocumentsDir.
|
Added wx.StandardPaths.GetDocumentsDir.
|
||||||
|
|
||||||
@@ -146,6 +146,13 @@ Added wrappers for Julian's new wxRichTextCtrl class, visible in
|
|||||||
wxPython as wx.richtext.RichTextCtrl window. It still needs some more
|
wxPython as wx.richtext.RichTextCtrl window. It still needs some more
|
||||||
work, but it is a great start.
|
work, but it is a great start.
|
||||||
|
|
||||||
|
wx.lib.mixins.listctrl.TextEditMixin: Fixed the double END_LABEL_EDIT
|
||||||
|
event problem in TextEditMixin by checking if the editor was already
|
||||||
|
hidden before continuing with the CloseEditor method. Also added code
|
||||||
|
to OpenEditor to send the BEGIN_LABEL_EDIT event and to not allow the
|
||||||
|
opening of the editor to continue if the event handler doesn't allow
|
||||||
|
it.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -74,50 +74,99 @@ public:
|
|||||||
%pythoncode {
|
%pythoncode {
|
||||||
def _initStockObjects():
|
def _initStockObjects():
|
||||||
import wx
|
import wx
|
||||||
wx.ITALIC_FONT = StockGDI.instance().GetFont(StockGDI.FONT_ITALIC)
|
wx.ITALIC_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_ITALIC).this
|
||||||
wx.NORMAL_FONT = StockGDI.instance().GetFont(StockGDI.FONT_NORMAL)
|
wx.NORMAL_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_NORMAL).this
|
||||||
wx.SMALL_FONT = StockGDI.instance().GetFont(StockGDI.FONT_SMALL)
|
wx.SMALL_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_SMALL).this
|
||||||
wx.SWISS_FONT = StockGDI.instance().GetFont(StockGDI.FONT_SWISS)
|
wx.SWISS_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_SWISS).this
|
||||||
|
|
||||||
wx.BLACK_DASHED_PEN = StockGDI.GetPen(StockGDI.PEN_BLACKDASHED)
|
wx.BLACK_DASHED_PEN.this = StockGDI.GetPen(StockGDI.PEN_BLACKDASHED).this
|
||||||
wx.BLACK_PEN = StockGDI.GetPen(StockGDI.PEN_BLACK)
|
wx.BLACK_PEN.this = StockGDI.GetPen(StockGDI.PEN_BLACK).this
|
||||||
wx.CYAN_PEN = StockGDI.GetPen(StockGDI.PEN_CYAN)
|
wx.CYAN_PEN.this = StockGDI.GetPen(StockGDI.PEN_CYAN).this
|
||||||
wx.GREEN_PEN = StockGDI.GetPen(StockGDI.PEN_GREEN)
|
wx.GREEN_PEN.this = StockGDI.GetPen(StockGDI.PEN_GREEN).this
|
||||||
wx.GREY_PEN = StockGDI.GetPen(StockGDI.PEN_GREY)
|
wx.GREY_PEN.this = StockGDI.GetPen(StockGDI.PEN_GREY).this
|
||||||
wx.LIGHT_GREY_PEN = StockGDI.GetPen(StockGDI.PEN_LIGHTGREY)
|
wx.LIGHT_GREY_PEN.this = StockGDI.GetPen(StockGDI.PEN_LIGHTGREY).this
|
||||||
wx.MEDIUM_GREY_PEN = StockGDI.GetPen(StockGDI.PEN_MEDIUMGREY)
|
wx.MEDIUM_GREY_PEN.this = StockGDI.GetPen(StockGDI.PEN_MEDIUMGREY).this
|
||||||
wx.RED_PEN = StockGDI.GetPen(StockGDI.PEN_RED)
|
wx.RED_PEN.this = StockGDI.GetPen(StockGDI.PEN_RED).this
|
||||||
wx.TRANSPARENT_PEN = StockGDI.GetPen(StockGDI.PEN_TRANSPARENT)
|
wx.TRANSPARENT_PEN.this = StockGDI.GetPen(StockGDI.PEN_TRANSPARENT).this
|
||||||
wx.WHITE_PEN = StockGDI.GetPen(StockGDI.PEN_WHITE)
|
wx.WHITE_PEN.this = StockGDI.GetPen(StockGDI.PEN_WHITE).this
|
||||||
|
|
||||||
wx.BLACK_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_BLACK)
|
wx.BLACK_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_BLACK).this
|
||||||
wx.BLUE_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_BLUE)
|
wx.BLUE_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_BLUE).this
|
||||||
wx.CYAN_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_CYAN)
|
wx.CYAN_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_CYAN).this
|
||||||
wx.GREEN_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_GREEN)
|
wx.GREEN_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_GREEN).this
|
||||||
wx.GREY_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_GREY)
|
wx.GREY_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_GREY).this
|
||||||
wx.LIGHT_GREY_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_LIGHTGREY)
|
wx.LIGHT_GREY_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_LIGHTGREY).this
|
||||||
wx.MEDIUM_GREY_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_MEDIUMGREY)
|
wx.MEDIUM_GREY_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_MEDIUMGREY).this
|
||||||
wx.RED_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_RED)
|
wx.RED_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_RED).this
|
||||||
wx.TRANSPARENT_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_TRANSPARENT)
|
wx.TRANSPARENT_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_TRANSPARENT).this
|
||||||
wx.WHITE_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_WHITE)
|
wx.WHITE_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_WHITE).this
|
||||||
|
|
||||||
wx.BLACK = StockGDI.GetColour(StockGDI.COLOUR_BLACK)
|
wx.BLACK.this = StockGDI.GetColour(StockGDI.COLOUR_BLACK).this
|
||||||
wx.BLUE = StockGDI.GetColour(StockGDI.COLOUR_BLUE)
|
wx.BLUE.this = StockGDI.GetColour(StockGDI.COLOUR_BLUE).this
|
||||||
wx.CYAN = StockGDI.GetColour(StockGDI.COLOUR_CYAN)
|
wx.CYAN.this = StockGDI.GetColour(StockGDI.COLOUR_CYAN).this
|
||||||
wx.GREEN = StockGDI.GetColour(StockGDI.COLOUR_GREEN)
|
wx.GREEN.this = StockGDI.GetColour(StockGDI.COLOUR_GREEN).this
|
||||||
wx.LIGHT_GREY = StockGDI.GetColour(StockGDI.COLOUR_LIGHTGREY)
|
wx.LIGHT_GREY.this = StockGDI.GetColour(StockGDI.COLOUR_LIGHTGREY).this
|
||||||
wx.RED = StockGDI.GetColour(StockGDI.COLOUR_RED)
|
wx.RED.this = StockGDI.GetColour(StockGDI.COLOUR_RED).this
|
||||||
wx.WHITE = StockGDI.GetColour(StockGDI.COLOUR_WHITE)
|
wx.WHITE.this = StockGDI.GetColour(StockGDI.COLOUR_WHITE).this
|
||||||
|
|
||||||
|
wx.CROSS_CURSOR.this = StockGDI.GetCursor(StockGDI.CURSOR_CROSS).this
|
||||||
|
wx.HOURGLASS_CURSOR.this = StockGDI.GetCursor(StockGDI.CURSOR_HOURGLASS).this
|
||||||
|
wx.STANDARD_CURSOR.this = StockGDI.GetCursor(StockGDI.CURSOR_STANDARD).this
|
||||||
|
|
||||||
|
wx.TheFontList.this = _wxPyInitTheFontList().this
|
||||||
|
wx.ThePenList.this = _wxPyInitThePenList().this
|
||||||
|
wx.TheBrushList.this = _wxPyInitTheBrushList().this
|
||||||
|
wx.TheColourDatabase.this = _wxPyInitTheColourDatabase().this
|
||||||
|
|
||||||
wx.CROSS_CURSOR = StockGDI.GetCursor(StockGDI.CURSOR_CROSS)
|
|
||||||
wx.HOURGLASS_CURSOR = StockGDI.GetCursor(StockGDI.CURSOR_HOURGLASS)
|
|
||||||
wx.STANDARD_CURSOR = StockGDI.GetCursor(StockGDI.CURSOR_STANDARD)
|
|
||||||
|
|
||||||
_initStockObjects = staticmethod(_initStockObjects)
|
_initStockObjects = staticmethod(_initStockObjects)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
%pythoncode {
|
||||||
|
%# Create an uninitialized instance for the stock objects, they will
|
||||||
|
%# be initialized later when the wx.App object is created.
|
||||||
|
ITALIC_FONT = Font.__new__(Font)
|
||||||
|
NORMAL_FONT = Font.__new__(Font)
|
||||||
|
SMALL_FONT = Font.__new__(Font)
|
||||||
|
SWISS_FONT = Font.__new__(Font)
|
||||||
|
|
||||||
|
BLACK_DASHED_PEN = Pen.__new__(Pen)
|
||||||
|
BLACK_PEN = Pen.__new__(Pen)
|
||||||
|
CYAN_PEN = Pen.__new__(Pen)
|
||||||
|
GREEN_PEN = Pen.__new__(Pen)
|
||||||
|
GREY_PEN = Pen.__new__(Pen)
|
||||||
|
LIGHT_GREY_PEN = Pen.__new__(Pen)
|
||||||
|
MEDIUM_GREY_PEN = Pen.__new__(Pen)
|
||||||
|
RED_PEN = Pen.__new__(Pen)
|
||||||
|
TRANSPARENT_PEN = Pen.__new__(Pen)
|
||||||
|
WHITE_PEN = Pen.__new__(Pen)
|
||||||
|
|
||||||
|
BLACK_BRUSH = Brush.__new__(Brush)
|
||||||
|
BLUE_BRUSH = Brush.__new__(Brush)
|
||||||
|
CYAN_BRUSH = Brush.__new__(Brush)
|
||||||
|
GREEN_BRUSH = Brush.__new__(Brush)
|
||||||
|
GREY_BRUSH = Brush.__new__(Brush)
|
||||||
|
LIGHT_GREY_BRUSH = Brush.__new__(Brush)
|
||||||
|
MEDIUM_GREY_BRUSH = Brush.__new__(Brush)
|
||||||
|
RED_BRUSH = Brush.__new__(Brush)
|
||||||
|
TRANSPARENT_BRUSH = Brush.__new__(Brush)
|
||||||
|
WHITE_BRUSH = Brush.__new__(Brush)
|
||||||
|
|
||||||
|
BLACK = Colour.__new__(Colour)
|
||||||
|
BLUE = Colour.__new__(Colour)
|
||||||
|
CYAN = Colour.__new__(Colour)
|
||||||
|
GREEN = Colour.__new__(Colour)
|
||||||
|
LIGHT_GREY = Colour.__new__(Colour)
|
||||||
|
RED = Colour.__new__(Colour)
|
||||||
|
WHITE = Colour.__new__(Colour)
|
||||||
|
|
||||||
|
CROSS_CURSOR = Cursor.__new__(Cursor)
|
||||||
|
HOURGLASS_CURSOR = Cursor.__new__(Cursor)
|
||||||
|
STANDARD_CURSOR = Cursor.__new__(Cursor)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
%immutable;
|
%immutable;
|
||||||
%threadWrapperOff;
|
%threadWrapperOff;
|
||||||
@@ -229,31 +278,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
%pythoncode {
|
%pythoncode {
|
||||||
%# This function makes a class used to do delayed initialization of some
|
|
||||||
%# stock wx objects. When they are used the first time then an init function
|
|
||||||
%# is called to make the real instance, which is then used to replace the
|
|
||||||
%# original instance and class seen by the programmer.
|
|
||||||
def _wxPyMakeDelayedInitWrapper(initFunc):
|
|
||||||
class _wxPyStockObjectWrapper(object):
|
|
||||||
def __init__(self, *args):
|
|
||||||
self._args = args
|
|
||||||
def __getattr__(self, name):
|
|
||||||
obj = initFunc(*self._args)
|
|
||||||
self.__class__ = obj.__class__
|
|
||||||
self.__dict__ = obj.__dict__
|
|
||||||
return getattr(self, name)
|
|
||||||
def __str__(self):
|
|
||||||
return self.__getattr__("__str__")()
|
|
||||||
def __repr__(self):
|
|
||||||
return self.__getattr__("__repr__")()
|
|
||||||
return _wxPyStockObjectWrapper
|
|
||||||
|
|
||||||
TheFontList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheFontList)()
|
%# Create an uninitialized instance for the stock objects, they will
|
||||||
ThePenList = _wxPyMakeDelayedInitWrapper(_wxPyInitThePenList)()
|
%# be initialized later when the wx.App object is created.
|
||||||
TheBrushList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheBrushList)()
|
TheFontList = FontList.__new__(FontList)
|
||||||
TheColourDatabase = _wxPyMakeDelayedInitWrapper(_wxPyInitTheColourDatabase)()
|
ThePenList = PenList.__new__(PenList)
|
||||||
|
TheBrushList = BrushList.__new__(BrushList)
|
||||||
|
TheColourDatabase = ColourDatabase.__new__(ColourDatabase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
%pythoncode { NullColor = NullColour }
|
%pythoncode { NullColor = NullColour }
|
||||||
|
@@ -540,42 +540,42 @@ wxRendererNative_GetGeneric = wx._gdi.RendererNative_GetGeneric
|
|||||||
wxRendererNative_GetDefault = wx._gdi.RendererNative_GetDefault
|
wxRendererNative_GetDefault = wx._gdi.RendererNative_GetDefault
|
||||||
wxRendererNative_Set = wx._gdi.RendererNative_Set
|
wxRendererNative_Set = wx._gdi.RendererNative_Set
|
||||||
wxMaskColour = wx._gdi.MaskColour
|
wxMaskColour = wx._gdi.MaskColour
|
||||||
## wxNORMAL_FONT = wx._gdi.NORMAL_FONT
|
wxNORMAL_FONT = wx._gdi.NORMAL_FONT
|
||||||
## wxSMALL_FONT = wx._gdi.SMALL_FONT
|
wxSMALL_FONT = wx._gdi.SMALL_FONT
|
||||||
## wxITALIC_FONT = wx._gdi.ITALIC_FONT
|
wxITALIC_FONT = wx._gdi.ITALIC_FONT
|
||||||
## wxSWISS_FONT = wx._gdi.SWISS_FONT
|
wxSWISS_FONT = wx._gdi.SWISS_FONT
|
||||||
## wxRED_PEN = wx._gdi.RED_PEN
|
wxRED_PEN = wx._gdi.RED_PEN
|
||||||
## wxCYAN_PEN = wx._gdi.CYAN_PEN
|
wxCYAN_PEN = wx._gdi.CYAN_PEN
|
||||||
## wxGREEN_PEN = wx._gdi.GREEN_PEN
|
wxGREEN_PEN = wx._gdi.GREEN_PEN
|
||||||
## wxBLACK_PEN = wx._gdi.BLACK_PEN
|
wxBLACK_PEN = wx._gdi.BLACK_PEN
|
||||||
## wxWHITE_PEN = wx._gdi.WHITE_PEN
|
wxWHITE_PEN = wx._gdi.WHITE_PEN
|
||||||
## wxTRANSPARENT_PEN = wx._gdi.TRANSPARENT_PEN
|
wxTRANSPARENT_PEN = wx._gdi.TRANSPARENT_PEN
|
||||||
## wxBLACK_DASHED_PEN = wx._gdi.BLACK_DASHED_PEN
|
wxBLACK_DASHED_PEN = wx._gdi.BLACK_DASHED_PEN
|
||||||
## wxGREY_PEN = wx._gdi.GREY_PEN
|
wxGREY_PEN = wx._gdi.GREY_PEN
|
||||||
## wxMEDIUM_GREY_PEN = wx._gdi.MEDIUM_GREY_PEN
|
wxMEDIUM_GREY_PEN = wx._gdi.MEDIUM_GREY_PEN
|
||||||
## wxLIGHT_GREY_PEN = wx._gdi.LIGHT_GREY_PEN
|
wxLIGHT_GREY_PEN = wx._gdi.LIGHT_GREY_PEN
|
||||||
## wxBLUE_BRUSH = wx._gdi.BLUE_BRUSH
|
wxBLUE_BRUSH = wx._gdi.BLUE_BRUSH
|
||||||
## wxGREEN_BRUSH = wx._gdi.GREEN_BRUSH
|
wxGREEN_BRUSH = wx._gdi.GREEN_BRUSH
|
||||||
## wxWHITE_BRUSH = wx._gdi.WHITE_BRUSH
|
wxWHITE_BRUSH = wx._gdi.WHITE_BRUSH
|
||||||
## wxBLACK_BRUSH = wx._gdi.BLACK_BRUSH
|
wxBLACK_BRUSH = wx._gdi.BLACK_BRUSH
|
||||||
## wxTRANSPARENT_BRUSH = wx._gdi.TRANSPARENT_BRUSH
|
wxTRANSPARENT_BRUSH = wx._gdi.TRANSPARENT_BRUSH
|
||||||
## wxCYAN_BRUSH = wx._gdi.CYAN_BRUSH
|
wxCYAN_BRUSH = wx._gdi.CYAN_BRUSH
|
||||||
## wxRED_BRUSH = wx._gdi.RED_BRUSH
|
wxRED_BRUSH = wx._gdi.RED_BRUSH
|
||||||
## wxGREY_BRUSH = wx._gdi.GREY_BRUSH
|
wxGREY_BRUSH = wx._gdi.GREY_BRUSH
|
||||||
## wxMEDIUM_GREY_BRUSH = wx._gdi.MEDIUM_GREY_BRUSH
|
wxMEDIUM_GREY_BRUSH = wx._gdi.MEDIUM_GREY_BRUSH
|
||||||
## wxLIGHT_GREY_BRUSH = wx._gdi.LIGHT_GREY_BRUSH
|
wxLIGHT_GREY_BRUSH = wx._gdi.LIGHT_GREY_BRUSH
|
||||||
## wxBLACK = wx._gdi.BLACK
|
wxBLACK = wx._gdi.BLACK
|
||||||
## wxWHITE = wx._gdi.WHITE
|
wxWHITE = wx._gdi.WHITE
|
||||||
## wxRED = wx._gdi.RED
|
wxRED = wx._gdi.RED
|
||||||
## wxBLUE = wx._gdi.BLUE
|
wxBLUE = wx._gdi.BLUE
|
||||||
## wxGREEN = wx._gdi.GREEN
|
wxGREEN = wx._gdi.GREEN
|
||||||
## wxCYAN = wx._gdi.CYAN
|
wxCYAN = wx._gdi.CYAN
|
||||||
## wxLIGHT_GREY = wx._gdi.LIGHT_GREY
|
wxLIGHT_GREY = wx._gdi.LIGHT_GREY
|
||||||
## wxSTANDARD_CURSOR = wx._gdi.STANDARD_CURSOR
|
wxSTANDARD_CURSOR = wx._gdi.STANDARD_CURSOR
|
||||||
## wxHOURGLASS_CURSOR = wx._gdi.HOURGLASS_CURSOR
|
wxHOURGLASS_CURSOR = wx._gdi.HOURGLASS_CURSOR
|
||||||
## wxCROSS_CURSOR = wx._gdi.CROSS_CURSOR
|
wxCROSS_CURSOR = wx._gdi.CROSS_CURSOR
|
||||||
## wxTheFontList = wx._gdi.wxTheFontList
|
wxTheFontList = wx._gdi.TheFontList
|
||||||
## wxTheBrushList = wx._gdi.wxTheBrushList
|
wxTheBrushList = wx._gdi.TheBrushList
|
||||||
## wxTheColourDatabase = wx._gdi.wxTheColourDatabase
|
wxTheColourDatabase = wx._gdi.TheColourDatabase
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user