Example #1
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)
Example #2
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)
Example #3
0
class RotatePanel(CtxSubPanel):

    name = 'RotatePanel'

    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 rot180(self):
        self.rotation(180)

    def rotLeft(self):
        self.rotation(90)

    def rotRight(self):
        self.rotation(-90)

    def applyRotate(self, *arg):
        self.rotation(self.angle.get())

    def rotation(self, angle):
        if angle < 0:
            if angle < -360:
                angle += int(angle / 360) * 360
            angle += 360
        self.doc.RotateSelected(angle)
Example #4
0
    def __init__(self, parent):
        CtxSubPanel.__init__(self, parent)
        b = TButton(self.panel,
                    command=self.makePageFrame,
                    style='Toolbutton',
                    image='context_add_page_frame')
        tooltips.AddDescription(b, _('Add page frame'))
        b.pack(side=LEFT)
        b = TButton(self.panel,
                    command=self.addCenteredGuides,
                    style='Toolbutton',
                    image='context_add_centered_guides')
        tooltips.AddDescription(b, _('Add guides for page center'))
        b.pack(side=LEFT)

        #############
        b = TLabel(self.panel, image="toolbar_sep")
        b.pack(side=LEFT)
        b = TButton(self.panel,
                    command=self.addGuidesFrame,
                    style='Toolbutton',
                    image='context_add_guides_frame')
        tooltips.AddDescription(b, _('Add guides across page border'))
        b.pack(side=LEFT)

        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)

        self.entry_jump = TSpinbox(self.panel,
                                   var=0,
                                   vartype=1,
                                   textvariable=self.var_jump_number,
                                   min=-1000,
                                   max=1000,
                                   step=5,
                                   width=6,
                                   command=self.addGuidesFrame)
        self.entry_jump.pack(side=LEFT, padx=2)
        config.preferences.Subscribe(CHANGED, self.update)
        self.var_jump.set(0)
        self.update(0, 0)

        b = TLabel(self.panel, image="toolbar_sep")
        b.pack(side=LEFT)
        ##############

        b = TButton(self.panel,
                    command=self.removeAllGuides,
                    style='Toolbutton',
                    image='context_remove_all_guides')
        tooltips.AddDescription(b, _('Remove all guides'))
        b.pack(side=LEFT)
Example #5
0
class RectanglePanel(CtxSubPanel):

	name = 'RectanglePanel'

	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 ReSubscribe(self):
		self.doc.Subscribe(SELECTION, self.Update)
		self.doc.Subscribe(EDITED, self.Update)

	def Update(self, *arg):
		obj = self.mw.document.CurrentObject()
		if obj and obj.is_Rectangle:
			self.entry_radius1.set_value(round(obj.radius1 * 200., 2))
			self.entry_radius2.set_value(round(obj.radius2 * 200., 2))

	def applyRadius1(self, *arg):
		trafo = self.mw.document.CurrentObject().trafo
		w = hypot(trafo.m11, trafo.m21)
		h = hypot(trafo.m12, trafo.m22)
		#print w, h
		radius1 = self.entry_radius1.get_value() / 200.
		radius2 = self.entry_radius2.get_value() / 200.

		if radius2 == 0:
			radius2 = min(w / h * radius1, 0.5)

		if radius1 == 0:
			radius1 = min(h / w * radius2, 0.5)

		self.mw.document.CallObjectMethod(rectangle.Rectangle, _("Edit Object"),
								'SetTrafoAndRadii', trafo, radius1, radius2)
Example #6
0
	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()
Example #7
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)
Example #8
0
	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)
Example #9
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)
Example #10
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 = _("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)
Example #11
0
class RotatePanel(CtxSubPanel):
	
	name='RotatePanel'	
	
	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 rot180(self):
		self.rotation(180)
		
	def rotLeft(self):
		self.rotation(90)
		
	def rotRight(self):
		self.rotation(-90)
		
	def applyRotate(self, *arg):
		self.rotation(self.angle.get())
		
	def rotation(self, angle):
		if angle<0:
			if angle<-360:
				angle+=int(angle/360)*360
			angle+=360
		self.doc.RotateSelected(angle)
Example #12
0
class GoToPageDialog(ModalDialog):

	class_name = 'GoToPageDialog'
	
	def __init__(self, master, is_before = 0, dlgname = '__dialog__'):
		self.master=master
		self.title = _("Go to page")
		self.is_before=is_before
		self.init_vars()
		ModalDialog.__init__(self, master, name = dlgname)
		
	def init_vars(self):
		self.pagenum=StringVar(self.master)
		self.pagenum.set('%u'%(app.mw.document.active_page+1))
	
	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 ok(self, *arg):		
		if not 0 <= self.pagenum_spin.get_value()-1 < len(app.mw.document.pages):
			msgDialog(self.top, title = _("Error"), message = _('Incorrect page number!'))
			self.pagenum_spin.entry.focus_set()
			return
		if self.pagenum_spin.get_value()-1<>app.mw.document.active_page:
			app.mw.document.GoToPage(self.pagenum_spin.get_value()-1)
		self.close_dlg()
	
	def cancel(self, *arg):
		self.close_dlg(None)
    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()
Example #14
0
class JumpPanel(CtxSubPanel):
	
	name='JumpPanel'	
	
	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 update(self,*arg):
		if self.my_changes:
			self.my_changes=0
		else:
			self.var_jump.unit=config.preferences.default_unit
			self.var_jump.set(config.preferences.handle_jump)

		
	def applyJump(self,*arg):
		self.my_changes=1
		self.var_jump.unit=config.preferences.default_unit
		config.preferences.handle_jump=self.var_jump.get()
		self.var_jump.set(config.preferences.handle_jump)
    def __init__(self, parent):
        CtxSubPanel.__init__(self, parent)
        self.my_changes = 0
        self.text_linegap = StringVar(self.mw.root, '100.0')
        self.text_wordgap = StringVar(self.mw.root, '100.0')
        self.text_chargap = StringVar(self.mw.root, '100.0')

        label = TLabel(self.panel, image='context_between_word')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Distance between words'))
        self.entry_word = TSpinbox(self.panel,
                                   var=100.0,
                                   vartype=1,
                                   textvariable=self.text_wordgap,
                                   min=0,
                                   max=5000,
                                   step=10,
                                   width=6,
                                   command=self.applyProperties)
        self.entry_word.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text='% ')
        label.pack(side=LEFT)
        label = TLabel(self.panel, image='context_between_line')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Distance between lines'))
        self.entry_line = TSpinbox(self.panel,
                                   var=100.0,
                                   vartype=1,
                                   textvariable=self.text_linegap,
                                   min=0,
                                   max=5000,
                                   step=10,
                                   width=6,
                                   command=self.applyProperties)
        self.entry_line.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text='% ')
        label.pack(side=LEFT)
        label = TLabel(self.panel, image='context_between_char')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Distance between characters'))
        self.entry_char = TSpinbox(self.panel,
                                   var=100.0,
                                   vartype=1,
                                   textvariable=self.text_chargap,
                                   min=0,
                                   max=5000,
                                   step=10,
                                   width=6,
                                   command=self.applyProperties)
        self.entry_char.pack(side=LEFT, padx=2)
        label = TLabel(self.panel, text='% ')
        label.pack(side=LEFT)

        self.ReSubscribe()
Example #16
0
	def __init__(self, parent):
		CtxSubPanel.__init__(self, parent)
		self.my_changes=0
		self.text_linegap=StringVar(self.mw.root,'100.0')
		self.text_wordgap=StringVar(self.mw.root,'100.0')
		self.text_chargap=StringVar(self.mw.root,'100.0')

		
		label = TLabel(self.panel, image='context_between_word')
		label.pack(side = LEFT)
		tooltips.AddDescription(label, _('Distance between words'))
		self.entry_word = TSpinbox(self.panel, var=100.0, vartype=1, textvariable = self.text_wordgap,
						min = 0, max = 5000, step = 10, width = 6, command = self.applyProperties)
		self.entry_word.pack(side = LEFT, padx=2)

		label = TLabel(self.panel, text='% ')
		label.pack(side = LEFT)
		label = TLabel(self.panel, image='context_between_line')
		label.pack(side = LEFT)
		tooltips.AddDescription(label, _('Distance between lines'))
		self.entry_line = TSpinbox(self.panel, var=100.0, vartype=1, textvariable = self.text_linegap,
						min = 0, max = 5000, step = 10, width = 6, command = self.applyProperties)
		self.entry_line.pack(side = LEFT, padx=2)

		label = TLabel(self.panel, text='% ')
		label.pack(side = LEFT)	
		label = TLabel(self.panel, image='context_between_char')
		label.pack(side = LEFT)
		tooltips.AddDescription(label, _('Distance between characters'))
		self.entry_char = TSpinbox(self.panel, var=100.0, vartype=1, textvariable = self.text_chargap,
						min = 0, max = 5000, step = 10, width = 6, command = self.applyProperties)
		self.entry_char.pack(side = LEFT, padx=2)
		label = TLabel(self.panel, text='% ')
		label.pack(side = LEFT)	
				
		self.ReSubscribe()
Example #17
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)
Example #18
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)
Example #19
0
	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()
Example #20
0
class DeletePageDialog(ModalDialog):

	class_name = 'DeletePageDialog'
	
	def __init__(self, master, is_before = 0, dlgname = '__dialog__'):
		self.master=master
		self.title = _("Delete page")
		self.is_before=is_before
		self.init_vars()
		ModalDialog.__init__(self, master, name = dlgname)
		
	def init_vars(self):
		self.pagenum=StringVar(self.master)
		self.pagenum.set('%u'%(app.mw.document.active_page+1))
	
	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 ok(self, *arg):		
		if not 0 <= self.pagenum_spin.get_value()-1 < len(app.mw.document.pages):
			msgDialog(self.top, title = _("Error"), message = _('Incorrect page number!'))
			self.pagenum_spin.entry.focus_set()
			return
		app.mw.document.DeletePage(self.pagenum_spin.get_value()-1)
		self.close_dlg()
	
	def cancel(self, *arg):
		self.close_dlg(None)
Example #21
0
def create_length_widgets(top, master, command):
    var_number = DoubleVar(top)
    var_unit = StringVar(top)
    var_length = LengthVar(1.0,
                           config.preferences.default_unit,
                           var_number,
                           var_unit,
                           command=command)
    entry = TSpinbox(master,
                     textvariable=var_number,
                     vartype=1,
                     min=0,
                     max=50000,
                     step=.1,
                     width=6,
                     command=var_length.UpdateNumber)
    unitlabel = UnitLabel(master)
    return var_length, entry, unitlabel
Example #22
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)
Example #23
0
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)
class RectanglePanel(CtxSubPanel):

    name = 'RectanglePanel'

    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 ReSubscribe(self):
        self.doc.Subscribe(SELECTION, self.Update)
        self.doc.Subscribe(EDITED, self.Update)

    def Update(self, *arg):
        obj = self.mw.document.CurrentObject()
        if obj and obj.is_Rectangle:
            self.entry_radius1.set_value(round(obj.radius1 * 200., 2))
            self.entry_radius2.set_value(round(obj.radius2 * 200., 2))

    def applyRadius1(self, *arg):
        trafo = self.mw.document.CurrentObject().trafo
        w = hypot(trafo.m11, trafo.m21)
        h = hypot(trafo.m12, trafo.m22)
        #print w, h
        radius1 = self.entry_radius1.get_value() / 200.
        radius2 = self.entry_radius2.get_value() / 200.

        if radius2 == 0:
            radius2 = min(w / h * radius1, 0.5)

        if radius1 == 0:
            radius1 = min(h / w * radius2, 0.5)

        self.mw.document.CallObjectMethod(rectangle.Rectangle,
                                          _("Edit Object"), 'SetTrafoAndRadii',
                                          trafo, radius1, radius2)
