Exemplo n.º 1
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)
			
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
0
class GuidelinesPanel(PluginPanel):
	name = 'Guidelines'
	title = _("Guides")


	def init(self, master):
		PluginPanel.init(self, master)
		top = self.panel

		grid_top = TFrame(top, borderwidth=2, style='FlatFrame')
		grid_top.pack(side=TOP, expand=1, fill=X)

		var_number = DoubleVar(top)
		var_unit = StringVar(top)
		self.var_pos = LengthVar(1.0, config.preferences.default_unit, var_number, var_unit, command=self.set_pos)

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

		list_frame = TFrame(top1, style="RoundedFrame", borderwidth=5)
		list_frame.pack(side=TOP, expand=1, fill=BOTH)

		sb_vert = TScrollbar(list_frame)
		sb_vert.pack(side=RIGHT, fill=Y)
		guides = UpdatedListbox(list_frame, bg='white', borderwidth=0, selectborderwidth=0, width=20, height=8)
		guides.pack(expand=1, fill=BOTH)
		guides.Subscribe(SELECTION, self.select_guide)
		sb_vert['command'] = (guides, 'yview')
		guides['yscrollcommand'] = (sb_vert, 'set')
		self.guides = guides
		self.selected = None

		pos_frame = TFrame(top1, style='FlatFrame')
		pos_frame.pack(side=TOP, expand=0)

		top2 = TFrame(pos_frame, height=15, style='FlatFrame')
		top2.pack(side=TOP, expand=0, fill=X)

		self.var_label = StringVar(top)
		self.var_label.set('X: ')

		labelunit = UnitLabel(pos_frame)
		labelunit.pack(side=RIGHT, expand=0, anchor=W)

		label = TLabel(pos_frame, image='space_6', style='FlatLabel')
		label.pack(side=RIGHT)

		self.entry = TSpinbox(pos_frame, var=0, vartype=1,
						min=-50000, max=50000, step=.1, width=6, command=self.pos_changed)
		self.entry.pack(side=RIGHT, expand=0, anchor=E)

		label = TLabel(pos_frame, textvariable=self.var_label, style='FlatLabel')
		label.pack(side=RIGHT, expand=0, anchor=E)

		frame = TFrame(top1, style='FlatFrame')
		frame.pack(side=TOP, fill=X)
		top2 = TFrame(frame, height=15, width=120, style='FlatFrame')
		top2.pack(side=TOP)

		button = UpdatedButton(frame, text=_("Add Horizontal Guide"), command=self.add_guide, args=1)
		button.pack(side=TOP)

		top2 = TFrame(frame, height=3, style='FlatFrame')
		top2.pack(side=TOP, expand=0, fill=X)

		button = UpdatedButton(frame, text=_("Add Vertical Guide"), command=self.add_guide, args=0)
		button.pack(side=TOP)

		top2 = TFrame(frame, height=3, style='FlatFrame')
		top2.pack(side=TOP, expand=0, fill=X)

		button = UpdatedButton(frame, text=_("Delete Guide"), command=self.del_guide)
		button.pack(side=TOP)

		top2 = TFrame(frame, height=5, style='FlatFrame')
		top2.pack(side=TOP, expand=0, fill=X)

		app.mw.docmanager.activedoc.Subscribe(GUIDE_LINES, self.init_from_doc)
		app.mw.Subscribe(DOCUMENT, self.init_from_doc)
		self.init_from_doc()

	def set_unit(self, *rest):
		apply(self.var_pos.UpdateUnit, rest)
		self.update_list()

	def init_from_doc(self, *rest):
		self.guide_lines = self.document.GuideLines()
		self.guide_lines.reverse()
		self.update_list()

	def update_list(self):
		strings = []
		factor = self.var_pos.Factor()
		unit = self.var_pos.UnitName()
		if unit in ('in', 'cm'):
			prec = 2
		else:
			prec = 1
		for line in self.guide_lines:
			pos, horizontal = line.Coordinates()
			if horizontal:
				format = _("% 6.*f %s    horizontal")
			else:
				format = _("% 6.*f %s    vertical")
			strings.append(format % (prec, pos / factor, unit))
		self.guides.SetList(strings)
		self.select_index(self.selected)

	def select_index(self, index):
		if index is not None and index < len(self.guide_lines):
			self.guides.Select(index)
			self.select_guide()
		else:
			self.selected = None

	def set_pos(self, *rest):
		if self.selected is not None:
			self.document.MoveGuideLine(self.guide_lines[self.selected],
										self.var_pos.get())

	def select_guide(self, *rest):
		sel = self.guides.curselection()
		if sel:
			self.selected = atoi(sel[0])
			pos, horizontal = self.guide_lines[self.selected].Coordinates()
			self.var_pos.set(pos)
			self.entry.set_value(round(pos * 100 / self.var_pos.Factor()) / 100)
			if horizontal:
				self.var_label.set("Y: ")
			else:
				self.var_label.set("X: ")
		else:
			self.selected = None

	def del_guide(self, *rest):
		if self.selected is not None:
			line = self.guide_lines[self.selected]
			self.document.RemoveGuideLine(line)

	def add_guide(self, horizontal):
		length = len(self.guide_lines)
		self.document.AddGuideLine(Point(0, 0), horizontal)
		self.select_index(length)

	def pos_changed(self, *rest):
		self.var_pos.set(self.entry.get_value() * self.var_pos.Factor())
		self.set_pos()
		self.update_list()
