def update(self, side=tk.TOP, expand=tk.FALSE): PackInfoFrame.update(self, side=side, expand=expand) self.lbl.config(text='expand={}'.format(str(expand))) if side in (tk.TOP, tk.BOTTOM): key = 'height' fill = tk.X innerFrameArgs = { 'width': self.width/4, 'height': cfg.PACKINFO.DUMMY_SIZE } else: key = 'width' fill = tk.Y innerFrameArgs = { 'width': cfg.PACKINFO.DUMMY_SIZE, 'height': self.height/4 } size = {key: cfg.PACKINFO.DUMMY_SIZE} frmBefore = tk.Frame(self.frm, bg=cfg.COLORS.DUMMY_FRAME, **size) frmBefore.pack(side=side, fill=fill) self._viewsToRemove.append(frmBefore) frmPacked = tk.Frame(self.frm, bg=cfg.COLORS.DUMMY_BACKGROUND, **size) frmPacked.pack(side=side, fill=tk.BOTH, expand=expand) frmPacked.pack_propagate(0) self._viewsToRemove.append(frmPacked) frmExpanded = tk.Frame(frmPacked, bg=cfg.COLORS.ACTIVE_VIEW, **innerFrameArgs) frmExpanded.pack(side=side, expand=expand) self._viewsToRemove.append(frmExpanded)
def update(self, side=tk.TOP): PackInfoFrame.update(self, side=side) self.lbl.config(text='side={}'.format(side.upper())) if side in (tk.TOP, tk.BOTTOM): innerSize = { 'height': cfg.PACKINFO.DUMMY_SIZE, 'width': self.width/4, } size = {'height': cfg.PACKINFO.DUMMY_SIZE} fill = tk.X axis = ArrowCanvas.Y else: innerSize = { 'width': cfg.PACKINFO.DUMMY_SIZE, 'height': self.height/4, } size = {'width': cfg.PACKINFO.DUMMY_SIZE} fill = tk.Y axis = ArrowCanvas.X flip = side in (tk.BOTTOM, tk.RIGHT) frmBefore = tk.Frame(self.frm, bg=cfg.COLORS.DUMMY_FRAME, **size) frmBefore.pack(side=side, fill=fill) self._viewsToRemove.append(frmBefore) frmPacked = tk.Frame(self.frm, bg=cfg.COLORS.ACTIVE_VIEW, **innerSize) frmPacked.pack(side=side) self._viewsToRemove.append(frmPacked) cvsArrow = ArrowCanvas(self.frm, axis, flip=flip) cvsArrow.pack(side=side) self._viewsToRemove.append(cvsArrow)
def __init__(self, master, bd=0, col='black', **kwargs): ''' Create a new instance of the BorderedFrame class. @param tk.Widget $master The tk widget to create the BorderedFrame in. @param int $bd [optional] The border width. Defaults to 0. @param str $col [optional] The border color. Defaults to black. ''' tk.Frame.__init__( self, master, bd=bd, bg=col, **{k: v for k, v in kwargs.iteritems() if k not in ('bd', 'bg')}) self.inner = tk.Frame(self, **kwargs) self.inner.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.TRUE)
def __init__(self, master, *args, **kwargs): ''' Create a new instance of the TkVisualiser class. @param tk.Widget $master The tk widget to create the TkVisualiser in. ''' tk.Toplevel.__init__(self, master, *args, **kwargs) #### Change window settings self.title('TK Visualiser') self.protocol('WM_DELETE_WINDOW', self.exit) #### Set up the window ## Left Right ## ## [listbox] ## [listbox] [labels] ## [side] [anchor] [pack details] ## [fill] [expand] ## #### Left frmLeft = tk.Frame(self) frmLeft.pack(side=tk.LEFT, expand=tk.TRUE, fill=tk.BOTH) ## Widget Listbox self.lbxWidgets = tk.Listbox(frmLeft, font=cfg.LISTBOX_FONT) self.lbxWidgets.pack(side=tk.TOP, expand=tk.TRUE, fill=tk.BOTH) self.lbxWidgets.bind('<<ListboxSelect>>', self.lbxWidgetsSelectionChanged) ## Problems Listbox tk.Label(frmLeft, text='Errors/Warnings for Selected Widget:')\ .pack(side=tk.TOP, pady=(10, 0)) self.lbxProblems = tk.Listbox(frmLeft, height=5) self.lbxProblems.pack(side=tk.TOP, fill=tk.X) ## Pack Args frmPackArgs = tk.Frame(frmLeft) frmPackArgs.pack(side=tk.TOP) # Side and Anchor frmTop = tk.Frame(frmPackArgs) frmTop.pack(side=tk.TOP) self.frmSide = SideFrame(frmTop) self.frmSide.pack(side=tk.LEFT, padx=10, pady=10) self.frmAnchor = AnchorFrame(frmTop) self.frmAnchor.pack(side=tk.LEFT, padx=10, pady=10) # Fill and Expand frmBottom = tk.Frame(frmPackArgs) frmBottom.pack(side=tk.TOP) self.frmFill = FillFrame(frmBottom) self.frmFill.pack(side=tk.LEFT, padx=10, pady=10) self.frmExpand = ExpandFrame(frmBottom) self.frmExpand.pack(side=tk.LEFT, padx=10, pady=10) #### Right frmRight = tk.Frame(self) frmRight.pack(side=tk.LEFT) ## Labels tk.Label(frmRight, text='Selected Widget: {}'.format( cfg.COLORS.ACTIVE_VIEW)).pack(side=tk.TOP) tk.Label(frmRight, text='Parent Widget: {}'.format( cfg.COLORS.PARENT_VIEW)).pack(side=tk.TOP) tk.Label(frmRight, text='Reserved Space: {}'.format( cfg.COLORS.RESERVED_SPACE)).pack(side=tk.TOP) ## Canvas self.cvsPackLayout = PackLayoutCanvas(frmRight) self.cvsPackLayout.pack(side=tk.TOP) #### Set up local vars self._selection = None, None # widget, bg self._selectionParent = None, None