def __init__(self, parent, **kw): TFrame.__init__(self, parent, style='FlatFrame', **kw) spot_frame = TFrame(self, borderwidth=2, style='FlatFrame') spot_frame.pack(side=TOP) label = TLabel(spot_frame, text=_('Color name:'), justify=LEFT) label.pack(side=TOP) self.colorname_value = StringVar('') self.colorname = TEntrybox(spot_frame, text='', width=25, textvariable=self.colorname_value) self.colorname.set_state('readonly') self.colorname.pack(side=BOTTOM, fill=X) cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame') cmyk_frame.pack(side=TOP) self.CMYK_label = TLabel(cmyk_frame, text='C:\nM:\nY:\nK:', justify=LEFT) self.CMYK_label.pack(side=LEFT, padx=10) self.RGB_label = TLabel(cmyk_frame, text='R:\nG:\nB:', justify=LEFT) self.RGB_label.pack(side=LEFT, padx=10) self.HTML_label = TLabel(self, text='HTML:', justify=LEFT) self.HTML_label.pack(side=BOTTOM, pady=5)
def build_dlg(self): root = TFrame(self.top, style='FlatFrame', borderwidth = 10) root.pack(side = TOP, fill = BOTH, expand = 1) middle = TFrame(root, style='FlatFrame', borderwidth = 5) middle.pack(side = TOP, fill = X, expand = 1) label = TLabel(middle, text = _("Go to page No.:")+" ", style='FlatLabel') label.pack(side = LEFT) self.pagenum_spin = TSpinbox(middle, var=app.mw.document.active_page+1, vartype=0, textvariable = self.pagenum, min = 1, max = len(app.mw.document.pages), step = 1, width = 6, command = self.ok) self.pagenum_spin.pack(side = LEFT) if len(app.mw.document.pages)==1: self.pagenum_spin.set_state('disabled') bottom = TFrame(root, style='FlatFrame', borderwidth = 5) bottom.pack(side = BOTTOM, fill = X, expand = 1) cancel = TButton(bottom, text=_("Cancel"), command=self.cancel) cancel.pack(side = RIGHT) label = TLabel(bottom, text = ' ', style='FlatLabel') label.pack(side = RIGHT) ok = TButton(bottom, text=_("OK"), command=self.ok) ok.pack(side = RIGHT) self.focus_widget = ok self.top.bind('<Escape>', self.cancel) self.top.protocol('WM_DELETE_WINDOW', self.cancel) self.top.resizable (width=0, height=0)
def build_dlg(self): root = TFrame(self.top, style='FlatFrame', borderwidth = 10) root.pack(side = TOP, fill = BOTH, expand = 1) middle = TFrame(root, style='FlatFrame', borderwidth = 5) middle.pack(side = TOP, fill = X, expand = 1) label = TLabel(middle, text = _("Delete page No.:")+" ", style='FlatLabel') label.pack(side = LEFT) self.pagenum_spin = TSpinbox(middle, var=app.mw.document.active_page+1, vartype=0, textvariable = self.pagenum, min = 1, max = len(app.mw.document.pages), step = 1, width = 6, command = self.ok) self.pagenum_spin.pack(side = LEFT) if len(app.mw.document.pages)==1: self.pagenum_spin.set_state('disabled') bottom = TFrame(root, style='FlatFrame', borderwidth = 5) bottom.pack(side = BOTTOM, fill = X, expand = 1) cancel = TButton(bottom, text=_("Cancel"), command=self.cancel) cancel.pack(side = RIGHT) label = TLabel(bottom, text = ' ', style='FlatLabel') label.pack(side = RIGHT) ok = TButton(bottom, text=_("OK"), command=self.ok) ok.pack(side = RIGHT) self.focus_widget = ok self.top.bind('<Escape>', self.cancel) self.top.protocol('WM_DELETE_WINDOW', self.cancel) self.top.resizable (width=0, height=0)
def build_dlg(self): root = self.top top = TFrame(root, style='FlatFrame', borderwidth=10) top.pack(side=TOP, fill=BOTH, expand=1) frame = TFrame(top, name='top', style='FlatFrame') frame.pack(side=TOP, fill=BOTH, expand=1) label = TLabel(frame, image='messagebox_' + self.image, style='FlatLabel') label.pack(side=LEFT, padx=5, pady=5) label = TLabel(frame, text=self.message, name='msg', style='FlatLabel', justify='center', anchor='center') label.pack(side=RIGHT, fill=BOTH, expand=1) frame = TFrame(top, name='bot', style='FlatFrame') frame.pack(side=BOTTOM)#, fill = X, expand = 1) command = self.ok for i in range(len(self.buttons)): button = UpdatedButton(frame, text=' ' + self.buttons[i] + ' ', command=command, args=i) button.grid(column=i, row=0, sticky='ew', padx=10, pady=0) if i == self.default: if TkVersion >= 8.0: button['default'] = 'active' self.focus_widget = button else: if TkVersion >= 8.0: button['default'] = 'normal' if self.default is not None: top.bind('<Return>', self.invoke_default) frame = TFrame(top, name='mid', style='FlatFrame', borderwidth=1) frame.pack(side=TOP, fill=X) root.resizable (width=0, height=0)
def init(self, master): PluginPanel.init(self, master) top = TFrame(self.panel, style='FlatFrame', borderwidth=7) top.pack(side = TOP, fill=BOTH) sign = TFrame(top, style='RoundedFrame', borderwidth=5) sign.pack(side=TOP) self.sign = TLabel(sign, image='color_converter') self.sign.pack(side=TOP) self.cs_name = StringVar(top) self.cs_name.set(RGB) label = TLabel(top, text=_("Colorspace:")+" ") label.pack(side = TOP, anchor=W) self.colorspaces = TCombobox(top, state='readonly', postcommand = self.set_cs, values=self.make_cs_list(), width=14, style='ComboNormal', textvariable=self.cs_name) self.colorspaces.pack(side = TOP, fill=X, pady=3) button = UpdatedButton(top, text = _("Apply"), command = self.apply_colorspace, sensitivecb = self.is_selection) button.pack(side = BOTTOM, expand = 1, fill = X, pady=3) self.Subscribe(SELECTION, button.Update) self.init_from_doc() self.subscribe_receivers()
def __init__(self, parent): self.my_changes = 0 CtxSubPanel.__init__(self, parent) self.var_jump_number = DoubleVar(self.mw.root) unit = config.preferences.default_unit var_jump_unit = StringVar(self.mw.root) self.var_jump = LengthVar(10, unit, self.var_jump_number, var_jump_unit) label = TLabel(self.panel, text=_("Jump:")) label.pack(side=LEFT, padx=2) self.entry_jump = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.var_jump_number, min=0, max=1000, step=.1, width=6, command=self.applyJump) self.entry_jump.pack(side=LEFT, padx=2) config.preferences.Subscribe(CHANGED, self.update) self.var_jump.set(config.preferences.handle_jump) self.update(0, 0)
def __init__(self, parent, color=None, **kw): TFrame.__init__(self, parent, style='FlatFrame', **kw) label = TLabel(self, image='empty_pattern_chooser', justify=CENTER) label.pack(side=TOP, pady=3) label2 = TLabel( self, text=_('Empty pattern selected,\ni.e. object will not be filled'), justify=CENTER) label2.pack(side=TOP, pady=10)
def create_balloon(self, root): self.root = root self.balloon = Toplevel(self.root) self.balloon.withdraw() self.balloon.overrideredirect(1) self.balloon["relief"] = 'flat' label = TLabel(self.balloon, text='Tooltip', style='Tooltips') label.pack(ipadx=2, ipady=2) self.balloon_label = label
def init(self, master): PluginPanel.init(self, master) top = TFrame(self.panel, style='FlatFrame', borderwidth=5) top.pack(side=TOP, fill=BOTH) sign = TFrame(top, style='RoundedFrame', borderwidth=5) sign.pack(side=TOP) self.sign = TLabel(sign, image='effects_blend') self.sign.pack(side=TOP) button_frame = TFrame(top, style='FlatFrame') button_frame.pack(side=BOTTOM, fill=BOTH, expand=1) self.update_buttons = [] button = UpdatedButton(top, text=_("Apply"), command=self.apply_blend, sensitivecb=self.doc_can_blend) button.pack(in_=button_frame, side=LEFT, expand=1, fill=X) self.document.Subscribe(SELECTION, button.Update) self.update_buttons.append(button) steps_frame = TFrame(top, style='FlatFrame', borderwidth=15) steps_frame.pack(side=TOP) label = TLabel(steps_frame, text=" " + _("Steps:") + " ") label.pack(side=LEFT, anchor=E) self.var_steps = IntVar(top) self.var_steps.set(config.preferences.blend_panel_default_steps) self.entry = TSpinbox(steps_frame, var=10, vartype=0, textvariable=self.var_steps, min=1, max=100000, step=1, width=6, command=self.apply_blend) self.entry.pack(side=LEFT, anchor=E) button = UpdatedButton(top, text=_("Select Start"), sensitivecb=self.can_select, command=self.select_control, args=SelectStart) button.pack(side=BOTTOM, fill=X, expand=1, pady=3) self.document.Subscribe(SELECTION, button.Update) self.update_buttons.append(button) button = UpdatedButton(top, text=_("Select End"), sensitivecb=self.can_select, command=self.select_control, args=SelectEnd) button.pack(side=BOTTOM, fill=X, expand=1) self.document.Subscribe(SELECTION, button.Update) self.update_buttons.append(button) self.init_from_doc() self.subscribe_receivers()
def build_dlg(self): root = self.top top = TFrame(root, borderwidth=5, style='FlatFrame') top.pack(side=TOP, expand=0, fill=BOTH) top2 = TFrame(top, style='FlatFrame') top2.pack(side=TOP, expand=0, fill=X) format_label = TLabel(top2, text=_('Style name:'), borderwidth=0) format_label.pack(side=LEFT, pady=3) self.entry_name = TEntrybox(top, command=self.ok, width=15) self.entry_name.pack(side=TOP, fill=X) top2 = TFrame(top, height=5, style='FlatFrame') top2.pack(side=TOP, expand=0, fill=X) prop_cont = TLabelframe(top, text=_('Style properties'), padding=10) prop_cont.pack(side=TOP, fill=X) properties = self.object.Properties() self.flags = {} for prop in property_names: type = property_types[prop] if type == FillProperty: state = self.object.has_fill and NORMAL or DISABLED elif type == LineProperty: state = self.object.has_line and NORMAL or DISABLED elif type == FontProperty: state = self.object.has_font and NORMAL or DISABLED else: # unknown property type! continue long, short = property_titles[prop] self.flags[prop] = var = IntVar(root) var.set(state == NORMAL) radio = TCheckbutton(prop_cont, text=long, state=state, variable=var) radio.pack(side=TOP, anchor=W) top2 = TFrame(top, height=3, style='FlatFrame') top2.pack(side=TOP, expand=0, fill=X) but_frame = Frame(top) but_frame.pack(side=TOP, fill=X) button = TButton(but_frame, text=_("Cancel"), command=self.cancel) button.pack(side=RIGHT, padx=5) button = TButton(but_frame, text=_("OK"), command=self.ok) button.pack(side=RIGHT, padx=5) root.resizable (width=0, height=0) self.entry_name.set_focus()
def __init__(self, parent, mainwindow): self.parent = parent self.mainwindow = mainwindow self.doc = self.mainwindow.document self.panel = TFrame(self.parent, name='ctxPanel', style='ToolBarFrame', borderwidth=2) label = TLabel(self.panel, image="toolbar_left") label.pack(side=LEFT) self.initPanels() self.mainwindow.Subscribe(DOCUMENT, self.doc_changed) self.ReSubscribe() self.changeContent(forPage)
def build_dlg(self): if not self.builded: cmds = self.mw.canvas.commands.Ellipse label = TLabel(self.panel, text=_("Start:")) label.pack(side=LEFT, padx=2) self.entry_start = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.start, min=-360, max=360, step=5, width=6, command=self.applyAngle) self.entry_start.pack(side=LEFT, padx=2) tooltips.AddDescription(self.entry_start, _('Arc start point angle')) #-------------- sep = FlatFrame(self.panel, width=5, height=2) sep.pack(side=LEFT) #-------------- label = TLabel(self.panel, text=_("End:")) label.pack(side=LEFT, padx=2) self.entry_end = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.end, min=-360, max=360, step=5, width=6, command=self.applyAngle) self.entry_end.pack(side=LEFT, padx=2) tooltips.AddDescription(self.entry_end, _('Arc end point angle')) b = TButton(self.panel, command=self.ResetAngle, style='Toolbutton', image='context_arc_reset') tooltips.AddDescription(b, _('Reset angles')) b.pack(side=LEFT) b = TButton(self.panel, command=self.SwapAngle, style='Toolbutton', image='context_arc_swap') tooltips.AddDescription(b, _('Swap angles')) b.pack(side=LEFT) b = TLabel(self.panel, image="toolbar_sep") b.pack(side=LEFT) b = TButton(self.panel, command=cmds.EllipseArc.Invoke, style='Toolbutton', image='context_arc') tooltips.AddDescription(b, _('to Arc')) b.pack(side=LEFT) b = TButton(self.panel, command=cmds.EllipseChord.Invoke, style='Toolbutton', image='context_chord') tooltips.AddDescription(b, _('to Chord')) b.pack(side=LEFT) b = TButton(self.panel, command=cmds.EllipsePieSlice.Invoke, style='Toolbutton', image='context_pie') tooltips.AddDescription(b, _('to Pie')) b.pack(side=LEFT) self.builded = 1 else: obj = self.mw.document.CurrentObject() if obj and obj.is_Ellipse: start_angle = round(obj.start_angle / degrees, 2) end_angle = round(obj.end_angle / degrees, 2) self.entry_start.set_value(start_angle) self.entry_end.set_value(end_angle)
def __init__(self, parent): CtxSubPanel.__init__(self, parent) self.my_changes = 0 self.var_width_number = DoubleVar(self.mw.root) self.var_height_number = DoubleVar(self.mw.root) var_width_unit = StringVar(self.mw.root) var_height_unit = StringVar(self.mw.root) unit = config.preferences.default_unit self.var_width = LengthVar(10, unit, self.var_width_number, var_width_unit) self.var_height = LengthVar(10, unit, self.var_height_number, var_height_unit) jump = config.preferences.default_unit_jump self.var_width.set(0) self.var_height.set(0) label = TLabel(self.panel, image='size_h') label.pack(side=LEFT) self.entry_width = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.var_width_number, min=0, max=50000, step=jump, width=6, command=self.applyResize) tooltips.AddDescription(self.entry_width, _("Width of selection")) self.entry_width.pack(side=LEFT, padx=5) label = TLabel(self.panel, image='size_v') label.pack(side=LEFT) self.entry_height = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.var_height_number, min=0, max=50000, step=jump, width=6, command=self.applyResize) tooltips.AddDescription(self.entry_height, _("Height of selection")) self.entry_height.pack(side=LEFT, padx=5) self.ReSubscribe() config.preferences.Subscribe(CHANGED, self.update_pref)
def __init__(self, parent): CtxSubPanel.__init__(self, parent) self.my_changes=0 self.var_unit = StringVar(self.mw.root) self.var_unit.set(config.preferences.default_unit) label = TLabel(self.panel, text=_("Units:")) label.pack(side = LEFT, padx=2) self.entry_width = TCombobox(self.panel, state='readonly', postcommand = self.applyUnits, values=self.make_units(), width=4, style='ComboNormal', textvariable=self.var_unit) self.entry_width.pack(side = LEFT, padx=2) config.preferences.Subscribe(CHANGED, self.update)
def __init__(self, master, root, mw, cnf={}, **kw): self.mw = mw self.root = root self.master = master ResizableTFrame.__init__(self, master, root, size=240, orient=LEFT, min=240, max=400) b = TLabel(self.panel, style='HLine') b.pack(side=BOTTOM, fill=X) self.pbrowser = PluginBrowser() self.plugins = app.objprop_plugins + app.layout_plugins self.plugins += app.transform_plugins + app.extentions_plugins self.plugins += app.effects_plugins + app.shaping_plugins self.plugins += [self.pbrowser]
def build_dlg(self): root = TFrame(self.top, style='FlatFrame', borderwidth = 10) root.pack(side = TOP, fill = BOTH, expand = 1) label = TLabel(root, text = '', style='FlatLabel', textvariable=info1) label.pack(side = TOP, anchor=W, pady=5) label = TLabel(root, text = '', style='FlatLabel', textvariable=info2) label.pack(side = TOP, anchor=W, pady=5) self.prgrs = TProgressbar(root, orient = 'horizontal', style='Horizontal.Progress', length = 450, value=10, variable=info3) self.prgrs.pack(side = TOP, anchor=W) self.top.protocol('WM_DELETE_WINDOW', self.cancel) self.top.resizable (width=0, height=0)
def __init__(self, parent, callback, color, sign, allow_emtpy=1, **kw): self.color=color self.callback=callback TFrame.__init__(self, parent, style='FlatFrame', **kw) self.cs_name = StringVar(self) self.set_cs_name(self.color) self.colorspaces = TCombobox(self, state='readonly', postcommand = self.set_cs, values=self.make_cs_list(allow_emtpy), width=17, style='ComboNormal', textvariable=self.cs_name) self.colorspaces.pack(side = BOTTOM, fill=X, pady=3) label = TLabel(self, text=_("Colorspace:")+" ") label.pack(side = LEFT, anchor='sw') label = TLabel(self, image=sign) label.pack(side = RIGHT)
def build_dlg(self): root = self.top top = TFrame(root, style='FlatFrame', borderwidth=10) top.pack(side=TOP, fill=BOTH, expand=1) frame = TFrame(top, name='top', style='FlatFrame') frame.pack(side=TOP, fill=BOTH, expand=1) label = TLabel(frame, image='messagebox_' + self.image, style='FlatLabel') label.pack(side=LEFT, padx=5, pady=5) label = TLabel(frame, text=self.message, name='msg', style='FlatLabel', justify='center', anchor='center') label.pack(side=RIGHT, fill=BOTH, expand=1) frame = TFrame(top, name='bot', style='FlatFrame') frame.pack(side=BOTTOM) #, fill = X, expand = 1) command = self.ok for i in range(len(self.buttons)): button = UpdatedButton(frame, text=' ' + self.buttons[i] + ' ', command=command, args=i) button.grid(column=i, row=0, sticky='ew', padx=10, pady=0) if i == self.default: if TkVersion >= 8.0: button['default'] = 'active' self.focus_widget = button else: if TkVersion >= 8.0: button['default'] = 'normal' if self.default is not None: top.bind('<Return>', self.invoke_default) frame = TFrame(top, name='mid', style='FlatFrame', borderwidth=1) frame.pack(side=TOP, fill=X) root.resizable(width=0, height=0)
def build_dlg(self): root = TFrame(self.top, style='FlatFrame', borderwidth = 10) root.pack(side = TOP, fill = BOTH, expand = 1) top = TFrame(root, style='FlatFrame', borderwidth = 5) top.pack(side = TOP, fill = X, expand = 1) label = TLabel(top, text = _("Insert:")+" ", style='FlatLabel') label.pack(side = LEFT) self.numpages_spin = TSpinbox(top, var=1, vartype=0, textvariable = self.numpages, min = 1, max = 1000, step = 1, width = 6, command = self.ok) self.numpages_spin.pack(side = LEFT) label = TLabel(top, text = " "+_("page(s)"), style='FlatLabel') label.pack(side = LEFT) middle = TFrame(root, style='FlatFrame', borderwidth = 5) middle.pack(side = TOP, fill = X, expand = 1) rbframe = TFrame(middle, style='FlatFrame', borderwidth = 5) rbframe.pack(side = LEFT) self.var_reference = StringVar(self.master) if self.is_before: self.var_reference.set('before') else: self.var_reference.set('after') radio = UpdatedRadiobutton(rbframe, value = 'before', text = _("Before")+" ", variable = self.var_reference) radio.pack(side=TOP, anchor=W) radio = UpdatedRadiobutton(rbframe, value = 'after', text = _("After")+" ", variable = self.var_reference) radio.pack(side=TOP, anchor=W) label = TLabel(middle, text = " "+_("page No.:")+" ", style='FlatLabel') label.pack(side = LEFT) self.pagenum_spin = TSpinbox(middle, var=app.mw.document.active_page+1, vartype=0, textvariable = self.pagenum, min = 1, max = len(app.mw.document.pages), step = 1, width = 6, command = self.ok) self.pagenum_spin.pack(side = LEFT) if len(app.mw.document.pages)==1: self.pagenum_spin.set_state('disabled') bottom = TFrame(root, style='FlatFrame', borderwidth = 5) bottom.pack(side = BOTTOM, fill = X, expand = 1) cancel = TButton(bottom, text=_("Cancel"), command=self.cancel) cancel.pack(side = RIGHT) label = TLabel(bottom, text = ' ', style='FlatLabel') label.pack(side = RIGHT) ok = TButton(bottom, text=_("OK"), command=self.ok) ok.pack(side = RIGHT) self.focus_widget = ok self.top.bind('<Escape>', self.cancel) self.top.protocol('WM_DELETE_WINDOW', self.cancel) self.top.resizable (width=0, height=0)
def __init__(self, parent): self.my_changes=0 CtxSubPanel.__init__(self, parent) self.var_jump_number=DoubleVar(self.mw.root) unit = config.preferences.default_unit var_jump_unit = StringVar(self.mw.root) self.var_jump = LengthVar(10, unit, self.var_jump_number, var_jump_unit) label = TLabel(self.panel, text=_("Jump:")) label.pack(side = LEFT, padx=2) self.entry_jump = TSpinbox(self.panel, var=0, vartype=1, textvariable = self.var_jump_number, min = 0, max = 1000, step = .1, width = 6, command = self.applyJump) self.entry_jump.pack(side = LEFT, padx=2) config.preferences.Subscribe(CHANGED, self.update) self.var_jump.set(config.preferences.handle_jump) self.update(0, 0)
def __init__(self, parent): CtxSubPanel.__init__(self, parent) self.my_changes = 0 self.var_unit = StringVar(self.mw.root) self.var_unit.set(config.preferences.default_unit) label = TLabel(self.panel, text=_("Units:")) label.pack(side=LEFT, padx=2) self.entry_width = TCombobox(self.panel, state='readonly', postcommand=self.applyUnits, values=self.make_units(), width=4, style='ComboNormal', textvariable=self.var_unit) self.entry_width.pack(side=LEFT, padx=2) config.preferences.Subscribe(CHANGED, self.update)
def init(self, master): TFrame.__init__(self, master) ##### Title ######################### self.title_label=TLabel(self, text=self.title, font=config.preferences.large_font, justify=LEFT) self.title_label.pack(side=TOP, anchor=W) ##### line ######################### line = TLabel(self, style='HLine2') line.pack(side = TOP, fill = X) ##### here should be panel content ######################### self.init_vars() self.build() self.activated=1
class PrefPanel(TFrame): name = 'PreferencePanel' title = _('Preference Panel') icon = 'pref_plugin' activated = 0 contents = [] def init(self, master): TFrame.__init__(self, master) ##### Title ######################### self.title_label = TLabel(self, text=self.title, font=config.preferences.large_font, justify=LEFT) self.title_label.pack(side=TOP, anchor=W) ##### line ######################### line = TLabel(self, style='HLine2') line.pack(side=TOP, fill=X) ##### here should be panel content ######################### self.init_vars() self.build() self.activated = 1 def init_vars(self): #Copies preferences to object fields pass def build(self): #builds panel UI pass def apply(self): #Applies changes pass
def build_dlg(self): root = TFrame(self.top, style='FlatFrame', borderwidth=10) root.pack(side=TOP, fill=BOTH, expand=1) label = TLabel(root, text='', style='FlatLabel', textvariable=info1) label.pack(side=TOP, anchor=W, pady=5) label = TLabel(root, text='', style='FlatLabel', textvariable=info2) label.pack(side=TOP, anchor=W, pady=5) self.prgrs = TProgressbar(root, orient='horizontal', style='Horizontal.Progress', length=450, value=10, variable=info3) self.prgrs.pack(side=TOP, anchor=W) self.top.protocol('WM_DELETE_WINDOW', self.cancel) self.top.resizable(width=0, height=0)
def __init__(self, parent): CtxSubPanel.__init__(self, parent) self.angle=DoubleVar(self.mw.root) self.angle.set(0) label = TLabel(self.panel, image='context_R') label.pack(side = LEFT) self.entry_width = TSpinbox(self.panel, var=0, vartype=1, textvariable = self.angle, min = -360, max = 360, step = 1, width = 6, command = self.applyRotate) tooltips.AddDescription(self.entry_width, _('Rotation angle')) self.entry_width.pack(side = LEFT, padx=5) b = TButton(self.panel, command=self.rotLeft, style='Toolbutton', image='context_rotate_ccw') tooltips.AddDescription(b, _(u'Rotate -90°')) b.pack(side = LEFT) b = TButton(self.panel, command=self.rot180, style='Toolbutton', image='context_rotate') tooltips.AddDescription(b, _(u'Rotate 180°')) b.pack(side = LEFT) b = TButton(self.panel, command=self.rotRight, style='Toolbutton', image='context_rotate_cw') tooltips.AddDescription(b, _(u'Rotate 90°')) b.pack(side = LEFT)
def __init__(self, parent, callback, color, sign, allow_emtpy=1, **kw): self.color = color self.callback = callback TFrame.__init__(self, parent, style='FlatFrame', **kw) self.cs_name = StringVar(self) self.set_cs_name(self.color) self.colorspaces = TCombobox(self, state='readonly', postcommand=self.set_cs, values=self.make_cs_list(allow_emtpy), width=17, style='ComboNormal', textvariable=self.cs_name) self.colorspaces.pack(side=BOTTOM, fill=X, pady=3) label = TLabel(self, text=_("Colorspace:") + " ") label.pack(side=LEFT, anchor='sw') label = TLabel(self, image=sign) label.pack(side=RIGHT)
def __init__(self, parent): CtxSubPanel.__init__(self, parent) self.radius1 = DoubleVar(self.mw.root, 0) self.radius2 = DoubleVar(self.mw.root, 0) label = TLabel(self.panel, image='context_rect_rx') label.pack(side=LEFT, padx=2) self.entry_radius1 = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.radius1, min=0, max=100, step=1, width=6, command=self.applyRadius1) self.entry_radius1.pack(side=LEFT, padx=2) tooltips.AddDescription(self.entry_radius1, _('Horizontal radius of rounded corners')) #-------------- sep = FlatFrame(self.panel, width=4, height=2) sep.pack(side=LEFT) #-------------- label = TLabel(self.panel, image='context_rect_ry') label.pack(side=LEFT, padx=2) self.entry_radius2 = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.radius2, min=0, max=100, step=1, width=6, command=self.applyRadius1) self.entry_radius2.pack(side=LEFT, padx=2) tooltips.AddDescription(self.entry_radius2, _('Vertical radius of rounded corners')) self.ReSubscribe()
def build_tab_about(self): panel = TFrame(self.root, style='FlatFrame', borderwidth=10) self.nb.add(panel, text=_('About application')) subpanel = TFrame(panel, style='FlatFrame', borderwidth=0) subpanel.pack(side=TOP, fill=Y, expand=1) subpanel = TFrame(subpanel, style='FlatFrame', borderwidth=5) subpanel.pack(side=LEFT, anchor='center') text = TLabel(subpanel, style='FlatLabel', text=_("Illustration program for prepress")) text.pack(side=TOP, anchor=W, pady=10) from time import gmtime, strftime year = strftime("%Y", gmtime()) text = TLabel(subpanel, style='FlatLabel', text="(c)2003-%s sK1 Team" % (year)) text.pack(side=TOP, anchor=W, pady=10) text = TLabel(subpanel, style='FlatLabel', text='http://sk1project.org', foreground='blue', underline=20, cursor='hand2') text.pack(side=TOP, anchor=W) text.bind('<Button-1>', self.goToSite)
def __init__(self, parent, mainwindow): self.parent=parent self.mainwindow=mainwindow TFrame.__init__(self, self.parent, name = 'pagerPanel', style='FlatFrame', borderwidth=0) top_border=TLabel(self, style='FlatLabel', image='space_1') top_border.pack(side=TOP, fill=X) self.container=TFrame(self, style='FlatFrame', borderwidth=0) space=TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.home_but=TButton(self.container, style='PagerHome', command=self.PageHome) self.home_but.pack(side=LEFT) self.home_but=TButton(self.container, style='PagerPrevious', command=self.PagePrevious) self.home_but.pack(side=LEFT) self.text=TLabel(self.container, style='FlatLabel', text=' '+_('Page 2 of 2')+' ') self.text.pack(side=LEFT) self.home_but=TButton(self.container, style='PagerNext', command=self.PageNext) self.home_but.pack(side=LEFT) self.home_but=TButton(self.container, style='PagerEnd', command=self.PageEnd) self.home_but.pack(side=LEFT) space=TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.mainwindow.Subscribe(DOCUMENT, self.Resubscribe) self.Resubscribe() self.doc_paged() self.text.bind('<Double-Button-1>', self.GoToPage)
def init(self, master): TFrame.__init__(self, master) ##### Title ######################### self.title_label = TLabel(self, text=self.title, font=config.preferences.large_font, justify=LEFT) self.title_label.pack(side=TOP, anchor=W) ##### line ######################### line = TLabel(self, style='HLine2') line.pack(side=TOP, fill=X) ##### here should be panel content ######################### self.init_vars() self.build() self.activated = 1
class PrefPanel(TFrame): name='PreferencePanel' title=_('Preference Panel') icon='pref_plugin' activated=0 contents=[] def init(self, master): TFrame.__init__(self, master) ##### Title ######################### self.title_label=TLabel(self, text=self.title, font=config.preferences.large_font, justify=LEFT) self.title_label.pack(side=TOP, anchor=W) ##### line ######################### line = TLabel(self, style='HLine2') line.pack(side = TOP, fill = X) ##### here should be panel content ######################### self.init_vars() self.build() self.activated=1 def init_vars(self): #Copies preferences to object fields pass def build(self): #builds panel UI pass def apply(self): #Applies changes pass
class CtxSubPanel: def __init__(self, parent): self.receivers = {} self.parent = parent self.mw = self.parent.mainwindow self.doc = self.parent.mainwindow.document self.panel = TFrame(parent.panel, style='FlatFrame', borderwidth=0) self.separator = TLabel(self.panel, image="toolbar_sep") self.mw.Subscribe(DOCUMENT, self.doc_changed) self.setNormal() def ReSubscribe(self): pass def doc_changed(self, doc): self.doc = doc self.ReSubscribe() def setLast(self): self.separator.forget() def setNormal(self): self.separator.pack(side=RIGHT, padx=2)
def build_dlg(self): root = self.top top = TFrame(root, style='FlatFrame', borderwidth=13) top.pack(side=TOP) label = TLabel(top, text=_("Please select the object categories whose\n default properties you want to change")) label.pack(side=TOP, anchor=W) frame = TFrame(top, style='FlatFrame', borderwidth=10) frame.pack(side=TOP) self.var_graphics_style = IntVar(top) self.var_graphics_style.set(0) if self.category != 'font': self.var_graphics_style.set(1) button = TCheckbutton(frame, text=_("Graphics Objects"), state=(self.category == 'font' and DISABLED or NORMAL), variable=self.var_graphics_style) button.pack(side=TOP, anchor=W) self.var_text_style = IntVar(top) self.var_text_style.set(0) if self.category == 'font': self.var_text_style.set(1) button = TCheckbutton(frame, text=_("Text Objects"), state=(self.category == 'line' and DISABLED or NORMAL), variable=self.var_text_style) button.pack(side=TOP, anchor=W) label = TLabel(top, style="HLine") label.pack(side=TOP, fill=BOTH) but_frame = TFrame(top, style='FlatFrame') but_frame.pack(side=TOP, fill=BOTH, expand=1) button = TButton(but_frame, text=_("Cancel"), command=self.cancel) button.pack(side=RIGHT, expand=1) button = TButton(but_frame, text=_("OK"), command=self.ok) button.pack(side=RIGHT, expand=1) root.resizable (width=0, height=0)
def __init__(self, parent): CtxSubPanel.__init__(self, parent) self.my_changes=0 self.var_width_number=DoubleVar(self.mw.root) self.var_height_number=DoubleVar(self.mw.root) var_width_unit = StringVar(self.mw.root) var_height_unit = StringVar(self.mw.root) unit = config.preferences.default_unit self.var_width = LengthVar(10, unit, self.var_width_number, var_width_unit) self.var_height = LengthVar(10, unit,self.var_height_number,var_height_unit) jump=config.preferences.default_unit_jump self.var_width.set(0) self.var_height.set(0) label = TLabel(self.panel, image='size_h') label.pack(side = LEFT) self.entry_width = TSpinbox(self.panel, var=0, vartype=1, textvariable = self.var_width_number, min = 0, max = 50000, step = jump, width = 6, command = self.applyResize) tooltips.AddDescription(self.entry_width, _("Width of selection")) self.entry_width.pack(side = LEFT, padx=5) label = TLabel(self.panel, image='size_v') label.pack(side = LEFT) self.entry_height = TSpinbox(self.panel, var=0, vartype=1, textvariable = self.var_height_number, min = 0, max = 50000, step = jump, width = 6, command = self.applyResize) tooltips.AddDescription(self.entry_height, _("Height of selection")) self.entry_height.pack(side = LEFT, padx=5) self.ReSubscribe() config.preferences.Subscribe(CHANGED, self.update_pref)
class CtxSubPanel: def __init__(self, parent): self.receivers={} self.parent=parent self.mw=self.parent.mainwindow self.doc=self.parent.mainwindow.document self.panel=TFrame(parent.panel, style='FlatFrame', borderwidth=0) self.separator = TLabel(self.panel, image = "toolbar_sep") self.mw.Subscribe(DOCUMENT, self.doc_changed) self.setNormal() def ReSubscribe(self): pass def doc_changed(self, doc): self.doc=doc self.ReSubscribe() def setLast(self): self.separator.forget() def setNormal(self): self.separator.pack(side = RIGHT, padx=2)
def __init__(self, parent): CtxSubPanel.__init__(self, parent) self.angle = DoubleVar(self.mw.root) self.angle.set(0) label = TLabel(self.panel, image='context_R') label.pack(side=LEFT) self.entry_width = TSpinbox(self.panel, var=0, vartype=1, textvariable=self.angle, min=-360, max=360, step=1, width=6, command=self.applyRotate) tooltips.AddDescription(self.entry_width, _('Rotation angle')) self.entry_width.pack(side=LEFT, padx=5) b = TButton(self.panel, command=self.rotLeft, style='Toolbutton', image='context_rotate_ccw') tooltips.AddDescription(b, _(u'Rotate -90°')) b.pack(side=LEFT) b = TButton(self.panel, command=self.rot180, style='Toolbutton', image='context_rotate') tooltips.AddDescription(b, _(u'Rotate 180°')) b.pack(side=LEFT) b = TButton(self.panel, command=self.rotRight, style='Toolbutton', image='context_rotate_cw') tooltips.AddDescription(b, _(u'Rotate 90°')) b.pack(side=LEFT)
class SPOTDigitizer(TFrame): def __init__(self, parent, **kw): TFrame.__init__(self, parent, style='FlatFrame', **kw) spot_frame = TFrame(self, borderwidth=2, style='FlatFrame') spot_frame.pack(side=TOP) label = TLabel(spot_frame, text=_('Color name:'), justify=LEFT) label.pack(side=TOP) self.colorname_value = StringVar('') self.colorname = TEntrybox(spot_frame, text='', width=25, textvariable=self.colorname_value) self.colorname.set_state('readonly') self.colorname.pack(side=BOTTOM, fill=X) cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame') cmyk_frame.pack(side=TOP) self.CMYK_label = TLabel(cmyk_frame, text='C:\nM:\nY:\nK:', justify=LEFT) self.CMYK_label.pack(side=LEFT, padx=10) self.RGB_label = TLabel(cmyk_frame, text='R:\nG:\nB:', justify=LEFT) self.RGB_label.pack(side=LEFT, padx=10) self.HTML_label = TLabel(self, text='HTML:', justify=LEFT) self.HTML_label.pack(side=BOTTOM, pady=5) def set_color(self, color): self.color = color c, m, y, k = color.getCMYK() self.CMYK_label['text'] = 'C: %d\nM: %d\nY: %d\nK: %d' % (round( c * 100, 2), round(m * 100, 2), round(y * 100, 2), round( k * 100, 2)) r, g, b = color.getRGB() text = 'R: %d\nG: %d\nB: %d' % (round(r * 255, 2), round( g * 255, 2), round(b * 255, 2)) self.RGB_label['text'] = text int_color = (round(r * 255), round(g * 255), round(b * 255)) text = 'HTML: #%02X%02X%02X' % int_color self.HTML_label['text'] = text if color.name == 'All': self.colorname_value.set(color.toString()) else: self.colorname_value.set(color.name)
class SPOTDigitizer(TFrame): def __init__(self, parent, **kw): TFrame.__init__(self, parent, style='FlatFrame', **kw) spot_frame = TFrame(self, borderwidth=2, style='FlatFrame') spot_frame.pack(side=TOP) label = TLabel(spot_frame, text=_('Color name:'), justify=LEFT) label.pack(side=TOP) self.colorname_value = StringVar('') self.colorname = TEntrybox(spot_frame, text='', width=25, textvariable=self.colorname_value) self.colorname.set_state('readonly') self.colorname.pack(side=BOTTOM, fill=X) cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame') cmyk_frame.pack(side=TOP) self.CMYK_label = TLabel(cmyk_frame, text='C:\nM:\nY:\nK:', justify=LEFT) self.CMYK_label.pack(side=LEFT, padx=10) self.RGB_label = TLabel(cmyk_frame, text='R:\nG:\nB:', justify=LEFT) self.RGB_label.pack(side=LEFT, padx=10) self.HTML_label = TLabel(self, text='HTML:', justify=LEFT) self.HTML_label.pack(side=BOTTOM, pady=5) def set_color(self, color): self.color = color c, m, y, k = color.getCMYK() self.CMYK_label['text'] = 'C: %d\nM: %d\nY: %d\nK: %d' % (round(c * 100, 2), round(m * 100, 2), round(y * 100, 2), round(k * 100, 2)) r, g, b = color.getRGB() text = 'R: %d\nG: %d\nB: %d' % (round(r * 255, 2), round(g * 255, 2), round(b * 255, 2)) self.RGB_label['text'] = text int_color = (round(r * 255), round(g * 255), round(b * 255)) text = 'HTML: #%02X%02X%02X' % int_color self.HTML_label['text'] = text if color.name == 'All': self.colorname_value.set(color.toString()) else: self.colorname_value.set(color.name)
def build_dlg(self): self.root = TFrame(self.top, style='FlatFrame', borderwidth=5) self.root.pack(side=TOP, fill=BOTH, expand=1) panel = TFrame(self.root, style='FlatFrame', borderwidth=5) panel.pack(side=TOP, fill=X) icon = TLabel(panel, style='FlatLabel', image='icon_sk1_48') icon.pack(side=LEFT, padx=5, pady=5) panel = TFrame(panel, style='FlatFrame', borderwidth=5) panel.pack(side=LEFT) text = TLabel(panel, style='FlatLabel', text='sK1 v.%s' % app.sKVersion, font=app.config.preferences.large_font + ' bold') text.pack(side=TOP, anchor=W) text = TLabel( panel, style='FlatLabel', text=_('Uses libraries: Tcl/Tk %s; Python %s; LCMS %s') % (TclVersion, string.split(sys.version)[0], cms.get_version())) text.pack(side=TOP, anchor=W) self.nb = TNotebook(self.root, height=150, width=500, padding=5) self.nb.pack(side=TOP, fill=BOTH, expand=1) self.build_tab_about() self.build_tab_authors() self.build_tab_localization() self.build_tab_license() ok = TButton(self.root, text=_("Close"), command=self.ok) ok.pack(side=RIGHT, padx=5, pady=5) self.focus_widget = ok self.top.bind('<Escape>', self.cancel) self.top.protocol('WM_DELETE_WINDOW', self.cancel) self.top.resizable(width=0, height=0)
def __init__(self, parent, mainwindow): self.parent = parent self.mainwindow = mainwindow TFrame.__init__(self, self.parent, name='pagerPanel', style='FlatFrame', borderwidth=0) top_border = TLabel(self, style='FlatLabel', image='space_1') top_border.pack(side=TOP, fill=X) self.container = TFrame(self, style='FlatFrame', borderwidth=0) space = TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.home_but = TButton(self.container, style='PagerHome', command=self.PageHome) self.home_but.pack(side=LEFT) self.home_but = TButton(self.container, style='PagerPrevious', command=self.PagePrevious) self.home_but.pack(side=LEFT) self.text = TLabel(self.container, style='FlatLabel', text=' ' + _('Page 2 of 2') + ' ') self.text.pack(side=LEFT) self.home_but = TButton(self.container, style='PagerNext', command=self.PageNext) self.home_but.pack(side=LEFT) self.home_but = TButton(self.container, style='PagerEnd', command=self.PageEnd) self.home_but.pack(side=LEFT) space = TLabel(self.container, style='FlatLabel', image='space_3') space.pack(side=LEFT, fill=Y) self.mainwindow.Subscribe(DOCUMENT, self.Resubscribe) self.Resubscribe() self.doc_paged() self.text.bind('<Double-Button-1>', self.GoToPage)
def build_dlg(self): self.root = TFrame(self.top, style='FlatFrame', borderwidth=5) self.root.pack(side=TOP, fill=BOTH, expand=1) panel = TFrame(self.root, style='FlatFrame', borderwidth=5) panel.pack(side=TOP, fill=X) icon = TLabel(panel, style='FlatLabel', image='icon_sk1_48') icon.pack(side=LEFT, padx=5, pady=5) panel = TFrame(panel, style='FlatFrame', borderwidth=5) panel.pack(side=LEFT) text = TLabel(panel, style='FlatLabel', text='sK1 v.%s' % app.sKVersion, font=app.config.preferences.large_font + ' bold') text.pack(side=TOP, anchor=W) text = TLabel(panel, style='FlatLabel', text=_('Uses libraries: Tcl/Tk %s; Python %s; LCMS %s') % (TclVersion, string.split(sys.version)[0], cms.get_version())) text.pack(side=TOP, anchor=W) self.nb = TNotebook(self.root, height=150, width=500, padding=5) self.nb.pack(side=TOP, fill=BOTH, expand=1) self.build_tab_about() self.build_tab_authors() self.build_tab_localization() self.build_tab_license() ok = TButton(self.root, text=_("Close"), command=self.ok) ok.pack(side=RIGHT, padx=5, pady=5) self.focus_widget = ok self.top.bind('<Escape>', self.cancel) self.top.protocol('WM_DELETE_WINDOW', self.cancel) self.top.resizable (width=0, height=0)
class ColorSpaceConverter(PluginPanel): name='ColorSpaceConverter' title = _("Color Space Converter") def init(self, master): PluginPanel.init(self, master) top = TFrame(self.panel, style='FlatFrame', borderwidth=7) top.pack(side = TOP, fill=BOTH) sign = TFrame(top, style='RoundedFrame', borderwidth=5) sign.pack(side=TOP) self.sign = TLabel(sign, image='color_converter') self.sign.pack(side=TOP) self.cs_name = StringVar(top) self.cs_name.set(RGB) label = TLabel(top, text=_("Colorspace:")+" ") label.pack(side = TOP, anchor=W) self.colorspaces = TCombobox(top, state='readonly', postcommand = self.set_cs, values=self.make_cs_list(), width=14, style='ComboNormal', textvariable=self.cs_name) self.colorspaces.pack(side = TOP, fill=X, pady=3) button = UpdatedButton(top, text = _("Apply"), command = self.apply_colorspace, sensitivecb = self.is_selection) button.pack(side = BOTTOM, expand = 1, fill = X, pady=3) self.Subscribe(SELECTION, button.Update) self.init_from_doc() self.subscribe_receivers() ############################################################################### def is_selection(self): return (len(self.document.selection) > 0) def subscribe_receivers(self): self.document.Subscribe(SELECTION, self.init_from_doc) def unsubscribe_receivers(self): self.document.Unsubscribe(SELECTION, self.init_from_doc) def init_from_doc(self, *arg): self.issue(SELECTION) def Update(self): pass def make_cs_list(self): cs=() cs+=(RGB,CMYK) return cs def set_cs(self): pass def apply_colorspace(self): objects = self.document.selection.GetObjects() name = self.cs_name.get() if name==RGB: cs_name= 'RGB' elif name==CMYK: cs_name= 'CMYK' self.document.begin_transaction(name) try: try: add_undo = self.document.add_undo self.apply_cs(objects, cs_name) add_undo(self.document.queue_edited()) except: self.document.abort_transaction() finally: self.document.end_transaction() app.mw.canvas.ForceRedraw() def apply_cs(self, objects, cs_name): for object in objects: if object.is_Compound: self.apply_cs(object.GetObjects(),cs_name) elif object.is_Text or object.is_Bezier or object.is_Rectangle or object.is_Ellipse: self.document.add_undo(self.FillStyle(object,cs_name)) self.document.add_undo(self.OutlineStyle(object,cs_name)) elif object.is_Image: if not cs_name==object.data.image_mode: self.document.add_undo(object.Convert(cs_name)) def FillStyle(self, object, cs_name): undo_info = None try: fill_pattern = object.properties.fill_pattern if fill_pattern is EmptyPattern: pass elif fill_pattern.is_Solid: color=fill_pattern.Color() undo_info = self.setSolidPatternFill(object, color, cs_name) elif fill_pattern.is_Hatching: pass elif fill_pattern.is_Tiled: pass elif fill_pattern.is_Gradient: pass elif fill_pattern.is_Image: pass finally: if undo_info is not None: return undo_info return NullUndo def setSolidPatternFill(self, object, color, cs_name): if color.model == cs_name: return color=self.convert_color(color, cs_name) undo=(object.SetProperties(fill_pattern=SolidPattern(color))) return undo def OutlineStyle(self, object, cs_name): undo_info = None try: line_pattern=object.properties.line_pattern if line_pattern is EmptyPattern: pass elif line_pattern.is_Solid: color=line_pattern.Color() undo_info = self.setSolidPatternOutline(object, color, cs_name) finally: if undo_info is not None: return undo_info return NullUndo def setSolidPatternOutline(self, object, color, cs_name): if color.model == cs_name: return color=self.convert_color(color, cs_name) undo=(object.SetProperties(line_pattern=SolidPattern(color))) return undo def convert_color(self, color, cs_name): if cs_name is None: return color elif cs_name == 'CMYK': c, m, y, k = color.getCMYK() return CreateCMYKAColor(c, m, y, k, color.alpha) elif cs_name == 'RGB': r, g, b = color.getRGB() return CreateRGBAColor(r, g, b, color.alpha)
def init(self, master): PluginPanel.init(self, master) self.width_priority=1 root=self.mw.root self.var_width_number=DoubleVar(root) self.var_height_number=DoubleVar(root) var_width_unit = StringVar(root) var_height_unit = StringVar(root) unit = config.preferences.default_unit self.var_width = LengthVar(10, unit, self.var_width_number, var_width_unit) self.var_height = LengthVar(10, unit,self.var_height_number,var_height_unit) jump=config.preferences.default_unit_jump self.var_width.set(0) self.var_height.set(0) self.var_proportional = IntVar(root) self.var_proportional.set(0) self.var_basepoint = StringVar(root) self.var_basepoint.set('C') #--------------------------------------------------------- top = TFrame(self.panel, style='FlatFrame') top.pack(side = TOP, fill=BOTH) #--------------------------------------------------------- # Horisontal size size_frameH = TFrame(top, style='FlatFrame', borderwidth=3) size_frameH.pack(side = TOP, fill = BOTH) label = TLabel(size_frameH, style='FlatLabel', image='size_h') label.pack(side = LEFT, padx=5) self.entry_width = TSpinbox(size_frameH, var=0, vartype=1, textvariable = self.var_width_number, min = 0, max = 50000, step = jump, width = 10, command=self.apply_resize) self.entry_width.pack(side = LEFT) self.entry_width.down_button.bind('<ButtonRelease>', self.entry_width_chang) self.entry_width.down_button.bind('<KeyRelease>', self.entry_width_chang) self.entry_width.up_button.bind('<ButtonRelease>', self.entry_width_chang) self.entry_width.up_button.bind('<KeyRelease>', self.entry_width_chang) self.entry_width.entry.bind('<ButtonRelease>', self.entry_width_chang) self.entry_width.entry.bind('<KeyRelease>', self.entry_width_chang) self.entry_width.entry.bind('<FocusOut>', self.entry_width_chang) self.entry_width.entry.bind('<FocusIn>', self.entry_width_FocusIn) self.labelwunit = TLabel(size_frameH, style='FlatLabel', text = self.var_width.unit) self.labelwunit.pack(side = LEFT, padx=5) #--------------------------------------------------------- # Vertical size_frameV = TFrame(top, style='FlatFrame', borderwidth=3) size_frameV.pack(side = TOP, fill = BOTH) label = TLabel(size_frameV, style='FlatLabel', image='size_v') label.pack(side = LEFT, padx=5) self.entry_height = TSpinbox(size_frameV, var=0, vartype=1, textvariable = self.var_height_number, min = 0, max = 50000, step = jump, width = 10, command=self.apply_resize) self.entry_height.pack(side = LEFT) self.entry_height.down_button.bind('<ButtonRelease>', self.entry_height_chang) self.entry_height.down_button.bind('<KeyRelease>', self.entry_height_chang) self.entry_height.up_button.bind('<ButtonRelease>', self.entry_height_chang) self.entry_height.up_button.bind('<KeyRelease>', self.entry_height_chang) self.entry_height.entry.bind('<ButtonRelease>', self.entry_height_chang) self.entry_height.entry.bind('<KeyRelease>', self.entry_height_chang) self.entry_height.entry.bind('<FocusOut>', self.entry_height_chang) self.entry_height.entry.bind('<FocusIn>', self.entry_height_FocusIn) self.labelhunit = TLabel(size_frameV, style='FlatLabel', text = self.var_height.unit) self.labelhunit.pack(side = LEFT, padx=5) #--------------------------------------------------------- # Proportional chek self.proportional_check = TCheckbutton(top, text = _("Proportional"), variable = self.var_proportional, command = self.proportional) self.proportional_check.pack(side = TOP, anchor=W, padx=5,pady=5) #--------------------------------------------------------- # Basepoint check label = TLabel(top, style='FlatLabel', text = _("Basepoint:")) label.pack(side = TOP, fill = BOTH, padx=5) basepoint_frame=TLabelframe(top, labelwidget=label, style='Labelframe', borderwidth=4) basepoint_frame.pack(side = TOP, fill=X, padx=5, pady=2) self.Basepoint = BasePointSelector(basepoint_frame, anchor=self.var_basepoint) self.Basepoint.pack(side = LEFT, fill = BOTH, padx=5) label = TLabel(basepoint_frame, style='FlatLabel', image = 'coordinate_sys') label.pack(side = LEFT, fill = BOTH, padx=10) #--------------------------------------------------------- # Button frame button_frame = TFrame(top, style='FlatFrame', borderwidth=5) button_frame.pack(side = BOTTOM, fill = BOTH) self.update_buttons = [] self.button = UpdatedButton(top, text = _("Apply"), command = self.apply_resize) self.button.pack(in_ = button_frame, side = BOTTOM, expand = 1, fill = X, pady=3) self.button_copy = UpdatedButton(top, text = _("Apply to Copy"), command = self.apply_to_copy) self.button_copy.pack(in_ = button_frame, side = BOTTOM, expand = 1, fill = X) self.subscribe_receivers() self.Update()
class ResizePanel(PluginPanel): name='Resize' title = _("Resize") def init(self, master): PluginPanel.init(self, master) self.width_priority=1 root=self.mw.root self.var_width_number=DoubleVar(root) self.var_height_number=DoubleVar(root) var_width_unit = StringVar(root) var_height_unit = StringVar(root) unit = config.preferences.default_unit self.var_width = LengthVar(10, unit, self.var_width_number, var_width_unit) self.var_height = LengthVar(10, unit,self.var_height_number,var_height_unit) jump=config.preferences.default_unit_jump self.var_width.set(0) self.var_height.set(0) self.var_proportional = IntVar(root) self.var_proportional.set(0) self.var_basepoint = StringVar(root) self.var_basepoint.set('C') #--------------------------------------------------------- top = TFrame(self.panel, style='FlatFrame') top.pack(side = TOP, fill=BOTH) #--------------------------------------------------------- # Horisontal size size_frameH = TFrame(top, style='FlatFrame', borderwidth=3) size_frameH.pack(side = TOP, fill = BOTH) label = TLabel(size_frameH, style='FlatLabel', image='size_h') label.pack(side = LEFT, padx=5) self.entry_width = TSpinbox(size_frameH, var=0, vartype=1, textvariable = self.var_width_number, min = 0, max = 50000, step = jump, width = 10, command=self.apply_resize) self.entry_width.pack(side = LEFT) self.entry_width.down_button.bind('<ButtonRelease>', self.entry_width_chang) self.entry_width.down_button.bind('<KeyRelease>', self.entry_width_chang) self.entry_width.up_button.bind('<ButtonRelease>', self.entry_width_chang) self.entry_width.up_button.bind('<KeyRelease>', self.entry_width_chang) self.entry_width.entry.bind('<ButtonRelease>', self.entry_width_chang) self.entry_width.entry.bind('<KeyRelease>', self.entry_width_chang) self.entry_width.entry.bind('<FocusOut>', self.entry_width_chang) self.entry_width.entry.bind('<FocusIn>', self.entry_width_FocusIn) self.labelwunit = TLabel(size_frameH, style='FlatLabel', text = self.var_width.unit) self.labelwunit.pack(side = LEFT, padx=5) #--------------------------------------------------------- # Vertical size_frameV = TFrame(top, style='FlatFrame', borderwidth=3) size_frameV.pack(side = TOP, fill = BOTH) label = TLabel(size_frameV, style='FlatLabel', image='size_v') label.pack(side = LEFT, padx=5) self.entry_height = TSpinbox(size_frameV, var=0, vartype=1, textvariable = self.var_height_number, min = 0, max = 50000, step = jump, width = 10, command=self.apply_resize) self.entry_height.pack(side = LEFT) self.entry_height.down_button.bind('<ButtonRelease>', self.entry_height_chang) self.entry_height.down_button.bind('<KeyRelease>', self.entry_height_chang) self.entry_height.up_button.bind('<ButtonRelease>', self.entry_height_chang) self.entry_height.up_button.bind('<KeyRelease>', self.entry_height_chang) self.entry_height.entry.bind('<ButtonRelease>', self.entry_height_chang) self.entry_height.entry.bind('<KeyRelease>', self.entry_height_chang) self.entry_height.entry.bind('<FocusOut>', self.entry_height_chang) self.entry_height.entry.bind('<FocusIn>', self.entry_height_FocusIn) self.labelhunit = TLabel(size_frameV, style='FlatLabel', text = self.var_height.unit) self.labelhunit.pack(side = LEFT, padx=5) #--------------------------------------------------------- # Proportional chek self.proportional_check = TCheckbutton(top, text = _("Proportional"), variable = self.var_proportional, command = self.proportional) self.proportional_check.pack(side = TOP, anchor=W, padx=5,pady=5) #--------------------------------------------------------- # Basepoint check label = TLabel(top, style='FlatLabel', text = _("Basepoint:")) label.pack(side = TOP, fill = BOTH, padx=5) basepoint_frame=TLabelframe(top, labelwidget=label, style='Labelframe', borderwidth=4) basepoint_frame.pack(side = TOP, fill=X, padx=5, pady=2) self.Basepoint = BasePointSelector(basepoint_frame, anchor=self.var_basepoint) self.Basepoint.pack(side = LEFT, fill = BOTH, padx=5) label = TLabel(basepoint_frame, style='FlatLabel', image = 'coordinate_sys') label.pack(side = LEFT, fill = BOTH, padx=10) #--------------------------------------------------------- # Button frame button_frame = TFrame(top, style='FlatFrame', borderwidth=5) button_frame.pack(side = BOTTOM, fill = BOTH) self.update_buttons = [] self.button = UpdatedButton(top, text = _("Apply"), command = self.apply_resize) self.button.pack(in_ = button_frame, side = BOTTOM, expand = 1, fill = X, pady=3) self.button_copy = UpdatedButton(top, text = _("Apply to Copy"), command = self.apply_to_copy) self.button_copy.pack(in_ = button_frame, side = BOTTOM, expand = 1, fill = X) self.subscribe_receivers() self.Update() ############################################################################### def subscribe_receivers(self): self.document.Subscribe(SELECTION, self.Update) self.document.Subscribe(EDITED, self.update_var) config.preferences.Subscribe(CHANGED, self.update_pref) def unsubscribe_receivers(self): self.document.Unsubscribe(SELECTION, self.Update) self.document.Unsubscribe(EDITED, self.update_var) config.preferences.Unsubscribe(CHANGED, self.update_pref) def init_from_doc(self, *arg): self.Update() def Update(self, *arg): if self.is_selection(): self.entry_width.set_state(NORMAL) self.entry_height.set_state(NORMAL) self.proportional_check['state']=NORMAL self.button['state']=NORMAL self.button_copy['state']=NORMAL else: self.entry_width.set_state(DISABLED) self.entry_height.set_state(DISABLED) self.proportional_check['state']=DISABLED self.button['state']=DISABLED self.button_copy['state']=DISABLED self.var_width.set(0) self.var_height.set(0) self.update_pref() def entry_width_FocusIn(self, *arg): self.width_priority=1 def entry_height_FocusIn(self, *arg): self.width_priority=0 def ResizeSelected(self, h, v, cnt_x=None, cnt_y=None): text = _("Resize") if self.document.selection: self.document.begin_transaction(text) try: try: br=self.document.selection.coord_rect hor_sel=br.right - br.left ver_sel=br.top - br.bottom if cnt_x is None: cnt_x=hor_sel/2+br.left if cnt_y is None: cnt_y=ver_sel/2+br.bottom trafo = Trafo(h, 0, 0, v, cnt_x-cnt_x*h, cnt_y-cnt_y*v) self.document.TransformSelected(trafo, text) except: self.document.abort_transaction() finally: self.document.end_transaction() def ResizeAndCopy(self, h, v, cnt_x=None, cnt_y=None): text = _("Resize&Copy") if self.document.selection: self.document.begin_transaction(text) try: try: br=self.document.selection.coord_rect hor_sel=br.right - br.left ver_sel=br.top - br.bottom if cnt_x is None: cnt_x=hor_sel/2+br.left if cnt_y is None: cnt_y=ver_sel/2+br.bottom trafo = Trafo(h, 0, 0, v, cnt_x-cnt_x*h, cnt_y-cnt_y*v) self.document.ApplyToDuplicate() self.document.TransformSelected(trafo, text) except: self.document.abort_transaction() finally: self.document.end_transaction() def entry_height_chang(self, *arg): if self.var_proportional.get(): try: height=self.var_height.get() br=self.document.selection.coord_rect hor_sel=br.right - br.left ver_sel=br.top - br.bottom self.var_width.set(hor_sel * height/ver_sel) except ZeroDivisionError: return def entry_width_chang(self, *arg): if self.var_proportional.get(): try: width=self.var_width.get() br=self.document.selection.coord_rect hor_sel=br.right - br.left ver_sel=br.top - br.bottom self.var_height.set(ver_sel * width/hor_sel) except ZeroDivisionError: return def proportional(self): if self.width_priority: self.entry_width_chang() else: self.entry_height_chang() def apply_resize(self, *arg): if self.button["state"]==DISABLED: return self.proportional() width=self.var_width.get() height=self.var_height.get() br=self.document.selection.coord_rect hor_sel=br.right - br.left ver_sel=br.top - br.bottom cnt_x,cnt_y=self.Basepoint.get_basepoint(hor_sel,ver_sel,br.left,br.bottom) try: h=width/hor_sel except ZeroDivisionError: h=0 try: v=height/ver_sel except ZeroDivisionError: v=0 if arg and arg[0] == 'Duplicate': self.ResizeAndCopy(h, v, cnt_x, cnt_y) else: self.ResizeSelected(h, v, cnt_x, cnt_y) self.update_var() def apply_to_copy(self): self.apply_resize('Duplicate') def update_pref(self, *arg): self.labelwunit['text']=config.preferences.default_unit self.labelhunit['text']=config.preferences.default_unit self.var_width.unit=config.preferences.default_unit self.var_height.unit=config.preferences.default_unit self.entry_width.step=config.preferences.default_unit_jump self.entry_height.step=config.preferences.default_unit_jump self.update_var() def update_var(self, *arg): if len(self.document.selection.GetInfo()): br=self.document.selection.coord_rect width=br.right - br.left height=br.top - br.bottom self.var_width.set(width) self.var_height.set(height) def is_selection(self): return (len(self.document.selection) > 0)
def init(self, master): PluginPanel.init(self, master) root = self.mw.root self.var_angle = DoubleVar(root) self.var_angle.set(0) self.var_width_number = DoubleVar(root) self.var_height_number = DoubleVar(root) self.var_width_base = DoubleVar(root) self.var_height_base = DoubleVar(root) self.cnt_x_absolute = None self.cnt_y_absolute = None var_width_unit = StringVar(root) var_height_unit = StringVar(root) unit = config.preferences.default_unit self.var_width = LengthVar(10, unit, self.var_width_number, var_width_unit) self.var_height = LengthVar(10, unit, self.var_height_number, var_height_unit) jump = config.preferences.default_unit_jump self.var_width.set(0) self.var_height.set(0) self.var_width_base.set(0) self.var_height_base.set(0) self.var_position = StringVar(root) self.var_position.set(ABSOLUTE) self.var_basepoint = StringVar(root) self.var_basepoint.set("C") # --------------------------------------------------------- top = TFrame(self.panel, style="FlatFrame") top.pack(side=TOP, fill=BOTH) # --------------------------------------------------------- angle_frame = TFrame(top, style="FlatFrame", borderwidth=3) angle_frame.pack(side=TOP, fill=BOTH) label = TLabel(angle_frame, style="FlatLabel", text=" " + _("Angle:") + " ") label.pack(side=LEFT, padx=5) self.entry_angle = TSpinbox( angle_frame, var=0, vartype=1, textvariable=self.var_angle, min=-360, max=360, step=5, width=6, command=self.apply_rotate, ) self.entry_angle.pack(side=LEFT, anchor=E) label = TLabel(angle_frame, style="FlatLabel", text=_("deg")) label.pack(side=LEFT, padx=5) # --------------------------------------------------------- label = TLabel(top, style="FlatLabel", text=_("Center:")) label.pack(side=TOP, fill=BOTH, padx=5) # --------------------------------------------------------- # Horisontal size_frameH = TFrame(top, style="FlatFrame", borderwidth=3) size_frameH.pack(side=TOP, fill=BOTH) label = TLabel(size_frameH, style="FlatLabel", image="center_h") label.pack(side=LEFT, padx=5) self.entry_width = TSpinbox( size_frameH, var=0, vartype=1, textvariable=self.var_width_number, min=-50000, max=50000, step=jump, width=10, command=self.apply_rotate, ) self.entry_width.pack(side=LEFT) self.labelwunit = TLabel(size_frameH, style="FlatLabel", text=self.var_width.unit) self.labelwunit.pack(side=LEFT, padx=5) # --------------------------------------------------------- # Vertical size_frameV = TFrame(top, style="FlatFrame", borderwidth=3) size_frameV.pack(side=TOP, fill=BOTH) label = TLabel(size_frameV, style="FlatLabel", image="center_v") label.pack(side=LEFT, padx=5) self.entry_height = TSpinbox( size_frameV, var=0, vartype=1, textvariable=self.var_height_number, min=-50000, max=50000, step=jump, width=10, command=self.apply_rotate, ) self.entry_height.pack(side=LEFT) self.labelhunit = TLabel(size_frameV, style="FlatLabel", text=self.var_height.unit) self.labelhunit.pack(side=LEFT, padx=5) # --------------------------------------------------------- # position chek self.position_check = TCheckbutton( top, text=_("Absolute Center"), variable=self.var_position, onvalue=ABSOLUTE, offvalue=RELATIVE, command=self.position, ) self.position_check.pack(side=TOP, anchor=W, padx=5, pady=5) # --------------------------------------------------------- # Basepoint check label = TLabel(top, style="FlatLabel", text=_("Basepoint:")) label.pack(side=TOP, fill=BOTH, padx=5) basepoint_frame = TLabelframe(top, labelwidget=label, style="Labelframe", borderwidth=4) basepoint_frame.pack(side=TOP, fill=X, padx=5, pady=2) self.Basepoint = BasePointSelector(basepoint_frame, anchor=self.var_basepoint, command=self.apply_basepoint) self.Basepoint.pack(side=LEFT, fill=BOTH, padx=5) label = TLabel(basepoint_frame, style="FlatLabel", image="coordinate_deg") label.pack(side=LEFT, fill=BOTH, padx=10) self.position_check.pack(side=TOP, anchor=W, padx=5, pady=5) # --------------------------------------------------------- # Button frame button_frame = TFrame(top, style="FlatFrame", borderwidth=5) button_frame.pack(side=BOTTOM, fill=BOTH) self.update_buttons = [] self.button = UpdatedButton(top, text=_("Apply"), command=self.apply_rotate) self.button.pack(in_=button_frame, side=BOTTOM, expand=1, fill=X, pady=3) self.button_copy = UpdatedButton(top, text=_("Apply to Copy"), command=self.apply_to_copy) self.button_copy.pack(in_=button_frame, side=BOTTOM, expand=1, fill=X) self.init_from_doc() self.subscribe_receivers()
def build(self): label = TLabel(self, text=self.__class__.name, font=config.preferences.large_font, justify=LEFT) label.pack(side=TOP, fill=X)
def init(self, master): PluginPanel.init(self, master) top = self.panel top = TFrame(top, borderwidth=2, style='FlatFrame') top.pack(side=TOP, expand=1, fill=X) button_frame = TFrame(top, borderwidth=2, style='FlatFrame') button_frame.pack(side=BOTTOM, fill=BOTH, expand=1) button = TButton(button_frame, text=_('Apply'), command=self.replace) button.pack(side=TOP) #---------------------------------------------------------- main_frame = TFrame(top, style='FlatFrame', borderwidth=3) main_frame.pack(side=TOP, fill=X) self.find_var = StringVar(top) self.find_var.set('') findField = TEntryExt(main_frame, textvariable=self.find_var) findField.pack(side=RIGHT) label = TLabel(main_frame, style='FlatLabel', text=_("Find:") + " ") label.pack(side=RIGHT, anchor=E) #--------------------------------------------------------- main_frame = TFrame(top, style='FlatFrame', borderwidth=3) main_frame.pack(side=TOP, fill=X) self.replace_var = StringVar(top) self.replace_var.set('') replaceField = TEntryExt(main_frame, textvariable=self.replace_var) replaceField.pack(side=RIGHT) label = TLabel(main_frame, style='FlatLabel', text=_("Replace to:") + " ") label.pack(side=RIGHT, anchor=E) main_frame = TFrame(top, style='FlatFrame', borderwidth=3) main_frame.pack(side=TOP) #--------------------------------------------------------- label = TLabel(top, text=" " + _("Parameters") + " ", style="FlatLabel") label.pack() parametersFrameLabel = TLabelframe(top, labelwidget=label, style='Labelframe', borderwidth=4) parametersFrameLabel.pack(side=TOP, fill=X, pady=4, padx=4) parametersFrame = TFrame(parametersFrameLabel, style='FlatFrame') self.var_case_sensitive = BooleanVar(top) self.var_case_sensitive.set(False) self.case_sensitive_check = TCheckbutton( parametersFrame, text=_("Case sensitive"), variable=self.var_case_sensitive) self.case_sensitive_check.pack(side=TOP, anchor=W, padx=5) self.var_whole_word = BooleanVar(top) self.var_whole_word.set(False) self.whole_word_check = TCheckbutton(parametersFrame, text=_("Whole word"), variable=self.var_whole_word) self.whole_word_check.pack(side=TOP, anchor=W, padx=5) self.var_regexp = BooleanVar(top) self.var_regexp.set(False) self.regexpCheck = TCheckbutton(parametersFrame, text=_("RegExp search"), variable=self.var_regexp, command=self.disable_enable_action) self.regexpCheck.pack(side=TOP, anchor=W, padx=5) parametersFrame.pack(side=TOP, fill=X, pady=2)