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) self.statusbar.SetStatusWidths([-4, -3]) self.statusbar.SetStatusText("Andrea Gavana @ 23 Mar 2005", 0) self.statusbar.SetStatusText("Welcome to wxPython!", 1) pnl = fpb.FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, agwStyle=fpb.FPB_VERTICAL) item = pnl.AddFoldPanel("Test Me", collapsed=False) button1 = wx.Button(item, wx.ID_ANY, "Collapse Me") pnl.AddFoldPanelWindow(item, button1, fpb.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.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.FPB_ALIGN_LEFT, fpb.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.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 20, 20) self.pnl = pnl
def CreateFoldBar(self, vertical=True): if vertical: self.SetSize((500, 600)) else: self.SetSize((700, 300)) newstyle = (vertical and [fpb.FPB_VERTICAL] or [fpb.FPB_HORIZONTAL])[0] bar = fpb.FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, agwStyle=fpb.FPB_COLLAPSE_TO_BOTTOM | newstyle) 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.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.FPB_ALIGN_LEFT, fpb.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.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 20) if hasattr(self, "pnl"): self.pnl.Destroy() self.pnl = bar size = self.GetClientSize() self.pnl.SetSize(0, 0, size.GetWidth(), size.GetHeight())
def ReCreateFoldPanel(self, fpb_flags): # delete earlier panel self._leftWindow1.DestroyChildren() # recreate the foldpanelbar self._pnl = fpb.FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition, wx.Size(-1, -1), agwStyle=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.FPB_ALIGN_WIDTH, 5, 20) # RED colour spin control self._rslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider1, fpb.FPB_ALIGN_WIDTH, 2, 20) # GREEN colour spin control self._gslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider1, fpb.FPB_ALIGN_WIDTH, 0, 20) # BLUE colour spin control self._bslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider1, fpb.FPB_ALIGN_WIDTH, 0, 20) self._pnl.AddFoldPanelSeparator(item) self._pnl.AddFoldPanelWindow( item, wx.StaticText(item, -1, "Adjust The Second Colour"), fpb.FPB_ALIGN_WIDTH, 5, 20) # RED colour spin control self._rslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider2, fpb.FPB_ALIGN_WIDTH, 2, 20) # GREEN colour spin control self._gslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider2, fpb.FPB_ALIGN_WIDTH, 0, 20) # BLUE colour spin control self._bslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider2, fpb.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.FPB_ALIGN_WIDTH, fpb.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.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio2, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio3, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio4, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelSeparator(item) self._single = wx.CheckBox(item, -1, "&Only This Caption") self._pnl.AddFoldPanelWindow(item, self._single, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) # one more panel to finish it cs = fpb.CaptionBarStyle() cs.SetCaptionStyle(fpb.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.FPB_ALIGN_WIDTH, 5, 20) self._pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, -1, "Comments"), fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe) self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4] self._leftWindow1.SizeWindows()