Example #25
0
class SkewPanel(PluginPanel):
    name = "Skew"
    title = _("Skew")

    def init(self, master):
        PluginPanel.init(self, master)

        self.width_priority = 1

        root = self.mw.root

        self.var_angleX = DoubleVar(root)
        self.var_angleY = DoubleVar(root)

        jump = 5
        self.var_angleX.set(0)
        self.var_angleY.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_frameH = TFrame(top, style="FlatFrame", borderwidth=3)
        size_frameH.pack(side=TOP, fill=BOTH)

        label = TLabel(size_frameH, style="FlatLabel", image="skew_h")
        label.pack(side=LEFT, padx=5)
        self.entry_angleX = TSpinbox(
            size_frameH,
            var=0,
            vartype=1,
            textvariable=self.var_angleX,
            min=-75,
            max=75,
            step=jump,
            width=10,
            command=self.apply_skew,
        )
        self.entry_angleX.pack(side=LEFT)

        self.labelwunit = TLabel(size_frameH, style="FlatLabel", text=_("deg"))
        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="skew_v")
        label.pack(side=LEFT, padx=5)

        self.entry_angleY = TSpinbox(
            size_frameV,
            var=0,
            vartype=1,
            textvariable=self.var_angleY,
            min=-75,
            max=75,
            step=jump,
            width=10,
            command=self.apply_skew,
        )
        self.entry_angleY.pack(side=LEFT)

        self.labelhunit = TLabel(size_frameV, style="FlatLabel", text=_("deg"))
        self.labelhunit.pack(side=LEFT, padx=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_deg")
        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_skew)
        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 subscribe_receivers(self):
        self.document.Subscribe(SELECTION, self.Update)

    def unsubscribe_receivers(self):
        self.document.Unsubscribe(SELECTION, self.Update)

    def init_from_doc(self):
        self.Update()

    def Update(self, *arg):
        if self.is_selection():
            self.entry_angleX.set_state(NORMAL)
            self.entry_angleY.set_state(NORMAL)
            self.button["state"] = NORMAL
            self.button_copy["state"] = NORMAL
        else:
            self.entry_angleX.set_state(DISABLED)
            self.entry_angleY.set_state(DISABLED)
            self.button["state"] = DISABLED
            self.button_copy["state"] = DISABLED

    def SkewSelected(self, axisX=0, axisY=0):
        if self.document.selection:
            self.document.begin_transaction()
            try:
                try:
                    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)

                    text = _("Skew")
                    ax, ay = tan(axisX), tan(axisY)
                    sx = 1.0
                    sy = 1.0 - (ax * ay)
                    tx = cnt_x * ax
                    ty = cnt_y * ax * ay - cnt_y * ay
                    # Move the selection in the coordinates x0 y0
                    trafo = Trafo(1, 0, 0, 1, -cnt_x, -cnt_y)
                    # Skew and Scaling
                    trafo = Trafo(sx, ay, -ax, sy, 0, 0)(trafo)
                    # Move the selection in the coordinates basepoint
                    trafo = Trafo(1, 0, 0, 1, cnt_x, cnt_y)(trafo)
                    self.document.TransformSelected(trafo, text)
                except:
                    self.document.abort_transaction()
            finally:
                self.document.end_transaction()

    def apply_skew(self, *arg):
        if self.button["state"] == DISABLED:
            return
        try:
            angleX = self.var_angleX.get() * degrees
            angleY = self.var_angleY.get() * degrees
            self.SkewSelected(angleX, angleY)
        except:
            return

    def apply_to_copy(self):
        if self.button["state"] == DISABLED:
            return
        self.document.begin_transaction(_("Skew&Copy"))
        try:
            try:
                self.document.ApplyToDuplicate()
                self.apply_skew()
            except:
                self.document.abort_transaction()
        finally:
            self.document.end_transaction()

    def is_selection(self):
        return len(self.document.selection) > 0
Example #26
0
class RotatePanel(PluginPanel):
    name = "Rotate"
    title = _("Rotate")

    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 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_angle.set_state(NORMAL)
            self.entry_width.set_state(NORMAL)
            self.entry_height.set_state(NORMAL)
            self.position_check["state"] = NORMAL
            self.button["state"] = NORMAL
            self.button_copy["state"] = NORMAL
            self.TestBasepoint()
        else:
            self.entry_angle.set_state(DISABLED)
            self.entry_width.set_state(DISABLED)
            self.entry_height.set_state(DISABLED)
            self.position_check["state"] = DISABLED
            self.button["state"] = DISABLED
            self.button_copy["state"] = DISABLED

        self.update_pref()

    def apply_basepoint(self):
        self.update_var()

    def position(self):
        self.update_var()

    def RotateSelected(self, angle, cnt=None):
        text = _("Rotation")
        if self.document.selection:
            self.document.begin_transaction(text)
            try:
                try:
                    if cnt is None:
                        cnt = self.document.selection.coord_rect.center()
                    angle = angle * degrees
                    trafo = Rotation(angle, cnt)
                    self.document.TransformSelected(trafo, text)
                except:
                    self.document.abort_transaction()
            finally:
                self.document.end_transaction()

    def RotateAndCopy(self, angle, cnt=None):
        text = _("Rotation&Copy")
        if self.document.selection:
            self.document.begin_transaction(text)
            try:
                try:
                    if cnt is None:
                        cnt = self.document.selection.coord_rect.center()
                    angle = angle * degrees
                    trafo = Rotation(angle, cnt)
                    self.document.ApplyToDuplicate()
                    self.document.TransformSelected(trafo, text)
                except:
                    self.document.abort_transaction()
            finally:
                self.document.end_transaction()

    def apply_rotate(self, *arg):
        if self.button["state"] == DISABLED:
            return

        try:
            var_x = self.var_width.get()
            var_y = self.var_height.get()
            var_a = self.var_angle.get()
        except:
            return

        if var_a < 0:
            if var_a < -360:
                var_a += int(var_a / 360) * 360
            var_a += 360

        if self.var_basepoint.get() != "USER":
            self.cnt_x_absolute, self.cnt_y_absolute = self.coordinates(ABSOLUTE)
            self.var_basepoint.set("USER")

        if self.var_width_base != var_x or self.var_height_base != var_y:

            if self.var_position.get() == ABSOLUTE:
                self.cnt_x_absolute = var_x
                self.cnt_y_absolute = var_y
            else:
                x, y = self.coordinates(ABSOLUTE, "C")
                self.cnt_x_absolute = var_x + x
                self.cnt_y_absolute = var_y + y

            self.var_basepoint.set("USER")

        if arg and arg[0] == "Duplicate":
            self.RotateAndCopy(var_a, Point(self.cnt_x_absolute, self.cnt_y_absolute))
        else:
            self.RotateSelected(var_a, Point(self.cnt_x_absolute, self.cnt_y_absolute))

    def apply_to_copy(self):
        self.apply_rotate("Duplicate")

    def coordinates(self, position, anchor=None):
        br = self.document.selection.coord_rect
        hor_sel = br.right - br.left
        ver_sel = br.top - br.bottom

        if position == RELATIVE:
            left, bottom = -hor_sel / 2.0, -ver_sel / 2.0
        else:
            left, bottom = br.left, br.bottom

        cnt_x, cnt_y = self.Basepoint.get_basepoint(hor_sel, ver_sel, left, bottom, anchor)
        return cnt_x, cnt_y

    def TestBasepoint(self):
        if self.cnt_x_absolute is None:
            return
        base = ["C", "NW", "N", "NE", "W", "E", "SW", "S", "SE"]
        for b in xrange(len(base)):
            cnt_x, cnt_y = self.coordinates(ABSOLUTE, base[b])
            if round(cnt_x, 2) == round(self.cnt_x_absolute, 2) and round(cnt_y, 2) == round(self.cnt_y_absolute, 2):
                self.var_basepoint.set(base[b])
                return
        self.var_basepoint.set("USER")

    def update_pref(self, *arg):
        self.labelwunit["text"] = config.preferences.default_unit
        self.labelhunit["text"] = 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()):

            self.var_width.unit = config.preferences.default_unit
            self.var_height.unit = config.preferences.default_unit

            if self.var_basepoint.get() == "USER":

                if self.var_position.get() == ABSOLUTE:
                    self.var_width.set(self.cnt_x_absolute)
                    self.var_height.set(self.cnt_y_absolute)
                else:
                    x, y = self.coordinates(ABSOLUTE, "C")
                    self.var_width.set(self.cnt_x_absolute - x)
                    self.var_height.set(self.cnt_y_absolute - y)

            else:
                x, y = self.coordinates(self.var_position.get())
                self.var_width.set(x)
                self.var_height.set(y)
                self.var_width_base = self.var_width.get()
                self.var_height_base = self.var_height.get()

    def is_selection(self):
        return len(self.document.selection) > 0
Example #27
0
class PagePanel(CtxSubPanel):

	name = 'PagePanel'

	def __init__(self, parent):
		CtxSubPanel.__init__(self, parent)

		self.USER_SPECIFIC = _("<Custom Size>")

		root = self.mw.root
		self.var_format_name = StringVar(root)
		self.var_format_name.set(config.preferences.default_paper_format)
		self.page_orientation = config.preferences.default_page_orientation

		label = TLabel(self.panel, text=_("Page:"))
		label.pack(side=LEFT, padx=2)
		self.page_formats = TCombobox(self.panel, state='readonly', postcommand=self.set_format,
									 values=self.make_formats(), width=17, style='ComboNormal',
									 textvariable=self.var_format_name)
		tooltips.AddDescription(self.page_formats, _("Page formats"))
		self.page_formats.pack(side=LEFT, padx=2)

		#--------------
		sep = FlatFrame(self.panel, width=5, height=2)
		sep.pack(side=LEFT)
		#--------------

		var_width_number = DoubleVar(root)
		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, var_width_number, var_width_unit)
		self.var_height = LengthVar(10, unit, var_height_number, var_height_unit)
		jump = config.preferences.default_unit_jump

		label = TLabel(self.panel, text=_("H:"))
		label.pack(side=LEFT)
		self.widthentry = TSpinbox(self.panel, textvariable=var_width_number, command=self.applyResize,
								vartype=1, min=5, max=50000, step=jump, width=7)
		tooltips.AddDescription(self.widthentry, _("Page width"))
		self.widthentry.pack(side=LEFT, padx=2)

		#--------------
		sep = FlatFrame(self.panel, width=5, height=2)
		sep.pack(side=LEFT)
		#--------------

		label = TLabel(self.panel, text=_("V:"))
		label.pack(side=LEFT)
		self.heightentry = TSpinbox(self.panel, textvariable=var_height_number, command=self.applyResize,
		 						vartype=1, min=5, max=50000, step=jump, width=7)
		tooltips.AddDescription(self.heightentry, _("Page height"))
		self.heightentry.pack(side=LEFT, padx=2)

		self.portrait_val = StringVar(root)
		self.landscape_val = StringVar(root)

		self.portrait = TCheckbutton(self.panel, image='context_portrait', variable=self.portrait_val,
								   command=self.set_portrait, style='ToolBarCheckButton')
		tooltips.AddDescription(self.portrait, _("Portrait"))
		self.portrait.pack(side=LEFT, padx=2)
		self.landscape = TCheckbutton(self.panel, image='context_landscape', variable=self.landscape_val,
									command=self.set_landscape, style='ToolBarCheckButton')
		tooltips.AddDescription(self.landscape, _("Landscape"))
		self.landscape.pack(side=LEFT)
		config.preferences.Subscribe(CHANGED, self.update_pref)
		self.doc.Subscribe(PAGE, self.update_pref)
		self.doc.Subscribe(UNDO, self.update_pref)


	def init_from_doc(self):
		self.page_orientation = self.doc.Layout().Orientation()

		formatname = self.doc.Layout().FormatName()
		if formatname == '':
			formatname = self.USER_SPECIFIC
			width, height = self.doc.PageSize()
			if width <= height:
				self.page_orientation = 0
			else:
				self.page_orientation = 1
			self.update_size(width, height)

		self.var_format_name.set(formatname)
		self.update()

	def ReSubscribe(self):
		self.init_from_doc()

	def make_formats(self):
		formats = ()
		for format in PapersizesList:
			formats += (format[0],)
		formats += (self.USER_SPECIFIC,)
		return formats

	def set_portrait(self):
		self.page_orientation = 0
		width = min(self.var_width.get(), self.var_height.get())
		height = max(self.var_width.get(), self.var_height.get())
		self.update_size(width, height)
		self.set_size()

	def set_landscape(self):
		self.page_orientation = 1
		width = max(self.var_width.get(), self.var_height.get())
		height = min(self.var_width.get(), self.var_height.get())
		self.update_size(width, height)
		self.set_size()

	def set_size(self):
		self.var_width.UpdateNumber()
		self.var_height.UpdateNumber()
		self.update()
		self.apply_settings()

	def set_format(self):
		if not self.var_format_name.get() == self.doc.page_layout.paperformat:
			self.set_size()

	def update_pref(self, *arg):
		self.var_width.unit = config.preferences.default_unit
		self.var_height.unit = config.preferences.default_unit
		width, height = self.doc.PageSize()
		self.var_format_name.set(self.doc.page_layout.paperformat)
		if self.doc.page_layout.paperformat == "":
			self.var_format_name.set(self.USER_SPECIFIC)
			self.set_entry_sensitivity()
		self.page_orientation = self.doc.page_layout.orientation
		self.update_size(width, height)
		self.update()

	def update(self):
		self.set_entry_sensitivity()
		self.update_size_from_name(self.var_format_name.get())
		if self.page_orientation:
			self.portrait_val.set('')
			self.landscape_val.set('1')
		else:
			self.portrait_val.set('1')
			self.landscape_val.set('')

	def set_entry_sensitivity(self):
		formatname = self.var_format_name.get()
		if formatname != self.USER_SPECIFIC:
			self.widthentry.set_state(DISABLED)
			self.heightentry.set_state(DISABLED)
		else:
			self.widthentry.set_state(NORMAL)
			self.heightentry.set_state(NORMAL)

	def update_size(self, width, height):
		self.var_width.set(width)
		self.var_height.set(height)

	def update_size_from_name(self, formatname):
		if formatname == "":
			formatname = self.USER_SPECIFIC
		if not formatname == self.USER_SPECIFIC:
			width, height = Papersize[formatname]
			if self.page_orientation:
				width, height = height, width
			self.update_size(width, height)

	def applyResize (self, event):
		try:
			width = self.var_width.get()
			height = self.var_height.get()
			if width <= height:
				self.set_portrait()
			else:
				self.set_landscape()
		except:
			return

	def apply_settings(self):
		formatname = self.var_format_name.get()
		if formatname == self.USER_SPECIFIC:
			layout = PageLayout(width=self.var_width.get(),
								height=self.var_height.get(),
								orientation=0)
		else:
			layout = PageLayout(formatname,
								orientation=self.page_orientation)
		self.mw.canvas.bitmap_buffer = None
		self.doc.SetLayout(layout)
		self.doc.pages[self.doc.active_page].page_layout = layout
