Merge pull request #2141 from swt2c/update_wx_3.1.6

Update wxWidgets to 3.1.6
This commit is contained in:
Scott Talbert
2022-05-02 22:41:42 -04:00
committed by GitHub
48 changed files with 372 additions and 94 deletions

View File

@@ -104,7 +104,7 @@ toolsURL = 'https://wxpython.org/Phoenix/tools'
# MS Edge code and DLLs needed for the wxWEBVIEW_BACKEND_EDGE backend
MS_edge_version = '1.0.622.22'
MS_edge_version = '1.0.1185.39'
MS_edge_url = 'https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/{}'.format(MS_edge_version)
#---------------------------------------------------------------------------

View File

@@ -62,5 +62,5 @@ VER_FLAGS = "a1" # wxPython release flags
# The version numbers of wxWidgets to be used in the build
wxVER_MAJOR = 3
wxVER_MINOR = 1
wxVER_RELEASE = 5 # only used when wxVER_MINOR is an odd value
wxVER_RELEASE = 6 # only used when wxVER_MINOR is an odd value

View File

@@ -157,18 +157,18 @@ class PyAUIFrame(wx.Frame):
tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER)
tb1.SetToolBitmapSize(wx.Size(48,48))
tb1.AddTool(101, "Test", wx.ArtProvider.GetBitmap(wx.ART_ERROR))
tb1.AddTool(101, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_ERROR))
tb1.AddSeparator()
tb1.AddTool(102, "Test", wx.ArtProvider.GetBitmap(wx.ART_QUESTION))
tb1.AddTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_INFORMATION))
tb1.AddTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_WARNING))
tb1.AddTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_MISSING_IMAGE))
tb1.AddTool(102, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_QUESTION))
tb1.AddTool(103, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_INFORMATION))
tb1.AddTool(103, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_WARNING))
tb1.AddTool(103, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_MISSING_IMAGE))
tb1.Realize()
tb2 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER)
tb2.SetToolBitmapSize(wx.Size(16,16))
tb2_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(16, 16))
tb2_bmp1 = wx.ArtProvider.GetBitmapBundle(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(16, 16))
tb2.AddTool(101, "Test", tb2_bmp1)
tb2.AddTool(101, "Test", tb2_bmp1)
tb2.AddTool(101, "Test", tb2_bmp1)
@@ -186,7 +186,7 @@ class PyAUIFrame(wx.Frame):
tb3 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER)
tb3.SetToolBitmapSize(wx.Size(16,16))
tb3_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16, 16))
tb3_bmp1 = wx.ArtProvider.GetBitmapBundle(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16, 16))
tb3.AddTool(101, "Test", tb3_bmp1)
tb3.AddTool(101, "Test", tb3_bmp1)
tb3.AddTool(101, "Test", tb3_bmp1)
@@ -199,7 +199,7 @@ class PyAUIFrame(wx.Frame):
tb4 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_HORZ_TEXT)
tb4.SetToolBitmapSize(wx.Size(16,16))
tb4_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16, 16))
tb4_bmp1 = wx.ArtProvider.GetBitmapBundle(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16, 16))
tb4.AddTool(101, "Item 1", tb4_bmp1)
tb4.AddTool(101, "Item 2", tb4_bmp1)
tb4.AddTool(101, "Item 3", tb4_bmp1)
@@ -214,12 +214,12 @@ class PyAUIFrame(wx.Frame):
tb5 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_VERTICAL)
tb5.SetToolBitmapSize(wx.Size(48, 48))
tb5.AddTool(101, "Test", wx.ArtProvider.GetBitmap(wx.ART_ERROR))
tb5.AddTool(101, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_ERROR))
tb5.AddSeparator()
tb5.AddTool(102, "Test", wx.ArtProvider.GetBitmap(wx.ART_QUESTION))
tb5.AddTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_INFORMATION))
tb5.AddTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_WARNING))
tb5.AddTool(103, "Test", wx.ArtProvider.GetBitmap(wx.ART_MISSING_IMAGE))
tb5.AddTool(102, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_QUESTION))
tb5.AddTool(103, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_INFORMATION))
tb5.AddTool(103, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_WARNING))
tb5.AddTool(103, "Test", wx.ArtProvider.GetBitmapBundle(wx.ART_MISSING_IMAGE))
tb5.Realize()
# add a bunch of panes
@@ -767,7 +767,7 @@ class SizeReportCtrl(wx.Control):
dc.SetPen(wx.LIGHT_GREY_PEN)
dc.DrawLine(0, 0, size.x, size.y)
dc.DrawLine(0, size.y, size.x, 0)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2))
dc.DrawText(s, int((size.x-w)/2), int((size.y-(height*5))/2))
if self._mgr:
@@ -775,19 +775,19 @@ class SizeReportCtrl(wx.Control):
s = ("Layer: %d")%pi.dock_layer
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*1))
dc.DrawText(s, int((size.x-w)/2), int(((size.y-(height*5))/2)+(height*1)))
s = ("Dock: %d Row: %d")%(pi.dock_direction, pi.dock_row)
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*2))
dc.DrawText(s, int((size.x-w)/2), int(((size.y-(height*5))/2)+(height*2)))
s = ("Position: %d")%pi.dock_pos
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*3))
dc.DrawText(s, int((size.x-w)/2), int(((size.y-(height*5))/2)+(height*3)))
s = ("Proportion: %d")%pi.dock_proportion
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*4))
dc.DrawText(s, int((size.x-w)/2), int(((size.y-(height*5))/2)+(height*4)))
def OnEraseBackground(self, event):
@@ -1002,37 +1002,41 @@ class SettingsPanel(wx.Panel):
return image.ConvertToBitmap()
def CreateColorBitmapBundle(self, c):
return wx.BitmapBundle(self.CreateColorBitmap(c))
def UpdateColors(self):
bk = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_BACKGROUND_COLOUR)
self._background_color.SetBitmapLabel(self.CreateColorBitmap(bk))
self._background_color.SetBitmapLabel(self.CreateColorBitmapBundle(bk))
cap = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR)
self._inactive_caption_color.SetBitmapLabel(self.CreateColorBitmap(cap))
self._inactive_caption_color.SetBitmapLabel(self.CreateColorBitmapBundle(cap))
capgrad = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR)
self._inactive_caption_gradient_color.SetBitmapLabel(self.CreateColorBitmap(capgrad))
self._inactive_caption_gradient_color.SetBitmapLabel(self.CreateColorBitmapBundle(capgrad))
captxt = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR)
self._inactive_caption_text_color.SetBitmapLabel(self.CreateColorBitmap(captxt))
self._inactive_caption_text_color.SetBitmapLabel(self.CreateColorBitmapBundle(captxt))
acap = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_ACTIVE_CAPTION_COLOUR)
self._active_caption_color.SetBitmapLabel(self.CreateColorBitmap(acap))
self._active_caption_color.SetBitmapLabel(self.CreateColorBitmapBundle(acap))
acapgrad = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR)
self._active_caption_gradient_color.SetBitmapLabel(self.CreateColorBitmap(acapgrad))
self._active_caption_gradient_color.SetBitmapLabel(self.CreateColorBitmapBundle(acapgrad))
acaptxt = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR)
self._active_caption_text_color.SetBitmapLabel(self.CreateColorBitmap(acaptxt))
self._active_caption_text_color.SetBitmapLabel(self.CreateColorBitmapBundle(acaptxt))
sash = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_SASH_COLOUR)
self._sash_color.SetBitmapLabel(self.CreateColorBitmap(sash))
self._sash_color.SetBitmapLabel(self.CreateColorBitmapBundle(sash))
border = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_BORDER_COLOUR)
self._border_color.SetBitmapLabel(self.CreateColorBitmap(border))
self._border_color.SetBitmapLabel(self.CreateColorBitmapBundle(border))
gripper = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_GRIPPER_COLOUR)
self._gripper_color.SetBitmapLabel(self.CreateColorBitmap(gripper))
self._gripper_color.SetBitmapLabel(self.CreateColorBitmapBundle(gripper))
def OnPaneBorderSize(self, event):

