From 63b6646e5d4d53611c5ea665701e2b2d978fbd22 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 11 Jul 2002 20:41:21 +0000 Subject: [PATCH] demo tweaks git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16140 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/ActiveXWrapper_Acrobat.py | 11 ++++------- wxPython/demo/ActiveXWrapper_IE.py | 15 +++++++-------- wxPython/demo/FontEnumerator.py | 16 +++++++++++----- wxPython/demo/PyCrustWithFilling.py | 5 +++++ wxPython/demo/SplitTree.py | 7 +++++++ wxPython/demo/wxIEHtmlWin.py | 24 +++++++++++++----------- wxPython/demo/wxListCtrl.py | 4 +++- wxPython/demo/wxStyledTextCtrl_1.py | 17 +++++++++++------ wxPython/demo/wxTextCtrl.py | 14 ++++++++++---- wxPython/demo/wxTreeCtrl.py | 1 + 10 files changed, 72 insertions(+), 42 deletions(-) diff --git a/wxPython/demo/ActiveXWrapper_Acrobat.py b/wxPython/demo/ActiveXWrapper_Acrobat.py index 06da8cc699..6eb972d109 100644 --- a/wxPython/demo/ActiveXWrapper_Acrobat.py +++ b/wxPython/demo/ActiveXWrapper_Acrobat.py @@ -64,7 +64,10 @@ class TestPanel(wxPanel): self.SetSizer(sizer) self.SetAutoLayout(true) - def __del__(self): + EVT_WINDOW_DESTROY(self, self.OnDestroy) + + + def OnDestroy(self, evt): if self.pdf: self.pdf.Cleanup() self.pdf = None @@ -114,12 +117,6 @@ if __name__ == '__main__': wxFrame.__init__(self, None, -1, "ActiveX test -- Acrobat", size=(640, 480), style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE) self.tp = TestPanel(self, sys.stdout) - EVT_CLOSE(self, self.OnCloseWindow) - - def OnCloseWindow(self, event): - - self.tp.pdf.Cleanup() - self.Destroy() app = wxPySimpleApp() diff --git a/wxPython/demo/ActiveXWrapper_IE.py b/wxPython/demo/ActiveXWrapper_IE.py index c91db4d56b..001455286a 100644 --- a/wxPython/demo/ActiveXWrapper_IE.py +++ b/wxPython/demo/ActiveXWrapper_IE.py @@ -104,15 +104,19 @@ class TestPanel(wxWindow): self.SetAutoLayout(true) EVT_SIZE(self, self.OnSize) + EVT_WINDOW_DESTROY(self, self.OnDestroy) - def OnSize(self, evt): - self.Layout() - def __del__(self): + def OnDestroy(self, evt): if self.ie: self.ie.Cleanup() self.ie = None + + def OnSize(self, evt): + self.Layout() + + def OnLocationSelect(self, evt): url = self.location.GetStringSelection() self.log.write('OnLocationSelect: %s\n' % url) @@ -211,11 +215,6 @@ if __name__ == '__main__': style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE) self.CreateStatusBar() self.tp = TestPanel(self, sys.stdout, self) - EVT_CLOSE(self, self.OnCloseWindow) - - def OnCloseWindow(self, event): - self.tp.ie.Cleanup() - self.Destroy() app = wxPySimpleApp() diff --git a/wxPython/demo/FontEnumerator.py b/wxPython/demo/FontEnumerator.py index 5ada2dac5c..27a1466d94 100644 --- a/wxPython/demo/FontEnumerator.py +++ b/wxPython/demo/FontEnumerator.py @@ -44,7 +44,10 @@ class TestPanel(wxPanel): self.txt.SetFont(font) self.txt.SetSize(self.txt.GetBestSize()) - +## st = font.GetNativeFontInfo().ToString() +## ni2 = wxNativeFontInfo() +## ni2.FromString(st) +## font2 = wxFontFromNativeInfo(ni2) #---------------------------------------------------------------------- @@ -61,11 +64,14 @@ def runTest(frame, nb, log): - - - - overview = """\ wxFontEnumerator enumerates either all available fonts on the system or only the ones with given attributes - either only fixed-width (suited for use in programs such as terminal emulators and the like) or the fonts available in the given encoding. """ + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/PyCrustWithFilling.py b/wxPython/demo/PyCrustWithFilling.py index 30ea8e1d74..a90c61649a 100644 --- a/wxPython/demo/PyCrustWithFilling.py +++ b/wxPython/demo/PyCrustWithFilling.py @@ -21,3 +21,8 @@ def runTest(frame, nb, log): overview = filling.__doc__ +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/SplitTree.py b/wxPython/demo/SplitTree.py index afdccb9e2e..fddd44f7dc 100644 --- a/wxPython/demo/SplitTree.py +++ b/wxPython/demo/SplitTree.py @@ -72,6 +72,7 @@ class TestPanel(wxPanel): tree = TestTree(splitter, -1, style = wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxTR_ROW_LINES | + #wxTR_HIDE_ROOT | wxNO_BORDER ) valueWindow = TestValueWindow(splitter, -1, style=wxNO_BORDER) @@ -111,3 +112,9 @@ also be useful by themselves. """ + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/wxIEHtmlWin.py b/wxPython/demo/wxIEHtmlWin.py index 5bdd7191be..a09476159b 100644 --- a/wxPython/demo/wxIEHtmlWin.py +++ b/wxPython/demo/wxIEHtmlWin.py @@ -54,16 +54,17 @@ class TestPanel(wxWindow): txt = wxStaticText(self, -1, "Location:") btnSizer.Add(txt, 0, wxCENTER|wxALL, 2) - self.location = wxComboBox(self, wxNewId(), "", style=wxCB_DROPDOWN) + self.location = wxComboBox(self, wxNewId(), "", style=wxCB_DROPDOWN|wxPROCESS_ENTER) EVT_COMBOBOX(self, self.location.GetId(), self.OnLocationSelect) EVT_KEY_UP(self.location, self.OnLocationKey) EVT_CHAR(self.location, self.IgnoreReturn) btnSizer.Add(self.location, 1, wxEXPAND|wxALL, 2) + sizer.Add(btnSizer, 0, wxEXPAND) sizer.Add(self.ie, 1, wxEXPAND) - self.ie.LoadUrl(self.current) + self.ie.Navigate(self.current) self.location.Append(self.current) self.SetSizer(sizer) @@ -82,22 +83,23 @@ class TestPanel(wxWindow): def OnSize(self, evt): self.Layout() + def OnLocationSelect(self, evt): url = self.location.GetStringSelection() self.log.write('OnLocationSelect: %s\n' % url) - self.ie.LoadUrl(url) + self.ie.Navigate(url) def OnLocationKey(self, evt): if evt.KeyCode() == WXK_RETURN: URL = self.location.GetValue() self.location.Append(URL) - self.ie.LoadUrl(URL) + self.ie.Navigate(URL) else: evt.Skip() + def IgnoreReturn(self, evt): - print 'IgnoreReturn' - if evt.KeyCode() != WXK_RETURN: + if evt.GetKeyCode() != WXK_RETURN: evt.Skip() def OnOpenButton(self, event): @@ -107,7 +109,7 @@ class TestPanel(wxWindow): dlg.CentreOnParent() if dlg.ShowModal() == wxID_OK: self.current = dlg.GetValue() - self.ie.LoadUrl(self.current) + self.ie.Navigate(self.current) dlg.Destroy() def OnHomeButton(self, event): @@ -132,7 +134,7 @@ class TestPanel(wxWindow): def logEvt(self, name, event): self.log.write('%s: %s\n' % - (name, (event.GetLong1(), event.GetLong2(), event.GetText()))) + (name, (event.GetLong1(), event.GetLong2(), event.GetText1()))) def OnBeforeNavigate2(self, evt): self.logEvt('OnBeforeNavigate2', evt) @@ -143,18 +145,18 @@ class TestPanel(wxWindow): def OnDocumentComplete(self, evt): self.logEvt('OnDocumentComplete', evt) - self.current = evt.GetText() + self.current = evt.GetText1() self.location.SetValue(self.current) def OnTitleChange(self, evt): self.logEvt('OnTitleChange', evt) if self.frame: - self.frame.SetTitle(self.titleBase + ' -- ' + evt.GetText()) + self.frame.SetTitle(self.titleBase + ' -- ' + evt.GetText1()) def OnStatusTextChange(self, evt): self.logEvt('OnStatusTextChange', evt) if self.frame: - self.frame.SetStatusText(evt.GetText()) + self.frame.SetStatusText(evt.GetText1()) #---------------------------------------------------------------------- diff --git a/wxPython/demo/wxListCtrl.py b/wxPython/demo/wxListCtrl.py index 9c23d2e674..2dcd901785 100644 --- a/wxPython/demo/wxListCtrl.py +++ b/wxPython/demo/wxListCtrl.py @@ -105,7 +105,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL) # Why doesn't this show up on MSW??? - self.list.SetToolTip(wxToolTip("This is a ToolTip!")) + #self.list.SetToolTip(wxToolTip("This is a ToolTip!")) if 0: # for normal, simple columns, you can add them like this: @@ -280,6 +280,8 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): def OnPopupOne(self, event): self.log.WriteText("Popup one\n") + print "FindItem:", self.list.FindItem(-1, "Billy Joel") + print "FindItemData:", self.list.FindItemData(-1, 20) def OnPopupTwo(self, event): self.log.WriteText("Popup two\n") diff --git a/wxPython/demo/wxStyledTextCtrl_1.py b/wxPython/demo/wxStyledTextCtrl_1.py index 0f082c2ca9..e0964cf78a 100644 --- a/wxPython/demo/wxStyledTextCtrl_1.py +++ b/wxPython/demo/wxStyledTextCtrl_1.py @@ -60,10 +60,13 @@ class MySTC(wxStyledTextCtrl): EVT_STC_START_DRAG(self, ID, self.OnStartDrag) EVT_STC_MODIFIED(self, ID, self.OnModified) -## EVT_WINDOW_DESTROY(self, self.OnDestroy) -## def OnDestroy(self, evt): -## wxTheClipboard.Flush() -## evt.Skip() + EVT_WINDOW_DESTROY(self, self.OnDestroy) + + def OnDestroy(self, evt): + # This is how the clipboard contents can be preserved after + # the app has exited. + wxTheClipboard.Flush() + evt.Skip() def OnStartDrag(self, evt): @@ -151,7 +154,7 @@ def runTest(frame, nb, log): ed = p = MySTC(nb, -1, log) else: - p = wxPanel(nb, -1) + p = wxPanel(nb, -1, style=wxNO_FULL_REPAINT_ON_RESIZE) ed = MySTC(p, -1, log) s = wxBoxSizer(wxHORIZONTAL) s.Add(ed, 1, wxEXPAND) @@ -248,10 +251,12 @@ def runTest(frame, nb, log): ed.SetSelection(25, 35) print "GetSelectedText(): ", repr(ed.GetSelectedText()) print "GetTextRange(25, 35): ", repr(ed.GetTextRange(25, 35)) - + print "FindText(0, max, 'indicators'): ", + print ed.FindText(0, ed.GetTextLength(), "indicators") ed.GotoPos(0) + return p diff --git a/wxPython/demo/wxTextCtrl.py b/wxPython/demo/wxTextCtrl.py index 56098d2023..7b55456399 100644 --- a/wxPython/demo/wxTextCtrl.py +++ b/wxPython/demo/wxTextCtrl.py @@ -47,16 +47,13 @@ class TestPanel(wxPanel): l4 = wxStaticText(self, -1, "Rich Text") t4 = wxTextCtrl(self, 40, "If supported by the native control, this is red, and this is a different font.", - size=(200, 100), style=wxTE_MULTILINE|wxTE_RICH) + size=(200, 100), style=wxTE_MULTILINE|wxTE_RICH2) t4.SetInsertionPoint(0) t4.SetStyle(44, 47, wxTextAttr("RED", "YELLOW")) points = t4.GetFont().GetPointSize() # get the current size f = wxFont(points+3, wxROMAN, wxITALIC, wxBOLD, true) -## print 'a1', sys.getrefcount(f) -## t4.SetStyle(63, 77, wxTextAttr("BLUE", font=f)) t4.SetStyle(63, 77, wxTextAttr("BLUE", wxNullColour, f)) -## print 'a2', sys.getrefcount(f) bsizer = wxBoxSizer(wxVERTICAL) bsizer.Add(b, 0, wxGROW) @@ -113,3 +110,12 @@ def runTest(frame, nb, log): overview = """\ """ + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/wxTreeCtrl.py b/wxPython/demo/wxTreeCtrl.py index 877c92bf61..ed5adc05e6 100644 --- a/wxPython/demo/wxTreeCtrl.py +++ b/wxPython/demo/wxTreeCtrl.py @@ -31,6 +31,7 @@ class TestTreeCtrlPanel(wxPanel): self.tree = MyTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS# | wxTR_MULTIPLE + #| wxTR_HIDE_ROOT , self.log) -- 2.45.2