Example #28
0
class GuidesPanel(CtxSubPanel):

    name = 'GuidesPanel'

    def __init__(self, parent):
        CtxSubPanel.__init__(self, parent)
        b = TButton(self.panel,
                    command=self.makePageFrame,
                    style='Toolbutton',
                    image='context_add_page_frame')
        tooltips.AddDescription(b, _('Add page frame'))
        b.pack(side=LEFT)
        b = TButton(self.panel,
                    command=self.addCenteredGuides,
                    style='Toolbutton',
                    image='context_add_centered_guides')
        tooltips.AddDescription(b, _('Add guides for page center'))
        b.pack(side=LEFT)

        #############
        b = TLabel(self.panel, image="toolbar_sep")
        b.pack(side=LEFT)
        b = TButton(self.panel,
                    command=self.addGuidesFrame,
                    style='Toolbutton',
                    image='context_add_guides_frame')
        tooltips.AddDescription(b, _('Add guides across page border'))
        b.pack(side=LEFT)

        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)

        self.entry_jump = TSpinbox(self.panel,
                                   var=0,
                                   vartype=1,
                                   textvariable=self.var_jump_number,
                                   min=-1000,
                                   max=1000,
                                   step=5,
                                   width=6,
                                   command=self.addGuidesFrame)
        self.entry_jump.pack(side=LEFT, padx=2)
        config.preferences.Subscribe(CHANGED, self.update)
        self.var_jump.set(0)
        self.update(0, 0)

        b = TLabel(self.panel, image="toolbar_sep")
        b.pack(side=LEFT)
        ##############

        b = TButton(self.panel,
                    command=self.removeAllGuides,
                    style='Toolbutton',
                    image='context_remove_all_guides')
        tooltips.AddDescription(b, _('Remove all guides'))
        b.pack(side=LEFT)

    def update(self, *arg):
        self.var_jump.unit = config.preferences.default_unit

    def makePageFrame(self):
        doc = self.doc
        layout = doc.Layout()
        hor_p = layout.Width()
        ver_p = layout.Height()
        path = CreatePath()
        path.AppendLine(Point(0, 0))
        path.AppendLine(Point(hor_p, 0))
        path.AppendLine(Point(hor_p, ver_p))
        path.AppendLine(Point(0, ver_p))
        path.AppendLine(Point(0, 0))
        path.AppendLine(path.Node(0))
        path.ClosePath()
        bezier = PolyBezier((path, ))
        doc.Insert(bezier)

    def addGuidesFrame(self, *arg):
        border = self.var_jump.get()
        doc = self.doc
        layout = doc.Layout()
        hor_p = layout.Width()
        ver_p = layout.Height()
        doc.AddGuideLine(Point(0, 0 + border), 1)
        doc.AddGuideLine(Point(0 + border, 0), 0)
        doc.AddGuideLine(Point(0, ver_p - border), 1)
        doc.AddGuideLine(Point(hor_p - border, 0), 0)

    def addCenteredGuides(self):
        doc = self.doc
        layout = doc.Layout()
        hor_p = layout.Width()
        ver_p = layout.Height()
        doc.AddGuideLine(Point(0, ver_p / 2), 1)
        doc.AddGuideLine(Point(hor_p / 2, 0), 0)

    def removeAllGuides(self):
        doc = self.doc
        guide_lines = doc.GuideLines()
        for line in guide_lines:
            doc.RemoveGuideLine(line)
Example #29
0
    def __init__(self, parent, callback, **kw):
        self.callback = callback
        TFrame.__init__(self, parent, style='FlatFrame', **kw)
        self.R_value = IntVar(0)
        self.G_value = IntVar(0)
        self.B_value = IntVar(0)
        self.A_value = IntVar(0)

        self.HTML_value = StringVar('')

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        frame = TFrame(self, borderwidth=0, style='FlatFrame')
        frame.pack(side=BOTTOM)
        label = TLabel(frame, text=_("Alpha channel: "))
        label.pack(side=LEFT)
        self.A_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.A_value,
                               command=self.rgb_component_changed)
        self.A_spin.pack(side=RIGHT)

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        html_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        html_frame.pack(side=BOTTOM)

        self.HTML_entry = TEntrybox(html_frame,
                                    text='#000000',
                                    width=10,
                                    textvariable=self.HTML_value,
                                    command=self.html_component_changed)
        self.HTML_entry.pack(side=RIGHT)

        label = TLabel(html_frame, text="HTML: ")
        label.pack(side=RIGHT)

        rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        rgb_frame.pack(side=LEFT, padx=10)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="R: ")
        label.pack(side=LEFT)
        self.R_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.R_value,
                               command=self.rgb_component_changed)
        self.R_spin.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="G: ")
        label.pack(side=LEFT)
        self.G_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.G_value,
                               command=self.rgb_component_changed)
        self.G_spin.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="B: ")
        label.pack(side=LEFT)
        self.B_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.B_value,
                               command=self.rgb_component_changed)
        self.B_spin.pack(side=RIGHT)

        cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        cmyk_frame.pack(side=LEFT)

        self.CMYK_label = TLabel(cmyk_frame,
                                 text='C:\nM:\nY:\nK:',
                                 justify=LEFT)
        self.CMYK_label.pack(side=LEFT)
class TextPropPanel(CtxSubPanel):

    name = 'TextPropPanel'

    def __init__(self, parent):
        CtxSubPanel.__init__(self, parent)
        self.my_changes = 0
        self.text_linegap = StringVar(self.mw.root, '100.0')
        self.text_wordgap = StringVar(self.mw.root, '100.0')
        self.text_chargap = StringVar(self.mw.root, '100.0')

        label = TLabel(self.panel, image='context_between_word')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Distance between words'))
        self.entry_word = TSpinbox(self.panel,
                                   var=100.0,
                                   vartype=1,
                                   textvariable=self.text_wordgap,
                                   min=0,
                                   max=5000,
                                   step=10,
                                   width=6,
                                   command=self.applyProperties)
        self.entry_word.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text='% ')
        label.pack(side=LEFT)
        label = TLabel(self.panel, image='context_between_line')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Distance between lines'))
        self.entry_line = TSpinbox(self.panel,
                                   var=100.0,
                                   vartype=1,
                                   textvariable=self.text_linegap,
                                   min=0,
                                   max=5000,
                                   step=10,
                                   width=6,
                                   command=self.applyProperties)
        self.entry_line.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text='% ')
        label.pack(side=LEFT)
        label = TLabel(self.panel, image='context_between_char')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Distance between characters'))
        self.entry_char = TSpinbox(self.panel,
                                   var=100.0,
                                   vartype=1,
                                   textvariable=self.text_chargap,
                                   min=0,
                                   max=5000,
                                   step=10,
                                   width=6,
                                   command=self.applyProperties)
        self.entry_char.pack(side=LEFT, padx=2)
        label = TLabel(self.panel, text='% ')
        label.pack(side=LEFT)

        self.ReSubscribe()

    def ReSubscribe(self):
        self.doc.Subscribe(SELECTION, self.Update)
        self.doc.Subscribe(EDITED, self.Update)

    def applyProperties(self, *arg):
        char = self.entry_char.get_value() / 100
        word = self.entry_word.get_value() / 100
        line = self.entry_line.get_value() / 100
        self.mw.document.CallObjectMethod(text.CommonText,
                                          _("Set Text properties"), 'SetGap',
                                          char, word, line)

    def Update(self, *arg):
        obj = self.mw.document.CurrentObject()
        if obj and obj.is_Text:
            self.entry_word.set_value(obj.properties.wordgap * 100)
            self.entry_line.set_value(obj.properties.linegap * 100)
            self.entry_char.set_value(obj.properties.chargap * 100)
Example #31
0
class TextPropPanel(CtxSubPanel):
	
	name='TextPropPanel'
	
	def __init__(self, parent):
		CtxSubPanel.__init__(self, parent)
		self.my_changes=0
		self.text_linegap=StringVar(self.mw.root,'100.0')
		self.text_wordgap=StringVar(self.mw.root,'100.0')
		self.text_chargap=StringVar(self.mw.root,'100.0')

		
		label = TLabel(self.panel, image='context_between_word')
		label.pack(side = LEFT)
		tooltips.AddDescription(label, _('Distance between words'))
		self.entry_word = TSpinbox(self.panel, var=100.0, vartype=1, textvariable = self.text_wordgap,
						min = 0, max = 5000, step = 10, width = 6, command = self.applyProperties)
		self.entry_word.pack(side = LEFT, padx=2)

		label = TLabel(self.panel, text='% ')
		label.pack(side = LEFT)
		label = TLabel(self.panel, image='context_between_line')
		label.pack(side = LEFT)
		tooltips.AddDescription(label, _('Distance between lines'))
		self.entry_line = TSpinbox(self.panel, var=100.0, vartype=1, textvariable = self.text_linegap,
						min = 0, max = 5000, step = 10, width = 6, command = self.applyProperties)
		self.entry_line.pack(side = LEFT, padx=2)

		label = TLabel(self.panel, text='% ')
		label.pack(side = LEFT)	
		label = TLabel(self.panel, image='context_between_char')
		label.pack(side = LEFT)
		tooltips.AddDescription(label, _('Distance between characters'))
		self.entry_char = TSpinbox(self.panel, var=100.0, vartype=1, textvariable = self.text_chargap,
						min = 0, max = 5000, step = 10, width = 6, command = self.applyProperties)
		self.entry_char.pack(side = LEFT, padx=2)
		label = TLabel(self.panel, text='% ')
		label.pack(side = LEFT)	
				
		self.ReSubscribe()

	def ReSubscribe(self):
		self.doc.Subscribe(SELECTION, self.Update)	
		self.doc.Subscribe(EDITED, self.Update)
						
	def applyProperties(self, *arg):
		char=self.entry_char.get_value()/100
		word=self.entry_word.get_value()/100
		line=self.entry_line.get_value()/100		
		self.mw.document.CallObjectMethod(text.CommonText, _("Set Text properties"),
											'SetGap', char, word, line)
	
	def Update(self, *arg):
		obj=self.mw.document.CurrentObject()		
		if obj and obj.is_Text:
			self.entry_word.set_value(obj.properties.wordgap*100)
			self.entry_line.set_value(obj.properties.linegap*100)
			self.entry_char.set_value(obj.properties.chargap*100)
			
