mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-07 04:20:07 +01:00
Add more new Python code snippets
This commit is contained in:
@@ -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 ...
|
||||
Reference in New Issue
Block a user