View File

@@ -46,7 +46,7 @@ class TestPanel(wx.Panel):
# we need to make it be the same size as the primary image, so
# grab a subsection of this new image
cropped = img.GetSubImage((20, 20, bmp.GetWidth(), bmp.GetHeight()))
b.SetBitmapPressed(cropped.ConvertToBitmap())
b.SetBitmapPressed(wx.BitmapBundle(cropped.ConvertToBitmap()))
b.SetToolTip("This is a bitmap button with \nwx.NO_BORDER style.")
self.Bind(wx.EVT_BUTTON, self.OnClick, b)

View File

@@ -30,7 +30,7 @@ class TestPanel(wx.Panel):
"above or below the label.")
self.Bind(wx.EVT_BUTTON, self.OnClick, b)
b.SetBitmap(images.Mondrian.Bitmap,
b.SetBitmap(wx.BitmapBundle(images.Mondrian.Bitmap),
wx.LEFT # Left is the default, the image can be on the other sides too
#wx.RIGHT
#wx.TOP

View File

@@ -23,7 +23,7 @@ class TestPanel(wx.Panel):
panel.Move((50,50))
b = wx.ToggleButton(self, -1, "can have bitmaps too", pos=(50,125))
b.SetBitmap(images.Mondrian.Bitmap)
b.SetBitmap(wx.BitmapBundle(images.Mondrian.Bitmap))
b.SetInitialSize() # adjust default size for the bitmap
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b)

View File

@@ -86,36 +86,38 @@ class TestToolBar(wx.Frame):
self.CreateStatusBar()
tsize = (24,24)
new_bmp = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR, tsize)
open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize)
copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, tsize)
paste_bmp= wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR, tsize)
new_bmp = wx.ArtProvider.GetBitmapBundle(wx.ART_NEW, wx.ART_TOOLBAR, tsize)
open_bmp = wx.ArtProvider.GetBitmapBundle(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize)
copy_bmp = wx.ArtProvider.GetBitmapBundle(wx.ART_COPY, wx.ART_TOOLBAR, tsize)
paste_bmp= wx.ArtProvider.GetBitmapBundle(wx.ART_PASTE, wx.ART_TOOLBAR, tsize)
null_bmp = wx.BitmapBundle(wx.NullBitmap)
tb.SetToolBitmapSize(tsize)
#tb.AddTool(10, new_bmp, "New", "Long help for 'New'")
tb.AddTool(10, "New", new_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "New", "Long help for 'New'", None)
tb.AddTool(10, "New", new_bmp, null_bmp, wx.ITEM_NORMAL, "New", "Long help for 'New'", None)
self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)
#tb.AddTool(20, open_bmp, "Open", "Long help for 'Open'")
tb.AddTool(20, "Open", open_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "Open", "Long help for 'Open'", None)
tb.AddTool(20, "Open", open_bmp, null_bmp, wx.ITEM_NORMAL, "Open", "Long help for 'Open'", None)
self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)
tb.AddSeparator()
tb.AddTool(30, "Copy", copy_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "Copy", "Long help for 'Copy'", None)
tb.AddTool(30, "Copy", copy_bmp, null_bmp, wx.ITEM_NORMAL, "Copy", "Long help for 'Copy'", None)
self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)
tb.AddTool(40, "Paste", paste_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "Paste", "Long help for 'Paste'", None)
tb.AddTool(40, "Paste", paste_bmp, null_bmp, wx.ITEM_NORMAL, "Paste", "Long help for 'Paste'", None)
self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)
tb.AddSeparator()
#tool = tb.AddCheckTool(50, images.Tog1.GetBitmap(), shortHelp="Toggle this")
tool = tb.AddTool(50, "Checkable", images.Tog1.GetBitmap(),
tool = tb.AddTool(50, "Checkable",
wx.BitmapBundle(images.Tog1.GetBitmap()),
shortHelp="Toggle this", kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_TOOL, self.OnToolClick, id=50)

View File

@@ -148,7 +148,7 @@ class TestPanel(wx.Panel):
def OnRunSimpleWizard(self, evt):
# Create the wizard and the pages
wizard = wiz(self, -1, "Simple Wizard", images.WizTest1.GetBitmap())
wizard = wiz(self, -1, "Simple Wizard", wx.BitmapBundle(images.WizTest1.GetBitmap()))
page1 = TitledPage(wizard, "Page 1")
page2 = TitledPage(wizard, "Page 2")
page3 = TitledPage(wizard, "Page 3")
@@ -181,7 +181,7 @@ wxWizardPageSimple class can easily be used for the pages."""))
#wizard.SetExtraStyle(wx.WIZARD_EX_HELPBUTTON)
#wizard.Create(self, self.ID_wiz, "Simple Wizard",
# images.WizTest1.GetBitmap())
wizard = wiz(self, -1, "Dynamic Wizard", images.WizTest1.GetBitmap())
wizard = wiz(self, -1, "Dynamic Wizard", wx.BitmapBundle(images.WizTest1.GetBitmap()))
page1 = TitledPage(wizard, "Page 1")
page2 = SkipNextPage(wizard, "Page 2")

View File

@@ -621,40 +621,44 @@ class SettingsPanel(wx.Panel):
return image.ConvertToBitmap()
def CreateColourBitmapBundle(self, c):
return wx.BitmapBundle(self.CreateColourBitmap(c))
def UpdateColours(self):
bk = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_BACKGROUND_COLOUR)
self._background_colour.SetBitmapLabel(self.CreateColourBitmap(bk))
self._background_colour.SetBitmapLabel(self.CreateColourBitmapBundle(bk))
cap = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR)
self._inactive_caption_colour.SetBitmapLabel(self.CreateColourBitmap(cap))
self._inactive_caption_colour.SetBitmapLabel(self.CreateColourBitmapBundle(cap))
capgrad = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR)
self._inactive_caption_gradient_colour.SetBitmapLabel(self.CreateColourBitmap(capgrad))
self._inactive_caption_gradient_colour.SetBitmapLabel(self.CreateColourBitmapBundle(capgrad))
captxt = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR)
self._inactive_caption_text_colour.SetBitmapLabel(self.CreateColourBitmap(captxt))
self._inactive_caption_text_colour.SetBitmapLabel(self.CreateColourBitmapBundle(captxt))
acap = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_ACTIVE_CAPTION_COLOUR)
self._active_caption_colour.SetBitmapLabel(self.CreateColourBitmap(acap))
self._active_caption_colour.SetBitmapLabel(self.CreateColourBitmapBundle(acap))
acapgrad = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR)
self._active_caption_gradient_colour.SetBitmapLabel(self.CreateColourBitmap(acapgrad))
self._active_caption_gradient_colour.SetBitmapLabel(self.CreateColourBitmapBundle(acapgrad))
acaptxt = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR)
self._active_caption_text_colour.SetBitmapLabel(self.CreateColourBitmap(acaptxt))
self._active_caption_text_colour.SetBitmapLabel(self.CreateColourBitmapBundle(acaptxt))
sash = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_SASH_COLOUR)
self._sash_colour.SetBitmapLabel(self.CreateColourBitmap(sash))
self._sash_colour.SetBitmapLabel(self.CreateColourBitmapBundle(sash))
border = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_BORDER_COLOUR)
self._border_colour.SetBitmapLabel(self.CreateColourBitmap(border))
self._border_colour.SetBitmapLabel(self.CreateColourBitmapBundle(border))
gripper = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_GRIPPER_COLOUR)
self._gripper_colour.SetBitmapLabel(self.CreateColourBitmap(gripper))
self._gripper_colour.SetBitmapLabel(self.CreateColourBitmapBundle(gripper))
hint = self._frame.GetDockArt().GetColour(aui.AUI_DOCKART_HINT_WINDOW_COLOUR)
self._hint_colour.SetBitmapLabel(self.CreateColourBitmap(hint))
self._hint_colour.SetBitmapLabel(self.CreateColourBitmapBundle(hint))
def OnPaneBorderSize(self, event):

View File

@@ -119,7 +119,7 @@ class BalloonTipDemo(wx.Frame):
button2 = wx.Button(panel, -1, "Disable BalloonTip")
tbicon = TaskBarIcon()
tbicon.SetIcon(images.Mondrian.GetIcon())
tbicon.SetIcon(wx.BitmapBundle(images.Mondrian.GetIcon()))
controls = list(panel.GetChildren())
controls.append(tbicon)

View File

@@ -2630,7 +2630,7 @@
"ObjectRefData":"wx.",
"OperatingSystemId":"wx.",
"Orientation":"wx.",
"Origin":"wx.grid.GridActivationSource.",
"Origin":"wx.HelpEvent.",
"OutBottom":"wx.",
"OutCode":"wx.",
"OutLeft":"wx.",
@@ -3582,6 +3582,7 @@
"RichTextImageBlock":"wx.richtext.",
"RichTextLine":"wx.richtext.",
"RichTextLineBreakChar":"wx.richtext.",
"RichTextLineVector":"wx.richtext.",
"RichTextListStyleDefinition":"wx.richtext.",
"RichTextModuleInit":"wx.richtext.",
"RichTextObject":"wx.richtext.",

View File

@@ -49,6 +49,7 @@ INCLUDES = [ # base and core stuff
'userdata',
'wxpybuffer',
'msgdlg_btnlabel',
'wxvector',
'stockgdi',
'longlong',
@@ -76,6 +77,7 @@ INCLUDES = [ # base and core stuff
'image',
'gdiobj',
'bitmap',
'bmpbndl',
'icon', 'iconloc', 'iconbndl',
'font',
'fontutil',

View File

@@ -152,6 +152,7 @@ def run():
tc_excludes = ['OSXEnableAutomaticQuoteSubstitution',
'OSXEnableAutomaticDashSubstitution',
'OSXDisableAllSmartSubstitutions',
'OSXEnableNewLineReplacement',
]
import textctrl
mod = textctrl.parseAndTweakModule()

View File

@@ -10,6 +10,7 @@
import etgtools
import etgtools.tweaker_tools as tools
from etgtools import PyFunctionDef, PyCodeDef, PyPropertyDef
import sys
PACKAGE = "wx"
MODULE = "_core"
@@ -206,6 +207,8 @@ def run():
c.addProperty('UseBestVisual GetUseBestVisual SetUseBestVisual')
c.addProperty('TopWindow GetTopWindow SetTopWindow')
if sys.platform != 'linux':
c.find('GTKSuppressDiagnostics').ignore()
#-------------------------------------------------------

58
etg/bmpbndl.py Normal file
View File

@@ -0,0 +1,58 @@
#---------------------------------------------------------------------------
# Name: etg/bmpbndl.py
# Author: Scott Talbert
#
# Created: 13-Apr-2022
# Copyright: (c) 2022 by Scott Talbert
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
from etgtools import MethodDef
PACKAGE = "wx"
MODULE = "_core"
NAME = "bmpbndl" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxBitmapBundle',
'wxBitmapBundleImpl',
]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
#module.addHeaderCode('#include <wx/some_header_file.h>')
c = module.find('wxBitmapBundle')
assert isinstance(c, etgtools.ClassDef)
c.find('FromSVG').findOverload('char *data, const wxSize &sizeDef').ignore()
c = module.find('wxBitmapBundleImpl')
assert isinstance(c, etgtools.ClassDef)
m = MethodDef(name='~wxBitmapBundleImpl', isDtor=True, isVirtual=True, protection='protected')
c.addItem(m)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -45,6 +45,7 @@ def run():
c.find('wxCursor').findOverload('cursorName').find('type').default='wxBITMAP_TYPE_ANY'
# TODO: This ctor ^^ in Classic has a custom implementation for wxGTK that
# sets the hotspot. Is that still needed?
c.find('wxCursor').findOverload('(const char *const *xpmData)').ignore()
c.addCppMethod('int', '__nonzero__', '()', "return self->IsOk();")
c.addCppMethod('int', '__bool__', '()', "return self->IsOk();")

View File

@@ -344,7 +344,7 @@ def run():
c.addItem(etgtools.WigCode("""\
virtual void SetTitle(const wxString& title);
virtual wxString GetTitle() const;
virtual void SetBitmap(const wxBitmap& bitmap);
virtual void SetBitmap(const wxBitmapBundle& bitmap);
virtual wxBitmap GetBitmap() const;
virtual void SetWidth(int width);
virtual int GetWidth() const;

View File

@@ -110,6 +110,9 @@ def run():
module.addPyCode("ADJUST_MINSIZE = 0")
module.addPyCode("WS_EX_VALIDATE_RECURSIVELY = 0")
# This is only supported with C++14, so ignore it for now
module.find('wxDEPRECATED_ATTR').ignore()
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -100,6 +100,11 @@ def run():
#endif
""")
# Missing in 3.1.6
module.addItem(etgtools.WigCode("""\
wxEventType wxEVT_FULLSCREEN /PyName=wxEVT_FULLSCREEN/;
"""))
module.addPyClass('PyEventBinder', ['object'],
doc="""\

View File

@@ -155,6 +155,9 @@ def run():
c.find('operator*=').all() + \
c.find('operator/=').all():
f.ignore(False)
# Ignore these because they conflict with __imul__() and __itruediv__()
c.find('operator*=').findOverload('double').ignore()
c.find('operator/=').findOverload('double').ignore()
c.addCppMethod('bool', '__eq__', '(const wxSize& other)',
body="return *self == *other;")

View File

@@ -73,7 +73,7 @@ def run():
virtual wxWindow* GetHTMLWindow();
virtual wxColour GetHTMLBackgroundColour() const;
virtual void SetHTMLBackgroundColour(const wxColour& clr);
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
virtual void SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg);
virtual void SetHTMLStatusText(const wxString& text);
virtual wxCursor GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor type) const;
"""))

View File

@@ -79,6 +79,9 @@ def run():
#endif
""")
# Documented wrongly in 3.1.6
c.find('GetLogicalSize').type = 'wxSize'
# For compatibility:
module.addPyFunction('EmptyIcon', '()',

View File

@@ -333,6 +333,10 @@ def run():
#endif
""")
# Documented wrongly in 3.1.6
c.find('RemoveSortIndicator').type = 'void'
c.find('RemoveSortIndicator').isConst = False
#-------------------------------------------------------
c = module.find('wxListView')

View File

@@ -109,11 +109,12 @@ def run():
c.find('GetBitmap').type = 'const wxBitmap*'
c.find('GetBitmap').transferBack = True
c.find('GetBitmap').setCppCode("""\
#ifdef __WXMSW__
return &self->GetBitmap(checked);
return new wxBitmap(self->GetBitmap(checked));
#else
return &self->GetBitmap();
return new wxBitmap(self->GetBitmap());
#endif
""")
@@ -157,6 +158,10 @@ def run():
module.addItem(tools.wxListWrapperTemplate('wxMenuItemList', 'wxMenuItem', module))
# Documented wrongly in 3.1.6
c.find('AddExtraAccel.accel').isConst = True
c.find('AddExtraAccel.accel').type = 'wxAcceleratorEntry&'
#-----------------------------------------------------------------

View File

@@ -219,7 +219,7 @@ def run():
# force a copy, in case the _colorData is shared
self.colour = wx.Colour(colour)
bmp = self._makeBitmap()
self.SetBitmapLabel(bmp)
self.SetBitmapLabel(wx.BitmapBundle(bmp))
def GetColour(self):
return self.colour

View File

@@ -79,8 +79,6 @@ def run():
tools.wxArrayWrapperTemplate('wxRichTextVariantArray', 'wxVariant', module))
module.addItem(
tools.wxListWrapperTemplate('wxRichTextObjectList', 'wxRichTextObject', module))
module.addItem(
tools.wxListWrapperTemplate('wxRichTextLineList', 'wxRichTextLine', module))
# Can this even work? Apparently it does.
module.addItem(
@@ -319,6 +317,21 @@ def run():
fakeListClassName='wxRichTextObjectList_'))
c.find('MoveToList.list').type = 'wxRichTextObjectList_&'
c.find('MoveFromList.list').type = 'wxRichTextObjectList_&'
# TODO: figure out why wxvector.sip doesn't work for this
c.find('GetLines').type = 'PyObject*'
c.find('GetLines').setCppCode("""\
wxPyThreadBlocker blocker;
PyObject* result = PyList_New(0);
const wxRichTextLineVector& vector = self->GetLines();
for (size_t idx=0; idx < vector.size(); idx++) {{
PyObject* obj;
wxRichTextLine* item = new wxRichTextLine(*vector.at(idx));
obj = wxPyConstructObject((void*)item, "wxRichTextLine", true);
PyList_Append(result, obj);
Py_DECREF(obj);
}}
return result;
""")
#-------------------------------------------------------

View File

@@ -9,6 +9,8 @@
# License: wxWindows License
#---------------------------------------------------------------------------
import sys
import etgtools
import etgtools.tweaker_tools as tools
@@ -144,6 +146,15 @@ def parseAndTweakModule():
#endif
""")
# TODO: add support for wxTextProofOptions (only supported on MSW/GTK3)
# so will need stubs on other platforms.
c.find('EnableProofCheck').ignore()
c.find('GetProofCheckOptions').ignore()
# This function only exists on OSX
if sys.platform != 'darwin':
c.find('OSXEnableNewLineReplacement').ignore()
c = module.find('wxTextUrlEvent')

