python - wxPython: A foldable panel widget -
I have my main program window, and I would like to create a foldable panel. What do I mean, a panel that is connected to any part of the window, in which open one fold / button. It is important that when the panel becomes multiplied / exposed, other widgets change their shape according to them so that they can take advantage of their location.
How do I do this?
This is a way using wx.SplitterWindow
Import wx, wx.calendar class FoldableWindowContainer (wx.Panel): Def __init __ (self, parent, left, right): wx.Panel.__init __ (self, parent) size scale = wx.BoxSizer ( Wx.HORIZONTAL) self.SetSizer (size measurement) self.splitter = wx.SplitterWindow (self, style = wx.SP_LIVE_UPDATE) left.Reparent (self.splitter) right.Reparent (self.splitter) self.left = left self. Right = true self.splitter.SplitVertically (self.left, self.right) self.splitter.SetMinimumPaneSize (50) self.sash_pos = self.splitter.SashPosition sizer.Add (self.splitter, 1, wx.EXPAND) fold_button = Wx.Button (auto, size = (10, -1)) fold_button.Bind (wx. EVT_BUTTON, self.On_FoldToggle) sizer.Add (fold_button, 0, wx.EXPAND) On_FoldToggle def (self, event): if self.splitter.IsSplit (): self.sal_swap_self.splitter.SashPositionself.splitter Unsplit () and: self.splitter.SplitVertically (self.left, self.right, self.sash_pos) square FoldTest (wx.Frame): def __init __ (self): wx.frame .__ init __ (self, none ) Left = wx .Panel (auto, style = wx.bordER_SUNKEN) correct = wx.panel (auto, style = wx.bordER_sUNKEN) left_sizer = wx.boxx (wx.VERTICAL) left.SetSizer (left_sizer) left_sizer.Add ( Wx.calendar.CalendarCtrl (left), 1, wx.EXPAND | wx.ALL, 5) left_sizer.Add (wx.Button (left, label = "ACT"), 0, wx.EXPAND | wx.ALL, 5) Right_sizer = wx.BoxSizer (wx.VERTICAL) right.SetSizer (right_sizer) Right_sizer.Add (wx.StaticText (right, label = "fold panel", style = wx.BORDER_RAISED), 1, wx.EXPAND | wx.ALL, 5) FoldableWindowContainer (self, left, right) app = wx.PySimpleApp () app. Topwando = Foldtest () app OpenDown Show () app Main Loop () Also check the wx.CollapsiblePane in the wxPython demo.
Comments
Post a Comment