def add_separator(self, height=None, pack={}, *a, **kw): if not height: height = self["height"] if self["height"]>1 else 16 bits = ("0x01,"*height)[:-1] imgdata = Toolbar.IMGDATA % locals() b = BitmapImage(data=imgdata, foreground="#555555", background="#BFBFBF") l = Label(self, image=b, *a, **kw) l.image = b l.pack(**utils.dictdefaults(pack, side=LEFT, padx=3, pady=2))
def add_button(self, text="Submit", image=None, command=None, pack={}, *a, **kw): """Add button with image or text, command, packing arguments (pack(...)) and *a, **kw for Button constructor """ if image: # FIXME: почему-то приходится два раза устанавливать image (чтобы ссылку сохранить?) img = PhotoImage(file=image) b = Button(self, image=img, command=command, *a, **kw) b.image = img else: b = Button(self, text=text, command=command, *a, **kw) b.pack(**utils.dictdefaults(pack, side=LEFT, padx=2, pady=2))
def pack(self, **kw): """панель размещает сама себя""" Frame.pack(self, **utils.dictdefaults(kw, side=TOP, expand=NO, anchor=N, fill=X))
def add_widget(self, w, pack={}): """Insert instantiated widget""" w.pack(**utils.dictdefaults(pack, side=LEFT, padx=6, pady=2))
def add_space(self, pack={}, *a, **kw): """Insert spacing""" d = Label(self, *a, **kw) d.pack(**utils.dictdefaults(pack, side=LEFT, padx=6, pady=2))
def add_check(self, text, var, command=None, pack={}, state=False, *a, **kw): """var - name (string) of Tk variable""" self.vars[var] = BooleanVar() self.vars[var].set(state) c = Checkbutton(self, text=text, variable=self.vars[var], command=command, *a, **kw) c.pack(**utils.dictdefaults(pack, side=LEFT, padx=2, pady=2))