View File

@@ -150,7 +150,6 @@ def run():
# transfer imagelist ownership
c.find('AssignImageList.imageList').transfer = True
c.find('AssignStateImageList.imageList').transfer = True
c.find('AssignButtonsImageList.imageList').transfer = True

View File

@@ -91,6 +91,11 @@ def run():
# This tweak is needed only for the stub code
module.find('wxWebViewHandler.wxWebViewHandler').argsString = '(const wxString& scheme="")'
# Documented wrongly in 3.1.6 (needs to be fixed in stubs too)
c = module.find('wxWebViewFactory')
c.find('GetVersionInfo').argsString = '()'
c.find('GetVersionInfo').items = []
tools.generateStubs('wxUSE_WEBVIEW', module,
typeValMap={
'wxWebViewNavigationActionFlags': 'wxWEBVIEW_NAV_ACTION_NONE',
@@ -98,6 +103,13 @@ def run():
'wxVersionInfo': 'wxVersionInfo()',
})
# Missing in 3.1.6
module.addItem(etgtools.WigCode("""\
wxEventType wxEVT_WEBVIEW_FULLSCREEN_CHANGED /PyName=wxEVT_WEBVIEW_FULLSCREEN_CHANGED/;
wxEventType wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED /PyName=wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED/;
wxEventType wxEVT_WEBVIEW_SCRIPT_RESULT /PyName=wxEVT_WEBVIEW_SCRIPT_RESULT/;
"""))
c = module.find('wxWebView')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)