Example #32
0
class RGBDigitizer(TFrame):
    def __init__(self, parent, callback, **kw):
        self.callback = callback
        TFrame.__init__(self, parent, style='FlatFrame', **kw)
        self.R_value = IntVar(0)
        self.G_value = IntVar(0)
        self.B_value = IntVar(0)
        self.A_value = IntVar(0)

        self.HTML_value = StringVar('')

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        frame = TFrame(self, borderwidth=0, style='FlatFrame')
        frame.pack(side=BOTTOM)
        label = TLabel(frame, text=_("Alpha channel: "))
        label.pack(side=LEFT)
        self.A_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.A_value,
                               command=self.rgb_component_changed)
        self.A_spin.pack(side=RIGHT)

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        html_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        html_frame.pack(side=BOTTOM)

        self.HTML_entry = TEntrybox(html_frame,
                                    text='#000000',
                                    width=10,
                                    textvariable=self.HTML_value,
                                    command=self.html_component_changed)
        self.HTML_entry.pack(side=RIGHT)

        label = TLabel(html_frame, text="HTML: ")
        label.pack(side=RIGHT)

        rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        rgb_frame.pack(side=LEFT, padx=10)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="R: ")
        label.pack(side=LEFT)
        self.R_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.R_value,
                               command=self.rgb_component_changed)
        self.R_spin.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="G: ")
        label.pack(side=LEFT)
        self.G_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.G_value,
                               command=self.rgb_component_changed)
        self.G_spin.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="B: ")
        label.pack(side=LEFT)
        self.B_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.B_value,
                               command=self.rgb_component_changed)
        self.B_spin.pack(side=RIGHT)

        cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        cmyk_frame.pack(side=LEFT)

        self.CMYK_label = TLabel(cmyk_frame,
                                 text='C:\nM:\nY:\nK:',
                                 justify=LEFT)
        self.CMYK_label.pack(side=LEFT)

    def set_color(self, color):
        self.color = color
        self.R_value.set(int(round(color.red * 255)))
        self.G_value.set(int(round(color.green * 255)))
        self.B_value.set(int(round(color.blue * 255)))
        self.A_value.set(int(round(color.alpha * 255)))
        c, m, y, k = color.getCMYK()
        self.CMYK_label['text'] = 'C: %.2f\nM: %.2f\nY: %.2f\nK: %.2f' % (
            round(c * 100, 2), round(m * 100, 2), round(y * 100,
                                                        2), round(k * 100, 2))
        int_color = (round(color.red * 255), round(color.green * 255),
                     round(color.blue * 255))
        self.HTML_value.set('#%02X%02X%02X' % int_color)

    def rgb_component_changed(self, *arg):
        r = self.R_value.get() / 255.0
        g = self.G_value.get() / 255.0
        b = self.B_value.get() / 255.0
        a = self.A_value.get() / 255.0
        self.callback(CreateRGBAColor(r, g, b, a))

    def html_component_changed(self, *arg):
        html = self.HTML_value.get()
        try:
            r = int(string.atoi(html[1:3], 0x10)) / 255.0
            g = int(string.atoi(html[3:5], 0x10)) / 255.0
            b = int(string.atoi(html[5:], 0x10)) / 255.0
        except:
            r = round(self.color.red * 255, 2)
            g = round(self.color.green * 255, 2)
            b = round(self.color.blue * 255, 2)
        self.callback(CreateRGBAColor(r, g, b, self.A_value.get() / 255.0))
Example #33
0
class CMYKDigitizer(TFrame):
    def __init__(self, parent, callback, **kw):
        self.callback = callback
        TFrame.__init__(self, parent, style='FlatFrame', **kw)
        self.C_value = DoubleVar(0)
        self.M_value = DoubleVar(0)
        self.Y_value = DoubleVar(0)
        self.K_value = DoubleVar(0)
        self.A_value = DoubleVar(0)

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        frame = TFrame(self, borderwidth=0, style='FlatFrame')
        frame.pack(side=BOTTOM)
        label = TLabel(frame, text=_("Opacity: "))
        label.pack(side=LEFT)
        self.A_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.A_value,
                               command=self.cmyk_component_changed)
        self.A_spin.pack(side=RIGHT)

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        cmyk_frame.pack(side=LEFT, padx=10)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="C: ")
        label.pack(side=LEFT)
        self.C_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.C_value,
                               command=self.cmyk_component_changed)
        self.C_spin.pack(side=RIGHT)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="M: ")
        label.pack(side=LEFT)
        self.M_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.M_value,
                               command=self.cmyk_component_changed)
        self.M_spin.pack(side=RIGHT)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="Y: ")
        label.pack(side=LEFT)
        self.Y_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.Y_value,
                               command=self.cmyk_component_changed)
        self.Y_spin.pack(side=RIGHT)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="K: ")
        label.pack(side=LEFT)
        self.K_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.K_value,
                               command=self.cmyk_component_changed)
        self.K_spin.pack(side=RIGHT)

        rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        rgb_frame.pack(side=LEFT)

        self.RGB_label = TLabel(rgb_frame, text='R:\nG:\nB:', justify=LEFT)
        self.RGB_label.pack(side=LEFT)

    def set_color(self, color):
        self.color = color
        c, m, y, k = color.getCMYK()
        self.C_value.set(round(c * 100, 2))
        self.M_value.set(round(m * 100, 2))
        self.Y_value.set(round(y * 100, 2))
        self.K_value.set(round(k * 100, 2))
        self.A_value.set(int(round(color.alpha * 100)))
        r, g, b = color.getRGB()
        text = 'R: %d\nG: %d\nB: %d' % (round(r * 255, 2), round(
            g * 255, 2), round(b * 255, 2))
        int_color = (round(r * 255), round(g * 255), round(b * 255))
        text += '\n\n#%02X%02X%02X' % int_color
        self.RGB_label['text'] = text

    def cmyk_component_changed(self, *arg):
        c = self.C_value.get() / 100.0
        m = self.M_value.get() / 100.0
        y = self.Y_value.get() / 100.0
        k = self.K_value.get() / 100.0
        a = self.A_value.get() / 100.0
        self.callback(CreateCMYKAColor(c, m, y, k, a))
Example #34
0
class SkewPanel(PluginPanel):
    name = 'Skew'
    title = _("Skew")

    def init(self, master):
        PluginPanel.init(self, master)

        self.width_priority = 1

        root = self.mw.root

        self.var_angleX = DoubleVar(root)
        self.var_angleY = DoubleVar(root)

        jump = 5
        self.var_angleX.set(0)
        self.var_angleY.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_frameH = TFrame(top, style='FlatFrame', borderwidth=3)
        size_frameH.pack(side=TOP, fill=BOTH)

        label = TLabel(size_frameH, style='FlatLabel', image='skew_h')
        label.pack(side=LEFT, padx=5)
        self.entry_angleX = TSpinbox(size_frameH,
                                     var=0,
                                     vartype=1,
                                     textvariable=self.var_angleX,
                                     min=-75,
                                     max=75,
                                     step=jump,
                                     width=10,
                                     command=self.apply_skew)
        self.entry_angleX.pack(side=LEFT)

        self.labelwunit = TLabel(size_frameH, style='FlatLabel', text=_("deg"))
        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='skew_v')
        label.pack(side=LEFT, padx=5)

        self.entry_angleY = TSpinbox(size_frameV,
                                     var=0,
                                     vartype=1,
                                     textvariable=self.var_angleY,
                                     min=-75,
                                     max=75,
                                     step=jump,
                                     width=10,
                                     command=self.apply_skew)
        self.entry_angleY.pack(side=LEFT)

        self.labelhunit = TLabel(size_frameV, style='FlatLabel', text=_("deg"))
        self.labelhunit.pack(side=LEFT, padx=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_deg')
        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_skew)
        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 subscribe_receivers(self):
        self.document.Subscribe(SELECTION, self.Update)

    def unsubscribe_receivers(self):
        self.document.Unsubscribe(SELECTION, self.Update)

    def init_from_doc(self):
        self.Update()

    def Update(self, *arg):
        if self.is_selection():
            self.entry_angleX.set_state(NORMAL)
            self.entry_angleY.set_state(NORMAL)
            self.button['state'] = NORMAL
            self.button_copy['state'] = NORMAL
        else:
            self.entry_angleX.set_state(DISABLED)
            self.entry_angleY.set_state(DISABLED)
            self.button['state'] = DISABLED
            self.button_copy['state'] = DISABLED

    def SkewSelected(self, axisX=0, axisY=0):
        if self.document.selection:
            self.document.begin_transaction()
            try:
                try:
                    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)

                    text = _("Skew")
                    ax, ay = tan(axisX), tan(axisY)
                    sx = 1.0
                    sy = 1.0 - (ax * ay)
                    tx = cnt_x * ax
                    ty = cnt_y * ax * ay - cnt_y * ay
                    # Move the selection in the coordinates x0 y0
                    trafo = Trafo(1, 0, 0, 1, -cnt_x, -cnt_y)
                    # Skew and Scaling
                    trafo = Trafo(sx, ay, -ax, sy, 0, 0)(trafo)
                    # Move the selection in the coordinates basepoint
                    trafo = Trafo(1, 0, 0, 1, cnt_x, cnt_y)(trafo)
                    self.document.TransformSelected(trafo, text)
                except:
                    self.document.abort_transaction()
            finally:
                self.document.end_transaction()

    def apply_skew(self, *arg):
        if self.button["state"] == DISABLED:
            return
        try:
            angleX = self.var_angleX.get() * degrees
            angleY = self.var_angleY.get() * degrees
            self.SkewSelected(angleX, angleY)
        except:
            return

    def apply_to_copy(self):
        if self.button["state"] == DISABLED:
            return
        self.document.begin_transaction(_("Skew&Copy"))
        try:
            try:
                self.document.ApplyToDuplicate()
                self.apply_skew()
            except:
                self.document.abort_transaction()
        finally:
            self.document.end_transaction()

    def is_selection(self):
        return (len(self.document.selection) > 0)
Example #35
0
class RotatePanel(PluginPanel):
    name = 'Rotate'
    title = _("Rotate")

    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 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_angle.set_state(NORMAL)
            self.entry_width.set_state(NORMAL)
            self.entry_height.set_state(NORMAL)
            self.position_check['state'] = NORMAL
            self.button['state'] = NORMAL
            self.button_copy['state'] = NORMAL
            self.TestBasepoint()
        else:
            self.entry_angle.set_state(DISABLED)
            self.entry_width.set_state(DISABLED)
            self.entry_height.set_state(DISABLED)
            self.position_check['state'] = DISABLED
            self.button['state'] = DISABLED
            self.button_copy['state'] = DISABLED

        self.update_pref()

    def apply_basepoint(self):
        self.update_var()

    def position(self):
        self.update_var()

    def RotateSelected(self, angle, cnt=None):
        text = _("Rotation")
        if self.document.selection:
            self.document.begin_transaction(text)
            try:
                try:
                    if cnt is None:
                        cnt = self.document.selection.coord_rect.center()
                    angle = angle * degrees
                    trafo = Rotation(angle, cnt)
                    self.document.TransformSelected(trafo, text)
                except:
                    self.document.abort_transaction()
            finally:
                self.document.end_transaction()

    def RotateAndCopy(self, angle, cnt=None):
        text = _("Rotation&Copy")
        if self.document.selection:
            self.document.begin_transaction(text)
            try:
                try:
                    if cnt is None:
                        cnt = self.document.selection.coord_rect.center()
                    angle = angle * degrees
                    trafo = Rotation(angle, cnt)
                    self.document.ApplyToDuplicate()
                    self.document.TransformSelected(trafo, text)
                except:
                    self.document.abort_transaction()
            finally:
                self.document.end_transaction()

    def apply_rotate(self, *arg):
        if self.button["state"] == DISABLED:
            return

        try:
            var_x = self.var_width.get()
            var_y = self.var_height.get()
            var_a = self.var_angle.get()
        except:
            return

        if var_a < 0:
            if var_a < -360:
                var_a += int(var_a / 360) * 360
            var_a += 360

        if self.var_basepoint.get() != 'USER':
            self.cnt_x_absolute, self.cnt_y_absolute = self.coordinates(
                ABSOLUTE)
            self.var_basepoint.set('USER')

        if self.var_width_base != var_x or self.var_height_base != var_y:

            if self.var_position.get() == ABSOLUTE:
                self.cnt_x_absolute = var_x
                self.cnt_y_absolute = var_y
            else:
                x, y = self.coordinates(ABSOLUTE, 'C')
                self.cnt_x_absolute = var_x + x
                self.cnt_y_absolute = var_y + y

            self.var_basepoint.set('USER')

        if arg and arg[0] == 'Duplicate':
            self.RotateAndCopy(var_a,
                               Point(self.cnt_x_absolute, self.cnt_y_absolute))
        else:
            self.RotateSelected(
                var_a, Point(self.cnt_x_absolute, self.cnt_y_absolute))

    def apply_to_copy(self):
        self.apply_rotate('Duplicate')

    def coordinates(self, position, anchor=None):
        br = self.document.selection.coord_rect
        hor_sel = br.right - br.left
        ver_sel = br.top - br.bottom

        if position == RELATIVE:
            left, bottom = -hor_sel / 2.0, -ver_sel / 2.0
        else:
            left, bottom = br.left, br.bottom

        cnt_x, cnt_y = self.Basepoint.get_basepoint(hor_sel, ver_sel, left,
                                                    bottom, anchor)
        return cnt_x, cnt_y

    def TestBasepoint(self):
        if self.cnt_x_absolute is None:
            return
        base = ['C', 'NW', 'N', 'NE', 'W', 'E', 'SW', 'S', 'SE']
        for b in xrange(len(base)):
            cnt_x, cnt_y = self.coordinates(ABSOLUTE, base[b])
            if round(cnt_x,2) == round(self.cnt_x_absolute,2) and \
                 round(cnt_y,2) == round(self.cnt_y_absolute,2):
                self.var_basepoint.set(base[b])
                return
        self.var_basepoint.set('USER')

    def update_pref(self, *arg):
        self.labelwunit['text'] = config.preferences.default_unit
        self.labelhunit['text'] = 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()):

            self.var_width.unit = config.preferences.default_unit
            self.var_height.unit = config.preferences.default_unit

            if self.var_basepoint.get() == 'USER':

                if self.var_position.get() == ABSOLUTE:
                    self.var_width.set(self.cnt_x_absolute)
                    self.var_height.set(self.cnt_y_absolute)
                else:
                    x, y = self.coordinates(ABSOLUTE, 'C')
                    self.var_width.set(self.cnt_x_absolute - x)
                    self.var_height.set(self.cnt_y_absolute - y)

            else:
                x, y = self.coordinates(self.var_position.get())
                self.var_width.set(x)
                self.var_height.set(y)
                self.var_width_base = self.var_width.get()
                self.var_height_base = self.var_height.get()

    def is_selection(self):
        return (len(self.document.selection) > 0)