Exemplo n.º 11
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)
Exemplo n.º 12
0
class GuidelinesPanel(PluginPanel):
    name = 'Guidelines'
    title = _("Guides")

    def init(self, master):
        PluginPanel.init(self, master)
        top = self.panel

        grid_top = TFrame(top, borderwidth=2, style='FlatFrame')
        grid_top.pack(side=TOP, expand=1, fill=X)

        var_number = DoubleVar(top)
        var_unit = StringVar(top)
        self.var_pos = LengthVar(1.0,
                                 config.preferences.default_unit,
                                 var_number,
                                 var_unit,
                                 command=self.set_pos)

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

        list_frame = TFrame(top1, style="RoundedFrame", borderwidth=5)
        list_frame.pack(side=TOP, expand=1, fill=BOTH)

        sb_vert = TScrollbar(list_frame)
        sb_vert.pack(side=RIGHT, fill=Y)
        guides = UpdatedListbox(list_frame,
                                bg='white',
                                borderwidth=0,
                                selectborderwidth=0,
                                width=20,
                                height=8)
        guides.pack(expand=1, fill=BOTH)
        guides.Subscribe(SELECTION, self.select_guide)
        sb_vert['command'] = (guides, 'yview')
        guides['yscrollcommand'] = (sb_vert, 'set')
        self.guides = guides
        self.selected = None

        pos_frame = TFrame(top1, style='FlatFrame')
        pos_frame.pack(side=TOP, expand=0)

        top2 = TFrame(pos_frame, height=15, style='FlatFrame')
        top2.pack(side=TOP, expand=0, fill=X)

        self.var_label = StringVar(top)
        self.var_label.set('X: ')

        labelunit = UnitLabel(pos_frame)
        labelunit.pack(side=RIGHT, expand=0, anchor=W)

        label = TLabel(pos_frame, image='space_6', style='FlatLabel')
        label.pack(side=RIGHT)

        self.entry = TSpinbox(pos_frame,
                              var=0,
                              vartype=1,
                              min=-50000,
                              max=50000,
                              step=.1,
                              width=6,
                              command=self.pos_changed)
        self.entry.pack(side=RIGHT, expand=0, anchor=E)

        label = TLabel(pos_frame,
                       textvariable=self.var_label,
                       style='FlatLabel')
        label.pack(side=RIGHT, expand=0, anchor=E)

        frame = TFrame(top1, style='FlatFrame')
        frame.pack(side=TOP, fill=X)
        top2 = TFrame(frame, height=15, width=120, style='FlatFrame')
        top2.pack(side=TOP)

        button = UpdatedButton(frame,
                               text=_("Add Horizontal Guide"),
                               command=self.add_guide,
                               args=1)
        button.pack(side=TOP)

        top2 = TFrame(frame, height=3, style='FlatFrame')
        top2.pack(side=TOP, expand=0, fill=X)

        button = UpdatedButton(frame,
                               text=_("Add Vertical Guide"),
                               command=self.add_guide,
                               args=0)
        button.pack(side=TOP)

        top2 = TFrame(frame, height=3, style='FlatFrame')
        top2.pack(side=TOP, expand=0, fill=X)

        button = UpdatedButton(frame,
                               text=_("Delete Guide"),
                               command=self.del_guide)
        button.pack(side=TOP)

        top2 = TFrame(frame, height=5, style='FlatFrame')
        top2.pack(side=TOP, expand=0, fill=X)

        app.mw.docmanager.activedoc.Subscribe(GUIDE_LINES, self.init_from_doc)
        app.mw.Subscribe(DOCUMENT, self.init_from_doc)
        self.init_from_doc()

    def set_unit(self, *rest):
        apply(self.var_pos.UpdateUnit, rest)
        self.update_list()

    def init_from_doc(self, *rest):
        self.guide_lines = self.document.GuideLines()
        self.guide_lines.reverse()
        self.update_list()

    def update_list(self):
        strings = []
        factor = self.var_pos.Factor()
        unit = self.var_pos.UnitName()
        if unit in ('in', 'cm'):
            prec = 2
        else:
            prec = 1
        for line in self.guide_lines:
            pos, horizontal = line.Coordinates()
            if horizontal:
                format = _("% 6.*f %s    horizontal")
            else:
                format = _("% 6.*f %s    vertical")
            strings.append(format % (prec, pos / factor, unit))
        self.guides.SetList(strings)
        self.select_index(self.selected)

    def select_index(self, index):
        if index is not None and index < len(self.guide_lines):
            self.guides.Select(index)
            self.select_guide()
        else:
            self.selected = None

    def set_pos(self, *rest):
        if self.selected is not None:
            self.document.MoveGuideLine(self.guide_lines[self.selected],
                                        self.var_pos.get())

    def select_guide(self, *rest):
        sel = self.guides.curselection()
        if sel:
            self.selected = atoi(sel[0])
            pos, horizontal = self.guide_lines[self.selected].Coordinates()
            self.var_pos.set(pos)
            self.entry.set_value(
                round(pos * 100 / self.var_pos.Factor()) / 100)
            if horizontal:
                self.var_label.set("Y: ")
            else:
                self.var_label.set("X: ")
        else:
            self.selected = None

    def del_guide(self, *rest):
        if self.selected is not None:
            line = self.guide_lines[self.selected]
            self.document.RemoveGuideLine(line)

    def add_guide(self, horizontal):
        length = len(self.guide_lines)
        self.document.AddGuideLine(Point(0, 0), horizontal)
        self.select_index(length)

    def pos_changed(self, *rest):
        self.var_pos.set(self.entry.get_value() * self.var_pos.Factor())
        self.set_pos()
        self.update_list()