View File

@@ -497,7 +497,6 @@ def addWindowVirtuals(klass):
('DoSetSize', 'void DoSetSize(int x, int y, int width, int height, int sizeFlags)'),
('DoSetClientSize', 'void DoSetClientSize(int width, int height)'),
('DoSetSizeHints', 'void DoSetSizeHints( int minW, int minH, int maxW, int maxH, int incW, int incH )'),
('DoGetBorderSize', 'wxSize DoGetBorderSize() const'),
('DoMoveWindow', 'void DoMoveWindow(int x, int y, int width, int height)'),
('DoSetWindowVariant', 'void DoSetWindowVariant( wxWindowVariant variant)'),
('GetDefaultBorder', 'wxBorder GetDefaultBorder() const'),

106
src/wxvector.sip Normal file
View File

@@ -0,0 +1,106 @@
//--------------------------------------------------------------------------
// Name: wxvector.sip
// Purpose: MappedType for wxVector
//
// Author: Scott Talbert
//
// Created: 14-Apr-2022
// Copyright: (c) 2022 by Scott Talbert
// Licence: wxWindows license
//--------------------------------------------------------------------------
template<_TYPE_>
%MappedType wxVector<_TYPE_>
{
%ConvertFromTypeCode
PyObject *l = PyList_New(sipCpp->size());
if (!l)
return 0;
for (int i = 0; i < sipCpp->size(); ++i) {
_TYPE_ *t = new _TYPE_(sipCpp->at(i));
PyObject *tobj = sipConvertFromNewType(t, sipType__TYPE_,
sipTransferObj);
if (!tobj) {
delete t;
Py_DECREF(l);
return 0;
}
PyList_SetItem(l, i, tobj);
}
return l;
%End
%ConvertToTypeCode
PyObject *iter = PyObject_GetIter(sipPy);
if (!sipIsErr) {
PyErr_Clear();
Py_XDECREF(iter);
return (iter
#if PY_MAJOR_VERSION < 3
&& !PyString_Check(sipPy)
#endif
&& !PyUnicode_Check(sipPy));
}
if (!iter) {
*sipIsErr = 1;
return 0;
}
wxVector<_TYPE_> *wv = new wxVector<_TYPE_>;
for (Py_ssize_t i = 0; ; ++i) {
PyErr_Clear();
PyObject *itm = PyIter_Next(iter);
if (!itm) {
if (PyErr_Occurred()) {
delete wv;
Py_DECREF(iter);
*sipIsErr = 1;
return 0;
}
break;
}
int state;
_TYPE_ *t = reinterpret_cast<_TYPE_ *>(
sipForceConvertToType(itm, sipType__TYPE_, sipTransferObj,
SIP_NOT_NONE, &state, sipIsErr));
if (*sipIsErr) {
PyErr_Format(PyExc_TypeError,
"index %zd has type '%s' but '_TYPE_' is expected", i,
sipPyTypeName(Py_TYPE(itm)));
Py_DECREF(itm);
delete wv;
Py_DECREF(iter);
return 0;
}
wv->push_back(*t);
sipReleaseType(t, sipType__TYPE_, state);
Py_DECREF(itm);
}
Py_DECREF(iter);
*sipCppPtr = wv;
return sipGetState(sipTransferObj);
%End
};