class ScalePanel(PluginPanel):
    name = 'ScaleAndMirror'
    title = _("Scale and Mirror")

    def init(self, master):
        PluginPanel.init(self, master)

        self.width_priority = 1

        root = self.mw.root
        self.var_width = DoubleVar(root)
        self.var_height = DoubleVar(root)

        unit = '%'
        jump = 5

        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=100,
                                    vartype=1,
                                    textvariable=self.var_width,
                                    min=-30000,
                                    max=30000,
                                    step=jump,
                                    width=6,
                                    command=self.apply_scale)
        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=unit)
        self.labelwunit.pack(side=LEFT, padx=5)

        self.hflip = BooleanVar(root)
        self.hflip.set(0)
        button = TCheckbutton(size_frameH,
                              image="pstrip_hflip",
                              style='ToolBarCheckButton',
                              variable=self.hflip,
                              command=None)
        button.pack(side=LEFT)

        #---------------------------------------------------------
        # 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=100,
                                     vartype=1,
                                     textvariable=self.var_height,
                                     min=-30000,
                                     max=30000,
                                     step=jump,
                                     width=6,
                                     command=self.apply_scale)
        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=unit)
        self.labelhunit.pack(side=LEFT, padx=5)

        self.vflip = BooleanVar(root)
        self.vflip.set(0)
        button = TCheckbutton(size_frameV,
                              image="pstrip_vflip",
                              style='ToolBarCheckButton',
                              variable=self.vflip,
                              command=None)
        button.pack(side=LEFT)

        #---------------------------------------------------------
        # 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_scale)
        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 subscribe_receivers(self):
        self.document.Subscribe(SELECTION, self.Update)

    def unsubscribe_receivers(self):
        self.document.Unsubscribe(SELECTION, self.Update)

    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

    def entry_width_FocusIn(self, *arg):
        self.width_priority = 1

    def entry_height_FocusIn(self, *arg):
        self.width_priority = 0

    def ScaleSelected(self, h, v, cnt_x=None, cnt_y=None):
        text = _("Scale")
        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 ScaleAndCopy(self, h, v, cnt_x=None, cnt_y=None):
        text = _("Scale&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():
            self.var_width.set(self.var_height.get())

    def entry_width_chang(self, *arg):
        if self.var_proportional.get():
            self.var_height.set(self.var_width.get())

    def proportional(self):
        if self.width_priority:
            self.entry_width_chang()
        else:
            self.entry_height_chang()

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

        h = width / 100
        if h == 0:
            h = 1
        if self.hflip.get():
            h = -1 * h

        v = height / 100
        if v == 0:
            v = 1
        if self.vflip.get():
            v = -1 * v

        if arg and arg[0] == 'Duplicate':
            self.ScaleAndCopy(h, v, cnt_x, cnt_y)
        else:
            self.ScaleSelected(h, v, cnt_x, cnt_y)

    def apply_to_copy(self):
        self.apply_scale('Duplicate')

    def is_selection(self):
        return (len(self.document.selection) > 0)
Example #37
0
class ResizePanel(CtxSubPanel):

    name = 'ResizePanel'

    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 ReSubscribe(self):
        self.doc.Subscribe(SELECTION, self.Update)
        self.doc.Subscribe(EDITED, self.update)
        self.Update()

    def applyResize(self, event):
        try:
            x = self.var_width.get()
            y = self.var_height.get()
            br = self.doc.selection.coord_rect
            hor_sel = br.right - br.left
            ver_sel = br.top - br.bottom
        except:
            return

        if hor_sel:
            xx = x / hor_sel
        else:
            xx = 1

        if ver_sel:
            yy = y / ver_sel
        else:
            yy = 1

        self.doc.ScaleSelected(xx, yy)
        self.update_size()

    def update(self, issue):
        self.Update()

    def Update(self):
        if len(self.doc.selection.GetInfo()):
            self.update_size()

    def update_size(self):
        self.var_width.unit = config.preferences.default_unit
        self.var_height.unit = config.preferences.default_unit
        br = self.doc.selection.coord_rect
        width = br.right - br.left
        height = br.top - br.bottom
        self.var_width.set(width)
        self.var_height.set(height)
        self.entry_width.step = config.preferences.default_unit_jump
        self.entry_height.step = config.preferences.default_unit_jump

    def update_pref(self, arg1, arg2):
        if self.my_changes:
            self.my_changes = 0
        else:
            if len(self.doc.selection.GetInfo()):
                self.update_size()
Example #38
0
class MovePanel(PluginPanel):
	name='Move'
	title = _("Move")


	def init(self, master):
		PluginPanel.init(self, master)

		root=self.mw.root
		self.var_width_number=DoubleVar(root)
		self.var_height_number=DoubleVar(root)
		
		self.var_width_base=DoubleVar(root)
		self.var_height_base=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_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)
		#---------------------------------------------------------
		# Horisontal size
		size_frameH = TFrame(top, style='FlatFrame', borderwidth=3)
		size_frameH.pack(side = TOP, fill = BOTH)
		
		label = TLabel(size_frameH, style='FlatLabel', image='move_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_move)
		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='move_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_move)
		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 Coordinates"), 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_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_move)
		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 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.position_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.position_check['state']=DISABLED
			self.button['state']=DISABLED
			self.button_copy['state']=DISABLED
			
		self.update_pref()

	def apply_basepoint(self):
		self.Update()

	def position(self):
		if self.var_position.get()==ABSOLUTE and self.var_basepoint.get()=='USER':
			self.var_basepoint.set('C')
		self.update_var()

	def apply_move(self, *arg):
		if self.button["state"]==DISABLED:
			return
		try:
				var_x=self.var_width.get()
				var_y=self.var_height.get()
		except:
				return
		
		x, y = self.coordinates(self.var_position.get())
		
		if self.var_position.get()==RELATIVE:
			if self.var_width_base != self.var_width.get() or self.var_height_base != self.var_height.get():
				self.var_basepoint.set('USER')
			x,y = var_x, var_y
		else:
			x,y = var_x-x, var_y-y
		
		if arg and arg[0] == 'Duplicate':
			self.document.MoveAndCopy(x, y, Point(0,0))
		else:
			self.document.MoveSelected(x, y)

	def apply_to_copy(self):
		self.apply_move('Duplicate')


	def coordinates(self, position):
		br=self.document.selection.coord_rect
		hor_sel=br.right - br.left
		ver_sel=br.top - br.bottom
		
		if position == RELATIVE:
			left, bottom = -hor_sel/2, -ver_sel/2
		else:
			left, bottom = br.left, br.bottom
		
		cnt_x,cnt_y=self.Basepoint.get_basepoint(hor_sel,ver_sel,left,bottom)
		
		if position == RELATIVE and cnt_x!=None:
			return cnt_x*2, cnt_y*2
		else:
			return cnt_x, cnt_y

	def update_pref(self, *arg):
		self.labelwunit['text']=config.preferences.default_unit
		self.labelhunit['text']=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()):
			if self.var_basepoint.get() == 'USER':
				x=self.var_width.get()
				y=self.var_height.get()
				self.var_width.unit=config.preferences.default_unit
				self.var_height.unit=config.preferences.default_unit
				self.var_width.set(x)
				self.var_height.set(y)
				
			else:
				self.var_width.unit=config.preferences.default_unit
				self.var_height.unit=config.preferences.default_unit
				x, y = self.coordinates(self.var_position.get())
				self.var_width.set(x)
				self.var_height.set(y)
				self.var_width_base=self.var_width.get()
				self.var_height_base=self.var_height.get()

	def is_selection(self):
		return (len(self.document.selection) > 0)
Example #39
0
    def build_dlg(self):
        super = self.top
        top = TFrame(super, borderwidth=10, style='FlatFrame')
        top.pack(side=TOP, fill=BOTH, expand=1)

        frame = TFrame(top, style='FlatFrame')
        frame.pack(side=BOTTOM, fill=BOTH, expand=0)

        label = TLabel(top, style="HLine")
        label.pack(side=BOTTOM, fill=BOTH, expand=0)

        button = TButton(frame, text=_("Cancel"), command=self.cancel)
        button.pack(side=RIGHT, expand=0)
        label = TLabel(frame, image="space_6", style="FlatLabel")
        label.pack(side=RIGHT)
        button = TButton(frame, text=_("OK"), command=self.ok)
        button.pack(side=RIGHT, expand=0)
        button = TButton(frame, image='colorpicker', state='disabled')
        button.pack(side=LEFT, expand=0)

        #       RGBlabel_frame = TFrame(top, borderwidth = 1, style='FlatFrame')
        #       RGBlabel_frame.pack(side = BOTTOM, fill = BOTH)
        #
        #       self.label = TLabel(RGBlabel_frame, style="FlatLabel")
        #       self.label.pack(side = LEFT)

        frame = TFrame(top, style="RoundedFrame", borderwidth=5)
        frame.pack(side=LEFT)
        viewxy = ChooseRGBXY(frame, xyramp_size[0], xyramp_size[1], 0, 1)
        viewxy.pack(side=LEFT)

        frame = TFrame(top, style="RoundedFrame", borderwidth=5)
        frame.pack(side=LEFT)
        viewz = ChooseRGBZ(frame, zramp_size[0], zramp_size[1], 2)
        viewz.pack(side=LEFT)

        frame1 = TFrame(top, borderwidth=3, style='FlatFrame')
        frame1.pack(side=RIGHT)

        CS_frame = TFrame(frame1, borderwidth=1, style='FlatFrame')
        CS_frame.pack(side=TOP)

        label = TLabel(CS_frame,
                       text="Old color:   \nNew color:   ",
                       justify='right')
        label.pack(side=LEFT)

        frame = TFrame(CS_frame, style="RoundedFrame", borderwidth=5)
        frame.pack(side=LEFT)

        self.sample = ColorSample(frame, self.color, width=60, height=20)
        self.sample.pack(side=BOTTOM)
        sample = ColorSample(frame, self.color, width=60, height=20)
        sample.pack(side=TOP)

        label = TLabel(frame1, style="HLine")
        label.pack(side=TOP, fill=BOTH, expand=0)

        spin_frame = TFrame(frame1, borderwidth=1, style='FlatFrame')
        spin_frame.pack(side=TOP)

        hsv_frame = TFrame(spin_frame, borderwidth=2, style='FlatFrame')
        hsv_frame.pack(side=LEFT)

        frame = TFrame(hsv_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="H: ")
        label.pack(side=LEFT)
        self.var1 = TSpinbox(frame,
                             min=0,
                             max=1.0,
                             step=0.01,
                             vartype=1,
                             command=self.component_changed)
        self.var1.pack(side=RIGHT)

        frame = TFrame(hsv_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="S: ")
        label.pack(side=LEFT)
        self.var2 = TSpinbox(frame,
                             min=0,
                             max=1.0,
                             step=0.01,
                             vartype=1,
                             command=self.component_changed)
        self.var2.pack(side=RIGHT)

        frame = TFrame(hsv_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="V: ")
        label.pack(side=LEFT)
        self.var3 = TSpinbox(frame,
                             min=0,
                             max=1.0,
                             step=0.01,
                             vartype=1,
                             command=self.component_changed)
        self.var3.pack(side=RIGHT)

        rgb_frame = TFrame(spin_frame, borderwidth=2, style='FlatFrame')
        rgb_frame.pack(side=LEFT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="R: ")
        label.pack(side=LEFT)
        self.var4 = TSpinbox(frame,
                             min=0,
                             max=255,
                             step=1,
                             vartype=0,
                             command=self.rgb_component_changed)
        self.var4.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="G: ")
        label.pack(side=LEFT)
        self.var5 = TSpinbox(frame,
                             min=0,
                             max=255,
                             step=1,
                             vartype=0,
                             command=self.rgb_component_changed)
        self.var5.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="B: ")
        label.pack(side=LEFT)
        self.var6 = TSpinbox(frame,
                             min=0,
                             max=255,
                             step=1,
                             vartype=0,
                             command=self.rgb_component_changed)
        self.var6.pack(side=RIGHT)

        HTML_frame = TFrame(frame1, borderwidth=3, style='FlatFrame')
        HTML_frame.pack(side=TOP)

        label = TLabel(HTML_frame, text="HTML: ")
        label.pack(side=LEFT)
        self.html = TEntrybox(HTML_frame,
                              text='#000000',
                              width=10,
                              command=self.html_component_changed)
        self.html.pack(side=LEFT)

        viewxy.Subscribe(CHANGED, self.color_changed)
        viewz.Subscribe(CHANGED, self.color_changed)
        self.viewxy = viewxy
        self.viewz = viewz

        super.resizable(width=0, height=0)

        self.color_changed(self.color)
