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()