View File

@@ -12,7 +12,7 @@ class bannerwindow_Tests(wtc.WidgetTestCase):
def test_bannerwindow1(self):
banner = wx.adv.BannerWindow(self.frame, dir=wx.LEFT)
banner.SetBitmap(wx.Bitmap(pngFile))
banner.SetBitmap(wx.BitmapBundle(wx.Bitmap(pngFile)))
def test_bannerwindow2(self):
banner = wx.adv.BannerWindow(self.frame, dir=wx.LEFT)

32
unittests/test_bmpbndl.py Normal file
View File

@@ -0,0 +1,32 @@
import unittest
from unittests import wtc
import wx
import os
icoFile = os.path.join(os.path.dirname(__file__), 'mondrian.ico')
pngFile = os.path.join(os.path.dirname(__file__), 'pointy.png')
#---------------------------------------------------------------------------
class bmpbndl_Tests(wtc.WidgetTestCase):
def test_BitmapBundleCtor1(self):
b1 = wx.BitmapBundle()
self.assertTrue( not b1.IsOk() )
def test_BitmapBundleCtor2(self):
b2 = wx.BitmapBundle(wx.Bitmap(5, 10, 32))
self.assertTrue( b2.IsOk() )
def test_BitmapBundleCtor3(self):
b3 = wx.BitmapBundle(wx.Icon(icoFile))
self.assertTrue( b3.IsOk() )
def test_BitmapBundleCtor4(self):
b4 = wx.BitmapBundle(wx.Image(pngFile))
self.assertTrue( b4.IsOk() )
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