Example #40
0
    def init(self, master):
        PluginPanel.init(self, master)

        self.width_priority = 1

        root = self.mw.root

        self.var_angleX = DoubleVar(root)
        self.var_angleY = DoubleVar(root)

        jump = 5
        self.var_angleX.set(0)
        self.var_angleY.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_frameH = TFrame(top, style="FlatFrame", borderwidth=3)
        size_frameH.pack(side=TOP, fill=BOTH)

        label = TLabel(size_frameH, style="FlatLabel", image="skew_h")
        label.pack(side=LEFT, padx=5)
        self.entry_angleX = TSpinbox(
            size_frameH,
            var=0,
            vartype=1,
            textvariable=self.var_angleX,
            min=-75,
            max=75,
            step=jump,
            width=10,
            command=self.apply_skew,
        )
        self.entry_angleX.pack(side=LEFT)

        self.labelwunit = TLabel(size_frameH, style="FlatLabel", text=_("deg"))
        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="skew_v")
        label.pack(side=LEFT, padx=5)

        self.entry_angleY = TSpinbox(
            size_frameV,
            var=0,
            vartype=1,
            textvariable=self.var_angleY,
            min=-75,
            max=75,
            step=jump,
            width=10,
            command=self.apply_skew,
        )
        self.entry_angleY.pack(side=LEFT)

        self.labelhunit = TLabel(size_frameV, style="FlatLabel", text=_("deg"))
        self.labelhunit.pack(side=LEFT, padx=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_deg")
        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_skew)
        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()
Example #41
0
class CMYKDigitizer(TFrame):
	
	def __init__(self, parent, callback, **kw):
		self.callback = callback
		TFrame.__init__(self, parent, style='FlatFrame', **kw)
		self.C_value = DoubleVar(0)
		self.M_value = DoubleVar(0)
		self.Y_value = DoubleVar(0)
		self.K_value = DoubleVar(0)
		self.A_value = DoubleVar(0)
		
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)
		
		frame = TFrame(self, borderwidth=0, style='FlatFrame')
		frame.pack(side=BOTTOM)
		label = TLabel(frame, text=_("Opacity: "))
		label.pack(side=LEFT)
		self.A_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.A_value, command=self.cmyk_component_changed)
		self.A_spin.pack(side=RIGHT)
		
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)
		
		cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		cmyk_frame.pack(side=LEFT, padx=10)
		
		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="C: ")
		label.pack(side=LEFT)
		self.C_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.C_value, command=self.cmyk_component_changed)
		self.C_spin.pack(side=RIGHT)

		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="M: ")
		label.pack(side=LEFT)
		self.M_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.M_value, command=self.cmyk_component_changed)
		self.M_spin.pack(side=RIGHT)

		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="Y: ")
		label.pack(side=LEFT)
		self.Y_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.Y_value, command=self.cmyk_component_changed)
		self.Y_spin.pack(side=RIGHT)		

		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="K: ")
		label.pack(side=LEFT)
		self.K_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.K_value, command=self.cmyk_component_changed)
		self.K_spin.pack(side=RIGHT)
		
		rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		rgb_frame.pack(side=LEFT)
		
		self.RGB_label = TLabel(rgb_frame, text='R:\nG:\nB:', justify=LEFT)
		self.RGB_label.pack(side=LEFT)		
		
		
	def set_color(self, color):
		self.color = color
		c, m, y, k = color.getCMYK()
		self.C_value.set(round(c * 100, 2))
		self.M_value.set(round(m * 100, 2))
		self.Y_value.set(round(y * 100, 2))
		self.K_value.set(round(k * 100, 2))
		self.A_value.set(int(round(color.alpha * 100)))
		r, g, b = color.getRGB()
		text = 'R: %d\nG: %d\nB: %d' % (round(r * 255, 2), round(g * 255, 2), round(b * 255, 2))
		int_color = (round(r * 255), round(g * 255), round(b * 255))
		text += '\n\n#%02X%02X%02X' % int_color		
		self.RGB_label['text'] = text	
		
		
	def cmyk_component_changed(self, *arg):
		c = self.C_value.get() / 100.0
		m = self.M_value.get() / 100.0
		y = self.Y_value.get() / 100.0
		k = self.K_value.get() / 100.0		
		a = self.A_value.get() / 100.0
		self.callback(CreateCMYKAColor(c, m, y, k, a))
Example #42
0
	def __init__(self, parent):
		CtxSubPanel.__init__(self, parent)

		self.USER_SPECIFIC = _("<Custom Size>")

		root = self.mw.root
		self.var_format_name = StringVar(root)
		self.var_format_name.set(config.preferences.default_paper_format)
		self.page_orientation = config.preferences.default_page_orientation

		label = TLabel(self.panel, text=_("Page:"))
		label.pack(side=LEFT, padx=2)
		self.page_formats = TCombobox(self.panel, state='readonly', postcommand=self.set_format,
									 values=self.make_formats(), width=17, style='ComboNormal',
									 textvariable=self.var_format_name)
		tooltips.AddDescription(self.page_formats, _("Page formats"))
		self.page_formats.pack(side=LEFT, padx=2)

		#--------------
		sep = FlatFrame(self.panel, width=5, height=2)
		sep.pack(side=LEFT)
		#--------------

		var_width_number = DoubleVar(root)
		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, var_width_number, var_width_unit)
		self.var_height = LengthVar(10, unit, var_height_number, var_height_unit)
		jump = config.preferences.default_unit_jump

		label = TLabel(self.panel, text=_("H:"))
		label.pack(side=LEFT)
		self.widthentry = TSpinbox(self.panel, textvariable=var_width_number, command=self.applyResize,
								vartype=1, min=5, max=50000, step=jump, width=7)
		tooltips.AddDescription(self.widthentry, _("Page width"))
		self.widthentry.pack(side=LEFT, padx=2)

		#--------------
		sep = FlatFrame(self.panel, width=5, height=2)
		sep.pack(side=LEFT)
		#--------------

		label = TLabel(self.panel, text=_("V:"))
		label.pack(side=LEFT)
		self.heightentry = TSpinbox(self.panel, textvariable=var_height_number, command=self.applyResize,
		 						vartype=1, min=5, max=50000, step=jump, width=7)
		tooltips.AddDescription(self.heightentry, _("Page height"))
		self.heightentry.pack(side=LEFT, padx=2)

		self.portrait_val = StringVar(root)
		self.landscape_val = StringVar(root)

		self.portrait = TCheckbutton(self.panel, image='context_portrait', variable=self.portrait_val,
								   command=self.set_portrait, style='ToolBarCheckButton')
		tooltips.AddDescription(self.portrait, _("Portrait"))
		self.portrait.pack(side=LEFT, padx=2)
		self.landscape = TCheckbutton(self.panel, image='context_landscape', variable=self.landscape_val,
									command=self.set_landscape, style='ToolBarCheckButton')
		tooltips.AddDescription(self.landscape, _("Landscape"))
		self.landscape.pack(side=LEFT)
		config.preferences.Subscribe(CHANGED, self.update_pref)
		self.doc.Subscribe(PAGE, self.update_pref)
		self.doc.Subscribe(UNDO, self.update_pref)
Example #43
0
class EllipsePanel(CtxSubPanel):

	name = 'EllipsePanel'

	def __init__(self, parent):
		CtxSubPanel.__init__(self, parent)
		self.start = DoubleVar(self.mw.root, 0)
		self.end = DoubleVar(self.mw.root, 0)
		self.builded = 0
		self.ReSubscribe()

	def ReSubscribe(self):
		self.doc.Subscribe(SELECTION, self.update)
		self.doc.Subscribe(EDITED, self.update)

	def update(self, *arg):
		if not self.mw.canvas is None:
			self.build_dlg()

	def applyAngle(self, *arg):
		start = self.entry_start.get_value() * degrees
		end = self.entry_end.get_value() * degrees
		self.mw.document.CallObjectMethod(ellipse.Ellipse, _("Edit Object"),
								'SetAngles', start, end)

	def SwapAngle(self):
		start = self.entry_start.get_value()
		end = self.entry_end.get_value()
		self.entry_start.set_value(end)
		self.entry_end.set_value(start)
		self.applyAngle()

	def ResetAngle(self):
		self.entry_start.set_value(0)
		self.entry_end.set_value(0)
		self.applyAngle()

	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)
Example #44
0
class ChooseColorDlg(SKModal):

    title = _("Select RGB Color")
    class_name = 'ColorDialog'

    def __init__(self, master, color, **kw):
        self.color = color.RGB()
        self.orig_color = color.RGB()
        apply(SKModal.__init__, (self, master), kw)

    def build_dlg(self):
        super = self.top
        top = TFrame(super, borderwidth=10, style='FlatFrame')
        top.pack(side=TOP, fill=BOTH, expand=1)

        frame = TFrame(top, style='FlatFrame')
        frame.pack(side=BOTTOM, fill=BOTH, expand=0)

        label = TLabel(top, style="HLine")
        label.pack(side=BOTTOM, fill=BOTH, expand=0)

        button = TButton(frame, text=_("Cancel"), command=self.cancel)
        button.pack(side=RIGHT, expand=0)
        label = TLabel(frame, image="space_6", style="FlatLabel")
        label.pack(side=RIGHT)
        button = TButton(frame, text=_("OK"), command=self.ok)
        button.pack(side=RIGHT, expand=0)
        button = TButton(frame, image='colorpicker', state='disabled')
        button.pack(side=LEFT, expand=0)

        #       RGBlabel_frame = TFrame(top, borderwidth = 1, style='FlatFrame')
        #       RGBlabel_frame.pack(side = BOTTOM, fill = BOTH)
        #
        #       self.label = TLabel(RGBlabel_frame, style="FlatLabel")
        #       self.label.pack(side = LEFT)

        frame = TFrame(top, style="RoundedFrame", borderwidth=5)
        frame.pack(side=LEFT)
        viewxy = ChooseRGBXY(frame, xyramp_size[0], xyramp_size[1], 0, 1)
        viewxy.pack(side=LEFT)

        frame = TFrame(top, style="RoundedFrame", borderwidth=5)
        frame.pack(side=LEFT)
        viewz = ChooseRGBZ(frame, zramp_size[0], zramp_size[1], 2)
        viewz.pack(side=LEFT)

        frame1 = TFrame(top, borderwidth=3, style='FlatFrame')
        frame1.pack(side=RIGHT)

        CS_frame = TFrame(frame1, borderwidth=1, style='FlatFrame')
        CS_frame.pack(side=TOP)

        label = TLabel(CS_frame,
                       text="Old color:   \nNew color:   ",
                       justify='right')
        label.pack(side=LEFT)

        frame = TFrame(CS_frame, style="RoundedFrame", borderwidth=5)
        frame.pack(side=LEFT)

        self.sample = ColorSample(frame, self.color, width=60, height=20)
        self.sample.pack(side=BOTTOM)
        sample = ColorSample(frame, self.color, width=60, height=20)
        sample.pack(side=TOP)

        label = TLabel(frame1, style="HLine")
        label.pack(side=TOP, fill=BOTH, expand=0)

        spin_frame = TFrame(frame1, borderwidth=1, style='FlatFrame')
        spin_frame.pack(side=TOP)

        hsv_frame = TFrame(spin_frame, borderwidth=2, style='FlatFrame')
        hsv_frame.pack(side=LEFT)

        frame = TFrame(hsv_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="H: ")
        label.pack(side=LEFT)
        self.var1 = TSpinbox(frame,
                             min=0,
                             max=1.0,
                             step=0.01,
                             vartype=1,
                             command=self.component_changed)
        self.var1.pack(side=RIGHT)

        frame = TFrame(hsv_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="S: ")
        label.pack(side=LEFT)
        self.var2 = TSpinbox(frame,
                             min=0,
                             max=1.0,
                             step=0.01,
                             vartype=1,
                             command=self.component_changed)
        self.var2.pack(side=RIGHT)

        frame = TFrame(hsv_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="V: ")
        label.pack(side=LEFT)
        self.var3 = TSpinbox(frame,
                             min=0,
                             max=1.0,
                             step=0.01,
                             vartype=1,
                             command=self.component_changed)
        self.var3.pack(side=RIGHT)

        rgb_frame = TFrame(spin_frame, borderwidth=2, style='FlatFrame')
        rgb_frame.pack(side=LEFT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="R: ")
        label.pack(side=LEFT)
        self.var4 = TSpinbox(frame,
                             min=0,
                             max=255,
                             step=1,
                             vartype=0,
                             command=self.rgb_component_changed)
        self.var4.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="G: ")
        label.pack(side=LEFT)
        self.var5 = TSpinbox(frame,
                             min=0,
                             max=255,
                             step=1,
                             vartype=0,
                             command=self.rgb_component_changed)
        self.var5.pack(side=RIGHT)

        frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="B: ")
        label.pack(side=LEFT)
        self.var6 = TSpinbox(frame,
                             min=0,
                             max=255,
                             step=1,
                             vartype=0,
                             command=self.rgb_component_changed)
        self.var6.pack(side=RIGHT)

        HTML_frame = TFrame(frame1, borderwidth=3, style='FlatFrame')
        HTML_frame.pack(side=TOP)

        label = TLabel(HTML_frame, text="HTML: ")
        label.pack(side=LEFT)
        self.html = TEntrybox(HTML_frame,
                              text='#000000',
                              width=10,
                              command=self.html_component_changed)
        self.html.pack(side=LEFT)

        viewxy.Subscribe(CHANGED, self.color_changed)
        viewz.Subscribe(CHANGED, self.color_changed)
        self.viewxy = viewxy
        self.viewz = viewz

        super.resizable(width=0, height=0)

        self.color_changed(self.color)

    def color_changed(self, color):
        #       self.label.configure(text = 'RGB:( %.3f %.3f %.3f )' % tuple(color))
        self.viewxy.SetColor(color)
        self.viewz.SetColor(color)
        self.sample.SetColor(color)
        v1, v2, v3 = apply(rgb_to_hsv, tuple(color))
        self.var1.set_value(v1)
        self.var2.set_value(v2)
        self.var3.set_value(v3)
        self.var4.set_value(round(color[0] * 255))
        self.var5.set_value(round(color[1] * 255))
        self.var6.set_value(round(color[2] * 255))
        int_color = (round(color[0] * 255), round(color[1] * 255),
                     round(color[2] * 255))
        self.html.set_text('#%02X%02X%02X' % int_color)
        self.color = color

    def component_changed(self, *rest):
        color = (self.var1.get_value(), self.var2.get_value(),
                 self.var3.get_value())
        color = apply(CreateRGBColor, apply(hsv_to_rgb, color)).RGB()
        self.color_changed(color)

    def rgb_component_changed(self, *rest):
        RGBColor = CreateRGBColor(self.var4.get_value() / 255.0,
                                  self.var5.get_value() / 255.0,
                                  self.var6.get_value() / 255.0).RGB()
        self.color_changed(RGBColor)

    def html_component_changed(self, *rest):
        html = self.html.get_text()
        try:
            RGBColor = CreateRGBColor(
                int(string.atoi(html[1:3], 0x10)) / 255.0,
                int(string.atoi(html[3:5], 0x10)) / 255.0,
                int(string.atoi(html[5:], 0x10)) / 255.0).RGB()
        except:
            RGBColor = self.color
        self.color_changed(RGBColor)

    def ok(self, *args):
        r, g, b = tuple(self.color)
        ColorObject = CreateRGBColor(r, g, b)
        self.close_dlg(ColorObject)
