From 8b8536ccfb6c774d2b04d2763bf6593710cc8a9a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 4 Aug 2016 15:19:43 -0700 Subject: [PATCH] More minor demo fixes and updates for Py3, Phoenix, etc. --- demo/MultiSash.py | 10 +++++----- demo/NotificationMessage.py | 2 +- demo/Overlay.py | 38 ++++++++++++++++++++++++++----------- demo/PopupWindow.py | 2 +- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/demo/MultiSash.py b/demo/MultiSash.py index 818c38fd..1903150f 100644 --- a/demo/MultiSash.py +++ b/demo/MultiSash.py @@ -47,11 +47,11 @@ class TestWindow(stc.StyledTextCtrl): wx.Font(fSize, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) ) - ## if self.doc: - ## self.SetDocPointer(self.doc) - ## else: - self.SetText(sampleText) - TestWindow.doc = self.GetDocPointer() + if self.doc: + self.SetDocPointer(self.doc) + else: + self.SetText(sampleText) + TestWindow.doc = self.GetDocPointer() def ShutDownDemo(self): diff --git a/demo/NotificationMessage.py b/demo/NotificationMessage.py index a78d1ccb..c7dfe990 100644 --- a/demo/NotificationMessage.py +++ b/demo/NotificationMessage.py @@ -1 +1 @@ -#!/usr/bin/env python import wx import wx.adv class TestPanel(wx.Panel): def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1) self.btn = wx.Button(self, -1, "Notify me of something...!", pos=(50,50)) self.btn.Bind(wx.EVT_BUTTON, self.OnButton) def OnButton(self, event): notify = wx.adv.NotificationMessage(title="Notify!", message="...you of something...\numm...Updates are Available.", parent=None, flags=wx.ICON_INFORMATION) notify.SetFlags( # wx.ICON_INFORMATION wx.ICON_WARNING # wx.ICON_ERROR ) # notify.SetTitle("Wooot") # notify.SetMessage("It's a message!") # notify.SetParent(self) notify.Show(timeout=1)#1 for short timeout, 100 for long timeout # notify.Close()# Hides the notification. def runTest(frame, nb, log): win = TestPanel(nb, log) return win #--------------------------------------------------------------------------- overview = """\ This class allows to show the user a message non intrusively. Currently it is implemented natively for Windows and GTK and uses (non-modal) dialogs for the display of the notifications under the other platforms. """ if __name__ == '__main__': import sys,os import run run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) \ No newline at end of file +#!/usr/bin/env python import wx import wx.adv class TestPanel(wx.Panel): def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1) self.btn = wx.Button(self, -1, "Notify me of something...!", pos=(50,50)) self.btn.Bind(wx.EVT_BUTTON, self.OnButton) def OnButton(self, event): notify = wx.adv.NotificationMessage( title="This is a Notification!", message="wxPython is awesome. Phoenix is awesomer! Python is awesomest!!\n\n" "The quick brown fox jumped over the lazy dog.", parent=None, flags=wx.ICON_INFORMATION) # Various options can be set after the message is created if desired. # notify.SetFlags(# wx.ICON_INFORMATION # wx.ICON_WARNING # # wx.ICON_ERROR # ) # notify.SetTitle("Wooot") # notify.SetMessage("It's a message!") # notify.SetParent(self) notify.Show(timeout=5) # 1 for short timeout, 100 for long timeout # notify.Close() # Hides the notification. def runTest(frame, nb, log): win = TestPanel(nb, log) return win #--------------------------------------------------------------------------- overview = """\ This class allows to show the user a message non intrusively. Currently it is implemented natively for Windows and GTK and uses (non-modal) dialogs for the display of the notifications under the other platforms. """ if __name__ == '__main__': import sys,os import run run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) \ No newline at end of file diff --git a/demo/Overlay.py b/demo/Overlay.py index 53e6df7e..65164cd8 100644 --- a/demo/Overlay.py +++ b/demo/Overlay.py @@ -26,7 +26,8 @@ class TestPanel(wx.Panel): self.endPos = None self.overlay = wx.Overlay() - self.cropbitmap = wx.Bitmap('bitmaps/cropshot24x20.png', wx.BITMAP_TYPE_PNG) + self.cropbitmap = wx.Bitmap('bitmaps/cropshot24x20.png') + self.honeyBitmap = wx.Bitmap('bitmaps/honeycomb300.png') self.wxPenStylesDict = OrderedDict([ ('Solid' , wx.PENSTYLE_SOLID), @@ -36,39 +37,47 @@ class TestPanel(wx.Panel): ('Dot Dash' , wx.PENSTYLE_DOT_DASH), ('User Dash' , wx.PENSTYLE_USER_DASH), ('Transparent' , wx.PENSTYLE_TRANSPARENT), - ('Stipple' , wx.PENSTYLE_STIPPLE), + #('Stipple' , wx.PENSTYLE_STIPPLE), ('BDiagonal Hatch' , wx.PENSTYLE_BDIAGONAL_HATCH), ('CrossDiag Hatch' , wx.PENSTYLE_CROSSDIAG_HATCH), ('FDiagonal Hatch' , wx.PENSTYLE_FDIAGONAL_HATCH), ('Cross Hatch' , wx.PENSTYLE_CROSS_HATCH), ('Horizontal Hatch' , wx.PENSTYLE_HORIZONTAL_HATCH), ('Vertical Hatch' , wx.PENSTYLE_VERTICAL_HATCH), - ('First Hatch' , wx.PENSTYLE_FIRST_HATCH), - ('Last Hatch' , wx.PENSTYLE_LAST_HATCH), ]) list = [] for key, value in self.wxPenStylesDict.items(): list.append(key) self.penstylesCombo = wx.ComboBox(self, -1, choices=list, - pos=(10, 5), size=(100, -1), + size=(150, -1), style=wx.CB_READONLY) self.penstylesCombo.SetSelection(0) self.penstylesCombo.SetToolTip('Pen Style') self.overlayPenWidth = wx.SpinCtrl(self, -1, value='', - pos=(120, 5), - size=(100, -1), + size=(75, -1), style=wx.SP_ARROW_KEYS, min=1, max=24, initial=1) self.overlayPenWidth.SetToolTip('Pen Width') - self.overlayPenColor = wx.ColourPickerCtrl(self, -1, colour=wx.BLUE, - pos=(230, 5), size=(100, -1)) + from wx.lib.colourselect import ColourSelect + self.overlayPenColor = ColourSelect(self, -1, colour=wx.BLUE) self.overlayPenColor.SetToolTip('Pen Color') + sizer = wx.BoxSizer(wx.HORIZONTAL) + sizer.Add(self.penstylesCombo, 0, wx.ALL, 5) + sizer.Add(self.overlayPenWidth, 0, wx.ALL, 5) + sizer.Add(self.overlayPenColor, 0, wx.ALL, 5) + box = wx.BoxSizer(wx.VERTICAL) + box.Add(sizer, 0) + box.Add((1,1), 1) + + self.SetSizer(box) + self.OnSize() + def OnLeftDown(self, event): # Capture the mouse and save the starting posiiton for the rubber-band self.CaptureMouse() @@ -77,6 +86,7 @@ class TestPanel(wx.Panel): self.SetFocus() ## print('OnLeftDown') + def OnMouseMove(self, event): if event.Dragging() and event.LeftIsDown(): evtPos = event.GetPosition() @@ -128,6 +138,7 @@ class TestPanel(wx.Panel): del odc # Make sure the odc is destroyed before the dc is. ## print('OnMouseMove') + def OnLeftUp(self, event): if self.HasCapture(): self.ReleaseMouse() @@ -146,7 +157,11 @@ class TestPanel(wx.Panel): self.overlay.Reset() ## print('OnLeftUp') + def OnSize(self, event=None): + if event: + event.Skip() + x, y = self.GetSize() if x <= 0 or y <= 0: return @@ -158,8 +173,9 @@ class TestPanel(wx.Panel): dc.SetBackground(self.background) dc.Clear() - dc.DrawBitmap(wx.Bitmap('bitmaps/snakey_render.png'), 10, 35) - dc.DrawBitmap(wx.Bitmap('bitmaps/honeycomb300.png'), 100, 210) + dc.DrawBitmap(self.honeyBitmap, 40, 40) + dc.SetFont(wx.Font(wx.FontInfo(18))) + dc.DrawText('Drag the mouse on this window.', 325, 100) del dc self.Refresh() diff --git a/demo/PopupWindow.py b/demo/PopupWindow.py index 0c964d1f..2428fbe8 100644 --- a/demo/PopupWindow.py +++ b/demo/PopupWindow.py @@ -69,7 +69,7 @@ class TestPopup(wx.PopupWindow): def OnRightUp(self, evt): self.Show(False) - self.Destroy() + wx.CallAfter(self.Destroy)