View File

@@ -12,7 +12,7 @@ class ButtonTests(wtc.WidgetTestCase):
def test_ButtonCtors(self):
btn = wx.Button(self.frame, label='label')
btn = wx.Button(self.frame, -1, 'label', (10,10), (100,-1), wx.BU_LEFT)
bmp = wx.Bitmap(pngFile)
bmp = wx.BitmapBundle(wx.Bitmap(pngFile))
btn.SetBitmap(bmp)
def test_ButtonProperties(self):

View File

@@ -87,7 +87,7 @@ class dataview_Tests(wtc.WidgetTestCase):
def test_dataviewIconText2(self):
icon = wx.Icon(pngFile)
dit = dv.DataViewIconText('Smile!', icon)
dit = dv.DataViewIconText('Smile!', wx.BitmapBundle(icon))
dit.Icon
dit.Text

View File

@@ -14,9 +14,9 @@ class headercol_Tests(wtc.WidgetTestCase):
def test_headercolCtor2(self):
bmp = wx.Bitmap(pngFile)
bmp = wx.BitmapBundle(wx.Bitmap(pngFile))
hc = wx.HeaderColumnSimple(bmp, flags=wx.COL_RESIZABLE)
hc.Bitmap
hc.BitmapBundle
def test_headercolProperties(self):

