diff --git a/demo/Sizers.py b/demo/Sizers.py index c13f4d06..6d06b3ca 100644 --- a/demo/Sizers.py +++ b/demo/Sizers.py @@ -551,37 +551,35 @@ class TestSelectionPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - self.list = wx.ListBox(self, -1, - (-1, -1), (-1, -1), - []) - self.list.Fit() + self.list = wx.ListBox(self, size=(300,150)) self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list) self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnDClick, self.list) btn = wx.Button(self, -1, "Try it!", (120, 10)) btn.Bind(wx.EVT_BUTTON, self.OnDClick) - self.text = wx.TextCtrl(self, -1, "", - (10, 115), - (200, 50), - wx.TE_MULTILINE | wx.TE_READONLY) + self.text = wx.TextCtrl(self, style = wx.TE_MULTILINE | wx.TE_READONLY) for item in theTests: self.list.Append(item[0]) + self.list.SetSelection(0) + wx.CallAfter(self.list.EnsureVisible, 0) + hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(self.list, 1, wx.ALL, 8) hsizer.Add(btn, 0, wx.ALL, 8) vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(hsizer) vsizer.Add(self.text, 1, wx.EXPAND | wx.ALL, 8) - self.SetSizerAndFit(vsizer) + self.SetSizer(vsizer) def OnSelect(self, event): pos = self.list.GetSelection() self.text.SetValue(theTests[pos][2]) + def OnDClick(self, event): pos = self.list.GetSelection() title = theTests[pos][0] diff --git a/demo/Slider.py b/demo/Slider.py index df4c6db6..503d19e5 100644 --- a/demo/Slider.py +++ b/demo/Slider.py @@ -10,15 +10,22 @@ class TestPanel(wx.Panel): self.log = log self.count = 0 - wx.StaticText(self, -1, "This is a wx.Slider.", (45, 15)) + label = wx.StaticText(self, -1, "This is a wx.Slider.") slider = wx.Slider( - self, 100, 25, 1, 100, (30, 60), (250, -1), - wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS + self, 100, 25, 1, 100, size=(250, -1), + style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS ) slider.SetTickFreq(5) + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add((1,20)) + sizer.Add(label, 0, wx.LEFT, 20) + sizer.Add((1,10)) + sizer.Add(slider, 0, wx.LEFT, 20) + self.SetSizer(sizer) + #---------------------------------------------------------------------- @@ -35,10 +42,6 @@ def runTest(frame, nb, log): overview = """\ A slider is a control with a handle which can be pulled back and forth to change the value. - -In Windows versions below Windows 95, a scrollbar is used to simulate the slider. -In Windows 95, the track bar control is used. - """ diff --git a/demo/Sound.py b/demo/Sound.py index c50543f9..96afa984 100644 --- a/demo/Sound.py +++ b/demo/Sound.py @@ -27,7 +27,7 @@ class TestPanel(wx.Panel): self.log.write("before Play...\n") sound.Play(wx.adv.SOUND_SYNC) self.log.write("...after Play\n") - except NotImplementedError, v: + except NotImplementedError as v: wx.MessageBox(str(v), "Exception Message") @@ -45,7 +45,7 @@ class TestPanel(wx.Panel): self.sound = sound # save a reference (This shoudln't be needed, but there seems to be a bug...) # wx.YieldIfNeeded() self.log.write("...after Play\n") - except NotImplementedError, v: + except NotImplementedError as v: wx.MessageBox(str(v), "Exception Message") @@ -62,7 +62,7 @@ class TestPanel(wx.Panel): # another way to do it. wx.adv.Sound.PlaySound(dlg.GetPath(), wx.adv.SOUND_SYNC) - except NotImplementedError, v: + except NotImplementedError as v: wx.MessageBox(str(v), "Exception Message") dlg.Destroy() diff --git a/demo/StaticBitmap.py b/demo/StaticBitmap.py index 75dad2b4..329b12d2 100644 --- a/demo/StaticBitmap.py +++ b/demo/StaticBitmap.py @@ -32,7 +32,6 @@ class TestPanel(wx.Panel): bmp = images.Robin.GetBitmap() StaticBitmap(self, -1, bmp, (80, 150)) - StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175)) #---------------------------------------------------------------------- diff --git a/demo/StyledTextCtrl_1.py b/demo/StyledTextCtrl_1.py index 37f0ecdf..759ad02f 100644 --- a/demo/StyledTextCtrl_1.py +++ b/demo/StyledTextCtrl_1.py @@ -1,15 +1,7 @@ -#!/usr/bin/env python - -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx.TheClipboard.Flush() generates a warning on program exit. - import wx import wx.stc as stc -import images - #---------------------------------------------------------------------- debug = 1 @@ -171,43 +163,20 @@ def runTest(frame, nb, log): p.SetAutoLayout(True) - #ed.SetBufferedDraw(False) - #ed.StyleClearAll() - #ed.SetScrollWidth(800) - #ed.SetWrapMode(True) - #ed.SetUseAntiAliasing(False) - #ed.SetViewEOL(True) - - #ed.CmdKeyClear(stc.STC_KEY_BACK, - # stc.STC_SCMOD_CTRL) - #ed.CmdKeyAssign(stc.STC_KEY_BACK, - # stc.STC_SCMOD_CTRL, - # stc.STC_CMD_DELWORDLEFT) - ed.SetText(demoText) - # if wx.USE_UNICODE: import codecs decode = codecs.lookup("utf-8")[1] ed.GotoPos(ed.GetLength()) ed.AddText("\n\nwx.StyledTextCtrl can also do Unicode:\n") uniline = ed.GetCurrentLine() - unitext, l = decode('\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd - ' - '\xd0\xbb\xd1\x83\xd1\x87\xd1\x88\xd0\xb8\xd0\xb9 ' - '\xd1\x8f\xd0\xb7\xd1\x8b\xd0\xba \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f!\n\n') + unitext, l = decode(b'\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd - ' + + b'\xd0\xbb\xd1\x83\xd1\x87\xd1\x88\xd0\xb8\xd0\xb9 ' + + b'\xd1\x8f\xd0\xb7\xd1\x8b\xd0\xba \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f!\n\n') ed.AddText('\tRussian: ') ed.AddText(unitext) ed.GotoPos(0) - #else: - # #ed.StyleSetFontEncoding(stc.STC_STYLE_DEFAULT, wx.FONTENCODING_KOI8) - # #text = u'\u041f\u0438\u0442\u043e\u043d - \u043b\u0443\u0447\u0448\u0438\u0439 \u044f\u0437\u044b\u043a \n\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f!' - # #text = text.encode('koi8-r') - # #ed.StyleSetFontEncoding(stc.STC_STYLE_DEFAULT, wx.FONTENCODING_BIG5) - # #text = u'Python \u662f\u6700\u597d\u7684\u7de8\u7a0b\u8a9e\u8a00\uff01' - # #text = text.encode('big5') - # ed.GotoPos(ed.GetLength()) - # ed.AddText('\n\n' + text) ed.EmptyUndoBuffer() diff --git a/demo/TablePrint.py b/demo/TablePrint.py index 2be3db08..f058962b 100644 --- a/demo/TablePrint.py +++ b/demo/TablePrint.py @@ -24,7 +24,7 @@ class TablePanel(wx.Panel): box = wx.BoxSizer(wx.VERTICAL) box.Add((20, 30)) - keys = buttonDefs.keys() + keys = list(buttonDefs.keys()) keys.sort() for k in keys: @@ -38,8 +38,8 @@ class TablePanel(wx.Panel): def OnButton(self, evt): funct = buttonDefs[evt.GetId()][0] - code = 'self.' + funct + '()' - eval(code) + funct = getattr(self, funct) + funct() def ReadData(self): test_file = "./data/testtable.txt" diff --git a/demo/Threads.py b/demo/Threads.py index 1cfe59b1..79fb6cb9 100644 --- a/demo/Threads.py +++ b/demo/Threads.py @@ -1,11 +1,9 @@ -#!/usr/bin/env python +import random +import time +from six.moves import _thread -import random -import time -import thread - -import wx -import wx.lib.newevent +import wx +import wx.lib.newevent #---------------------------------------------------------------------- @@ -23,7 +21,7 @@ class CalcBarThread: def Start(self): self.keepGoing = self.running = True - thread.start_new_thread(self.Run, ()) + _thread.start_new_thread(self.Run, ()) def Stop(self): self.keepGoing = False diff --git a/demo/TreeMixin.py b/demo/TreeMixin.py index b838ac1a..782d0ec0 100644 --- a/demo/TreeMixin.py +++ b/demo/TreeMixin.py @@ -126,31 +126,31 @@ class VirtualTreeCtrl(DemoTreeMixin, wx.TreeCtrl): pass -class VirtualTreeListCtrl(DemoTreeMixin, wx.adv.TreeListCtrl): - def __init__(self, *args, **kwargs): - kwargs['style'] = wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT - super(VirtualTreeListCtrl, self).__init__(*args, **kwargs) - self.AppendColumn('Column 0') - self.AppendColumn('Column 1') - for art in wx.ART_TIP, wx.ART_WARNING: - self.imageList.Add(wx.ArtProvider.GetBitmap(art, wx.ART_OTHER, - (16, 16))) - - def OnGetItemText(self, indices, column=0): - # Return a different label depending on column. - return '%s, column %d'%\ - (super(VirtualTreeListCtrl, self).OnGetItemText(indices), column) - - def OnGetItemImage(self, indices, which, column=0): - # Also change the image of the other columns when the item has - # children. - if column == 0: - return super(VirtualTreeListCtrl, self).OnGetItemImage(indices, - which) - elif self.OnGetChildrenCount(indices): - return 4 - else: - return 3 +# class VirtualTreeListCtrl(DemoTreeMixin, wx.adv.TreeListCtrl): +# def __init__(self, *args, **kwargs): +# kwargs['style'] = wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT +# super(VirtualTreeListCtrl, self).__init__(*args, **kwargs) +# self.AppendColumn('Column 0') +# self.AppendColumn('Column 1') +# for art in wx.ART_TIP, wx.ART_WARNING: +# self.imageList.Add(wx.ArtProvider.GetBitmap(art, wx.ART_OTHER, +# (16, 16))) +# +# def OnGetItemText(self, indices, column=0): +# # Return a different label depending on column. +# return '%s, column %d'%\ +# (super(VirtualTreeListCtrl, self).OnGetItemText(indices), column) +# +# def OnGetItemImage(self, indices, which, column=0): +# # Also change the image of the other columns when the item has +# # children. +# if column == 0: +# return super(VirtualTreeListCtrl, self).OnGetItemImage(indices, +# which) +# elif self.OnGetChildrenCount(indices): +# return 4 +# else: +# return 3 class VirtualCustomTreeCtrl(DemoTreeMixin, @@ -192,7 +192,7 @@ class TreeNotebook(wx.Notebook): super(TreeNotebook, self).__init__(*args, **kwargs) self.trees = [] for class_, title in [(VirtualTreeCtrl, 'TreeCtrl'), - (VirtualTreeListCtrl, 'TreeListCtrl'), + #(VirtualTreeListCtrl, 'TreeListCtrl'), (VirtualCustomTreeCtrl, 'CustomTreeCtrl')]: tree = class_(self, treemodel=treemodel, log=log) self.trees.append(tree) diff --git a/wx/lib/printout.py b/wx/lib/printout.py index 5b7ad7c6..52afc6f6 100644 --- a/wx/lib/printout.py +++ b/wx/lib/printout.py @@ -27,6 +27,8 @@ import copy import types import wx +import six + class PrintBase(object): def SetPrintFont(self, font): # set the DC font parameters fattr = font["Attr"] @@ -271,7 +273,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase): self.column.append(pos_x) #module logic expects two dimensional data -- fix input if needed - if isinstance(self.data,types.StringTypes): + if isinstance(self.data, six.string_types): self.data = [[copy.copy(self.data)]] # a string becomes a single cell try: rows = len(self.data) @@ -280,7 +282,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase): rows = 1 first_value = self.data[0] - if isinstance(first_value, types.StringTypes): # a sequence of strings + if isinstance(first_value, six.string_types): # a sequence of strings if self.label == [] and self.set_column == []: data = [] for x in self.data: #becomes one column @@ -560,7 +562,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase): self.col = 0 max_y = 0 for vtxt in row_val: - if not isinstance(vtxt,types.StringTypes): + if not isinstance(vtxt, six.string_types): vtxt = str(vtxt) self.region = self.column[self.col+1] - self.column[self.col] self.indent = self.column[self.col] @@ -681,7 +683,10 @@ class PrintTable(object): self.row_line_colour = {} self.parentFrame = parentFrame - self.SetPreviewSize() + if parentFrame: + self.SetPreviewSize(parentFrame.GetPosition(), parentFrame.GetSize()) + else: + self.SetPreviewSize() self.printData = wx.PrintData() self.scale = 1.0