def __init__(self, master=None, **kw): apply(PatternFrame.__init__, (self, master), kw) label = Label(self, text = _("Color")) label.pack(side = LEFT, expand = 1, anchor = E) self.color_but = ColorButton(self, width = 3, height = 1, command = self.set_color) self.color_but.pack(side = LEFT, expand = 1, anchor = W) self.SetPattern(SolidPattern(StandardColors.black))
def create_widgets(self, frame, idx, set_active_layer, rename, set_layer_state, set_color, context_menu): self.index.SetValue(idx) idx = (self.index,) self.button = UpdatedRadiobutton(frame, anchor = W, value = idx, width = 10, variable = self.active_var, command = set_active_layer) self.button.bind('<ButtonPress-3>', context_menu) self.button.bind('<ButtonPress-2>', rename) self.button.bind('<Double-Button-1>', rename) self.var_visible = IntVar(frame) self.visible = UpdatedCheckbutton(frame, variable = self.var_visible, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.var_printable = IntVar(frame) self.printable = UpdatedCheckbutton(frame, variable = self.var_printable, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.var_locked = IntVar(frame) self.locked = UpdatedCheckbutton(frame, variable = self.var_locked, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.var_outlined = IntVar(frame) self.outlined = UpdatedCheckbutton(frame, variable = self.var_outlined, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.color = ColorButton(frame, command = set_color, args = idx, width = 2, dialog_master = frame.master.master.master.master)
def create_widgets(self, frame, idx, set_active_layer, rename, set_layer_state, set_color, context_menu): self.index.SetValue(idx) idx = (self.index, ) self.button = UpdatedRadiobutton(frame, anchor=W, value=idx, width=10, variable=self.active_var, command=set_active_layer) self.button.bind('<ButtonPress-3>', context_menu) self.button.bind('<ButtonPress-2>', rename) self.button.bind('<Double-Button-1>', rename) self.var_visible = IntVar(frame) self.visible = UpdatedCheckbutton(frame, variable=self.var_visible, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.var_printable = IntVar(frame) self.printable = UpdatedCheckbutton(frame, variable=self.var_printable, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.var_locked = IntVar(frame) self.locked = UpdatedCheckbutton(frame, variable=self.var_locked, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.var_outlined = IntVar(frame) self.outlined = UpdatedCheckbutton(frame, variable=self.var_outlined, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.color = ColorButton( frame, command=set_color, args=idx, width=2, dialog_master=frame.master.master.master.master)
def __init__(self, master=None, **kw): apply(PatternFrame.__init__, (self, master), kw) gradient = CreateSimpleGradient(StandardColors.white, StandardColors.black) frame = Frame(self) frame.pack(side = TOP, fill = X) self.var_gradient_type = IntVar(self) for value, bitmap in [(0, 'linear'), (1, 'conical'), (2, 'radial')]: bitmap = getattr(pixmaps, 'gradient_' + bitmap) button = make_button(frame, bitmap = bitmap, value = value, variable = self.var_gradient_type, command = self.choose_type) button.pack(side = LEFT, fill = X, expand = 1) frame = Frame(self) frame.pack(side = TOP, expand = 1, fill = X) self.colors = [None, None] self.colors[0] = ColorButton(frame, height = 1, color = gradient.StartColor(), command = self.set_color, args = 0) self.colors[0].pack(side = LEFT, fill = X, expand = 1) self.colors[1] = ColorButton(frame, height = 1, color = gradient.EndColor(), command = self.set_color, args = 1) self.colors[1].pack(side = LEFT, fill = X, expand = 1) self.var_border = DoubleVar(self) self.var_border.set(0.0) frame = Frame(self) frame.pack(side = TOP, fill = X, expand = 1) label = Label(frame, text = _("Border")) label.pack(side = LEFT, expand = 1, anchor = E) entry = MyEntry(frame, textvariable = self.var_border, width = 4, justify = RIGHT, command = self.set_border) entry.pack(side = LEFT, expand = 1, fill = X) scroll = MiniScroller(frame, variable = self.var_border, min = 0.0, max = 100.0, step = 1.0, command = self.set_border) scroll.pack(side = LEFT, fill = Y) button = UpdatedButton(self, text = _("Edit Gradient"), command = self.edit_gradient) button.pack(side = TOP, fill = X) pattern = LinearGradient(gradient) self.SetPattern(pattern)
class SolidPatternFrame(PatternFrame): def __init__(self, master=None, **kw): apply(PatternFrame.__init__, (self, master), kw) label = Label(self, text = _("Color")) label.pack(side = LEFT, expand = 1, anchor = E) self.color_but = ColorButton(self, width = 3, height = 1, command = self.set_color) self.color_but.pack(side = LEFT, expand = 1, anchor = W) self.SetPattern(SolidPattern(StandardColors.black)) def set_color(self): self.pattern = SolidPattern(self.__get_color()) self.issue(CHANGED) def __get_color(self): return self.color_but.Color() def SetPattern(self, pattern): PatternFrame.SetPattern(self, pattern) self.color_but.SetColor(pattern.Color())
def __init__(self, master=None, **kw): apply(PatternFrame.__init__, (self, master), kw) frame = Frame(self) frame.pack(side = TOP, fill = X, expand = 1) self.colors = [None, None] self.colors[0] = ColorButton(frame, height = 1, command = self.set_color, args = 0) self.colors[0].pack(side = LEFT, fill = X, expand = 1) self.colors[1] = ColorButton(frame, height = 1, command = self.set_color, args = 1) self.colors[1].pack(side = LEFT, fill = X, expand = 1) var_spacing_number = DoubleVar(self) var_unit = StringVar(self) self.var_spacing = LengthVar(1.0, config.preferences.default_unit, var_spacing_number, var_unit, command = self.set_spacing) width_frame = Frame(self) width_frame.pack(side = TOP, fill = X, expand = 1) #label = Label(width_frame, text = 'Spacing') #label.pack(side = LEFT, expand = 1, anchor = E) entry = MyEntry(width_frame, textvariable = var_spacing_number, justify = RIGHT, width = 6, command = self.var_spacing.UpdateNumber) entry.pack(side = LEFT, expand = 1, fill = X) scroll = MiniScroller(width_frame, variable = var_spacing_number, min = 0.0, max = None, step = 1.0, command = self.var_spacing.UpdateNumber) scroll.pack(side = LEFT, fill = Y) optmenu = create_unit_menu(width_frame, self.var_spacing.UpdateUnit, variable = var_unit, indicatoron = 0, width = 3) optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W) self.SetPattern(HatchingPattern(StandardColors.red))
def build_dlg(self): top = self.top button_frame = self.create_std_buttons(top) button_frame.grid(row=5, columnspan=2, sticky='ew') color_frame = Frame(top, relief=GROOVE, bd=2) color_frame.grid(row=0, columnspan=2, sticky='ew') label = Label(color_frame, text=_("Color")) label.pack(side=LEFT, expand=1, anchor=E) self.color_but = ColorButton(color_frame, width=3, height=1, command=self.set_line_color) self.color_but.SetColor(StandardColors.black) self.color_but.pack(side=LEFT, expand=1, anchor=W) self.var_color_none = IntVar(top) check = UpdatedCheckbutton(color_frame, text=_("None"), variable=self.var_color_none, command=self.do_apply) check.pack(side=LEFT, expand=1) width_frame = Frame(top, relief=GROOVE, bd=2) width_frame.grid(row=1, columnspan=2, sticky='ew') label = Label(width_frame, text=_("Width")) label.pack(side=LEFT, expand=1, anchor=E) self.var_width = create_length_entry(top, width_frame, self.set_line_width, scroll_pad=0) tkwin = self.main_window.canvas.tkwin gc, bitmap, dashlist = create_dash_images(self.top.tk, tkwin, StandardDashes()) self.opt_dash = MyOptionMenu2(top, dashlist, command=self.set_dash, entry_type='image', highlightthickness=0) self.opt_dash.grid(row=2, columnspan=2, sticky='ew', ipady=2) self.dash_gc = gc self.dash_bitmap = bitmap gc, bitmap, arrow1, arrow2 = create_arrow_images( self.top.tk, tkwin, StandardArrows()) self.opt_arrow1 = MyOptionMenu2(top, arrow1, command=self.set_arrow, args=1, entry_type='image', highlightthickness=0) self.opt_arrow1.grid(row=3, column=0, sticky='ew', ipady=2) self.opt_arrow2 = MyOptionMenu2(top, arrow2, command=self.set_arrow, args=2, entry_type='image', highlightthickness=0) self.opt_arrow2.grid(row=3, column=1, sticky='ew', ipady=2) self.arrow_gc = gc self.arrow_bitmap = bitmap self.opt_join = MyOptionMenu2(top, [(pixmaps.JoinMiter, JoinMiter), (pixmaps.JoinRound, JoinRound), (pixmaps.JoinBevel, JoinBevel)], command=self.set_line_join, entry_type='bitmap', highlightthickness=0) self.opt_join.grid(row=4, column=0, sticky='ew') self.opt_cap = MyOptionMenu2(top, [(pixmaps.CapButt, CapButt), (pixmaps.CapRound, CapRound), (pixmaps.CapProjecting, CapProjecting)], command=self.set_line_cap, entry_type='bitmap', highlightthickness=0) self.opt_cap.grid(row=4, column=1, sticky='ew') self.opt_cap.SetValue(None)
class LinePanel(StylePropertyPanel): title = _("Line Style") def __init__(self, master, main_window, doc): StylePropertyPanel.__init__(self, master, main_window, doc, name='linedlg') def build_dlg(self): top = self.top button_frame = self.create_std_buttons(top) button_frame.grid(row=5, columnspan=2, sticky='ew') color_frame = Frame(top, relief=GROOVE, bd=2) color_frame.grid(row=0, columnspan=2, sticky='ew') label = Label(color_frame, text=_("Color")) label.pack(side=LEFT, expand=1, anchor=E) self.color_but = ColorButton(color_frame, width=3, height=1, command=self.set_line_color) self.color_but.SetColor(StandardColors.black) self.color_but.pack(side=LEFT, expand=1, anchor=W) self.var_color_none = IntVar(top) check = UpdatedCheckbutton(color_frame, text=_("None"), variable=self.var_color_none, command=self.do_apply) check.pack(side=LEFT, expand=1) width_frame = Frame(top, relief=GROOVE, bd=2) width_frame.grid(row=1, columnspan=2, sticky='ew') label = Label(width_frame, text=_("Width")) label.pack(side=LEFT, expand=1, anchor=E) self.var_width = create_length_entry(top, width_frame, self.set_line_width, scroll_pad=0) tkwin = self.main_window.canvas.tkwin gc, bitmap, dashlist = create_dash_images(self.top.tk, tkwin, StandardDashes()) self.opt_dash = MyOptionMenu2(top, dashlist, command=self.set_dash, entry_type='image', highlightthickness=0) self.opt_dash.grid(row=2, columnspan=2, sticky='ew', ipady=2) self.dash_gc = gc self.dash_bitmap = bitmap gc, bitmap, arrow1, arrow2 = create_arrow_images( self.top.tk, tkwin, StandardArrows()) self.opt_arrow1 = MyOptionMenu2(top, arrow1, command=self.set_arrow, args=1, entry_type='image', highlightthickness=0) self.opt_arrow1.grid(row=3, column=0, sticky='ew', ipady=2) self.opt_arrow2 = MyOptionMenu2(top, arrow2, command=self.set_arrow, args=2, entry_type='image', highlightthickness=0) self.opt_arrow2.grid(row=3, column=1, sticky='ew', ipady=2) self.arrow_gc = gc self.arrow_bitmap = bitmap self.opt_join = MyOptionMenu2(top, [(pixmaps.JoinMiter, JoinMiter), (pixmaps.JoinRound, JoinRound), (pixmaps.JoinBevel, JoinBevel)], command=self.set_line_join, entry_type='bitmap', highlightthickness=0) self.opt_join.grid(row=4, column=0, sticky='ew') self.opt_cap = MyOptionMenu2(top, [(pixmaps.CapButt, CapButt), (pixmaps.CapRound, CapRound), (pixmaps.CapProjecting, CapProjecting)], command=self.set_line_cap, entry_type='bitmap', highlightthickness=0) self.opt_cap.grid(row=4, column=1, sticky='ew') self.opt_cap.SetValue(None) def close_dlg(self): StylePropertyPanel.close_dlg(self) self.var_width = None def init_from_style(self, style): if style.HasLine(): self.var_color_none.set(0) self.opt_join.SetValue(style.line_join) self.opt_cap.SetValue(style.line_cap) self.color_but.SetColor(style.line_pattern.Color()) self.var_width.set(style.line_width) self.init_dash(style) self.init_arrow(style) else: self.var_color_none.set(1) def init_from_doc(self): self.Update() def Update(self): if self.document.HasSelection(): properties = self.document.CurrentProperties() self.init_from_style(properties) def do_apply(self): kw = {} if not self.var_color_none.get(): color = self.color_but.Color() kw["line_pattern"] = SolidPattern(color) kw["line_width"] = self.var_width.get() kw["line_join"] = self.opt_join.GetValue() kw["line_cap"] = self.opt_cap.GetValue() kw["line_dashes"] = self.opt_dash.GetValue() kw["line_arrow1"] = self.opt_arrow1.GetValue() kw["line_arrow2"] = self.opt_arrow2.GetValue() else: kw["line_pattern"] = EmptyPattern self.set_properties(_("Set Outline"), 'line', kw) def set_line_join(self, *args): self.document.SetProperties(line_join=self.opt_join.GetValue(), if_type_present=1) def set_line_cap(self, *args): self.document.SetProperties(line_cap=self.opt_cap.GetValue(), if_type_present=1) def set_line_color(self): self.document.SetLineColor(self.color_but.Color()) def set_line_width(self, *rest): self.document.SetProperties(line_width=self.var_width.get(), if_type_present=1) def set_dash(self, *args): self.document.SetProperties(line_dashes=self.opt_dash.GetValue(), if_type_present=1) def init_dash(self, style): dashes = style.line_dashes draw_dash_bitmap(self.dash_gc, dashes) dash_image = create_bitmap_image(self.top.tk, 'dash_image', self.dash_bitmap) self.opt_dash.SetValue(dashes, dash_image) def set_arrow(self, arrow, which): if which == 1: self.document.SetProperties(line_arrow1=arrow, if_type_present=1) else: self.document.SetProperties(line_arrow2=arrow, if_type_present=1) def init_arrow(self, style): arrow = style.line_arrow1 draw_arrow_bitmap(self.arrow_gc, arrow, 1) arrow_image = create_bitmap_image(self.top.tk, 'arrow1_image', self.arrow_bitmap) self.opt_arrow1.SetValue(arrow, arrow_image) arrow = style.line_arrow2 draw_arrow_bitmap(self.arrow_gc, arrow, 2) arrow_image = create_bitmap_image(self.top.tk, 'arrow2_image', self.arrow_bitmap) self.opt_arrow2.SetValue(arrow, arrow_image) def update_from_object_cb(self, obj): if obj is not None: self.init_from_style(obj.Properties())
def build_dlg(self): top = self.top button_frame = self.create_std_buttons(top) button_frame.grid(row = 5, columnspan = 2, sticky = 'ew') color_frame = Frame(top, relief = GROOVE, bd = 2) color_frame.grid(row = 0, columnspan = 2, sticky = 'ew') label = Label(color_frame, text = _("Color")) label.pack(side = LEFT, expand = 1, anchor = E) self.color_but = ColorButton(color_frame, width = 3, height = 1, command = self.set_line_color) self.color_but.SetColor(StandardColors.black) self.color_but.pack(side = LEFT, expand = 1, anchor = W) self.var_color_none = IntVar(top) check = UpdatedCheckbutton(color_frame, text = _("None"), variable = self.var_color_none, command = self.do_apply) check.pack(side = LEFT, expand = 1) width_frame = Frame(top, relief = GROOVE, bd = 2) width_frame.grid(row = 1, columnspan = 2, sticky = 'ew') label = Label(width_frame, text = _("Width")) label.pack(side = LEFT, expand = 1, anchor = E) self.var_width = create_length_entry(top, width_frame, self.set_line_width, scroll_pad = 0) tkwin = self.main_window.canvas.tkwin gc, bitmap, dashlist = create_dash_images(self.top.tk, tkwin, StandardDashes()) self.opt_dash = MyOptionMenu2(top, dashlist, command = self.set_dash, entry_type = 'image', highlightthickness = 0) self.opt_dash.grid(row = 2, columnspan = 2, sticky = 'ew', ipady = 2) self.dash_gc = gc self.dash_bitmap = bitmap gc, bitmap, arrow1, arrow2 = create_arrow_images(self.top.tk, tkwin, StandardArrows()) self.opt_arrow1 = MyOptionMenu2(top, arrow1, command = self.set_arrow, args = 1, entry_type = 'image', highlightthickness = 0) self.opt_arrow1.grid(row = 3, column = 0, sticky = 'ew', ipady = 2) self.opt_arrow2 = MyOptionMenu2(top, arrow2, command = self.set_arrow, args = 2, entry_type = 'image', highlightthickness = 0) self.opt_arrow2.grid(row = 3, column = 1, sticky = 'ew', ipady = 2) self.arrow_gc = gc self.arrow_bitmap = bitmap self.opt_join = MyOptionMenu2(top, [(pixmaps.JoinMiter, JoinMiter), (pixmaps.JoinRound, JoinRound), (pixmaps.JoinBevel, JoinBevel)], command = self.set_line_join, entry_type = 'bitmap', highlightthickness = 0) self.opt_join.grid(row = 4, column = 0, sticky = 'ew') self.opt_cap = MyOptionMenu2(top, [(pixmaps.CapButt, CapButt), (pixmaps.CapRound, CapRound), (pixmaps.CapProjecting, CapProjecting)], command = self.set_line_cap, entry_type = 'bitmap', highlightthickness = 0) self.opt_cap.grid(row = 4, column = 1, sticky = 'ew') self.opt_cap.SetValue(None)
class LinePanel(StylePropertyPanel): title = _("Line Style") def __init__(self, master, main_window, doc): StylePropertyPanel.__init__(self, master, main_window, doc, name = 'linedlg') def build_dlg(self): top = self.top button_frame = self.create_std_buttons(top) button_frame.grid(row = 5, columnspan = 2, sticky = 'ew') color_frame = Frame(top, relief = GROOVE, bd = 2) color_frame.grid(row = 0, columnspan = 2, sticky = 'ew') label = Label(color_frame, text = _("Color")) label.pack(side = LEFT, expand = 1, anchor = E) self.color_but = ColorButton(color_frame, width = 3, height = 1, command = self.set_line_color) self.color_but.SetColor(StandardColors.black) self.color_but.pack(side = LEFT, expand = 1, anchor = W) self.var_color_none = IntVar(top) check = UpdatedCheckbutton(color_frame, text = _("None"), variable = self.var_color_none, command = self.do_apply) check.pack(side = LEFT, expand = 1) width_frame = Frame(top, relief = GROOVE, bd = 2) width_frame.grid(row = 1, columnspan = 2, sticky = 'ew') label = Label(width_frame, text = _("Width")) label.pack(side = LEFT, expand = 1, anchor = E) self.var_width = create_length_entry(top, width_frame, self.set_line_width, scroll_pad = 0) tkwin = self.main_window.canvas.tkwin gc, bitmap, dashlist = create_dash_images(self.top.tk, tkwin, StandardDashes()) self.opt_dash = MyOptionMenu2(top, dashlist, command = self.set_dash, entry_type = 'image', highlightthickness = 0) self.opt_dash.grid(row = 2, columnspan = 2, sticky = 'ew', ipady = 2) self.dash_gc = gc self.dash_bitmap = bitmap gc, bitmap, arrow1, arrow2 = create_arrow_images(self.top.tk, tkwin, StandardArrows()) self.opt_arrow1 = MyOptionMenu2(top, arrow1, command = self.set_arrow, args = 1, entry_type = 'image', highlightthickness = 0) self.opt_arrow1.grid(row = 3, column = 0, sticky = 'ew', ipady = 2) self.opt_arrow2 = MyOptionMenu2(top, arrow2, command = self.set_arrow, args = 2, entry_type = 'image', highlightthickness = 0) self.opt_arrow2.grid(row = 3, column = 1, sticky = 'ew', ipady = 2) self.arrow_gc = gc self.arrow_bitmap = bitmap self.opt_join = MyOptionMenu2(top, [(pixmaps.JoinMiter, JoinMiter), (pixmaps.JoinRound, JoinRound), (pixmaps.JoinBevel, JoinBevel)], command = self.set_line_join, entry_type = 'bitmap', highlightthickness = 0) self.opt_join.grid(row = 4, column = 0, sticky = 'ew') self.opt_cap = MyOptionMenu2(top, [(pixmaps.CapButt, CapButt), (pixmaps.CapRound, CapRound), (pixmaps.CapProjecting, CapProjecting)], command = self.set_line_cap, entry_type = 'bitmap', highlightthickness = 0) self.opt_cap.grid(row = 4, column = 1, sticky = 'ew') self.opt_cap.SetValue(None) def close_dlg(self): StylePropertyPanel.close_dlg(self) self.var_width = None def init_from_style(self, style): if style.HasLine(): self.var_color_none.set(0) self.opt_join.SetValue(style.line_join) self.opt_cap.SetValue(style.line_cap) self.color_but.SetColor(style.line_pattern.Color()) self.var_width.set(style.line_width) self.init_dash(style) self.init_arrow(style) else: self.var_color_none.set(1) def init_from_doc(self): self.Update() def Update(self): if self.document.HasSelection(): properties = self.document.CurrentProperties() self.init_from_style(properties) def do_apply(self): kw = {} if not self.var_color_none.get(): color = self.color_but.Color() kw["line_pattern"] = SolidPattern(color) kw["line_width"] = self.var_width.get() kw["line_join"] = self.opt_join.GetValue() kw["line_cap"] = self.opt_cap.GetValue() kw["line_dashes"] = self.opt_dash.GetValue() kw["line_arrow1"] = self.opt_arrow1.GetValue() kw["line_arrow2"] = self.opt_arrow2.GetValue() else: kw["line_pattern"] = EmptyPattern self.set_properties(_("Set Outline"), 'line', kw) def set_line_join(self, *args): self.document.SetProperties(line_join = self.opt_join.GetValue(), if_type_present = 1) def set_line_cap(self, *args): self.document.SetProperties(line_cap = self.opt_cap.GetValue(), if_type_present = 1) def set_line_color(self): self.document.SetLineColor(self.color_but.Color()) def set_line_width(self, *rest): self.document.SetProperties(line_width = self.var_width.get(), if_type_present = 1) def set_dash(self, *args): self.document.SetProperties(line_dashes = self.opt_dash.GetValue(), if_type_present = 1) def init_dash(self, style): dashes = style.line_dashes draw_dash_bitmap(self.dash_gc, dashes) dash_image = create_bitmap_image(self.top.tk, 'dash_image', self.dash_bitmap) self.opt_dash.SetValue(dashes, dash_image) def set_arrow(self, arrow, which): if which == 1: self.document.SetProperties(line_arrow1 = arrow, if_type_present = 1) else: self.document.SetProperties(line_arrow2 = arrow, if_type_present = 1) def init_arrow(self, style): arrow = style.line_arrow1 draw_arrow_bitmap(self.arrow_gc, arrow, 1) arrow_image = create_bitmap_image(self.top.tk, 'arrow1_image', self.arrow_bitmap) self.opt_arrow1.SetValue(arrow, arrow_image) arrow = style.line_arrow2 draw_arrow_bitmap(self.arrow_gc, arrow, 2) arrow_image = create_bitmap_image(self.top.tk, 'arrow2_image', self.arrow_bitmap) self.opt_arrow2.SetValue(arrow, arrow_image) def update_from_object_cb(self, obj): if obj is not None: self.init_from_style(obj.Properties())
class LayerInfo: def __init__(self, frame, idx, info, active_var, rename, set_active_layer, set_layer_state, set_color, context_menu): self.index = MutableNumber() self.active_var = active_var self.create_widgets(frame, idx, set_active_layer, rename, set_layer_state, set_color, context_menu) if info: self.SetInfo(info) def create_widgets(self, frame, idx, set_active_layer, rename, set_layer_state, set_color, context_menu): self.index.SetValue(idx) idx = (self.index,) self.button = UpdatedRadiobutton(frame, anchor = W, value = idx, width = 10, variable = self.active_var, command = set_active_layer) self.button.bind('<ButtonPress-3>', context_menu) self.button.bind('<ButtonPress-2>', rename) self.button.bind('<Double-Button-1>', rename) self.var_visible = IntVar(frame) self.visible = UpdatedCheckbutton(frame, variable = self.var_visible, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.var_printable = IntVar(frame) self.printable = UpdatedCheckbutton(frame, variable = self.var_printable, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.var_locked = IntVar(frame) self.locked = UpdatedCheckbutton(frame, variable = self.var_locked, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.var_outlined = IntVar(frame) self.outlined = UpdatedCheckbutton(frame, variable = self.var_outlined, indicatoron = 0, selectcolor = '', command = set_layer_state, args = idx) self.color = ColorButton(frame, command = set_color, args = idx, width = 2, dialog_master = frame.master.master.master.master) def SetInfo(self, idx, info): self.index.SetValue(idx) p = pixmaps #name, visible, printable, locked, outlined, color = info self.button['text'] = info.Name() visible = info.Visible() self.var_visible.set(visible) self.visible['bitmap'] = visible and p.MiniEyeOpen or p.MiniEyeClosed printable = info.Printable() self.var_printable.set(printable) self.printable['bitmap']= printable and p.MiniPrintOn or p.MiniPrintOff locked = info.Locked() self.var_locked.set(locked) self.locked['bitmap'] = locked and p.MiniLockClosed or p.MiniLockOpen outlined = info.Outlined() self.var_outlined.set(outlined) bm = outlined and p.MiniOutlineOn or p.MiniOutlineOff self.outlined['bitmap'] = bm self.color.SetColor(info.OutlineColor()) if info.is_GridLayer: self.locked['state'] = self.outlined['state'] \ = self.printable['state'] = DISABLED else: self.locked['state'] = NORMAL if info.is_GuideLayer: self.printable['state'] = self.outlined['state'] = DISABLED else: self.printable['state'] = self.outlined['state'] = NORMAL def PlaceWidgets(self, idx): self.button.grid(row = idx, column = 0, sticky = 'NEWS') self.visible.grid(row = idx, column = 1, sticky = 'NEWS') self.printable.grid(row = idx, column = 2, sticky = 'NEWS') self.locked.grid(row = idx, column = 3, sticky = 'NEWS') self.outlined.grid(row = idx, column = 4, sticky = 'NEWS') self.color.grid(row = idx, column = 5, sticky = 'NEWS') def State(self): return (self.var_visible.get(), self.var_printable.get(), self.var_locked.get(), self.var_outlined.get()) def Color(self): return self.color.Color() def Destroy(self): self.button.destroy() self.visible.destroy() self.printable.destroy() self.locked.destroy() self.outlined.destroy() self.color.destroy()
class LayerInfo: def __init__(self, frame, idx, info, active_var, rename, set_active_layer, set_layer_state, set_color, context_menu): self.index = MutableNumber() self.active_var = active_var self.create_widgets(frame, idx, set_active_layer, rename, set_layer_state, set_color, context_menu) if info: self.SetInfo(info) def create_widgets(self, frame, idx, set_active_layer, rename, set_layer_state, set_color, context_menu): self.index.SetValue(idx) idx = (self.index, ) self.button = UpdatedRadiobutton(frame, anchor=W, value=idx, width=10, variable=self.active_var, command=set_active_layer) self.button.bind('<ButtonPress-3>', context_menu) self.button.bind('<ButtonPress-2>', rename) self.button.bind('<Double-Button-1>', rename) self.var_visible = IntVar(frame) self.visible = UpdatedCheckbutton(frame, variable=self.var_visible, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.var_printable = IntVar(frame) self.printable = UpdatedCheckbutton(frame, variable=self.var_printable, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.var_locked = IntVar(frame) self.locked = UpdatedCheckbutton(frame, variable=self.var_locked, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.var_outlined = IntVar(frame) self.outlined = UpdatedCheckbutton(frame, variable=self.var_outlined, indicatoron=0, selectcolor='', command=set_layer_state, args=idx) self.color = ColorButton( frame, command=set_color, args=idx, width=2, dialog_master=frame.master.master.master.master) def SetInfo(self, idx, info): self.index.SetValue(idx) p = pixmaps #name, visible, printable, locked, outlined, color = info self.button['text'] = info.Name() visible = info.Visible() self.var_visible.set(visible) self.visible['bitmap'] = visible and p.MiniEyeOpen or p.MiniEyeClosed printable = info.Printable() self.var_printable.set(printable) self.printable[ 'bitmap'] = printable and p.MiniPrintOn or p.MiniPrintOff locked = info.Locked() self.var_locked.set(locked) self.locked['bitmap'] = locked and p.MiniLockClosed or p.MiniLockOpen outlined = info.Outlined() self.var_outlined.set(outlined) bm = outlined and p.MiniOutlineOn or p.MiniOutlineOff self.outlined['bitmap'] = bm self.color.SetColor(info.OutlineColor()) if info.is_GridLayer: self.locked['state'] = self.outlined['state'] \ = self.printable['state'] = DISABLED else: self.locked['state'] = NORMAL if info.is_GuideLayer: self.printable['state'] = self.outlined['state'] = DISABLED else: self.printable['state'] = self.outlined['state'] = NORMAL def PlaceWidgets(self, idx): self.button.grid(row=idx, column=0, sticky='NEWS') self.visible.grid(row=idx, column=1, sticky='NEWS') self.printable.grid(row=idx, column=2, sticky='NEWS') self.locked.grid(row=idx, column=3, sticky='NEWS') self.outlined.grid(row=idx, column=4, sticky='NEWS') self.color.grid(row=idx, column=5, sticky='NEWS') def State(self): return (self.var_visible.get(), self.var_printable.get(), self.var_locked.get(), self.var_outlined.get()) def Color(self): return self.color.Color() def Destroy(self): self.button.destroy() self.visible.destroy() self.printable.destroy() self.locked.destroy() self.outlined.destroy() self.color.destroy()