mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-13 08:10:08 +01:00
Merge branch 'add-doc-snippets'
This commit is contained in:
4
build.py
4
build.py
@@ -1901,6 +1901,10 @@ def cmd_bdist_wheel(options, args):
|
||||
if options.upload:
|
||||
filemask = "dist/%s-%s-*.whl" % (baseName, cfg.VERSION)
|
||||
filenames = glob.glob(filemask)
|
||||
print(f'**** filemask: {filemask}')
|
||||
print(f'**** matched: {filenames}')
|
||||
print(f'**** all dist: {glob.glob("dist/*")}')
|
||||
|
||||
assert len(filenames) == 1, "Unknown files found:"+repr(filenames)
|
||||
uploadPackage(filenames[0], options)
|
||||
if pdbzip:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
# In __init__ for a wx.Frame
|
||||
...
|
||||
toolBar = self.CreateToolBar()
|
||||
bitmaps = [ wx.Bitmap('open_32x32.png'),
|
||||
wx.Bitmap('open_32x32.png'),
|
||||
wx.Bitmap('open_32x32.png') ]
|
||||
toolBar.AddTool(wx.ID_OPEN, wx.BitmapBundle.FromBitmaps(bitmaps))
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
# RC resources are not supported in wxPython
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
class MyCustomBitmapBundleImpl(wx.BitmapBundleImpl):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.img = wx.Image(pngFile)
|
||||
self.size = self.img.GetSize()
|
||||
|
||||
def GetDefaultSize(self):
|
||||
# Report the best or default size for the bitmap
|
||||
return self.size
|
||||
|
||||
def GetPreferredBitmapSizeAtScale(self, scale):
|
||||
# Return the size of the bitmap at the given display scale. It
|
||||
# doesn't need to be size*scale if there are unscaled bitmaps
|
||||
# near that size.
|
||||
return self.size * scale
|
||||
|
||||
def GetBitmap(self, size):
|
||||
# Return the version of the bitmap at the desired size
|
||||
img = self.img.Scale(size.width, size.height)
|
||||
return wx.Bitmap(img)
|
||||
|
||||
|
||||
|
||||
toolBar.AddTool(wx.ID_OPEN, wx.BitmapBundle.FromImpl(MyCustomBitmapBundleImpl())
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
# Create the combo control using its default ctor.
|
||||
combo = wx.ComboCtrl()
|
||||
|
||||
# Create the custom main control using its default ctor too.
|
||||
someMainWindow = SomeWindow()
|
||||
|
||||
# Set the custom main control before creating the combo.
|
||||
combo.SetMainControl(someMainWindow)
|
||||
|
||||
# And only create it now: wx.TextCtrl won't be unnecessarily
|
||||
# created because the combo already has a main window.
|
||||
combo.Create(panel, wx.ID_ANY, wx.EmptyString)
|
||||
|
||||
# Finally create the main window itself, now that its parent was
|
||||
# created.
|
||||
someMainWindow.Create(combo, ...)
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
listctrl = wx.ListCtrl(...)
|
||||
for i in range(3):
|
||||
listctrl.InsertColumn(i, wx.String.Format("Column %d", i))
|
||||
|
||||
order = [ 2, 0, 1]
|
||||
listctrl.SetColumnsOrder(order)
|
||||
|
||||
# Now listctrl.GetColumnsOrder() will return order and
|
||||
# listctrl.GetColumnIndexFromOrder(n) will return order[n] and
|
||||
# listctrl.GetColumnOrder() will return 1, 2 and 0 for the column 0, 1 and 2
|
||||
# respectively.
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
def OnColClick(self, event):
|
||||
col = event.GetColumn()
|
||||
if col == -1:
|
||||
return # clicked outside any column.
|
||||
|
||||
ascending = self.GetUpdatedAscendingSortIndicator(col)
|
||||
self.SortItems(self.MyCompareFunction, ascending)
|
||||
self.ShowSortIndicator(col, ascending)
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
# In a frame's __init__
|
||||
...
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
sizer.Add(...)
|
||||
sizer.Add(...)
|
||||
panel.SetSizer(sizer)
|
||||
|
||||
# Use the panel sizer to set the initial and minimal size of the
|
||||
# frame to fit its contents.
|
||||
sizer.SetSizeHints(self)
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
if wx.html2.WebView.IsBackendAvailable(wx.html2.WebViewBackendEdge):
|
||||
# Do whatever you need to do when the Edge backend is available
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
xrc_data = ... # Retrieve it from wherever.
|
||||
xmlDoc = wx.xml.XmlDocument(io.BytesIO(xrc_data))
|
||||
if not xmlDoc.IsOk():
|
||||
... handle invalid XML here ...
|
||||
return
|
||||
|
||||
if not wx.XmlResource.Get().LoadDocument(xmlDoc):
|
||||
... handle invalid XRC here ...
|
||||
return
|
||||
|
||||
... use the just loaded XRC as usual ...
|
||||
@@ -212,6 +212,9 @@ def run():
|
||||
#endif
|
||||
""")
|
||||
|
||||
c.find('GetGUIInstance').ignore()
|
||||
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
module.find('wxHandleFatalExceptions').setCppCode("""\
|
||||
|
||||
@@ -39,6 +39,7 @@ def run():
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
|
||||
c.find('FromSVG').findOverload('char *data, const wxSize &sizeDef').ignore()
|
||||
c.find('FromImpl.impl').transfer = True
|
||||
|
||||
# Allow on-the-fly creation of a wx.BitmapBundle from a wx.Bitmap, wx.Icon
|
||||
# or a wx.Image
|
||||
|
||||
@@ -4,7 +4,7 @@ import wx
|
||||
import os
|
||||
|
||||
icoFile = os.path.join(os.path.dirname(__file__), 'mondrian.ico')
|
||||
pngFile = os.path.join(os.path.dirname(__file__), 'pointy.png')
|
||||
pngFile = os.path.join(os.path.dirname(__file__), 'toucan.png')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -35,7 +35,7 @@ class bmpbndl_Tests(wtc.WidgetTestCase):
|
||||
self.assertTrue( bb.IsOk() )
|
||||
b = bb.GetBitmap((32,32))
|
||||
self.assertTrue(b.IsOk())
|
||||
self.assertEquals(b.GetSize(), wx.Size(32,32))
|
||||
self.assertEqual(b.GetSize(), wx.Size(32,32))
|
||||
|
||||
def test_BitmapBundle_ImplicitCtor(self):
|
||||
"Ensure that a wx.Bitmap can still be used where a wx.BitmapBundle is needed"
|
||||
@@ -44,6 +44,39 @@ class bmpbndl_Tests(wtc.WidgetTestCase):
|
||||
btn.SetBitmap(bmp)
|
||||
|
||||
|
||||
def test_BitmapBundleImpl(self):
|
||||
"Test deriving a new class from wx.BitmapBundleImpl"
|
||||
class MyCustomBitmapBundleImpl(wx.BitmapBundleImpl):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.img = wx.Image(pngFile)
|
||||
self.size = self.img.GetSize()
|
||||
|
||||
def GetDefaultSize(self):
|
||||
# Report the best or default size for the bitmap
|
||||
return self.size
|
||||
|
||||
def GetPreferredBitmapSizeAtScale(self, scale):
|
||||
# Return the size of the bitmap at the given display scale. It
|
||||
# doesn't need to be size*scale if there are unscaled bitmaps
|
||||
# near that size.
|
||||
return self.size * scale
|
||||
|
||||
def GetBitmap(self, size):
|
||||
# Return the version of the bitmap at the desired size
|
||||
img = self.img.Scale(size.width, size.height)
|
||||
return wx.Bitmap(img)
|
||||
|
||||
bb = wx.BitmapBundle.FromImpl(MyCustomBitmapBundleImpl())
|
||||
self.assertTrue( bb.IsOk() )
|
||||
b = bb.GetBitmap((32,32))
|
||||
self.assertTrue(b.IsOk())
|
||||
self.assertEqual(b.GetSize(), wx.Size(32,32))
|
||||
b = bb.GetBitmap((48,48))
|
||||
self.assertTrue(b.IsOk())
|
||||
self.assertEqual(b.GetSize(), wx.Size(48,48))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user