View File

@@ -99,7 +99,7 @@ class lib_agw_speedmeter_Tests(wtc.WidgetTestCase):
fgSizer.Add(panel1, 1, wx.EXPAND)
boxSizer = wx.BoxSizer()
panel.SetSizer(boxSizer)
panel1.SetSizer(boxSizer)
spW = SM.SpeedMeter(panel1,
agwStyle=SM.SM_DRAW_HAND |
SM.SM_DRAW_SECTORS |

View File

@@ -22,8 +22,8 @@ class preferences_Tests(wtc.WidgetTestCase):
class MyPrefsPage(wx.PreferencesPage):
def GetName(self):
return 'MyPrefsPage'
def GetLargeIcon(self):
return wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_TOOLBAR, (32,32))
def GetIcon(self):
return wx.ArtProvider.GetBitmapBundle(wx.ART_HELP, wx.ART_TOOLBAR)
def CreateWindow(self, parent):
return MyPrefsPanel(parent)

View File

@@ -238,7 +238,13 @@ class richtextbuffer_Tests(wtc.WidgetTestCase):
o1 = wx.richtext.RichTextLine(None)
def test_richtextbuffer26(self):
o1 = wx.richtext.RichTextLineList()
para = wx.richtext.RichTextParagraph()
para.AllocateLine(0)
para.AllocateLine(1)
lines = para.GetLines()
self.assertEqual(len(lines), 2)
for l in lines:
self.assertTrue(isinstance(l, wx.richtext.RichTextLine))
def test_richtextbuffer27(self):
o1 = wx.richtext.RichTextParagraph()

View File

@@ -12,7 +12,7 @@ class taskbar_Tests(wtc.WidgetTestCase):
def test_taskbar1(self):
icon = wx.adv.TaskBarIcon(wx.adv.TBI_DOCK)
icon.SetIcon(wx.Icon(icoFile), "The tip string")
icon.SetIcon(wx.BitmapBundle(wx.Icon(icoFile)), "The tip string")
self.assertTrue(icon.IsOk())
icon.Destroy()
self.myYield()

View File

@@ -12,7 +12,7 @@ class tglbtn_Tests(wtc.WidgetTestCase):
def test_tglbtnCtors(self):
btn = wx.ToggleButton(self.frame, label='label')
btn = wx.ToggleButton(self.frame, -1, 'label', (10,10), (100,-1), wx.BU_LEFT)
bmp = wx.Bitmap(pngFile)
bmp = wx.BitmapBundle(wx.Bitmap(pngFile))
btn.SetBitmap(bmp)

