def Show(self, type, object, options=None, item=None): self.current = [type, object, options, item] if self.selected == True: self.foldPanel = FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, self.GetSize(), style=wx.FULL_REPAINT_ON_RESIZE) if not self.current == None: self.showAttributes(self.current[0], self.current[1], self.current[2], self.current[3]) if not self.ogreView == None: EnviromentOptions(self, (self.ogreScene, self.ogreView), self.Level)
def Show(self): if self.selected == True: self.foldPanel = FoldPanelBar( self, wx.ID_ANY, wx.DefaultPosition, size=self.GetSize(), style=wx.FULL_REPAINT_ON_RESIZE) #( 242,1000) if not self.ogreView == None: Render(self, self.ogreView) ShadowOptions(self, self.ogreScene) if not self.ogreView == None: EnviromentOptions(self, (self.ogreScene, self.ogreView)) DefaultLight(self, self.ogreScene) Sky(self, self.ogreScene)
def CreateFoldBar(self, vertical=True): if vertical: self.SetSize((500,600)) else: self.SetSize((700,300)) newstyle = (vertical and [FPB_VERTICAL] or [FPB_HORIZONTAL])[0] bar = FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, FPB_DEFAULT_STYLE | newstyle, FPB_COLLAPSE_TO_BOTTOM) item = bar.AddFoldPanel("Test me", collapsed=False) button1 = wx.Button(item, wx.ID_ANY, "Collapse Me") button1.Bind(wx.EVT_BUTTON, self.OnCollapseMe) bar.AddFoldPanelWindow(item, button1, FPB_ALIGN_LEFT) item = bar.AddFoldPanel("Test me too!", collapsed=True) button2 = wx.Button(item, wx.ID_ANY, "Expand First One") button2.Bind(wx.EVT_BUTTON, self.OnExpandMe) bar.AddFoldPanelWindow(item, button2) bar.AddFoldPanelSeparator(item) newfoldpanel = FoldTestPanel(item, wx.ID_ANY) bar.AddFoldPanelWindow(item, newfoldpanel) bar.AddFoldPanelSeparator(item) bar.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), FPB_ALIGN_LEFT, FPB_DEFAULT_SPACING, 20) item = bar.AddFoldPanel("Some Opinions ...", collapsed=False) bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "I Like This")) if vertical: # do not add this for horizontal for better presentation bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "And also this")) bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "And gimme this too")) bar.AddFoldPanelSeparator(item) bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "Check this too if you like")) if vertical: # do not add this for horizontal for better presentation bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "What about this")) item = bar.AddFoldPanel("Choose one ...", collapsed=False) bar.AddFoldPanelWindow(item, wx.StaticText(item, wx.ID_ANY, "Enter your comment")) bar.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 20) if hasattr(self, "pnl"): self.pnl.Destroy() self.pnl = bar size = self.GetClientSize() self.pnl.SetDimensions(0, 0, size.GetWidth(), size.GetHeight())
def ReCreateFoldPanel(self, fpb_flags): # delete earlier panel self._leftWindow1.DestroyChildren() # recreate the foldpanelbar self._pnl = FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition, wx.Size(-1, -1), FPB_DEFAULT_STYLE, fpb_flags) Images = wx.ImageList(16, 16) Images.Add(GetExpandedIconBitmap()) Images.Add(GetCollapsedIconBitmap()) item = self._pnl.AddFoldPanel("Caption Colours", collapsed=False, foldIcons=Images) self._pnl.AddFoldPanelWindow( item, wx.StaticText(item, -1, "Adjust The First Colour"), FPB_ALIGN_WIDTH, 5, 20) # RED color spin control self._rslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider1, FPB_ALIGN_WIDTH, 2, 20) # GREEN color spin control self._gslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider1, FPB_ALIGN_WIDTH, 0, 20) # BLUE color spin control self._bslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider1, FPB_ALIGN_WIDTH, 0, 20) self._pnl.AddFoldPanelSeparator(item) self._pnl.AddFoldPanelWindow( item, wx.StaticText(item, -1, "Adjust The Second Colour"), FPB_ALIGN_WIDTH, 5, 20) # RED color spin control self._rslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider2, FPB_ALIGN_WIDTH, 2, 20) # GREEN color spin control self._gslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider2, FPB_ALIGN_WIDTH, 0, 20) # BLUE color spin control self._bslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider2, FPB_ALIGN_WIDTH, 0, 20) self._pnl.AddFoldPanelSeparator(item) button1 = wx.Button(item, wx.ID_ANY, "Apply To All") button1.Bind(wx.EVT_BUTTON, self.OnExpandMe) self._pnl.AddFoldPanelWindow(item, button1) # read back current gradients and set the sliders # for the colour which is now taken as default style = self._pnl.GetCaptionStyle(item) col = style.GetFirstColour() self._rslider1.SetValue(col.Red()) self._gslider1.SetValue(col.Green()) self._bslider1.SetValue(col.Blue()) col = style.GetSecondColour() self._rslider2.SetValue(col.Red()) self._gslider2.SetValue(col.Green()) self._bslider2.SetValue(col.Blue()) # put down some caption styles from which the user can # select to show how the current or all caption bars will look like item = self._pnl.AddFoldPanel("Caption Style", False, foldIcons=Images) self.ID_USE_VGRADIENT = wx.NewId() self.ID_USE_HGRADIENT = wx.NewId() self.ID_USE_SINGLE = wx.NewId() self.ID_USE_RECTANGLE = wx.NewId() self.ID_USE_FILLED_RECTANGLE = wx.NewId() currStyle = wx.RadioButton(item, self.ID_USE_VGRADIENT, "&Vertical Gradient") self._pnl.AddFoldPanelWindow(item, currStyle, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) currStyle.SetValue(True) radio1 = wx.RadioButton(item, self.ID_USE_HGRADIENT, "&Horizontal Gradient") radio2 = wx.RadioButton(item, self.ID_USE_SINGLE, "&Single Colour") radio3 = wx.RadioButton(item, self.ID_USE_RECTANGLE, "&Rectangle Box") radio4 = wx.RadioButton(item, self.ID_USE_FILLED_RECTANGLE, "&Filled Rectangle Box") currStyle.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio1.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio2.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio3.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio4.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) self._pnl.AddFoldPanelWindow(item, radio1, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio2, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio3, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio4, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelSeparator(item) self._single = wx.CheckBox(item, -1, "&Only This Caption") self._pnl.AddFoldPanelWindow(item, self._single, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) # one more panel to finish it cs = CaptionBarStyle() cs.SetCaptionStyle(CAPTIONBAR_RECTANGLE) item = self._pnl.AddFoldPanel("Misc Stuff", collapsed=True, foldIcons=Images, cbstyle=cs) button2 = wx.Button(item, wx.NewId(), "Collapse All") self._pnl.AddFoldPanelWindow(item, button2) self._pnl.AddFoldPanelWindow( item, wx.StaticText(item, -1, "Enter Some Comments"), FPB_ALIGN_WIDTH, 5, 20) self._pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, -1, "Comments"), FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe) self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4] self._leftWindow1.SizeWindows()
class Extended(wx.Frame): def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=(700, 650), style=wx.DEFAULT_FRAME_STYLE): wx.Frame.__init__(self, parent, id, title, pos, size, style) self._flags = 0 self.SetIcon(GetMondrianIcon()) self.SetMenuBar(self.CreateMenuBar()) self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) self.statusbar.SetStatusWidths([-4, -3]) self.statusbar.SetStatusText("Andrea Gavana @ 23 Mar 2005", 0) self.statusbar.SetStatusText("Welcome to wxPython!", 1) self._leftWindow1 = wx.SashLayoutWindow( self, 101, wx.DefaultPosition, wx.Size(200, 1000), wx.NO_BORDER | wx.SW_3D | wx.CLIP_CHILDREN) self._leftWindow1.SetDefaultSize(wx.Size(200, 1000)) self._leftWindow1.SetOrientation(wx.LAYOUT_VERTICAL) self._leftWindow1.SetAlignment(wx.LAYOUT_LEFT) self._leftWindow1.SetSashVisible(wx.SASH_RIGHT, True) self._leftWindow1.SetExtraBorderSize(10) self._pnl = 0 # will occupy the space not used by the Layout Algorithm self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER) self.remainingSpace.SetBackgroundColour(wx.BLUE) self.ID_WINDOW_TOP = 100 self.ID_WINDOW_LEFT1 = 101 self.ID_WINDOW_RIGHT1 = 102 self.ID_WINDOW_BOTTOM = 103 self._leftWindow1.Bind(wx.EVT_SASH_DRAGGED_RANGE, self.OnFoldPanelBarDrag, id=100, id2=103) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_SCROLL, self.OnSlideColour) self.ReCreateFoldPanel(0) def OnSize(self, event): wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) event.Skip() def OnQuit(self, event): self.Destroy() def OnAbout(self, event): msg = "This Is The About Dialog Of The FoldPanelBar Demo.\n\n" + \ "Author: Andrea Gavana @ 23 Mar 2005\n\n" + \ "Please Report Any Bug/Requests Of Improvements\n" + \ "To Me At The Following Adresses:\n\n" + \ "[email protected]\n" + "[email protected]\n\n" + \ "Based On Julian Smart C++ Demo Implementation.\n\n" + \ "Welcome To wxPython " + wx.VERSION_STRING + "!!" dlg = wx.MessageDialog(self, msg, "FoldPanelBar Extended Demo", wx.OK | wx.ICON_INFORMATION) dlg.SetFont( wx.Font(8, wx.NORMAL, wx.NORMAL, wx.NORMAL, False, "Verdana")) dlg.ShowModal() dlg.Destroy() def OnToggleWindow(self, event): self._leftWindow1.Show(not self._leftWindow1.IsShown()) # Leaves bits of itself behind sometimes wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh() event.Skip() def OnFoldPanelBarDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return if event.GetId() == self.ID_WINDOW_LEFT1: self._leftWindow1.SetDefaultSize( wx.Size(event.GetDragRect().width, 1000)) # Leaves bits of itself behind sometimes wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh() event.Skip() def ReCreateFoldPanel(self, fpb_flags): # delete earlier panel self._leftWindow1.DestroyChildren() # recreate the foldpanelbar self._pnl = FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition, wx.Size(-1, -1), FPB_DEFAULT_STYLE, fpb_flags) Images = wx.ImageList(16, 16) Images.Add(GetExpandedIconBitmap()) Images.Add(GetCollapsedIconBitmap()) item = self._pnl.AddFoldPanel("Caption Colours", collapsed=False, foldIcons=Images) self._pnl.AddFoldPanelWindow( item, wx.StaticText(item, -1, "Adjust The First Colour"), FPB_ALIGN_WIDTH, 5, 20) # RED color spin control self._rslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider1, FPB_ALIGN_WIDTH, 2, 20) # GREEN color spin control self._gslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider1, FPB_ALIGN_WIDTH, 0, 20) # BLUE color spin control self._bslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider1, FPB_ALIGN_WIDTH, 0, 20) self._pnl.AddFoldPanelSeparator(item) self._pnl.AddFoldPanelWindow( item, wx.StaticText(item, -1, "Adjust The Second Colour"), FPB_ALIGN_WIDTH, 5, 20) # RED color spin control self._rslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider2, FPB_ALIGN_WIDTH, 2, 20) # GREEN color spin control self._gslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider2, FPB_ALIGN_WIDTH, 0, 20) # BLUE color spin control self._bslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider2, FPB_ALIGN_WIDTH, 0, 20) self._pnl.AddFoldPanelSeparator(item) button1 = wx.Button(item, wx.ID_ANY, "Apply To All") button1.Bind(wx.EVT_BUTTON, self.OnExpandMe) self._pnl.AddFoldPanelWindow(item, button1) # read back current gradients and set the sliders # for the colour which is now taken as default style = self._pnl.GetCaptionStyle(item) col = style.GetFirstColour() self._rslider1.SetValue(col.Red()) self._gslider1.SetValue(col.Green()) self._bslider1.SetValue(col.Blue()) col = style.GetSecondColour() self._rslider2.SetValue(col.Red()) self._gslider2.SetValue(col.Green()) self._bslider2.SetValue(col.Blue()) # put down some caption styles from which the user can # select to show how the current or all caption bars will look like item = self._pnl.AddFoldPanel("Caption Style", False, foldIcons=Images) self.ID_USE_VGRADIENT = wx.NewId() self.ID_USE_HGRADIENT = wx.NewId() self.ID_USE_SINGLE = wx.NewId() self.ID_USE_RECTANGLE = wx.NewId() self.ID_USE_FILLED_RECTANGLE = wx.NewId() currStyle = wx.RadioButton(item, self.ID_USE_VGRADIENT, "&Vertical Gradient") self._pnl.AddFoldPanelWindow(item, currStyle, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) currStyle.SetValue(True) radio1 = wx.RadioButton(item, self.ID_USE_HGRADIENT, "&Horizontal Gradient") radio2 = wx.RadioButton(item, self.ID_USE_SINGLE, "&Single Colour") radio3 = wx.RadioButton(item, self.ID_USE_RECTANGLE, "&Rectangle Box") radio4 = wx.RadioButton(item, self.ID_USE_FILLED_RECTANGLE, "&Filled Rectangle Box") currStyle.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio1.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio2.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio3.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio4.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) self._pnl.AddFoldPanelWindow(item, radio1, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio2, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio3, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio4, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelSeparator(item) self._single = wx.CheckBox(item, -1, "&Only This Caption") self._pnl.AddFoldPanelWindow(item, self._single, FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) # one more panel to finish it cs = CaptionBarStyle() cs.SetCaptionStyle(CAPTIONBAR_RECTANGLE) item = self._pnl.AddFoldPanel("Misc Stuff", collapsed=True, foldIcons=Images, cbstyle=cs) button2 = wx.Button(item, wx.NewId(), "Collapse All") self._pnl.AddFoldPanelWindow(item, button2) self._pnl.AddFoldPanelWindow( item, wx.StaticText(item, -1, "Enter Some Comments"), FPB_ALIGN_WIDTH, 5, 20) self._pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, -1, "Comments"), FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 10) button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe) self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4] self._leftWindow1.SizeWindows() def OnCreateBottomStyle(self, event): # recreate with style collapse to bottom, which means # all panels that are collapsed are placed at the bottom, # or normal if event.IsChecked(): self.GetMenuBar().Check(self._singlestyle, False) self.GetMenuBar().Check(self._exclusivestyle, False) self._flags = self._flags & ~FPB_SINGLE_FOLD self._flags = self._flags & ~FPB_EXCLUSIVE_FOLD self._flags = self._flags | FPB_COLLAPSE_TO_BOTTOM else: self._flags = self._flags & ~FPB_COLLAPSE_TO_BOTTOM self.ReCreateFoldPanel(self._flags) def OnCreateNormalStyle(self, event): # recreate with style where only one panel at the time is # allowed to be opened if event.IsChecked(): self.GetMenuBar().Check(self._bottomstyle, False) self.GetMenuBar().Check(self._exclusivestyle, False) self._flags = self._flags & ~FPB_EXCLUSIVE_FOLD self._flags = self._flags & ~FPB_COLLAPSE_TO_BOTTOM self._flags = self._flags | FPB_SINGLE_FOLD else: self._flags = self._flags & ~FPB_SINGLE_FOLD self.ReCreateFoldPanel(self._flags) def OnCreateExclusiveStyle(self, event): # recreate with style where only one panel at the time is # allowed to be opened and the others are collapsed to bottom if event.IsChecked(): self.GetMenuBar().Check(self._singlestyle, False) self.GetMenuBar().Check(self._bottomstyle, False) self._flags = self._flags & ~FPB_SINGLE_FOLD self._flags = self._flags & ~FPB_COLLAPSE_TO_BOTTOM self._flags = self._flags | FPB_EXCLUSIVE_FOLD else: self._flags = self._flags & ~FPB_EXCLUSIVE_FOLD self.ReCreateFoldPanel(self._flags) def OnCollapseMe(self, event): for i in range(0, self._pnl.GetCount()): item = self._pnl.GetFoldPanel(i) self._pnl.Collapse(item) def OnExpandMe(self, event): col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), self._bslider1.GetValue()) col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), self._bslider2.GetValue()) style = CaptionBarStyle() style.SetFirstColour(col1) style.SetSecondColour(col2) counter = 0 for items in self.radiocontrols: if items.GetValue(): break counter = counter + 1 if counter == 0: mystyle = CAPTIONBAR_GRADIENT_V elif counter == 1: mystyle = CAPTIONBAR_GRADIENT_H elif counter == 2: mystyle = CAPTIONBAR_SINGLE elif counter == 3: mystyle = CAPTIONBAR_RECTANGLE else: mystyle = CAPTIONBAR_FILLED_RECTANGLE style.SetCaptionStyle(mystyle) self._pnl.ApplyCaptionStyleAll(style) def OnSlideColour(self, event): col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), self._bslider1.GetValue()) col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), self._bslider2.GetValue()) style = CaptionBarStyle() counter = 0 for items in self.radiocontrols: if items.GetValue(): break counter = counter + 1 if counter == 0: mystyle = CAPTIONBAR_GRADIENT_V elif counter == 1: mystyle = CAPTIONBAR_GRADIENT_H elif counter == 2: mystyle = CAPTIONBAR_SINGLE elif counter == 3: mystyle = CAPTIONBAR_RECTANGLE else: mystyle = CAPTIONBAR_FILLED_RECTANGLE style.SetFirstColour(col1) style.SetSecondColour(col2) style.SetCaptionStyle(mystyle) item = self._pnl.GetFoldPanel(0) self._pnl.ApplyCaptionStyle(item, style) def OnStyleChange(self, event): style = CaptionBarStyle() eventid = event.GetId() if eventid == self.ID_USE_HGRADIENT: style.SetCaptionStyle(CAPTIONBAR_GRADIENT_H) elif eventid == self.ID_USE_VGRADIENT: style.SetCaptionStyle(CAPTIONBAR_GRADIENT_V) elif eventid == self.ID_USE_SINGLE: style.SetCaptionStyle(CAPTIONBAR_SINGLE) elif eventid == self.ID_USE_RECTANGLE: style.SetCaptionStyle(CAPTIONBAR_RECTANGLE) elif eventid == self.ID_USE_FILLED_RECTANGLE: style.SetCaptionStyle(CAPTIONBAR_FILLED_RECTANGLE) else: raise "ERROR: Undefined Style Selected For CaptionBar: " + repr( eventid) col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), self._bslider1.GetValue()) col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), self._bslider2.GetValue()) style.SetFirstColour(col1) style.SetSecondColour(col2) if self._single.GetValue(): item = self._pnl.GetFoldPanel(1) self._pnl.ApplyCaptionStyle(item, style) else: self._pnl.ApplyCaptionStyleAll(style) def CreateMenuBar(self, with_window=False): # Make a menubar file_menu = wx.Menu() FPBTEST_QUIT = wx.NewId() FPBTEST_REFRESH = wx.NewId() FPB_BOTTOM_FOLD = wx.NewId() FPB_SINGLE_FOLD = wx.NewId() FPB_EXCLUSIVE_FOLD = wx.NewId() FPBTEST_TOGGLE_WINDOW = wx.NewId() FPBTEST_ABOUT = wx.NewId() file_menu.Append(FPBTEST_QUIT, "&Exit") option_menu = None if with_window: # Dummy option option_menu = wx.Menu() option_menu.Append(FPBTEST_REFRESH, "&Refresh picture") # make fold panel menu fpb_menu = wx.Menu() fpb_menu.AppendCheckItem(FPB_BOTTOM_FOLD, "Create with &FPB_COLLAPSE_TO_BOTTOM") # Now Implemented! fpb_menu.AppendCheckItem(FPB_SINGLE_FOLD, "Create with &FPB_SINGLE_FOLD") # Now Implemented! fpb_menu.AppendCheckItem(FPB_EXCLUSIVE_FOLD, "Create with &FPB_EXCLUSIVE_FOLD") fpb_menu.AppendSeparator() fpb_menu.Append(FPBTEST_TOGGLE_WINDOW, "&Toggle FoldPanelBar") help_menu = wx.Menu() help_menu.Append(FPBTEST_ABOUT, "&About") menu_bar = wx.MenuBar() menu_bar.Append(file_menu, "&File") menu_bar.Append(fpb_menu, "&FoldPanel") if option_menu: menu_bar.Append(option_menu, "&Options") menu_bar.Append(help_menu, "&Help") self.Bind(wx.EVT_MENU, self.OnAbout, id=FPBTEST_ABOUT) self.Bind(wx.EVT_MENU, self.OnQuit, id=FPBTEST_QUIT) self.Bind(wx.EVT_MENU, self.OnToggleWindow, id=FPBTEST_TOGGLE_WINDOW) self.Bind(wx.EVT_MENU, self.OnCreateBottomStyle, id=FPB_BOTTOM_FOLD) self.Bind(wx.EVT_MENU, self.OnCreateNormalStyle, id=FPB_SINGLE_FOLD) self.Bind(wx.EVT_MENU, self.OnCreateExclusiveStyle, id=FPB_EXCLUSIVE_FOLD) self._bottomstyle = FPB_BOTTOM_FOLD self._singlestyle = FPB_SINGLE_FOLD self._exclusivestyle = FPB_EXCLUSIVE_FOLD return menu_bar
class ogreyLevelAttributesPanel(wx.Panel): def __init__(self, parent, window, resourceInformation, middle): wx.Panel.__init__(self, parent, -1, style=wx.FULL_REPAINT_ON_RESIZE) self.current = None self.Bind(wx.EVT_SIZE, self.OnSize) self.window = window self.resourceInformation = resourceInformation self.parent = parent self.middle = middle self.ogreView = None self.ogreScene = None self.selected = True def select(self, selected=True): self.selected = selected def showAttributes(self, type, object, options=None, item=None): self.current = [type, object, options, item] #self.foldPanel = FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, # self.GetSize(), style = wx.FULL_REPAINT_ON_RESIZE) if type == "EntityInstance": EntityInstanceAttributes(self, object, options, item) if type == "Entity": EntityAttributes(self, object, options, item) if not type == None: pass #Comments(self, object, options, item) #self.Show() def Show(self, type, object, options=None, item=None): self.current = [type, object, options, item] if self.selected == True: self.foldPanel = FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, self.GetSize(), style=wx.FULL_REPAINT_ON_RESIZE) if not self.current == None: self.showAttributes(self.current[0], self.current[1], self.current[2], self.current[3]) if not self.ogreView == None: EnviromentOptions(self, (self.ogreScene, self.ogreView), self.Level) def bindView(self, view): self.ogreView = view self.update() def bindScene(self, scene): self.ogreScene = scene self.update() def bindLevel(self, level): self.Level = level def OnSize(self, event): self.update() def clear(self): self.DestroyChildren() def update(self, event=None): self.clear() if not self.current == None: self.clear() self.Show(self.current[0], self.current[1], self.current[2], self.current[3]) #self.Show(n, self.current[1], self.current[2], self.current[3]) def showObjectAttributes(self, Attributes, name): column = (5, 105, 205) row = 22 pan = self.foldPanel.AddFoldPanel(name, False) r = 0 tulo = wx.Panel(pan, -1, style=wx.FULL_REPAINT_ON_RESIZE) for attrib in Attributes: c = 0 for rowItem in attrib: if rowItem["type"] == "text": obj = wx.TextCtrl(tulo, -1, "", style=rowItem["style"], pos=(column[c], row * r)) if not rowItem["attribs"] == None: obj.SetDefaultStyle(rowItem["attribs"]) obj.WriteText(rowItem["value"]) obj.SetEditable(rowItem["editable"]) if not rowItem["event"] == None: obj.Bind(wx.EVT_TEXT, rowItem["event"]) elif rowItem["type"] == "bitmapbutton": modelButton = wx.BitmapButton(tulo, -1, rowItem["image"], pos=(column[c], row * r)) modelButton.Bind(wx.EVT_BUTTON, rowItem["event"]) elif rowItem["type"] == "combobox": comboBox = wx.ComboBox(tulo, -1, pos=(column[c], row * r), choices=rowItem["value"], style=rowItem["style"], size=(self.GetSizeTuple()[0] - 8, -1)) comboBox.Bind(wx.EVT_COMBOBOX, rowItem["event"]) elif rowItem["type"] == "button": modelButton = wx.Button(tulo, -1, rowItem["value"], pos=(column[c], row * r)) modelButton.Bind(wx.EVT_BUTTON, rowItem["event"]) elif rowItem["type"] == "checkbox": checkbox = wx.CheckBox(tulo, -1, rowItem["value"], pos=(column[c] + 5, row * r)) checkbox.Bind(wx.EVT_CHECKBOX, rowItem["event"]) checkbox.SetValue(rowItem["state"]) elif rowItem["type"] == "slider": slider = wx.Slider(tulo, -1, value=rowItem["value"], minValue=rowItem["minValue"], maxValue=rowItem["maxValue"], style=rowItem["style"], pos=(column[c], row * r)) slider.Bind(wx.EVT_SLIDER, rowItem["event"]) elif rowItem["type"] == "panel": panel = wx.Panel(tulo, -1, pos=(column[c], row * r), size=rowItem["size"], style=rowItem["style"]) panel.SetBackgroundColour(rowItem["bgcolor"]) panel.Refresh(True, None) elif rowItem["type"] == "textctrl": self.text = wx.TextCtrl(tulo, -1, rowItem["value"], pos=(column[c], row * r), size=(self.GetSizeTuple()[0] - 8, rowItem["height"]), style=rowItem["style"]) self.text.Bind(wx.EVT_TEXT, rowItem["event"]) elif rowItem["type"] == "comment": text = wx.StaticText(tulo, -1, label=rowItem["label"], pos=(column[c], row * r)) elif rowItem["type"] == "empty": pass c += 1 r += 1 tulo.Fit() self.foldPanel.AddFoldPanelWindow(pan, tulo)
class ogreyOptionsPanel(wx.Panel): def __init__(self, parent, resourceInformation): wx.Panel.__init__(self, parent, -1, style=wx.FULL_REPAINT_ON_RESIZE, size=(242, parent.GetSizeTuple()[1])) self.parent = parent #self.window = window self.current = None self.Bind(wx.EVT_SIZE, self.OnSize) self.ogreView = None self.ogreScene = None self.resourceInformation = resourceInformation self.selected = True #self.GetSize() #self.Show() def Show(self): if self.selected == True: self.foldPanel = FoldPanelBar( self, wx.ID_ANY, wx.DefaultPosition, size=self.GetSize(), style=wx.FULL_REPAINT_ON_RESIZE) #( 242,1000) if not self.ogreView == None: Render(self, self.ogreView) ShadowOptions(self, self.ogreScene) if not self.ogreView == None: EnviromentOptions(self, (self.ogreScene, self.ogreView)) DefaultLight(self, self.ogreScene) Sky(self, self.ogreScene) def select(self, selected=True): self.selected = selected def update(self, event=None): self.DestroyChildren() self.Show() def OnSize(self, event): self.update() def bindView(self, view): self.ogreView = view self.update() def bindScene(self, scene): self.ogreScene = scene self.update() def showObjectAttributes(self, Attributes, name): column = (5, 105, 205) row = 22 pan = self.foldPanel.AddFoldPanel(name, True) r = 0 tulo = wx.Panel(pan, -1, style=wx.FULL_REPAINT_ON_RESIZE) for attrib in Attributes: c = 0 for rowItem in attrib: if rowItem["type"] == "text": obj = wx.TextCtrl(tulo, -1, "", style=rowItem["style"], pos=(column[c], row * r)) if not rowItem["attribs"] == None: obj.SetDefaultStyle(rowItem["attribs"]) obj.WriteText(rowItem["value"]) obj.SetEditable(rowItem["editable"]) if not rowItem["event"] == None: obj.Bind(wx.EVT_TEXT, rowItem["event"]) elif rowItem["type"] == "bitmapbutton": modelButton = wx.BitmapButton(tulo, -1, rowItem["image"], pos=(column[c], row * r)) modelButton.Bind(wx.EVT_BUTTON, rowItem["event"]) elif rowItem["type"] == "combobox": comboBox = wx.ComboBox(tulo, -1, pos=(column[c], row * r), choices=rowItem["value"], style=rowItem["style"], size=(self.GetSizeTuple()[0] - 8, -1)) comboBox.Bind(wx.EVT_COMBOBOX, rowItem["event"]) if not rowItem["selection"] == None: comboBox.SetStringSelection(rowItem["selection"]) elif rowItem["type"] == "comboboxstandard": comboBox = wx.ComboBox(tulo, -1, pos=(column[c], row * r), choices=rowItem["value"], style=rowItem["style"], size=(self.GetSizeTuple()[0] - 110, -1)) comboBox.Bind(wx.EVT_COMBOBOX, rowItem["event"]) if not rowItem["selection"] == None: comboBox.SetStringSelection(rowItem["selection"]) elif rowItem["type"] == "button": modelButton = wx.Button(tulo, -1, rowItem["value"], pos=(column[c], row * r)) modelButton.Bind(wx.EVT_BUTTON, rowItem["event"]) elif rowItem["type"] == "checkbox": checkbox = wx.CheckBox(tulo, -1, rowItem["value"], pos=(column[c] + 5, row * r)) checkbox.Bind(wx.EVT_CHECKBOX, rowItem["event"]) checkbox.SetValue(rowItem["state"]) elif rowItem["type"] == "slider": slider = wx.Slider(tulo, -1, value=rowItem["value"], minValue=rowItem["minValue"], maxValue=rowItem["maxValue"], style=rowItem["style"], pos=(column[c], row * r)) slider.Bind(wx.EVT_SLIDER, rowItem["event"]) elif rowItem["type"] == "panel": panel = wx.Panel(tulo, -1, pos=(column[c], row * r), size=rowItem["size"], style=rowItem["style"]) panel.SetBackgroundColour(rowItem["bgcolor"]) panel.Refresh(True, None) elif rowItem["type"] == "comment": text = wx.StaticText(tulo, -1, label=rowItem["label"], pos=(column[c], row * r)) elif rowItem["type"] == "radio": radio = wx.RadioButton(tulo, -1, rowItem["value"], pos=(column[c], row * r), style=rowItem["style"]) radio.Bind(wx.EVT_RADIOBUTTON, rowItem["event"]) radio.SetValue(rowItem["attribs"]) elif rowItem["type"] == "empty": pass c += 1 r += 1 tulo.Fit() self.foldPanel.AddFoldPanelWindow(pan, tulo)
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=(400, 300), style=wx.DEFAULT_FRAME_STYLE): wx.Frame.__init__(self, parent, id, title, pos, size, style) self.SetIcon(GetMondrianIcon()) self.SetMenuBar(self.CreateMenuBar()) self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) self.statusbar.SetStatusWidths([-4, -3]) self.statusbar.SetStatusText("Andrea Gavana @ 23 Mar 2005", 0) self.statusbar.SetStatusText("Welcome to wxPython!", 1) pnl = FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, FPB_DEFAULT_STYLE | FPB_VERTICAL) item = pnl.AddFoldPanel("Test Me", collapsed=False) button1 = wx.Button(item, wx.ID_ANY, "Collapse Me") pnl.AddFoldPanelWindow(item, button1, FPB_ALIGN_LEFT) pnl.AddFoldPanelSeparator(item) button1.Bind(wx.EVT_BUTTON, self.OnCollapseMe) item = pnl.AddFoldPanel("Test Me Too!", collapsed=True) button2 = wx.Button(item, wx.ID_ANY, "Expand First One") pnl.AddFoldPanelWindow(item, button2, FPB_ALIGN_LEFT) pnl.AddFoldPanelSeparator(item) button2.Bind(wx.EVT_BUTTON, self.OnExpandMe) newfoldpanel = FoldTestPanel(item, wx.ID_ANY) pnl.AddFoldPanelWindow(item, newfoldpanel) pnl.AddFoldPanelSeparator(item) pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), FPB_ALIGN_LEFT, FPB_DEFAULT_SPACING, 20) item = pnl.AddFoldPanel("Some Opinions ...", collapsed=False) pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "I Like This")) pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "And Also This")) pnl.AddFoldPanelWindow( item, wx.CheckBox(item, wx.ID_ANY, "And Gimme This Too")) pnl.AddFoldPanelSeparator(item) pnl.AddFoldPanelWindow( item, wx.CheckBox(item, wx.ID_ANY, "Check This Too If You Like")) pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "What About This")) item = pnl.AddFoldPanel("Choose One ...", collapsed=False) pnl.AddFoldPanelWindow( item, wx.StaticText(item, wx.ID_ANY, "Enter Your Comment")) pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 20, 20) self.pnl = pnl