diff --git a/wxPython/demo/FloatCanvas.py b/wxPython/demo/FloatCanvas.py index 953fb0800b..b3786c7538 100644 --- a/wxPython/demo/FloatCanvas.py +++ b/wxPython/demo/FloatCanvas.py @@ -109,7 +109,7 @@ else: # Add the Canvas self.Canvas = floatcanvas.FloatCanvas(self,-1,(500,500), ProjectionFun = 'FlatEarth', - Debug = 1, + Debug = 0, EnclosingFrame = self, BackgroundColor = "DARK SLATE BLUE", UseBackground = 0, diff --git a/wxPython/demo/GridHugeTable.py b/wxPython/demo/GridHugeTable.py index a2084fb6e3..f421dce98a 100644 --- a/wxPython/demo/GridHugeTable.py +++ b/wxPython/demo/GridHugeTable.py @@ -16,7 +16,17 @@ class HugeTable(wxPyGridTableBase): wxPyGridTableBase.__init__(self) self.log = log - def GetNumberRows(self): + self.odd=wxGridCellAttr() + self.odd.SetBackgroundColour("sky blue") + self.even=wxGridCellAttr() + self.even.SetBackgroundColour("sea green") + + def GetAttr(self, row, col, kind): + attr = [self.even,self.odd][row%2] + attr.IncRef() + return attr + + def GetNumberRows(self): return 10000 def GetNumberCols(self): diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index e0c58ec8c2..28623da7f5 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -19,6 +19,13 @@ import wx.html import images +# Use Python's bool constants if available, make aliases if not +try: + True +except NameError: + True = 1==1 + False = 1==0 + #--------------------------------------------------------------------------- @@ -27,6 +34,7 @@ _treeList = [ ('Recent Additions', [ 'wxMaskedNumCtrl', 'FloatCanvas', + 'wxXmlResourceSubclass', ]), # managed windows == things with a (optional) caption you can close @@ -146,6 +154,7 @@ _treeList = [ 'wxScrolledPanel', 'wxXmlResource', 'wxXmlResourceHandler', + 'wxXmlResourceSubclass', ]), # ditto @@ -183,7 +192,9 @@ _treeList = [ 'DialogUnits', 'DrawXXXList', 'FontEnumerator', + 'NewNamespace', 'PrintFramework', + 'ShapedWindow', 'Throbber', 'Unicode', 'wxFileHistory', diff --git a/wxPython/demo/encode_bitmaps.py b/wxPython/demo/encode_bitmaps.py index 5cff6582ce..87aa11b7dd 100644 --- a/wxPython/demo/encode_bitmaps.py +++ b/wxPython/demo/encode_bitmaps.py @@ -38,6 +38,7 @@ command_lines = [ "-a -u -n New -m #C0C0C0 bmp_source/new.bmp images.py", "-a -u -n Open -m #C0C0C0 bmp_source/open.bmp images.py", "-a -u -n Copy -m #C0C0C0 bmp_source/copy.bmp images.py", + "-a -u -n Copy2 -m #C0C0C0 bmp_source/copy2.bmp images.py", "-a -u -n Paste -m #C0C0C0 bmp_source/paste.bmp images.py", "-a -u -n Tog1 -m #C0C0C0 bmp_source/tog1.bmp images.py", "-a -u -n Tog2 -m #C0C0C0 bmp_source/tog2.bmp images.py", diff --git a/wxPython/demo/images.py b/wxPython/demo/images.py index 8dc456bec2..71e3010f7b 100644 --- a/wxPython/demo/images.py +++ b/wxPython/demo/images.py @@ -3439,6 +3439,26 @@ def getCopyImage(): stream = cStringIO.StringIO(getCopyData()) return wxImageFromStream(stream) +#---------------------------------------------------------------------- +def getCopy2Data(): + return \ +'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ +\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ +\x00\x00\x9fIDATx\x9c\xa5\x93\xdb\x0e\x830\x0cC\xed\x84\xdfF\xeb\xb4\xef\xa6\ +\xde\x030z\t\x94\tK\x91z\xcb\x01\xbb*i\x8e\'\x9a\x00@yQ\xb4Is\x8e\x00\xb6\ +\x0f$Uu\x05\x0e\x01\x91$\r!\xa49\x94\x17I\x02\xc9_\xe3:Nq\x93}XL|\xeb\xe9\ +\x05\xa4p\rH\xa29h^[ Y\xd5\xb9\xb5\x17\x94gu\x19DA\x96\xe0c\xfe^\xcf\xe7Y\ +\x95\x05\x00M\xf5\x16Z;\x7f\xfdAd\xcf\xee\x1cj\xc1%|\xdan"LL\x19\xda\xe1}\ +\x90:\x00#\x95_l5\x04\xec\x89\x9f\xef?|\x8d\x97o\xe1\x8e\xbeJ\xfc\xb1\xde\ +\xf4x\xe1\x1d\x00\x00\x00\x00IEND\xaeB`\x82' + +def getCopy2Bitmap(): + return wxBitmapFromImage(getCopy2Image()) + +def getCopy2Image(): + stream = cStringIO.StringIO(getCopy2Data()) + return wxImageFromStream(stream) + #---------------------------------------------------------------------- def getPasteData(): return \ diff --git a/wxPython/demo/redemo.py b/wxPython/demo/redemo.py deleted file mode 100644 index 60b66fabeb..0000000000 --- a/wxPython/demo/redemo.py +++ /dev/null @@ -1,25 +0,0 @@ -"""Basic regular expression demonstration facility (Perl style syntax).""" - -from wxPython.wx import * -import re - -#---------------------------------------------------------------------- - -class ReDemoPanel(wxPanel): - def __init__(self, parent): - wxPanel.__init__(self, parent, -1) - - rePrompt = wxStaticText(self, -1, "Enter a Perl-style regular expression") - reText = wxTextCtrl(self, 101, "") - - options = self.AddOptions() - - sPrompt = wxStaticText(self, -1, "Enter a string to search") - sText = wxTextCtrl(self, 102, "", style=wxTE_MULTILINE) - - dispPrompt = wxStaticText(self, -1, "Groups:") - dispText = wxTextCtrl(self, 103, "", style=wxTE_MULTILINE|wxTE_READONLY) - - -#---------------------------------------------------------------------- -#---------------------------------------------------------------------- diff --git a/wxPython/demo/wxFontDialog.py b/wxPython/demo/wxFontDialog.py index e27ad38d74..b3c075c530 100644 --- a/wxPython/demo/wxFontDialog.py +++ b/wxPython/demo/wxFontDialog.py @@ -61,6 +61,11 @@ class TestPanel(wxPanel): self.nfi.SetFont(font) fgs.Add(self.nfi, 0, wxADJUST_MINSIZE) + fgs.Add(wxStaticText(self, -1, "IsFixedWidth:")) + self.ifw = wxStaticText(self, -1, "") + self.ifw.SetFont(font) + fgs.Add(self.ifw, 0, wxADJUST_MINSIZE) + # give it some border space sizer = wxBoxSizer(wxVERTICAL) sizer.Add(fgs, 0, wxGROW|wxADJUST_MINSIZE|wxALL, 25) @@ -77,6 +82,7 @@ class TestPanel(wxPanel): self.weight.SetLabel(self.curFont.GetWeightString()) self.face.SetLabel(self.curFont.GetFaceName()) self.nfi.SetLabel(self.curFont.GetNativeFontInfo().ToString()) + self.ifw.SetLabel(str(self.curFont.IsFixedWidth())) self.Layout() diff --git a/wxPython/demo/wxOGL.py b/wxPython/demo/wxOGL.py index 2094959821..9a69372a17 100644 --- a/wxPython/demo/wxOGL.py +++ b/wxPython/demo/wxOGL.py @@ -107,6 +107,11 @@ class MyEvtHandler(wxShapeEvtHandler): def OnLeftClick(self, x, y, keys = 0, attachment = 0): shape = self.GetShape() print shape.__class__, shape.GetClassName() + regions = shape.GetRegions() + if regions: + #print regions, + print regions[0].GetFormattedText() + canvas = shape.GetCanvas() dc = wxClientDC(canvas) canvas.PrepareDC(dc) diff --git a/wxPython/demo/wxPopupWindow.py b/wxPython/demo/wxPopupWindow.py index 0ee3df748c..2e71555901 100644 --- a/wxPython/demo/wxPopupWindow.py +++ b/wxPython/demo/wxPopupWindow.py @@ -71,7 +71,8 @@ class TestTransientPopup(wxPopupTransientWindow): "wxPopupWindow which disappears\n" "automatically when the user\n" "clicks the mouse outside it or if it\n" - "loses focus in any other way." + "(or its first child) loses focus in \n" + "any other way." , pos=(10,10)) sz = st.GetBestSize() diff --git a/wxPython/demo/wxStyledTextCtrl_2.py b/wxPython/demo/wxStyledTextCtrl_2.py index d19196f07f..4c738fa00c 100644 --- a/wxPython/demo/wxStyledTextCtrl_2.py +++ b/wxPython/demo/wxStyledTextCtrl_2.py @@ -37,6 +37,9 @@ else: #---------------------------------------------------------------------- class PythonSTC(wxStyledTextCtrl): + + fold_symbols = 2 + def __init__(self, parent, ID): wxStyledTextCtrl.__init__(self, parent, ID, style = wxNO_FULL_REPAINT_ON_RESIZE) @@ -51,10 +54,9 @@ class PythonSTC(wxStyledTextCtrl): self.SetProperty("tab.timmy.whinge.level", "1") self.SetMargins(0,0) - #self.SetViewWhiteSpace(True) + self.SetViewWhiteSpace(False) #self.SetBufferedDraw(False) #self.SetViewEOL(True) - #self.SetTwoPhaseDraw(False) self.SetEdgeMode(wxSTC_EDGE_BACKGROUND) self.SetEdgeColumn(78) @@ -66,23 +68,46 @@ class PythonSTC(wxStyledTextCtrl): self.SetMarginSensitive(2, True) self.SetMarginWidth(2, 12) - if 0: # simple folder marks, like the old version - self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, "navy", "navy") - self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "navy", "navy") - # Set these to an invisible mark - self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BACKGROUND, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_BACKGROUND, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_BACKGROUND, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_BACKGROUND, "white", "black") - else: # more involved "outlining" folder marks - self.MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, "white", "black") - self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, "white", "black") + if self.fold_symbols == 0: + # Arrow pointing right for contracted folders, arrow pointing down for expanded + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "black", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, "black", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, "black", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, "black", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, "white", "black"); + + elif self.fold_symbols == 1: + # Plus for contracted folders, minus for expanded + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_MINUS, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_PLUS, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, "white", "black"); + + elif self.fold_symbols == 2: + # Like a flattened tree control using circular headers and curved joins + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_CIRCLEMINUS, "white", "#404040"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_CIRCLEPLUS, "white", "#404040"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "white", "#404040"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNERCURVE, "white", "#404040"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_CIRCLEPLUSCONNECTED, "white", "#404040"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_CIRCLEMINUSCONNECTED, "white", "#404040"); + self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNERCURVE, "white", "#404040"); + + elif self.fold_symbols == 3: + # Like a flattened tree control using square headers + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, "white", "#808080") + self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, "white", "#808080") + self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "white", "#808080") + self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "white", "#808080") + self.MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, "white", "#808080") + self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, "white", "#808080") + self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "white", "#808080") EVT_STC_UPDATEUI(self, ID, self.OnUpdateUI) @@ -94,10 +119,10 @@ class PythonSTC(wxStyledTextCtrl): # just have to define what each style looks like. This set is adapted from # Scintilla sample property files. - self.StyleClearAll() - # Global default styles for all languages self.StyleSetSpec(wxSTC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % faces) + self.StyleClearAll() # Reset all to be like the default + self.StyleSetSpec(wxSTC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces) self.StyleSetSpec(wxSTC_STYLE_CONTROLCHAR, "face:%(other)s" % faces) self.StyleSetSpec(wxSTC_STYLE_BRACELIGHT, "fore:#FFFFFF,back:#0000FF,bold") @@ -139,7 +164,7 @@ class PythonSTC(wxStyledTextCtrl): # register some images for use in the AutoComplete box. self.RegisterImage(1, images.getSmilesBitmap()) self.RegisterImage(2, images.getFile1Bitmap()) - self.RegisterImage(3, images.getCopyBitmap()) + self.RegisterImage(3, images.getCopy2Bitmap()) diff --git a/wxPython/demo/wxXmlResourceHandler.py b/wxPython/demo/wxXmlResourceHandler.py index 87d8598447..7a97c5106f 100644 --- a/wxPython/demo/wxXmlResourceHandler.py +++ b/wxPython/demo/wxXmlResourceHandler.py @@ -40,6 +40,9 @@ class PreMyBluePanel(wxPanel): def __init__(self): p = wxPrePanel() self.this = p.this + self.thisown = p.thisown + self._setOORInfo(self) + def Create(self, parent, id, pos, size, style, name): wxPanel.Create(self, parent, id, pos, size, style, name) diff --git a/wxPython/demo/wxXmlResourceSubclass.py b/wxPython/demo/wxXmlResourceSubclass.py new file mode 100644 index 0000000000..1729900b44 --- /dev/null +++ b/wxPython/demo/wxXmlResourceSubclass.py @@ -0,0 +1,106 @@ + +from wxPython.wx import * +from wxPython.xrc import * + +#---------------------------------------------------------------------- + +resourceText = r''' + + + + + + 200,100 + + + 10,10 + + + +''' + +#---------------------------------------------------------------------- + +class MyBluePanel(wxPanel): + def __init__(self): + #print "MyBluePanel.__init__" + p = wxPrePanel() + self.this = p.this + self.thisown = p.thisown + self._setOORInfo(self) + + EVT_WINDOW_CREATE(self, self.OnCreate) + + def OnCreate(self, evt): + # This is the little bit of customization that we do for this + # silly example. It could just as easily have been done in + # the resource. We do it in the EVT_WINDOW_CREATE handler + # because the window doesn't really exist yet in the __init__. + self.SetBackgroundColour("BLUE") + self.SetForegroundColour("WHITE") + +#---------------------------------------------------------------------- + + +class TestPanel(wxPanel): + def __init__(self, parent, log): + self.log = log + wxPanel.__init__(self, parent, -1) + + # make the components + label = wxStaticText(self, -1, "The lower panel was built from this XML:") + label.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD)) + + text = wxTextCtrl(self, -1, resourceText, + style=wxTE_READONLY|wxTE_MULTILINE) + text.SetInsertionPoint(0) + + line = wxStaticLine(self, -1) + + # Load the resource + res = wxEmptyXmlResource() + res.LoadFromString(resourceText) + + # Now create a panel from the resource data + panel = res.LoadPanel(self, "MyPanel") + + # and do the layout + sizer = wxBoxSizer(wxVERTICAL) + sizer.Add(label, 0, wxEXPAND|wxTOP|wxLEFT, 5) + sizer.Add(text, 1, wxEXPAND|wxALL, 5) + sizer.Add(line, 0, wxEXPAND) + sizer.Add(panel, 1, wxEXPAND|wxALL, 5) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wxXmlResourceSubclass

+ +Sometimes it is necessary to use custom classes, but you still want +them to be created from XRC. The subclass XRC attribute allows you to +do that. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) +