Example #45
0
class InsertPageDialog(ModalDialog):

	class_name = 'InsertPageDialog'
	
	def __init__(self, master, is_before = 0, dlgname = '__dialog__'):
		self.master=master
		self.title = _("Insert pages")
		self.is_before=is_before
		self.init_vars()
		ModalDialog.__init__(self, master, name = dlgname)
		
	def init_vars(self):
		self.numpages=StringVar(self.master)
		self.numpages.set('1')
		self.pagenum=StringVar(self.master)
		self.pagenum.set('%u'%(app.mw.document.active_page+1))
	
	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 ok(self, *arg):
		is_before=0
		if not 0 <= self.pagenum_spin.get_value()-1 < len(app.mw.document.pages):
			msgDialog(self.top, title = _("Error"), message = _('Incorrect page number!'))
			self.pagenum_spin.entry.focus_set()
			return
		if not 0 < self.numpages_spin.get_value():
			msgDialog(self.top, title = _("Error"), message = _('Incorrect number of pages!'))
			self.numpages_spin.entry.focus_set()
			return
		if self.var_reference.get()=='before':
			is_before=1
		app.mw.document.InsertPages(number=self.numpages_spin.get_value(), 
								index=self.pagenum_spin.get_value()-1, 
								is_before=is_before)
		self.close_dlg()
	
	def cancel(self, *arg):
		self.close_dlg(None)
Example #46
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()
Example #47
0
	def __init__(self, parent, callback, **kw):
		self.callback = callback
		TFrame.__init__(self, parent, style='FlatFrame', **kw)
		self.R_value = IntVar(0)
		self.G_value = IntVar(0)
		self.B_value = IntVar(0)
		self.A_value = IntVar(0)
		
		self.HTML_value = StringVar('')
		
			
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)	
		
		frame = TFrame(self, borderwidth=0, style='FlatFrame')
		frame.pack(side=BOTTOM)
		label = TLabel(frame, text=_("Alpha channel: "))
		label.pack(side=LEFT)
		self.A_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.A_value, command=self.rgb_component_changed)
		self.A_spin.pack(side=RIGHT)
		
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)
		
		
		html_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		html_frame.pack(side=BOTTOM)
		

		self.HTML_entry = TEntrybox(html_frame, text='#000000', width=10,
								textvariable=self.HTML_value, command=self.html_component_changed)
		self.HTML_entry.pack(side=RIGHT)
		
		label = TLabel(html_frame, text="HTML: ")
		label.pack(side=RIGHT)
		
		rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		rgb_frame.pack(side=LEFT, padx=10)
		
		frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="R: ")
		label.pack(side=LEFT)
		self.R_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.R_value, command=self.rgb_component_changed)
		self.R_spin.pack(side=RIGHT)

		frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="G: ")
		label.pack(side=LEFT)
		self.G_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.G_value, command=self.rgb_component_changed)
		self.G_spin.pack(side=RIGHT)

		frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="B: ")
		label.pack(side=LEFT)
		self.B_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.B_value, command=self.rgb_component_changed)
		self.B_spin.pack(side=RIGHT)
		
		cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		cmyk_frame.pack(side=LEFT)
		
		self.CMYK_label = TLabel(cmyk_frame, text='C:\nM:\nY:\nK:', justify=LEFT)
		self.CMYK_label.pack(side=LEFT)
Example #48
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()
Example #49
0
class PagePlugin(PluginPanel):
	
	name='Page'
	title = _("Page")
	
	def init(self, master):
		PluginPanel.init(self, master)
		self.top = self.panel
		root = self.top
		
		self.USER_SPECIFIC = _("<Custom Size>")
		
		top_root = TFrame(root, borderwidth=2, style='FlatFrame')
		top_root.pack(side = TOP, expand = 1, fill = X)
		
		top=TLabelframe(top_root, text='Page format')
		top.pack(side = TOP, fill=X, pady=2)

		
		var_width_number = DoubleVar(root)
		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, var_width_number, var_width_unit)
		self.var_height = LengthVar(10, unit,var_height_number,var_height_unit)


# ===========================================================
		format_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		format_frame.pack(side = TOP, expand = 1, fill = X, pady = 4)

		format_names = map(lambda t: t[0], PapersizesList)
		format_names.append(self.USER_SPECIFIC)
		self.var_format_name = StringVar(root)
		
		format_menu =TComboSmall(format_frame, format_names, command = self.choose_format,
								 variable = self.var_format_name, width=17)
		format_menu.configure(width = max(map(len, format_names)))
		format_menu.pack(side = RIGHT, expand = 1, fill = X)

# =====================		
		size_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)		
		label = TLabel(size_frame, text ="H: ", style='FlatLabel')
		
		self.widthentry = TSpinbox(size_frame, textvariable = var_width_number, command = self.var_width.UpdateNumber,
								vartype=1, min = 5, max = 50000, step = 1, width = 7)
		self.widthentry.pack(side = RIGHT, anchor = E, padx = 5)
		label.pack(side = RIGHT, anchor = E)
		
		size_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)
		label = TLabel(size_frame, text = "V: ", style='FlatLabel')
			
		self.heightentry = TSpinbox(size_frame, textvariable =var_height_number, command = self.var_height.UpdateNumber,
		 						vartype=1, min = 5, max = 50000, step = 1, width = 7)
		self.heightentry.pack(side = RIGHT, anchor = E, padx = 5)
		label.pack(side = RIGHT, anchor = E)
		
		size_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)

		def CallBoth(arg, x = self.var_width, y = self.var_height):
			x.UpdateUnit(arg)
			y.UpdateUnit(arg)

		optmenu = create_unit_menu(size_frame, CallBoth, variable = var_width_unit, width = 3)
		optmenu.pack(side = RIGHT, padx = 5)

		label = TLabel(size_frame, text = "Units: ", style='FlatLabel')
		label.pack(side = RIGHT)
#---------------------------------------------------------------------------------------------------------------------
		middle=TLabelframe(top_root, text='Page orientation')
		middle.pack(side = TOP, fill=X, pady=2)
		
		self.label = TLabel(middle, image = 'portrait', style='FlatLabel')
		self.label.pack(side = LEFT, padx=4)

		orientation_frame = TFrame(middle, borderwidth=0, style='FlatFrame')
		orientation_frame.pack(side = LEFT, expand = 1, fill = X)
		
		self.var_orientation = IntVar(root)
		radio = UpdatedRadiobutton(orientation_frame, text = _("Portrait"),
									variable = self.var_orientation,
									value = Portrait,
									command = self.choose_orientation)
		radio.pack(side = TOP, anchor=W)
		
		radio = UpdatedRadiobutton(orientation_frame, text = _("Landscape"),
									variable = self.var_orientation,
									value = Landscape,
									command = self.choose_orientation)
		radio.pack(side = TOP, anchor=W)

#---------------------------------------------------------------------------------------------------------------------
		button_frame = TFrame(top_root, borderwidth=1, style='FlatFrame')
		button_frame.pack(side = BOTTOM, fill = BOTH, pady=2)
		button = UpdatedButton(button_frame, text = _("Apply"), command = self.apply_settings, width=15)
		button.pack(side = BOTTOM)
		
		app.mw.docmanager.activedoc.Subscribe(LAYOUT, self.init_from_doc)
		app.mw.Subscribe(DOCUMENT, self.init_from_doc)
		

	def init_from_doc(self, *arg):
		self.Update()

	def update_size_from_name(self, formatname):
		width, height = Papersize[formatname]
		if self.var_orientation.get() == Landscape:
			width, height = height, width
		self.update_size(width, height)

	def update_size(self, width, height):
		self.var_width.set(width)
		self.var_height.set(height)

	def Update(self):
		layout = self.document.Layout()
		formatname = layout.FormatName()
		self.var_orientation.set(layout.Orientation())
		if self.var_orientation.get() == Landscape:
			self.label["image"] = 'landscape'
		else:
			self.label["image"] = 'portrait'
		if formatname and formatname != self.USER_SPECIFIC:
			self.update_size_from_name(formatname)
		else:
			formatname = self.USER_SPECIFIC
			self.update_size(layout.Width(), layout.Height())
		self.var_format_name.set(formatname)
		self.set_entry_sensitivity()

	def set_entry_sensitivity(self):
		formatname = self.var_format_name.get()
		if formatname != self.USER_SPECIFIC:
			self.widthentry.set_state("disabled")
			self.heightentry.set_state("disabled")
		else:
			self.widthentry.set_state("enabled")
			self.heightentry.set_state("enabled")

	def choose_format(self, formatname):
		self.var_format_name.set(formatname)
		if formatname != self.USER_SPECIFIC:
			self.update_size_from_name(formatname)
		self.set_entry_sensitivity()

	def choose_orientation(self):
		name = self.var_format_name.get()
		if name != self.USER_SPECIFIC:
			self.update_size_from_name(name)
		if self.var_orientation.get() == Landscape:
			self.label["image"] = 'landscape'
		else:
			self.label["image"] = 'portrait'	

	def apply_settings(self):
		formatname = self.var_format_name.get()
		if formatname == self.USER_SPECIFIC:
			layout = PageLayout(width = self.var_width.get(),
								height = self.var_height.get(),
								orientation = self.var_orientation.get())
		else:
			layout = PageLayout(formatname,
								orientation = self.var_orientation.get())
		self.document.SetLayout(layout)
Example #50
0
	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()
Example #51
0
	def init(self, master):
		PluginPanel.init(self, master)
		self.top = self.panel
		root = self.top
		
		self.USER_SPECIFIC = _("<Custom Size>")
		
		top_root = TFrame(root, borderwidth=2, style='FlatFrame')
		top_root.pack(side = TOP, expand = 1, fill = X)
		
		top=TLabelframe(top_root, text='Page format')
		top.pack(side = TOP, fill=X, pady=2)

		
		var_width_number = DoubleVar(root)
		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, var_width_number, var_width_unit)
		self.var_height = LengthVar(10, unit,var_height_number,var_height_unit)


