mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-07-21 12:41:10 +02:00
⁉️ Trim trailing whitespace docs/sphinx/rest_substitutions/*.py
⁉️ Not sure if the generated .rst stuff is intended to have
whitespace like this in it or not, so seperating this from the other
commits, so easy to revert if necessary.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
##Andrea Gavana
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This sample shows how to retrieve default platform's
|
||||
# This sample shows how to retrieve default platform's
|
||||
# bitmaps using wx.ArtProvider
|
||||
|
||||
import wx
|
||||
@@ -18,7 +18,7 @@ class BitmapFrame(wx.Frame):
|
||||
bitmap_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
bitmap_sizer.Add((0, 0), 1, wx.EXPAND)
|
||||
|
||||
|
||||
# Show a few bitmaps retrieved via wx.ArtProvider
|
||||
for kind in [wx.ART_INFORMATION, wx.ART_WARNING, wx.ART_CDROM, wx.ART_CUT]:
|
||||
bmp = wx.ArtProvider.GetBitmap(kind, wx.ART_OTHER, (32, 32))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
##Andrea Gavana
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This sample makes the main frame "immortal", i.e., non-closable
|
||||
# This sample makes the main frame "immortal", i.e., non-closable
|
||||
# by the user. The main window can not be close by pressing Alt+F4
|
||||
# or by clicking on the "X" button in the titlebar
|
||||
|
||||
@@ -19,7 +19,7 @@ class MainWindow(wx.Frame):
|
||||
self.Show()
|
||||
self.close_attempts = 0
|
||||
|
||||
|
||||
|
||||
def OnClose(self, event):
|
||||
|
||||
# Veto the event the user can not close the main
|
||||
|
@@ -17,7 +17,7 @@ class MainWindow(wx.Frame):
|
||||
|
||||
self.Show()
|
||||
|
||||
|
||||
|
||||
def OnClose(self, event):
|
||||
|
||||
# This displays a message box asking the user to confirm
|
||||
|
@@ -1,8 +1,8 @@
|
||||
##Andrea Gavana
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This sample shows how to create a wx.StatusBar with 2 fields,
|
||||
# set the second field to have double width with respect to the
|
||||
# This sample shows how to create a wx.StatusBar with 2 fields,
|
||||
# set the second field to have double width with respect to the
|
||||
# first and and display the date of today in the second field.
|
||||
|
||||
import wx
|
||||
|
@@ -1,36 +1,36 @@
|
||||
##Andrea Gavana
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This sample shows how to listen to a move change event for a
|
||||
# This sample shows how to listen to a move change event for a
|
||||
# top-level window (wx.Frame, wx.Dialog). This is MSW-specific
|
||||
|
||||
import wx
|
||||
|
||||
class MovingFrame(wx.Frame):
|
||||
|
||||
|
||||
def __init__(self, parent, title):
|
||||
|
||||
wx.Frame.__init__(self, parent, title=title)
|
||||
|
||||
|
||||
wx.StaticText(self, label='x:', pos=(10, 10))
|
||||
wx.StaticText(self, label='y:', pos=(10, 30))
|
||||
|
||||
|
||||
self.st1 = wx.StaticText(self, label='', pos=(30, 10))
|
||||
self.st2 = wx.StaticText(self, label='', pos=(30, 30))
|
||||
|
||||
self.Bind(wx.EVT_MOVE, self.OnMove)
|
||||
|
||||
self.Show()
|
||||
|
||||
self.Show()
|
||||
|
||||
def OnMove(self, event):
|
||||
|
||||
|
||||
# Capture the mouse position (in screen coordinates) and
|
||||
# assign its x, y values to the statictexts
|
||||
x, y = event.GetPosition()
|
||||
self.st1.SetLabel('%d'%x)
|
||||
self.st2.SetLabel('%d'%y)
|
||||
|
||||
|
||||
|
||||
app = wx.App(False)
|
||||
frame = MovingFrame(None, 'MoveEvent example')
|
||||
app.MainLoop()
|
||||
|
@@ -14,7 +14,7 @@ class NotebookFrame(wx.Frame):
|
||||
|
||||
wx.Frame.__init__(self, parent, title=title)
|
||||
|
||||
# Create the notebook
|
||||
# Create the notebook
|
||||
self.notebook = wx.Notebook(self, style=wx.NB_BOTTOM)
|
||||
|
||||
# Setting up the menu
|
||||
@@ -30,7 +30,7 @@ class NotebookFrame(wx.Frame):
|
||||
|
||||
# Adding the 'file_menu' to the menu bar
|
||||
menu_bar.Append(file_menu, '&File')
|
||||
|
||||
|
||||
# Adding the menu bar to the frame content
|
||||
self.SetMenuBar(menu_bar)
|
||||
|
||||
@@ -42,11 +42,11 @@ class NotebookFrame(wx.Frame):
|
||||
# This is how you pre-establish a file filter so that the dialog
|
||||
# only shows the extension(s) you want it to.
|
||||
wildcard = 'Python source (*.py)|*.py'
|
||||
|
||||
dlg = wx.FileDialog(None, message="Choose a Python file", defaultDir=os.getcwd(),
|
||||
|
||||
dlg = wx.FileDialog(None, message="Choose a Python file", defaultDir=os.getcwd(),
|
||||
defaultFile="", wildcard=wildcard, style=wx.FD_OPEN)
|
||||
|
||||
# Show the dialog and retrieve the user response. If it is the OK response,
|
||||
# Show the dialog and retrieve the user response. If it is the OK response,
|
||||
# process the data.
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
# This returns the file that was selected
|
||||
|
@@ -21,16 +21,16 @@ class PaintFrame(wx.Frame):
|
||||
|
||||
def OnPaint(self, event):
|
||||
|
||||
dc = wx.PaintDC(self)
|
||||
dc = wx.PaintDC(self)
|
||||
w, h = self.GetClientSize()
|
||||
|
||||
# Use a blue pen, for example...
|
||||
|
||||
dc.SetPen(wx.Pen('BLUE'))
|
||||
|
||||
|
||||
# Remember the signature of wx.DC.DrawLine:
|
||||
# DrawLine(x1, y1, x2, y2)
|
||||
|
||||
|
||||
for i in range(100):
|
||||
x1 = random.randint(1, w-1)
|
||||
y1 = random.randint(1, h-1)
|
||||
@@ -38,7 +38,7 @@ class PaintFrame(wx.Frame):
|
||||
y2 = random.randint(1, h-1)
|
||||
dc.DrawLine(x1, y1, x2, y2)
|
||||
|
||||
|
||||
|
||||
app = wx.App(False)
|
||||
frame = PaintFrame(None, 'PaintDC example')
|
||||
app.MainLoop()
|
@@ -26,7 +26,7 @@ class ProcessFrame(wx.Frame):
|
||||
|
||||
self.Bind(wx.EVT_IDLE, self.OnIdle)
|
||||
self.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded)
|
||||
|
||||
|
||||
def OnButton(self, event):
|
||||
self.btn.Enable(False)
|
||||
self.label.SetValue('')
|
||||
|
@@ -15,7 +15,7 @@ class SplitterFrame(wx.Frame):
|
||||
# Create the main splitter window (to be split vertically)
|
||||
splitter = wx.SplitterWindow(self, -1, style=wx.SP_LIVE_UPDATE)
|
||||
splitter.SetMinimumPaneSize(100)
|
||||
|
||||
|
||||
panel1 = wx.Panel(splitter, -1)
|
||||
|
||||
static = wx.StaticText(panel1, -1, 'Hello World', pos=(10, 100))
|
||||
@@ -24,7 +24,7 @@ class SplitterFrame(wx.Frame):
|
||||
# Create the second splitter window (to be split horizontally)
|
||||
splitter2 = wx.SplitterWindow(splitter, -1, style=wx.SP_LIVE_UPDATE)
|
||||
splitter2.SetMinimumPaneSize(100)
|
||||
|
||||
|
||||
panel2 = wx.Panel(splitter2, -1)
|
||||
panel2.SetBackgroundColour(wx.BLUE)
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
##Andrea Gavana
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This sample shows how to create a wx.StatusBar with 2 fields,
|
||||
# set the second field to have double width with respect to the
|
||||
# This sample shows how to create a wx.StatusBar with 2 fields,
|
||||
# set the second field to have double width with respect to the
|
||||
# first and and display the date of today in the second field.
|
||||
|
||||
import wx
|
||||
|
@@ -1,10 +1,10 @@
|
||||
##Andrea Gavana
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This sample classifies the Python keywords alphabetically, using the
|
||||
# first letter of the keyword (i.e., ``and`` goes into ``a``, ``for``
|
||||
# This sample classifies the Python keywords alphabetically, using the
|
||||
# first letter of the keyword (i.e., ``and`` goes into ``a``, ``for``
|
||||
# goes into ``f`` and so on):
|
||||
#
|
||||
#
|
||||
# * For each letter, adds a child to the treectrl root
|
||||
# * In each child of the root item, adds its corresponding keyword(s)
|
||||
#
|
||||
@@ -27,7 +27,7 @@ class TreeFrame(wx.Frame):
|
||||
root = tree_ctrl.AddRoot('Python keywords')
|
||||
|
||||
letters = []
|
||||
|
||||
|
||||
for kwd in keyword.kwlist:
|
||||
first = kwd[0]
|
||||
if first not in letters:
|
||||
@@ -39,7 +39,7 @@ class TreeFrame(wx.Frame):
|
||||
first = kwd[0]
|
||||
if first == letter:
|
||||
sub_item = tree_ctrl.AppendItem(item, kwd)
|
||||
|
||||
|
||||
tree_ctrl.ExpandAll()
|
||||
self.Centre()
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
def OnCompareItems(self, item1, item2):
|
||||
"""Changes the sort order of the items in the tree control. """
|
||||
|
||||
|
||||
t1 = self.GetItemText(item1)
|
||||
t2 = self.GetItemText(item2)
|
||||
|
||||
|
@@ -26,7 +26,7 @@ class ProcessFrame(wx.Frame):
|
||||
|
||||
self.Bind(wx.EVT_IDLE, self.OnIdle)
|
||||
self.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded)
|
||||
|
||||
|
||||
def OnButton(self, event):
|
||||
self.btn.Enable(False)
|
||||
self.label.SetValue('')
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
entries = [wx.AcceleratorEntry() for i in xrange(4)]
|
||||
|
||||
|
||||
entries[0].Set(wx.ACCEL_CTRL, ord('N'), ID_NEW_WINDOW)
|
||||
entries[1].Set(wx.ACCEL_CTRL, ord('X'), wx.ID_EXIT)
|
||||
entries[2].Set(wx.ACCEL_SHIFT, ord('A'), ID_ABOUT)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | t.m_11 t.m_12 0 | | m_11 m_12 0 |
|
||||
# matrix' = | t.m_21 t.m_22 0 | x | m_21 m_22 0 |
|
||||
# | t.m_tx t.m_ty 1 | | m_tx m_ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | m_11 m_12 0 |
|
||||
# Invert | m_21 m_22 0 |
|
||||
# | m_tx m_ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | cos sin 0 | | self.11 self.12 0 |
|
||||
# matrix' = | -sin cos 0 | x | self.21 self.22 0 |
|
||||
# | 0 0 1 | | self.tx self.ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | xScale 0 0 | | self.11 self.12 0 |
|
||||
# matrix' = | 0 yScale 0 | x | self.21 self.22 0 |
|
||||
# | 0 0 1 | | self.tx self.ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | self.11 self.12 0 |
|
||||
# dist' = | src.self.x src._my 0 | x | self.21 self.22 0 |
|
||||
# | self.tx self.ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | self.11 self.12 0 |
|
||||
# dist' = | src.self.x src._my 0 | x | self.21 self.22 0 |
|
||||
# | self.tx self.ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | self.11 self.12 0 |
|
||||
# point' = | src.self.x src._my 1 | x | self.21 self.22 0 |
|
||||
# | self.tx self.ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | self.11 self.12 0 |
|
||||
# point' = | src.self.x src._my 1 | x | self.21 self.22 0 |
|
||||
# | self.tx self.ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | 1 0 0 | | self.11 self.12 0 |
|
||||
# matrix' = | 0 1 0 | x | self.21 self.22 0 |
|
||||
# | dx dy 1 | | self.tx self.ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | t.m_11 t.m_12 0 | | m_11 m_12 0 |
|
||||
# matrix' = | t.m_21 t.m_22 0 | x | m_21 m_22 0 |
|
||||
# | t.m_tx t.m_ty 1 | | m_tx m_ty 1 |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
# | m_11 m_12 0 |
|
||||
# Invert | m_21 m_22 0 |
|
||||
# | m_tx m_ty 1 |
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
wx.App.SetTopWindow(None)
|
||||
|
||||
wx.App.SetTopWindow(None)
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
setlocale(LC_ALL, "")
|
||||
|
@@ -1,18 +1,18 @@
|
||||
|
||||
|
||||
class MyProvider(wx.ArtProvider):
|
||||
|
||||
def CreateBitmap(self, id, client, size):
|
||||
|
||||
# Your implementation of CreateBitmap here
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
# optionally override this one as well
|
||||
def CreateIconBundle(self, id, client):
|
||||
|
||||
# Your implementation of CreateIconBundle here
|
||||
pass
|
||||
|
||||
|
||||
|
||||
# Later on...
|
||||
wx.ArtProvider.Push(MyProvider())
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
if wx.Platform == '__WXGTK__':
|
||||
bmp = wx.ArtProvider.GetBitmap("gtk-cdrom", wx.ART_MENU)
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
wx.Image.AddHandler(wx.PNGHandler)
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
newBitmap = oldBitmap.GetSubBitmap(
|
||||
wx.Rect(0, 0, oldBitmap.GetWidth(), oldBitmap.GetHeight()))
|
||||
|
@@ -1,9 +1,9 @@
|
||||
|
||||
|
||||
if boxSizer.IsVertical():
|
||||
|
||||
|
||||
boxSizer.Add(0, size, 0)
|
||||
|
||||
|
||||
else:
|
||||
|
||||
|
||||
boxSizer.Add(size, 0, 0)
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
wait = wx.BusyCursor()
|
||||
|
||||
|
||||
for i in xrange(10000):
|
||||
DoACalculation()
|
||||
|
||||
del wait
|
||||
del wait
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
wait = wx.BusyInfo("Please wait, working...")
|
||||
|
||||
|
||||
for i in xrange(10000):
|
||||
DoACalculation()
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
|
||||
|
||||
disableAll = wx.WindowDisabler()
|
||||
wait = wx.BusyInfo("Please wait, working...")
|
||||
|
||||
|
||||
for i in xrange(10000):
|
||||
DoACalculation()
|
||||
|
||||
|
||||
if i % 1000 == 0:
|
||||
wx.GetApp().Yield()
|
||||
|
||||
|
||||
del wait
|
||||
|
@@ -1,15 +1,15 @@
|
||||
|
||||
|
||||
def OnClose(self, event):
|
||||
|
||||
|
||||
if event.CanVeto() and self.fileNotSaved:
|
||||
|
||||
|
||||
if wx.MessageBox("The file has not been saved... continue closing?",
|
||||
"Please confirm",
|
||||
wx.ICON_QUESTION | wx.YES_NO) != wx.YES:
|
||||
|
||||
|
||||
event.Veto()
|
||||
return
|
||||
|
||||
|
||||
self.Destroy() # you may also do: event.Skip()
|
||||
# since the default event handler does call Destroy(), too
|
||||
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
|
||||
|
||||
collpane = wx.CollapsiblePane(self, wx.ID_ANY, "Details:")
|
||||
|
||||
|
||||
# add the pane with a zero proportion value to the 'sz' sizer which contains it
|
||||
sz.Add(collpane, 0, wx.GROW | wx.ALL, 5)
|
||||
|
||||
|
||||
# now add a test label in the collapsible pane using a sizer to layout it:
|
||||
win = collpane.GetPane()
|
||||
paneSz = wx.BoxSizer(wx.VERTICAL)
|
||||
|
@@ -6,14 +6,14 @@
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# This class is used to provide an interface between a ComboCtrl and the
|
||||
# ListCtrl that is used as the popoup for the combo widget.
|
||||
# ListCtrl that is used as the popoup for the combo widget.
|
||||
|
||||
class ListCtrlComboPopup(wx.ComboPopup):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
wx.ComboPopup.__init__(self)
|
||||
self.lc = None
|
||||
|
||||
|
||||
def AddItem(self, txt):
|
||||
self.lc.InsertItem(self.lc.GetItemCount(), txt)
|
||||
|
||||
@@ -97,11 +97,10 @@
|
||||
# Return true if you want delay the call to Create until the popup
|
||||
# is shown for the first time. It is more efficient, but note that
|
||||
# it is often more convenient to have the control created
|
||||
# immediately.
|
||||
# immediately.
|
||||
# Default returns false.
|
||||
def LazyCreate(self):
|
||||
return wx.ComboPopup.LazyCreate(self)
|
||||
|
||||
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
|
||||
|
||||
comboCtrl = wx.ComboCtrl(self, wx.ID_ANY, "")
|
||||
|
||||
|
||||
popupCtrl = ListViewComboPopup()
|
||||
|
||||
|
||||
# It is important to call SetPopupControl() as soon as possible
|
||||
comboCtrl.SetPopupControl(popupCtrl)
|
||||
|
||||
|
||||
# Populate using wx.ListView methods
|
||||
popupCtrl.InsertItem(popupCtrl.GetItemCount(), "First Item")
|
||||
popupCtrl.InsertItem(popupCtrl.GetItemCount(), "Second Item")
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
comboCtrl = wx.ComboCtrl()
|
||||
|
||||
|
||||
# Let's make the text right-aligned
|
||||
comboCtrl.SetTextCtrlStyle(wx.TE_RIGHT)
|
||||
|
||||
|
||||
comboCtrl.Create(parent, wx.ID_ANY, "")
|
||||
|
@@ -1,14 +1,13 @@
|
||||
|
||||
|
||||
# using wx.Config instead of writing wx.FileConfig or wx.RegConfig enhances
|
||||
# portability of the code
|
||||
config = wx.Config("MyAppName")
|
||||
config = wx.Config("MyAppName")
|
||||
strs = config.Read("LastPrompt")
|
||||
|
||||
|
||||
# another example: using default values and the full path instead of just
|
||||
# key name: if the key is not found , the value 17 is returned
|
||||
value = config.ReadInt("/LastRun/CalculatedValues/MaxValue", 17)
|
||||
|
||||
|
||||
# at the end of the program we would save everything back
|
||||
config.Write("LastPrompt", strs)
|
||||
config.Write("/LastRun/CalculatedValues/MaxValue", value)
|
||||
|
@@ -1,22 +1,22 @@
|
||||
|
||||
|
||||
config = wx.Config("FooBarApp")
|
||||
|
||||
|
||||
# right now the current path is '/'
|
||||
conf.Write("RootEntry", 1)
|
||||
|
||||
|
||||
# go to some other place: if the group(s) don't exist, they will be created
|
||||
conf.SetPath("/Group/Subgroup")
|
||||
|
||||
|
||||
# create an entry in subgroup
|
||||
conf.Write("SubgroupEntry", 3)
|
||||
|
||||
|
||||
# '..' is understood
|
||||
conf.Write("../GroupEntry", 2)
|
||||
conf.SetPath("..")
|
||||
|
||||
|
||||
if conf.ReadInt("Subgroup/SubgroupEntry", 0) != 3:
|
||||
raise Exception('Invalid SubgroupEntry')
|
||||
|
||||
|
||||
# use absolute path: it is allowed, too
|
||||
if conf.ReadInt("/RootEntry", 0) != 1:
|
||||
raise Exception('Invalid RootEntry')
|
||||
|
@@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
def foo(config):
|
||||
|
||||
|
||||
oldPath = config.GetPath()
|
||||
|
||||
|
||||
config.SetPath("/Foo/Data")
|
||||
# ...
|
||||
|
||||
|
||||
config.SetPath(oldPath)
|
||||
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
def bar(config):
|
||||
|
||||
|
||||
config.Write("Test", 17)
|
||||
|
||||
|
||||
foo(config)
|
||||
|
||||
|
||||
# we're reading "/Foo/Data/Test" here! -1 will probably be returned...
|
||||
if config.ReadInt("Test", -1) != 17:
|
||||
raise Exception('Invalid Test')
|
||||
|
@@ -1,21 +1,21 @@
|
||||
|
||||
config = wx.Config("MyAppName")
|
||||
|
||||
config = wx.Config("MyAppName")
|
||||
names = []
|
||||
|
||||
|
||||
# first enum all entries
|
||||
more, value, index = config.GetFirstEntry()
|
||||
|
||||
|
||||
while more:
|
||||
names.append(value)
|
||||
more, value, index = config.GetNextEntry(index)
|
||||
|
||||
|
||||
# ... we have all entry names in names...
|
||||
|
||||
|
||||
# now all groups...
|
||||
more, value, index = config.GetFirstGroup()
|
||||
|
||||
|
||||
while more:
|
||||
names.append(value)
|
||||
names.append(value)
|
||||
more, value, index = config.GetNextGroup(index)
|
||||
|
||||
|
||||
# ... we have all group (and entry) names in names...
|
||||
|
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
# this function loads somes settings from the given wx.Config object
|
||||
# the path selected inside it is left unchanged
|
||||
def LoadMySettings(config):
|
||||
|
||||
|
||||
changer = wx.ConfigPathChanger(config, "/Foo/Data/SomeString")
|
||||
|
||||
strs = config.Read("SomeString")
|
||||
@@ -10,12 +10,12 @@
|
||||
if not strs:
|
||||
wx.LogError("Couldn't read SomeString!")
|
||||
return False
|
||||
|
||||
|
||||
# NOTE: without wx.ConfigPathChanger it would be easy to forget to
|
||||
# set the old path back into the wx.Config object before this return!
|
||||
|
||||
|
||||
|
||||
|
||||
# do something useful with SomeString...
|
||||
|
||||
|
||||
return True # again: wx.ConfigPathChanger dtor will restore the original wx.Config path
|
||||
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
wx.ConfigPathChanger(wx.ConfigBase.Get(), "/MyProgram/SomeKeyName")
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
wx.ConfigPathChanger(wx.ConfigBase.Get(), "/MyProgram/")
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
contextHelp = wx.ContextHelp(myWindow)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
# Create a control for post code entry.
|
||||
postcode = wx.TextCtrl(self, -1, "")
|
||||
|
||||
|
||||
# And set its initial and minimal size to be big enough for
|
||||
# entering 5 digits.
|
||||
postcode.SetInitialSize(
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
# Create a control for post code entry.
|
||||
postcode = wx.TextCtrl(self, -1, "")
|
||||
|
||||
|
||||
# And set its initial and minimal size to be big enough for
|
||||
# entering 5 digits.
|
||||
postcode.SetInitialSize(
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
text = wx.StaticText(self, -1, 'Hello world!')
|
||||
|
||||
|
||||
# Some more code...
|
||||
text.SetLabelMarkup("<b>&Bed</b> &mp "
|
||||
"<span foreground='red'>breakfast</span> "
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
down_bits = [255, 255, 255, 255, 31,
|
||||
255, 255, 255, 31, 255, 255, 255, 31, 255, 255, 255,
|
||||
31, 255, 255, 255, 31, 255, 255, 255, 31, 255, 255,
|
||||
@@ -12,7 +12,7 @@
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255]
|
||||
|
||||
|
||||
down_mask = [240, 1, 0, 0, 240, 1,
|
||||
0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1,
|
||||
0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 255, 31, 0, 0, 255,
|
||||
@@ -22,19 +22,19 @@
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0]
|
||||
|
||||
|
||||
if wx.Platform == '__WXMSW__':
|
||||
|
||||
|
||||
down_bitmap = wx.BitmapFromBits(down_bits, 32, 32)
|
||||
down_mask_bitmap = wx.BitmapFromBits(down_mask, 32, 32)
|
||||
|
||||
|
||||
down_bitmap.SetMask(wx.Mask(down_mask_bitmap))
|
||||
down_image = down_bitmap.ConvertToImage()
|
||||
down_image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 6)
|
||||
down_image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 14)
|
||||
down_cursor = wx.Cursor(down_image)
|
||||
|
||||
|
||||
elif wx.Platform == '__WXGTK__':
|
||||
|
||||
|
||||
down_cursor = wx.Cursor(down_bits, 32, 32, 6, 14,
|
||||
down_mask, wx.WHITE, wx.BLACK)
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX)
|
||||
image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_X, hotSpotY)
|
||||
|
@@ -1,13 +1,13 @@
|
||||
|
||||
|
||||
def MyFunction(dc):
|
||||
|
||||
|
||||
clip = wx.DCClipper(dc, rect)
|
||||
# ... drawing functions here are affected by clipping rect ...
|
||||
|
||||
|
||||
|
||||
|
||||
def OtherFunction():
|
||||
|
||||
|
||||
dc = wx.DC()
|
||||
MyFunction(dc)
|
||||
# ... drawing functions here are not affected by clipping rect ...
|
||||
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
def OnData(self, x, y, defaultDragResult):
|
||||
|
||||
dragResult = wx.DropTarget.OnData(x, y, defaultDragResult)
|
||||
|
||||
|
||||
if dragResult == defaultDragResult:
|
||||
dataobjComp = self.GetDataObject()
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
if format.GetType() == wx.DF_BITMAP:
|
||||
dataobjBitmap = dataobj
|
||||
# ... use dataobj.GetBitmap() ...
|
||||
|
||||
|
||||
|
||||
elif format.GetType() == wx.DF_FILENAME:
|
||||
dataobjFile = dataobj
|
||||
# ... use dataobj.GetFilenames() ...
|
||||
|
||||
|
||||
else:
|
||||
raise Exception("unexpected data object format")
|
||||
|
||||
|
||||
return dragResult
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
dt = wx.DateTimeFromDMY(8, 5, 1977)
|
||||
y = dt.GetYear()
|
||||
epoch = (y > 0 and ["AD"] or ["BC"])[0]
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
now = wx.DateTime.Now()
|
||||
print "Current time in Paris:\t%s\n"%(now.Format("%c", wx.DateTime.CET))
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
-1
|
||||
|
||||
-1
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
dlg = wx.DirDialog (None, "Choose input directory", "",
|
||||
wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
def Clone(self):
|
||||
|
||||
return MyEvent()
|
||||
return MyEvent()
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
def DoSomething(self):
|
||||
# block all events directed to this window while
|
||||
# we do the 1000 FunctionWhichSendsEvents() calls
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
for i in xrange(1000):
|
||||
FunctionWhichSendsEvents(i)
|
||||
|
||||
|
||||
# wx.EventBlocker destructor called, old event handler is restored
|
||||
|
||||
|
||||
# the event generated by this call will be processed:
|
||||
FunctionWhichSendsEvents(0)
|
||||
|
||||
|
||||
|
@@ -1,43 +1,43 @@
|
||||
|
||||
|
||||
# This class allows to determine the last time the user has worked with
|
||||
# this application:
|
||||
class LastActivityTimeDetector(wx.EventFilter):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
|
||||
wx.EventFilter.__init__(self)
|
||||
|
||||
|
||||
wx.EvtHandler.AddFilter(self)
|
||||
|
||||
|
||||
self.last = wx.DateTime.Now()
|
||||
|
||||
|
||||
|
||||
def __del__(self):
|
||||
|
||||
|
||||
wx.EvtHandler.RemoveFilter(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def FilterEvent(self, event):
|
||||
|
||||
|
||||
# Update the last user activity
|
||||
t = event.GetEventType()
|
||||
|
||||
|
||||
if t == wx.EVT_KEY_DOWN.typeId or t == wx.EVT_MOTION.typeId or \
|
||||
t == wx.EVT_LEFT_DOWN.typeId or t == wx.EVT_RIGHT_DOWN.typeId or \
|
||||
t == wx.EVT_MIDDLE_DOWN.typeId:
|
||||
|
||||
|
||||
self.last = wx.DateTime.Now()
|
||||
|
||||
|
||||
|
||||
|
||||
# Continue processing the event normally as well.
|
||||
return self.Event_Skip
|
||||
|
||||
|
||||
|
||||
|
||||
# This function could be called periodically from some timer to
|
||||
# do something (e.g. hide sensitive data or log out from remote
|
||||
# server) if the user has been inactive for some time period.
|
||||
def IsInactiveFor(self, diff):
|
||||
|
||||
|
||||
return wx.DateTime.Now() - diff > self.last
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
|
||||
|
||||
class MyEventLoop(wx.EventLoopBase):
|
||||
|
||||
|
||||
def RunMyLoop(self):
|
||||
|
||||
|
||||
loop = MyEventLoop()
|
||||
activate = wx.EventLoopActivator(loop)
|
||||
|
||||
|
||||
# other code...
|
||||
|
||||
|
||||
# the previously active event loop restored here
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
while evtloop.Pending():
|
||||
evtloop.Dispatch()
|
||||
|
@@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
def FunctionInAWorkerThread(strs):
|
||||
|
||||
|
||||
evt = wx.CommandEvent()
|
||||
|
||||
|
||||
# NOT evt.SetString(strs) as this would be a shallow copy
|
||||
evt.SetString(strs[:]) # make a deep copy
|
||||
|
||||
|
||||
wx.TheApp.QueueEvent(evt)
|
||||
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
def FunctionInAWorkerThread(strs):
|
||||
|
||||
|
||||
evt = wx.ThreadEvent()
|
||||
evt.SetString(strs)
|
||||
|
||||
|
||||
# wx.ThreadEvent.Clone() makes sure that the internal wx.String
|
||||
# member is not shared by other string instances:
|
||||
wx.TheApp.QueueEvent(evt.Clone())
|
||||
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
handlerA.SetNextHandler(handlerB)
|
||||
handlerB.SetPreviousHandler(handlerA)
|
||||
|
@@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
class MyClass(public BaseClass): # something inheriting from wx.EvtHandler
|
||||
|
||||
|
||||
...
|
||||
def TryAfter(self, event):
|
||||
if (BaseClass.TryAfter(self, event))
|
||||
return True
|
||||
|
||||
|
||||
return self.MyPostProcess(event)
|
||||
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
class MyClass(BaseClass): # something inheriting from wx.EvtHandler
|
||||
|
||||
|
||||
...
|
||||
def TryBefore(self, event):
|
||||
if (self.MyPreProcess(event)):
|
||||
return True
|
||||
|
||||
|
||||
return BaseClass.TryBefore(self, event)
|
||||
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
class MyFSFile(wx.FSFile):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
wx.FSFile.__init__(self)
|
||||
|
||||
|
||||
wx.FSFile.__init__(self)
|
||||
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
wildcard = "BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png"
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
wx.FileSystem.AddHandler(My_FS_Handler)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
ChangePathTo("dir/subdir/xh.htm")
|
||||
ChangePathTo("dir/subdir", True)
|
||||
ChangePathTo("dir/subdir/", True)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
f = fs.OpenFile("hello.htm") # opens file 'hello.htm'
|
||||
fs.ChangePathTo("subdir/folder", True)
|
||||
f = fs.OpenFile("hello.htm") # opens file 'subdir/folder/hello.htm' !!
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
|
||||
def CanOpen(self, location):
|
||||
|
||||
|
||||
return self.GetProtocol(location) == "http"
|
||||
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
|
||||
if self.GetAnchor("index.htm#chapter2") == "chapter2":
|
||||
DoSomething()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
if self.GetLeftLocation("file:myzipfile.zip#zip:index.htm") == "file:myzipfile.zip":
|
||||
DoSomething()
|
||||
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
if self.GetProtocol("file:myzipfile.zip#zip:index.htm") == "zip":
|
||||
UnzipFile(filename)
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
if self.GetRightLocation("file:myzipfile.zip#zip:index.htm") == "index.htm":
|
||||
ReadHTML(filename)
|
||||
|
@@ -8,11 +8,11 @@
|
||||
|
||||
|
||||
def GetParamValue(self, name):
|
||||
|
||||
|
||||
# parameter names are not case-sensitive
|
||||
if name.lower() == "charset":
|
||||
return "US-ASCII"
|
||||
else:
|
||||
return wx.MessageParameters.GetParamValue(name)
|
||||
|
||||
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
|
||||
|
||||
if filetype.GetOpenCommand(MailMessageParameters("foo.txt", "text/plain")):
|
||||
|
||||
|
||||
# the full command for opening the text documents is in 'command'
|
||||
# (it might be "notepad foo.txt" under Windows or "cat foo.txt" under Unix)
|
||||
HandleCommand()
|
||||
|
||||
|
||||
else:
|
||||
|
||||
|
||||
# we don't know how to handle such files...
|
||||
pass
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
font = wx.Font(wx.FontInfo(12).FaceName("Helvetica").Italic())
|
||||
|
@@ -5,9 +5,9 @@
|
||||
convFrom = wx.FontMapper.Get().GetEncodingName(enc)
|
||||
convTo = wx.FontMapper.Get().GetEncodingName(alt)
|
||||
text = text.decode(convFrom).encode(convTo)
|
||||
|
||||
|
||||
else:
|
||||
# ...failure (or we may try iso8859-1/7bit ASCII)...
|
||||
pass
|
||||
|
||||
|
||||
# ...display text...
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
style = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
|
||||
|
@@ -1,14 +1,14 @@
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
|
||||
|
||||
# Create paint DC
|
||||
dc = wx.PaintDC(self)
|
||||
|
||||
|
||||
# Create graphics context from it
|
||||
gc = wx.GraphicsContext.Create(dc)
|
||||
|
||||
|
||||
if gc:
|
||||
|
||||
|
||||
# make a path that contains a circle and some lines
|
||||
gc.SetPen(wx.RED_PEN)
|
||||
path = gc.CreatePath()
|
||||
@@ -19,7 +19,7 @@
|
||||
path.AddLineToPoint(50.0, 100.0)
|
||||
path.CloseSubpath()
|
||||
path.AddRectangle(25.0, 25.0, 50.0, 50.0)
|
||||
|
||||
|
||||
gc.StrokePath(path)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
path = wx.GraphicsPath() # from somewhere
|
||||
brush = path.GetRenderer().CreateBrush(wx.BLACK_BRUSH)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
header = wx.HeaderCtrlSimple() # Fill in the constructor
|
||||
col = wx.HeaderColumnSimple("Title")
|
||||
col.SetWidth(100)
|
||||
|
@@ -1,13 +1,13 @@
|
||||
|
||||
def ColumnItems(self):
|
||||
|
||||
|
||||
menu = wx.Menu()
|
||||
menu.Append(100, "Some custom command")
|
||||
menu.AppendSeparator()
|
||||
self.AddColumnsItems(menu, 200)
|
||||
rc = self.GetPopupMenuSelectionFromUser(menu, pt)
|
||||
|
||||
|
||||
if rc >= 200:
|
||||
# ... toggle visibility of the column rc-200 ...
|
||||
ToggleVisibility()
|
||||
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
wx.HD_DEFAULT_STYLE & ~wx.HD_ALLOW_REORDER
|
||||
|
||||
wx.HD_DEFAULT_STYLE & ~wx.HD_ALLOW_REORDER
|
||||
|
@@ -7,13 +7,13 @@
|
||||
|
||||
|
||||
def SetWidth(self, width):
|
||||
|
||||
self.width = width
|
||||
|
||||
self.width = width
|
||||
|
||||
|
||||
def GetWidth(self):
|
||||
|
||||
return self.width
|
||||
return self.width
|
||||
|
||||
|
||||
class MyHeaderCtrl(wx.HeaderCtrl):
|
||||
@@ -22,19 +22,19 @@
|
||||
|
||||
wx.HeaderCtrl.__init__(self, parent)
|
||||
self.cols = []
|
||||
|
||||
|
||||
|
||||
def GetColumn(idx):
|
||||
|
||||
|
||||
return self.cols[idx]
|
||||
|
||||
|
||||
|
||||
def UpdateColumnWidthToFit(self, idx, widthTitle):
|
||||
|
||||
# ... compute minimal width for column idx ...
|
||||
widthContents = self.CalculateMinWidth(idx)
|
||||
self.cols[idx].SetWidth(max(widthContents, widthTitle))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
self.ShowColumn(idx, False)
|
||||
|
||||
self.ShowColumn(idx, False)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
self.help.SetViewer("kdehelp")
|
||||
self.help.SetViewer("gnome-help-browser")
|
||||
self.help.SetViewer("netscape", wx.HELP_NETSCAPE)
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
GetIcon(wx.Size(size, size))
|
||||
|
||||
GetIcon(wx.Size(size, size))
|
||||
|
@@ -1,2 +1,2 @@
|
||||
|
||||
|
||||
wx.Image.AddHandler(wx.PNGHandler)
|
||||
|
@@ -2,9 +2,9 @@
|
||||
# This is a raw translation of the ImageHistogramEntry
|
||||
# code in C++, not a real Python class
|
||||
class ImageHistogramEntry(object):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
|
||||
|
||||
self.index = 0
|
||||
self.value = 0
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
FileDlg = wx.FileDialog(self, "Choose Image", os.getcwd(), "",
|
||||
"Image Files " + wx.Image.GetImageExtWildcard(),
|
||||
wx.FD_OPEN)
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
hotspot_x = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X)
|
||||
hotspot_y = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y)
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
hotspot_x = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X)
|
||||
hotspot_y = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y)
|
||||
|
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_X, hotspotX)
|
||||
image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user