View File

@@ -43,7 +43,7 @@ class toolbar_Tests(wtc.WidgetTestCase):
tools = []
for bmp in bmps:
tool = tb.AddTool(-1, 'label', bmp)
tool = tb.AddTool(-1, 'label', wx.BitmapBundle(bmp))
self.assertTrue(isinstance(tool, wx.ToolBarToolBase))
tools.append(tool)
tb.Realize()

View File

@@ -34,7 +34,7 @@ class wizard_Tests(wtc.WidgetTestCase):
def test_wizard2(self):
# Create the wizard
bmp = wx.Bitmap(pngFile)
bmp = wx.BitmapBundle(wx.Bitmap(pngFile))
wiz = wx.adv.Wizard(self.frame, title="Test Wizard 2", bitmap=bmp)
# create the pages
@@ -54,7 +54,7 @@ class wizard_Tests(wtc.WidgetTestCase):
def test_wizard3(self):
# Same as above but use the Chain function to connect the pages
bmp = wx.Bitmap(pngFile)
bmp = wx.BitmapBundle(wx.Bitmap(pngFile))
wiz = wx.adv.Wizard(self.frame, title="Test Wizard 2", bitmap=bmp)
pages = []
@@ -74,7 +74,7 @@ class wizard_Tests(wtc.WidgetTestCase):
def test_wizard4(self):
# Create the wizard
bmp = wx.Bitmap(pngFile)
bmp = wx.BitmapBundle(wx.Bitmap(pngFile))
wiz = wx.adv.Wizard(self.frame, title="Test Wizard 2", bitmap=bmp)
# create the pages

View File

@@ -158,7 +158,7 @@ class datetime_Tests(wtc.WidgetTestCase):
def test_datetimeParseDate3(self):
d = wx.DateTime()
val = d.ParseDate('10/25/2015 non-date text')
self.assertEqual(val, 13)
self.assertEqual(val, 10)
def test_datetimeParseDateTime1(self):

View File

@@ -381,8 +381,8 @@ class InfoBar(wx.Control):
self._button = wx.BitmapButton(self, wx.ID_ANY, bmp, style=wx.BORDER_NONE)
if wx.Platform != '__WXGTK__':
self._button.SetBitmapPressed(GetCloseButtonBitmap(self, sizeBmp, colBg, wx.CONTROL_PRESSED))
self._button.SetBitmapCurrent(GetCloseButtonBitmap(self, sizeBmp, colBg, wx.CONTROL_CURRENT))
self._button.SetBitmapPressed(wx.BitmapBundle(GetCloseButtonBitmap(self, sizeBmp, colBg, wx.CONTROL_PRESSED)))
self._button.SetBitmapCurrent(wx.BitmapBundle(GetCloseButtonBitmap(self, sizeBmp, colBg, wx.CONTROL_CURRENT)))
self._button.SetBackgroundColour(colBg)
self._button.SetToolTip(_("Hide this notification message."))

View File

@@ -119,7 +119,8 @@ class NavCanvas(wx.Panel):
self.ModesDict = {}
for Mode in Modes:
tool = tb.AddTool(wx.ID_ANY, label=Mode[0],
shortHelp=Mode[0], bitmap=Mode[2],
shortHelp=Mode[0],
bitmap=wx.BitmapBundle(Mode[2]),
kind=wx.ITEM_RADIO)
self.Bind(wx.EVT_TOOL, self.SetMode, tool)
self.ModesDict[tool.GetId()]=Mode[1]

View File

@@ -208,15 +208,15 @@ class InspectionFrame(wx.Frame):
tbar = self.CreateToolBar(wx.TB_HORIZONTAL | wx.TB_FLAT | wx.TB_TEXT | wx.NO_BORDER )
tbar.SetToolBitmapSize((24,24))
refreshBmp = Refresh.GetBitmap()
findWidgetBmp = Find.GetBitmap()
showSizersBmp = ShowSizers.GetBitmap()
expandTreeBmp = ExpandTree.GetBitmap()
collapseTreeBmp = CollapseTree.GetBitmap()
highlightItemBmp = HighlightItem.GetBitmap()
evtWatcherBmp = EvtWatcher.GetBitmap()
refreshBmp = wx.BitmapBundle(Refresh.GetBitmap())
findWidgetBmp = wx.BitmapBundle(Find.GetBitmap())
showSizersBmp = wx.BitmapBundle(ShowSizers.GetBitmap())
expandTreeBmp = wx.BitmapBundle(ExpandTree.GetBitmap())
collapseTreeBmp = wx.BitmapBundle(CollapseTree.GetBitmap())
highlightItemBmp = wx.BitmapBundle(HighlightItem.GetBitmap())
evtWatcherBmp = wx.BitmapBundle(EvtWatcher.GetBitmap())
toggleFillingBmp = ShowFilling.GetBitmap()
toggleFillingBmp = wx.BitmapBundle(ShowFilling.GetBitmap())
refreshTool = tbar.AddTool(-1, 'Refresh', refreshBmp,
shortHelp = 'Refresh widget tree (F1)')