# ===========================================================
		format_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		format_frame.pack(side = TOP, expand = 1, fill = X, pady = 4)

		format_names = map(lambda t: t[0], PapersizesList)
		format_names.append(self.USER_SPECIFIC)
		self.var_format_name = StringVar(root)
		
		format_menu =TComboSmall(format_frame, format_names, command = self.choose_format,
								 variable = self.var_format_name, width=17)
		format_menu.configure(width = max(map(len, format_names)))
		format_menu.pack(side = RIGHT, expand = 1, fill = X)

# =====================		
		size_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)		
		label = TLabel(size_frame, text ="H: ", style='FlatLabel')
		
		self.widthentry = TSpinbox(size_frame, textvariable = var_width_number, command = self.var_width.UpdateNumber,
								vartype=1, min = 5, max = 50000, step = 1, width = 7)
		self.widthentry.pack(side = RIGHT, anchor = E, padx = 5)
		label.pack(side = RIGHT, anchor = E)
		
		size_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)
		label = TLabel(size_frame, text = "V: ", style='FlatLabel')
			
		self.heightentry = TSpinbox(size_frame, textvariable =var_height_number, command = self.var_height.UpdateNumber,
		 						vartype=1, min = 5, max = 50000, step = 1, width = 7)
		self.heightentry.pack(side = RIGHT, anchor = E, padx = 5)
		label.pack(side = RIGHT, anchor = E)
		
		size_frame = TFrame(top, borderwidth=0, style='FlatFrame')
		size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)

		def CallBoth(arg, x = self.var_width, y = self.var_height):
			x.UpdateUnit(arg)
			y.UpdateUnit(arg)

		optmenu = create_unit_menu(size_frame, CallBoth, variable = var_width_unit, width = 3)
		optmenu.pack(side = RIGHT, padx = 5)

		label = TLabel(size_frame, text = "Units: ", style='FlatLabel')
		label.pack(side = RIGHT)
#---------------------------------------------------------------------------------------------------------------------
		middle=TLabelframe(top_root, text='Page orientation')
		middle.pack(side = TOP, fill=X, pady=2)
		
		self.label = TLabel(middle, image = 'portrait', style='FlatLabel')
		self.label.pack(side = LEFT, padx=4)

		orientation_frame = TFrame(middle, borderwidth=0, style='FlatFrame')
		orientation_frame.pack(side = LEFT, expand = 1, fill = X)
		
		self.var_orientation = IntVar(root)
		radio = UpdatedRadiobutton(orientation_frame, text = _("Portrait"),
									variable = self.var_orientation,
									value = Portrait,
									command = self.choose_orientation)
		radio.pack(side = TOP, anchor=W)
		
		radio = UpdatedRadiobutton(orientation_frame, text = _("Landscape"),
									variable = self.var_orientation,
									value = Landscape,
									command = self.choose_orientation)
		radio.pack(side = TOP, anchor=W)

#---------------------------------------------------------------------------------------------------------------------
		button_frame = TFrame(top_root, borderwidth=1, style='FlatFrame')
		button_frame.pack(side = BOTTOM, fill = BOTH, pady=2)
		button = UpdatedButton(button_frame, text = _("Apply"), command = self.apply_settings, width=15)
		button.pack(side = BOTTOM)
		
		app.mw.docmanager.activedoc.Subscribe(LAYOUT, self.init_from_doc)
		app.mw.Subscribe(DOCUMENT, self.init_from_doc)
Example #52
0
	def __init__(self, parent, callback, **kw):
		self.callback = callback
		TFrame.__init__(self, parent, style='FlatFrame', **kw)
		self.C_value = DoubleVar(0)
		self.M_value = DoubleVar(0)
		self.Y_value = DoubleVar(0)
		self.K_value = DoubleVar(0)
		self.A_value = DoubleVar(0)
		
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)
		
		frame = TFrame(self, borderwidth=0, style='FlatFrame')
		frame.pack(side=BOTTOM)
		label = TLabel(frame, text=_("Opacity: "))
		label.pack(side=LEFT)
		self.A_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.A_value, command=self.cmyk_component_changed)
		self.A_spin.pack(side=RIGHT)
		
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)
		
		cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		cmyk_frame.pack(side=LEFT, padx=10)
		
		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="C: ")
		label.pack(side=LEFT)
		self.C_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.C_value, command=self.cmyk_component_changed)
		self.C_spin.pack(side=RIGHT)

		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="M: ")
		label.pack(side=LEFT)
		self.M_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.M_value, command=self.cmyk_component_changed)
		self.M_spin.pack(side=RIGHT)

		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="Y: ")
		label.pack(side=LEFT)
		self.Y_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.Y_value, command=self.cmyk_component_changed)
		self.Y_spin.pack(side=RIGHT)		

		frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="K: ")
		label.pack(side=LEFT)
		self.K_spin = TSpinbox(frame, min=0, max=100, step=1, vartype=1, width=7,
							textvariable=self.K_value, command=self.cmyk_component_changed)
		self.K_spin.pack(side=RIGHT)
		
		rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		rgb_frame.pack(side=LEFT)
		
		self.RGB_label = TLabel(rgb_frame, text='R:\nG:\nB:', justify=LEFT)
		self.RGB_label.pack(side=LEFT)		
Example #53
0
    def init(self, master):
        PluginPanel.init(self, master)

        self.width_priority = 1

        root = self.mw.root

        self.var_angleX = DoubleVar(root)
        self.var_angleY = DoubleVar(root)

        jump = 5
        self.var_angleX.set(0)
        self.var_angleY.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_frameH = TFrame(top, style='FlatFrame', borderwidth=3)
        size_frameH.pack(side=TOP, fill=BOTH)

        label = TLabel(size_frameH, style='FlatLabel', image='skew_h')
        label.pack(side=LEFT, padx=5)
        self.entry_angleX = TSpinbox(size_frameH,
                                     var=0,
                                     vartype=1,
                                     textvariable=self.var_angleX,
                                     min=-75,
                                     max=75,
                                     step=jump,
                                     width=10,
                                     command=self.apply_skew)
        self.entry_angleX.pack(side=LEFT)

        self.labelwunit = TLabel(size_frameH, style='FlatLabel', text=_("deg"))
        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='skew_v')
        label.pack(side=LEFT, padx=5)

        self.entry_angleY = TSpinbox(size_frameV,
                                     var=0,
                                     vartype=1,
                                     textvariable=self.var_angleY,
                                     min=-75,
                                     max=75,
                                     step=jump,
                                     width=10,
                                     command=self.apply_skew)
        self.entry_angleY.pack(side=LEFT)

        self.labelhunit = TLabel(size_frameV, style='FlatLabel', text=_("deg"))
        self.labelhunit.pack(side=LEFT, padx=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_deg')
        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_skew)
        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()
Example #54
0
    def __init__(self, parent, callback, **kw):
        self.callback = callback
        TFrame.__init__(self, parent, style='FlatFrame', **kw)
        self.C_value = DoubleVar(0)
        self.M_value = DoubleVar(0)
        self.Y_value = DoubleVar(0)
        self.K_value = DoubleVar(0)
        self.A_value = DoubleVar(0)

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        frame = TFrame(self, borderwidth=0, style='FlatFrame')
        frame.pack(side=BOTTOM)
        label = TLabel(frame, text=_("Opacity: "))
        label.pack(side=LEFT)
        self.A_spin = TSpinbox(frame,
                               min=0,
                               max=255,
                               step=1,
                               vartype=0,
                               width=7,
                               textvariable=self.A_value,
                               command=self.cmyk_component_changed)
        self.A_spin.pack(side=RIGHT)

        b = TLabel(self, style='HLine')
        b.pack(side=BOTTOM, fill=X)

        cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        cmyk_frame.pack(side=LEFT, padx=10)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="C: ")
        label.pack(side=LEFT)
        self.C_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.C_value,
                               command=self.cmyk_component_changed)
        self.C_spin.pack(side=RIGHT)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="M: ")
        label.pack(side=LEFT)
        self.M_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.M_value,
                               command=self.cmyk_component_changed)
        self.M_spin.pack(side=RIGHT)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="Y: ")
        label.pack(side=LEFT)
        self.Y_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.Y_value,
                               command=self.cmyk_component_changed)
        self.Y_spin.pack(side=RIGHT)

        frame = TFrame(cmyk_frame, borderwidth=2, style='FlatFrame')
        frame.pack(side=TOP)
        label = TLabel(frame, text="K: ")
        label.pack(side=LEFT)
        self.K_spin = TSpinbox(frame,
                               min=0,
                               max=100,
                               step=1,
                               vartype=1,
                               width=7,
                               textvariable=self.K_value,
                               command=self.cmyk_component_changed)
        self.K_spin.pack(side=RIGHT)

        rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
        rgb_frame.pack(side=LEFT)

        self.RGB_label = TLabel(rgb_frame, text='R:\nG:\nB:', justify=LEFT)
        self.RGB_label.pack(side=LEFT)
Example #55
0
class RGBDigitizer(TFrame):
	
	def __init__(self, parent, callback, **kw):
		self.callback = callback
		TFrame.__init__(self, parent, style='FlatFrame', **kw)
		self.R_value = IntVar(0)
		self.G_value = IntVar(0)
		self.B_value = IntVar(0)
		self.A_value = IntVar(0)
		
		self.HTML_value = StringVar('')
		
			
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)	
		
		frame = TFrame(self, borderwidth=0, style='FlatFrame')
		frame.pack(side=BOTTOM)
		label = TLabel(frame, text=_("Alpha channel: "))
		label.pack(side=LEFT)
		self.A_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.A_value, command=self.rgb_component_changed)
		self.A_spin.pack(side=RIGHT)
		
		b = TLabel(self, style='HLine')
		b.pack(side=BOTTOM, fill=X)
		
		
		html_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		html_frame.pack(side=BOTTOM)
		

		self.HTML_entry = TEntrybox(html_frame, text='#000000', width=10,
								textvariable=self.HTML_value, command=self.html_component_changed)
		self.HTML_entry.pack(side=RIGHT)
		
		label = TLabel(html_frame, text="HTML: ")
		label.pack(side=RIGHT)
		
		rgb_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		rgb_frame.pack(side=LEFT, padx=10)
		
		frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="R: ")
		label.pack(side=LEFT)
		self.R_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.R_value, command=self.rgb_component_changed)
		self.R_spin.pack(side=RIGHT)

		frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="G: ")
		label.pack(side=LEFT)
		self.G_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.G_value, command=self.rgb_component_changed)
		self.G_spin.pack(side=RIGHT)

		frame = TFrame(rgb_frame, borderwidth=2, style='FlatFrame')
		frame.pack(side=TOP)
		label = TLabel(frame, text="B: ")
		label.pack(side=LEFT)
		self.B_spin = TSpinbox(frame, min=0, max=255, step=1, vartype=0, width=7,
							textvariable=self.B_value, command=self.rgb_component_changed)
		self.B_spin.pack(side=RIGHT)
		
		cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame')
		cmyk_frame.pack(side=LEFT)
		
		self.CMYK_label = TLabel(cmyk_frame, text='C:\nM:\nY:\nK:', justify=LEFT)
		self.CMYK_label.pack(side=LEFT)
		
		
		
	def set_color(self, color):
		self.color = color
		self.R_value.set(int(round(color.red * 255)))
		self.G_value.set(int(round(color.green * 255)))
		self.B_value.set(int(round(color.blue * 255)))
		self.A_value.set(int(round(color.alpha * 255)))
		c, m, y, k = color.getCMYK()
		self.CMYK_label['text'] = 'C: %.2f\nM: %.2f\nY: %.2f\nK: %.2f' % (round(c * 100, 2), round(m * 100, 2), round(y * 100, 2), round(k * 100, 2))
		int_color = (round(color.red * 255), round(color.green * 255), round(color.blue * 255))
		self.HTML_value.set('#%02X%02X%02X' % int_color)
		
		
		
	def rgb_component_changed(self, *arg):
		r = self.R_value.get() / 255.0
		g = self.G_value.get() / 255.0
		b = self.B_value.get() / 255.0
		a = self.A_value.get() / 255.0
		self.callback(CreateRGBAColor(r, g, b, a))
	
	def html_component_changed(self, *arg):
		html = self.HTML_value.get()
		try:     
			r = int(string.atoi(html[1:3], 0x10)) / 255.0
			g = int(string.atoi(html[3:5], 0x10)) / 255.0 
			b = int(string.atoi(html[5:], 0x10)) / 255.0
		except:
			r = round(self.color.red * 255, 2)
			g = round(self.color.green * 255, 2)
			b = round(self.color.blue * 255, 2)		
		self.callback(CreateRGBAColor(r, g, b, self.A_value.get() / 255.0))