X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e0465cbdca787b836518b55fa9199dcef0c5ca00..1dd82eff99693729c49a1c578f3b47356c5c6f0c:/wxPython/demo/Main.py diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index dd1f9044c2..be0cd0a4f9 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -47,8 +47,9 @@ import images _treeList = [ # new stuff ('Recent Additions/Updates', [ - 'OGL', - 'FloatCanvas', + 'StockButtons', + 'Ticker', + 'Choicebook', ]), # managed windows == things with a (optional) caption you can close @@ -89,6 +90,7 @@ _treeList = [ 'CheckBox', 'CheckListBox', 'Choice', + 'Choicebook', 'ComboBox', 'Gauge', 'Grid', @@ -112,6 +114,7 @@ _treeList = [ 'StaticBitmap', 'StaticText', 'StatusBar', + 'StockButtons', 'TextCtrl', 'ToggleButton', 'ToolBar', @@ -162,6 +165,7 @@ _treeList = [ 'StyledTextCtrl_2', 'TablePrint', 'Throbber', + 'Ticker', 'TimeCtrl', 'VListBox', ]), @@ -394,8 +398,7 @@ try: # The rest remains unchanged. # Line numbers in margin - self.StyleSetSpec(wx.stc.STC_STYLE_LINENUMBER,'fore:#000000,back:#99A9C2') - + self.StyleSetSpec(wx.stc.STC_STYLE_LINENUMBER,'fore:#000000,back:#99A9C2') # Highlighted brace self.StyleSetSpec(wx.stc.STC_STYLE_BRACELIGHT,'fore:#00009D,back:#FFFF00') # Unmatched brace @@ -945,6 +948,80 @@ class DemoErrorPanel(wx.Panel): #--------------------------------------------------------------------------- +class DemoTaskBarIcon(wx.TaskBarIcon): + TBMENU_RESTORE = wx.NewId() + TBMENU_CLOSE = wx.NewId() + TBMENU_CHANGE = wx.NewId() + TBMENU_REMOVE = wx.NewId() + + def __init__(self, frame): + wx.TaskBarIcon.__init__(self) + self.frame = frame + + # Set the image + icon = self.MakeIcon(images.getMondrianImage()) + self.SetIcon(icon, "wxPython Demo") + + # bind some events + self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarActivate) + self.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=self.TBMENU_RESTORE) + self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=self.TBMENU_CLOSE) + self.Bind(wx.EVT_MENU, self.OnTaskBarChange, id=self.TBMENU_CHANGE) + self.Bind(wx.EVT_MENU, self.OnTaskBarRemove, id=self.TBMENU_REMOVE) + + + def CreatePopupMenu(self): + """ + This method is called by the base class when it needs to popup + the menu for the default EVT_RIGHT_DOWN event. Just create + the menu how you want it and return it from this function, + the base class takes care of the rest. + """ + menu = wx.Menu() + menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo") + menu.Append(self.TBMENU_CLOSE, "Close wxPython Demo") + menu.AppendSeparator() + menu.Append(self.TBMENU_CHANGE, "Change the TB Icon") + menu.Append(self.TBMENU_REMOVE, "Remove the TB Icon") + return menu + + + def MakeIcon(self, img): + """ + The various platforms have different requirements for the + icon size... + """ + if "wxMSW" in wx.PlatformInfo: + img.Scale(16, 16) + elif "wxGTK" in wx.PlatformInfo: + img.Scale(20, 20) + # wxMac can be any size upto 128.128.... + icon = wx.IconFromBitmap(img.ConvertToBitmap() ) + return icon + + + def OnTaskBarActivate(self, evt): + if self.frame.IsIconized(): + self.frame.Iconize(False) + if not self.frame.IsShown(): + self.frame.Show(True) + self.frame.Raise() + + + def OnTaskBarClose(self, evt): + self.frame.Close() + + + def OnTaskBarChange(self, evt): + icon = self.MakeIcon(images.getBlom10MaskedImage()) + self.SetIcon(icon, "This is a new icon") + + + def OnTaskBarRemove(self, evt): + self.RemoveIcon() + + +#--------------------------------------------------------------------------- class wxPythonDemo(wx.Frame): overviewText = "wxPython Overview" @@ -963,19 +1040,7 @@ class wxPythonDemo(wx.Frame): icon = images.getMondrianIcon() self.SetIcon(icon) - if wx.Platform != '__WXMAC__': - # setup a taskbar icon, and catch some events from it - dim = 16 # (may want to use 22 on wxGTK, but 16 looks okay too) - icon = wx.IconFromBitmap( - images.getMondrianImage().Scale(dim,dim).ConvertToBitmap() ) - #icon = wx.Icon('bmp_source/mondrian.ico', wx.BITMAP_TYPE_ICO) - #icon = images.getMondrianIcon() - self.tbicon = wx.TaskBarIcon() - self.tbicon.SetIcon(icon, "wxPython Demo") - self.tbicon.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarActivate) - self.tbicon.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTaskBarMenu) - self.tbicon.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=self.TBMENU_RESTORE) - self.tbicon.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=self.TBMENU_CLOSE) + self.tbicon = DemoTaskBarIcon(self) wx.CallAfter(self.ShowTip) @@ -1118,7 +1183,7 @@ class wxPythonDemo(wx.Frame): panel.Bind(wx.EVT_ERASE_BACKGROUND, EmptyHandler) if "gtk2" in wx.PlatformInfo: - self.ovr.NormalizeFontSizes() + self.ovr.SetStandardFonts() self.SetOverview(self.overviewText, mainOverview) @@ -1137,6 +1202,9 @@ class wxPythonDemo(wx.Frame): #wx.Log_SetTraceMask(wx.TraceMessages) + self.Bind(wx.EVT_ACTIVATE, self.OnActivate) + wx.GetApp().Bind(wx.EVT_ACTIVATE_APP, self.OnAppActivate) + # add the windows to the splitter and split it. splitter2.SplitHorizontally(self.nb, self.log, -160) splitter.SplitVertically(self.tree, splitter2, 200) @@ -1254,9 +1322,8 @@ class wxPythonDemo(wx.Frame): self.ShutdownDemoModule() overviewText = "" - # o If the demo returns a window it is placed in a tab. - # o Otherwise, a placeholder tab is created, informing the user that the - # demo runs outside the main window, and allowing it to be reloaded. + # o The RunTest() for all samples must now return a window that can + # be palced in a tab in the main notebook. # o If an error occurs (or has occured before) an error tab is created. if module is not None: @@ -1453,6 +1520,7 @@ class wxPythonDemo(wx.Frame): self.demoPage = None self.codePage = None self.mainmenu = None + self.tbicon.Destroy() self.Destroy() @@ -1490,38 +1558,10 @@ class wxPythonDemo(wx.Frame): self.tree.EnsureVisible(selectedDemo) - #--------------------------------------------- - def OnTaskBarActivate(self, evt): - if self.IsIconized(): - self.Iconize(False) - if not self.IsShown(): - self.Show(True) - self.Raise() - - #--------------------------------------------- - - TBMENU_RESTORE = 1000 - TBMENU_CLOSE = 1001 - - def OnTaskBarMenu(self, evt): - menu = wx.Menu() - menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo") - menu.Append(self.TBMENU_CLOSE, "Close") - self.tbicon.PopupMenu(menu) - menu.Destroy() - - #--------------------------------------------- - def OnTaskBarClose(self, evt): - self.Close() - - # because of the way wx.TaskBarIcon.PopupMenu is implemented we have to - # prod the main idle handler a bit to get the window to actually close - wx.GetApp().ProcessIdle() - #--------------------------------------------- def OnIconfiy(self, evt): - wx.LogMessage("OnIconfiy: %d" % evt.Iconized()) + wx.LogMessage("OnIconfiy: %s" % evt.Iconized()) evt.Skip() #--------------------------------------------- @@ -1529,8 +1569,15 @@ class wxPythonDemo(wx.Frame): wx.LogMessage("OnMaximize") evt.Skip() + #--------------------------------------------- + def OnActivate(self, evt): + wx.LogMessage("OnActivate: %s" % evt.GetActive()) + evt.Skip() - + #--------------------------------------------- + def OnAppActivate(self, evt): + wx.LogMessage("OnAppActivate: %s" % evt.GetActive()) + evt.Skip() #--------------------------------------------------------------------------- #---------------------------------------------------------------------------