Пример #1
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)
Пример #2
0
	def __init__(self, parent):
		CtxSubPanel.__init__(self, parent)
		self.var_reference = StringVar(self.mw.root,'left')
		self.var_stub = StringVar(self.mw.root)
			
		radio = UpdatedRadiobutton(self.panel, value='left', image='context_text_left', 
								command=self.applyProperties, variable=self.var_reference, style='ToolbarRadiobutton')
		radio.pack(side=LEFT)
		tooltips.AddDescription(radio, _('Left alignment'))
		radio = UpdatedRadiobutton(self.panel, value = 'center', image='context_text_center', 
								command=self.applyProperties, variable = self.var_reference, style='ToolbarRadiobutton')
		radio.pack(side=LEFT)
		tooltips.AddDescription(radio, _('Center alignment'))
		radio = UpdatedRadiobutton(self.panel, value = 'right', image='context_text_right', 
								command=self.applyProperties, variable = self.var_reference, style='ToolbarRadiobutton')
		radio.pack(side=LEFT)
		tooltips.AddDescription(radio, _('Right alignment'))
#		radio = UpdatedRadiobutton(self.panel, value = 'justify', image='context_text_justify_disabled', 
#								command=self.applyProperties, variable = self.var_stub, style='ToolbarRadiobutton', state='disabled')
#		radio.pack(side=LEFT)
#		tooltips.AddDescription(radio, _('Justify'))
						
		self.ReSubscribe()
Пример #3
0
    def __init__(self, parent):
        CtxSubPanel.__init__(self, parent)

        self.var_font_name = StringVar(self.mw.root, " ")
        self.var_style_name = StringVar(self.mw.root, " ")
        self.var_font_size = StringVar(self.mw.root, " ")

        label = TLabel(self.panel, image="context_font_name")
        label.pack(side=LEFT, padx=2)
        tooltips.AddDescription(label, _("Font name"))
        self.font_name = TCombobox(
            self.panel,
            state="readonly",
            postcommand=self.name_changed,
            values=self.make_families(),
            width=25,
            style="PseudoActive",
            textvariable=self.var_font_name,
        )
        self.font_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=" ")
        label.pack(side=LEFT)

        label = TLabel(self.panel, image="context_font_style")
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _("Font style"))
        self.style_name = TCombobox(
            self.panel,
            state="readonly",
            postcommand=self.style_changed,
            values=(),
            width=18,
            style="PseudoActive",
            textvariable=self.var_style_name,
        )
        self.style_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=" ")
        label.pack(side=LEFT)

        label = TLabel(self.panel, image="context_font_size")
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _("Font size"))
        self.font_size = TCombobox(
            self.panel,
            state="normal",
            postcommand=self.apply_changes,
            values=self.make_sizes(),
            width=5,
            style="ComboNormal",
            textvariable=self.var_font_size,
        )
        self.font_size.pack(side=LEFT, padx=2)

        ######################################
        self.var_bold = StringVar(self.mw.root, "")
        self.var_italic = StringVar(self.mw.root, "")
        self.var_underline = StringVar(self.mw.root, "")

        self.bold_check = UpdatedRadiobutton(
            self.panel,
            value="bold",
            image="context_text_bold",
            command=self.bold_action,
            variable=self.var_bold,
            style="ToolbarRadiobutton",
        )
        self.bold_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.bold_check, _("Bold"))

        self.italic_check = UpdatedRadiobutton(
            self.panel,
            value="italic",
            image="context_text_italic",
            command=self.italic_action,
            variable=self.var_italic,
            style="ToolbarRadiobutton",
        )
        self.italic_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.italic_check, _("Italic"))

        # 		self.underline_check = UpdatedRadiobutton(self.panel, value = 'under', image='context_text_under_disabled', state='disabled',
        # 								command=self.action, variable = self.var_underline, style='ToolbarRadiobutton')
        # 		self.underline_check.pack(side=LEFT, padx=2)
        # 		tooltips.AddDescription(self.underline_check, _('Underline'))

        self.ReSubscribe()
Пример #4
0
class FontPanel(CtxSubPanel):

    name = "FontPanel"
    family_to_fonts = {}
    families = []
    styles = []
    bold = 0
    italic = 0

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

        self.var_font_name = StringVar(self.mw.root, " ")
        self.var_style_name = StringVar(self.mw.root, " ")
        self.var_font_size = StringVar(self.mw.root, " ")

        label = TLabel(self.panel, image="context_font_name")
        label.pack(side=LEFT, padx=2)
        tooltips.AddDescription(label, _("Font name"))
        self.font_name = TCombobox(
            self.panel,
            state="readonly",
            postcommand=self.name_changed,
            values=self.make_families(),
            width=25,
            style="PseudoActive",
            textvariable=self.var_font_name,
        )
        self.font_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=" ")
        label.pack(side=LEFT)

        label = TLabel(self.panel, image="context_font_style")
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _("Font style"))
        self.style_name = TCombobox(
            self.panel,
            state="readonly",
            postcommand=self.style_changed,
            values=(),
            width=18,
            style="PseudoActive",
            textvariable=self.var_style_name,
        )
        self.style_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=" ")
        label.pack(side=LEFT)

        label = TLabel(self.panel, image="context_font_size")
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _("Font size"))
        self.font_size = TCombobox(
            self.panel,
            state="normal",
            postcommand=self.apply_changes,
            values=self.make_sizes(),
            width=5,
            style="ComboNormal",
            textvariable=self.var_font_size,
        )
        self.font_size.pack(side=LEFT, padx=2)

        ######################################
        self.var_bold = StringVar(self.mw.root, "")
        self.var_italic = StringVar(self.mw.root, "")
        self.var_underline = StringVar(self.mw.root, "")

        self.bold_check = UpdatedRadiobutton(
            self.panel,
            value="bold",
            image="context_text_bold",
            command=self.bold_action,
            variable=self.var_bold,
            style="ToolbarRadiobutton",
        )
        self.bold_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.bold_check, _("Bold"))

        self.italic_check = UpdatedRadiobutton(
            self.panel,
            value="italic",
            image="context_text_italic",
            command=self.italic_action,
            variable=self.var_italic,
            style="ToolbarRadiobutton",
        )
        self.italic_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.italic_check, _("Italic"))

        # 		self.underline_check = UpdatedRadiobutton(self.panel, value = 'under', image='context_text_under_disabled', state='disabled',
        # 								command=self.action, variable = self.var_underline, style='ToolbarRadiobutton')
        # 		self.underline_check.pack(side=LEFT, padx=2)
        # 		tooltips.AddDescription(self.underline_check, _('Underline'))

        self.ReSubscribe()

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

    def Update(self, *arg):
        object = self.mw.document.CurrentObject()
        if object is not None and object.is_Text:
            _font = object.Font()
            self.var_font_name.set(_font.familyname)
            self.var_style_name.set(_font.facename)
            self.style_name["values"] = self.make_styles()
            self.var_font_size.set(object.FontSize())
        # 		else:
        # 			try:
        # 				default = ft2engine.GetFont(config.preferences.default_font)
        # 			except:
        # 				name = self.family_to_fonts.keys()[0]#[0]
        # 				fonts = self.family_to_fonts[name]
        # 				default = ft2engine.GetFont(fonts[1])
        # 			self.var_font_name.set(default.family)
        # 			self.var_style_name.set(default.font_attrs)
        # 			self.style_name['values'] = self.make_styles()
        # 			self.var_font_size.set(properties.default_text_style.font_size)
        self.checkBI()

    def make_families(self):
        result = ()
        self.families = libpango.FAMILIES_LIST
        for item in self.families:
            result += (item,)
        return result

    def make_styles(self):
        faces = libpango.FAMILIES_DICT[self.var_font_name.get()]
        attrs = ()
        self.styles = []
        for name in faces:
            self.styles.append(name)
            attrs += (name,)
        return attrs

    def make_sizes(self):
        sizes = ()
        for size in [5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 48, 56, 64, 72]:
            sizes += (size,)
        return sizes

    def name_changed(self):
        self.style_name["values"] = self.make_styles()
        if not self.var_style_name.get() in self.styles:
            self.setRegular()
        self.checkBI()
        self.apply_changes()

    def style_changed(self):
        self.checkBI()
        self.apply_changes()

    def apply_changes(self):
        familyname = self.var_font_name.get()
        facename = self.var_style_name.get()
        self.mw.document.CallObjectMethod(
            text.CommonText,
            _("Set Font Properties"),
            "SetFont",
            libpango.get_fontface(familyname, facename),
            atof(self.var_font_size.get()),
        )
        self.mw.canvas.ForceRedraw()

    def bold_action(self):
        if self.bold:
            self.bold = 0
            self.var_bold.set("")
        else:
            self.bold = 1
            self.var_bold.set("bold")

        if self.bold and self.italic:
            if "Bold Italic" in self.styles:
                self.var_style_name.set("Bold Italic")
            elif "Bold Oblique" in self.styles:
                self.var_style_name.set("Bold Oblique")
            else:
                self.bold = 0
                self.var_bold.set("")
        elif self.bold:
            self.var_style_name.set("Bold")
        elif self.italic:
            if "Italic" in self.styles:
                self.var_style_name.set("Italic")
            if "Oblique" in self.styles:
                self.var_style_name.set("Oblique")
        else:
            self.setRegular()
        self.style_changed()

    def italic_action(self):
        if self.italic:
            self.italic = 0
            self.var_italic.set("")
        else:
            self.italic = 1
            self.var_italic.set("italic")

        if self.bold and self.italic:
            if "Bold Italic" in self.styles:
                self.var_style_name.set("Bold Italic")
            elif "Bold Oblique" in self.styles:
                self.var_style_name.set("Bold Oblique")
            else:
                self.italic = 0
                self.var_italic.set("")
        elif self.italic:
            if "Italic" in self.styles:
                self.var_style_name.set("Italic")
            if "Oblique" in self.styles:
                self.var_style_name.set("Oblique")
        elif self.bold:
            self.var_style_name.set("Bold")
        else:
            self.setRegular()
        self.style_changed()

    def setRegular(self):
        normal = None
        for item in ["Roman", "Book", "Normal", "Regular"]:
            if item in self.styles:
                normal = item
        if normal:
            self.var_style_name.set(normal)
        else:
            self.var_style_name.set(self.styles[0])

    def checkBI(self):
        if "Bold" in self.styles:
            self.bold_check["state"] = "normal"
        else:
            self.bold_check["state"] = "disabled"
            self.bold = 0
            self.var_bold.set("")
        if "Italic" in self.styles or "Oblique" in self.styles:
            self.italic_check["state"] = "normal"
        else:
            self.italic = 0
            self.italic_check["state"] = "disabled"
            self.var_italic.set("")

        if self.var_style_name.get() == "Bold":
            self.bold = 1
            self.italic = 0
            self.var_bold.set("bold")
            self.var_italic.set("")
        elif self.var_style_name.get() in ["Italic", "Oblique"]:
            self.bold = 0
            self.italic = 1
            self.var_italic.set("italic")
            self.var_bold.set("")
        elif self.var_style_name.get() in ["Bold Italic", "Bold Oblique"]:
            self.bold = 1
            self.italic = 1
            self.var_bold.set("bold")
            self.var_italic.set("italic")
        else:
            self.bold = 0
            self.italic = 0
            self.var_bold.set("")
            self.var_italic.set("")

    def action(self):
        pass
Пример #5
0
    def __init__(self, parent):
        CtxSubPanel.__init__(self, parent)

        self.var_font_name = StringVar(self.mw.root, ' ')
        self.var_style_name = StringVar(self.mw.root, ' ')
        self.var_font_size = StringVar(self.mw.root, ' ')

        label = TLabel(self.panel, image='context_font_name')
        label.pack(side=LEFT, padx=2)
        tooltips.AddDescription(label, _('Font name'))
        self.font_name = TCombobox(self.panel,
                                   state='readonly',
                                   postcommand=self.name_changed,
                                   values=self.make_families(),
                                   width=25,
                                   style='PseudoActive',
                                   textvariable=self.var_font_name)
        self.font_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=' ')
        label.pack(side=LEFT)

        label = TLabel(self.panel, image='context_font_style')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Font style'))
        self.style_name = TCombobox(self.panel,
                                    state='readonly',
                                    postcommand=self.style_changed,
                                    values=(),
                                    width=18,
                                    style='PseudoActive',
                                    textvariable=self.var_style_name)
        self.style_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=' ')
        label.pack(side=LEFT)

        label = TLabel(self.panel, image='context_font_size')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Font size'))
        self.font_size = TCombobox(self.panel,
                                   state='normal',
                                   postcommand=self.apply_changes,
                                   values=self.make_sizes(),
                                   width=5,
                                   style='ComboNormal',
                                   textvariable=self.var_font_size)
        self.font_size.pack(side=LEFT, padx=2)

        ######################################
        self.var_bold = StringVar(self.mw.root, '')
        self.var_italic = StringVar(self.mw.root, '')
        self.var_underline = StringVar(self.mw.root, '')

        self.bold_check = UpdatedRadiobutton(self.panel,
                                             value='bold',
                                             image='context_text_bold',
                                             command=self.bold_action,
                                             variable=self.var_bold,
                                             style='ToolbarRadiobutton')
        self.bold_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.bold_check, _('Bold'))

        self.italic_check = UpdatedRadiobutton(self.panel,
                                               value='italic',
                                               image='context_text_italic',
                                               command=self.italic_action,
                                               variable=self.var_italic,
                                               style='ToolbarRadiobutton')
        self.italic_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.italic_check, _('Italic'))

        #		self.underline_check = UpdatedRadiobutton(self.panel, value = 'under', image='context_text_under_disabled', state='disabled',
        #								command=self.action, variable = self.var_underline, style='ToolbarRadiobutton')
        #		self.underline_check.pack(side=LEFT, padx=2)
        #		tooltips.AddDescription(self.underline_check, _('Underline'))

        self.ReSubscribe()
Пример #6
0
class FontPanel(CtxSubPanel):

    name = 'FontPanel'
    family_to_fonts = {}
    families = []
    styles = []
    bold = 0
    italic = 0

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

        self.var_font_name = StringVar(self.mw.root, ' ')
        self.var_style_name = StringVar(self.mw.root, ' ')
        self.var_font_size = StringVar(self.mw.root, ' ')

        label = TLabel(self.panel, image='context_font_name')
        label.pack(side=LEFT, padx=2)
        tooltips.AddDescription(label, _('Font name'))
        self.font_name = TCombobox(self.panel,
                                   state='readonly',
                                   postcommand=self.name_changed,
                                   values=self.make_families(),
                                   width=25,
                                   style='PseudoActive',
                                   textvariable=self.var_font_name)
        self.font_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=' ')
        label.pack(side=LEFT)

        label = TLabel(self.panel, image='context_font_style')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Font style'))
        self.style_name = TCombobox(self.panel,
                                    state='readonly',
                                    postcommand=self.style_changed,
                                    values=(),
                                    width=18,
                                    style='PseudoActive',
                                    textvariable=self.var_style_name)
        self.style_name.pack(side=LEFT, padx=2)

        label = TLabel(self.panel, text=' ')
        label.pack(side=LEFT)

        label = TLabel(self.panel, image='context_font_size')
        label.pack(side=LEFT)
        tooltips.AddDescription(label, _('Font size'))
        self.font_size = TCombobox(self.panel,
                                   state='normal',
                                   postcommand=self.apply_changes,
                                   values=self.make_sizes(),
                                   width=5,
                                   style='ComboNormal',
                                   textvariable=self.var_font_size)
        self.font_size.pack(side=LEFT, padx=2)

        ######################################
        self.var_bold = StringVar(self.mw.root, '')
        self.var_italic = StringVar(self.mw.root, '')
        self.var_underline = StringVar(self.mw.root, '')

        self.bold_check = UpdatedRadiobutton(self.panel,
                                             value='bold',
                                             image='context_text_bold',
                                             command=self.bold_action,
                                             variable=self.var_bold,
                                             style='ToolbarRadiobutton')
        self.bold_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.bold_check, _('Bold'))

        self.italic_check = UpdatedRadiobutton(self.panel,
                                               value='italic',
                                               image='context_text_italic',
                                               command=self.italic_action,
                                               variable=self.var_italic,
                                               style='ToolbarRadiobutton')
        self.italic_check.pack(side=LEFT, padx=2)
        tooltips.AddDescription(self.italic_check, _('Italic'))

        #		self.underline_check = UpdatedRadiobutton(self.panel, value = 'under', image='context_text_under_disabled', state='disabled',
        #								command=self.action, variable = self.var_underline, style='ToolbarRadiobutton')
        #		self.underline_check.pack(side=LEFT, padx=2)
        #		tooltips.AddDescription(self.underline_check, _('Underline'))

        self.ReSubscribe()

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

    def Update(self, *arg):
        object = self.mw.document.CurrentObject()
        if object is not None and object.is_Text:
            _font = object.Font()
            self.var_font_name.set(_font.familyname)
            self.var_style_name.set(_font.facename)
            self.style_name['values'] = self.make_styles()
            self.var_font_size.set(object.FontSize())
#		else:
#			try:
#				default = ft2engine.GetFont(config.preferences.default_font)
#			except:
#				name = self.family_to_fonts.keys()[0]#[0]
#				fonts = self.family_to_fonts[name]
#				default = ft2engine.GetFont(fonts[1])
#			self.var_font_name.set(default.family)
#			self.var_style_name.set(default.font_attrs)
#			self.style_name['values'] = self.make_styles()
#			self.var_font_size.set(properties.default_text_style.font_size)
        self.checkBI()

    def make_families(self):
        result = ()
        self.families = libpango.FAMILIES_LIST
        for item in self.families:
            result += (item, )
        return result

    def make_styles(self):
        faces = libpango.FAMILIES_DICT[self.var_font_name.get()]
        attrs = ()
        self.styles = []
        for name in faces:
            self.styles.append(name)
            attrs += (name, )
        return attrs

    def make_sizes(self):
        sizes = ()
        for size in [
                5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40,
                48, 56, 64, 72
        ]:
            sizes += (size, )
        return sizes

    def name_changed(self):
        self.style_name['values'] = self.make_styles()
        if not self.var_style_name.get() in self.styles:
            self.setRegular()
        self.checkBI()
        self.apply_changes()

    def style_changed(self):
        self.checkBI()
        self.apply_changes()

    def apply_changes(self):
        familyname = self.var_font_name.get()
        facename = self.var_style_name.get()
        self.mw.document.CallObjectMethod(
            text.CommonText, _("Set Font Properties"), 'SetFont',
            libpango.get_fontface(familyname, facename),
            atof(self.var_font_size.get()))
        self.mw.canvas.ForceRedraw()

    def bold_action(self):
        if self.bold:
            self.bold = 0
            self.var_bold.set('')
        else:
            self.bold = 1
            self.var_bold.set('bold')

        if self.bold and self.italic:
            if 'Bold Italic' in self.styles:
                self.var_style_name.set('Bold Italic')
            elif 'Bold Oblique' in self.styles:
                self.var_style_name.set('Bold Oblique')
            else:
                self.bold = 0
                self.var_bold.set('')
        elif self.bold:
            self.var_style_name.set('Bold')
        elif self.italic:
            if 'Italic' in self.styles:
                self.var_style_name.set('Italic')
            if 'Oblique' in self.styles:
                self.var_style_name.set('Oblique')
        else:
            self.setRegular()
        self.style_changed()

    def italic_action(self):
        if self.italic:
            self.italic = 0
            self.var_italic.set('')
        else:
            self.italic = 1
            self.var_italic.set('italic')

        if self.bold and self.italic:
            if 'Bold Italic' in self.styles:
                self.var_style_name.set('Bold Italic')
            elif 'Bold Oblique' in self.styles:
                self.var_style_name.set('Bold Oblique')
            else:
                self.italic = 0
                self.var_italic.set('')
        elif self.italic:
            if 'Italic' in self.styles:
                self.var_style_name.set('Italic')
            if 'Oblique' in self.styles:
                self.var_style_name.set('Oblique')
        elif self.bold:
            self.var_style_name.set('Bold')
        else:
            self.setRegular()
        self.style_changed()

    def setRegular(self):
        normal = None
        for item in ['Roman', 'Book', 'Normal', 'Regular']:
            if item in self.styles:
                normal = item
        if normal:
            self.var_style_name.set(normal)
        else:
            self.var_style_name.set(self.styles[0])

    def checkBI(self):
        if 'Bold' in self.styles:
            self.bold_check['state'] = 'normal'
        else:
            self.bold_check['state'] = 'disabled'
            self.bold = 0
            self.var_bold.set('')
        if 'Italic' in self.styles or 'Oblique' in self.styles:
            self.italic_check['state'] = 'normal'
        else:
            self.italic = 0
            self.italic_check['state'] = 'disabled'
            self.var_italic.set('')

        if self.var_style_name.get() == 'Bold':
            self.bold = 1
            self.italic = 0
            self.var_bold.set('bold')
            self.var_italic.set('')
        elif self.var_style_name.get() in ['Italic', 'Oblique']:
            self.bold = 0
            self.italic = 1
            self.var_italic.set('italic')
            self.var_bold.set('')
        elif self.var_style_name.get() in ['Bold Italic', 'Bold Oblique']:
            self.bold = 1
            self.italic = 1
            self.var_bold.set('bold')
            self.var_italic.set('italic')
        else:
            self.bold = 0
            self.italic = 0
            self.var_bold.set('')
            self.var_italic.set('')

    def action(self):
        pass
Пример #7
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)
Пример #8
0
	def __init__(self, parent, anchor='C', command = None, **kw):
		TFrame.__init__(self, parent, style='FlatFrame', **kw)
		self.command = command
		self.anchor = anchor
		#---------------------------------------------------------
		# Basepoint check
		# NW -- N -- NE
		# |     |     |
		# W  -- C --  E
		# |     |     |
		# SW -- S -- SE
		#
		# USER - basepoint
		
		frame=TFrame(self, style='FlatFrame')
		frame.pack(side = TOP, fill = BOTH)
		
		radio = UpdatedRadiobutton(frame, value = 'NW',variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		radio = UpdatedRadiobutton(frame, value = 'N', variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		radio = UpdatedRadiobutton(frame, value = 'NE', variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		
		frame=TFrame(self, style='FlatFrame')
		frame.pack(side = TOP, fill = BOTH)
		
		radio = UpdatedRadiobutton(frame, value = 'W', variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		radio = UpdatedRadiobutton(frame, value = 'C', variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		radio = UpdatedRadiobutton(frame, value = 'E', variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		
		frame=TFrame(self, style='FlatFrame')
		frame.pack(side = TOP, fill = BOTH)
		
		radio = UpdatedRadiobutton(frame, value = 'SW', variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		radio = UpdatedRadiobutton(frame, value = 'S',  variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
		radio = UpdatedRadiobutton(frame, value = 'SE', variable = self.anchor, command = self.command)
		radio.pack(side=LEFT, anchor=W)
Пример #9
0
	def init(self, master):
		PluginPanel.init(self, master)
		
		root=self.mw.root
		
		top = TFrame(self.panel, style='FlatFrame', borderwidth=5)
		top.pack(side = TOP, fill=BOTH)

		########### APPLY BUTTON ################################################
		button = UpdatedButton(top, text = _("Apply"),
								command = self.apply_properties,
								sensitivecb = self.is_correct_selection)
		button.pack(side = BOTTOM, expand = 1, fill = X)
		self.Subscribe(SELECTION, button.Update)

		########### COLOR BUTTON ################################################		
		
		color_frame = TFrame(top, style='FlatFrame', borderwidth=3)
		color_frame.pack(side = TOP)
		
		label = TLabel(color_frame, style='FlatLabel', text=_('Color:'))
		label.pack(side = LEFT, padx=5)
		
		self.color_button = TColorButton(color_frame, command=self.show_outline_color)
		self.color_button.pack(side = LEFT, padx=5)
		self.color_button.set_color((255,0,0))
		
		########### LINE WIDTH ##################################################

		self.var_width_number=DoubleVar(root)
		
		self.var_width_base=DoubleVar(root)

		var_width_unit = StringVar(root)
		
		unit = config.preferences.default_unit
		
		self.var_width = LengthVar(10, unit, self.var_width_number, var_width_unit)
		
		line_width_frame = TFrame(top, style='FlatFrame', borderwidth=3)
		line_width_frame.pack(side = TOP, fill = BOTH)

		self.labelwunit = TLabel(line_width_frame, style='FlatLabel', text = self.var_width.unit)
		self.labelwunit.pack(side = RIGHT, padx=5)
		
		self.entry_width = TSpinbox(line_width_frame,  var=0, vartype=1, textvariable = self.var_width_number, 
									min = 0, max = 50000, step = .1, width = 8, command=self.update_pattern)
		self.entry_width.pack(side = RIGHT)
		
		label = TLabel(line_width_frame, style='FlatLabel', text=_('Line width:'))
		label.pack(side = RIGHT, padx=5)		
		########### LINE STYLE #################################################		
		style_frame = TFrame(top, style='FlatFrame', borderwidth=5)
		style_frame.pack(side = TOP, fill=X)
		
		for item in range(1,12):
			self.dashlist.append("dash%d"%(item))
		
		self.style_button = TOptionMenu(style_frame, self.dashlist, command = self.set_dash, 
									entry_type = 'image', style='TComboSmall')
		self.style_button.pack(side = RIGHT, fill=X)
		
		label = TLabel(style_frame, style='FlatLabel', text=_('Style:'))
		label.pack(side = RIGHT, padx=5)

		########################################################################		
		selection_frame = TFrame(top, style='FlatFrame', borderwidth=1)
		selection_frame.pack(side = TOP)
			
		########### CORNERS #####################################################	
		
		label=TLabel(selection_frame, text=" "+_("Corners:")+" ", style="FlatLabel")
		label.pack()
		
		corners_frame=TLabelframe(selection_frame, labelwidget=label, style='Labelframe', borderwidth=8)

		corners_frame.pack(side = LEFT, fill=Y, pady=1, padx=1)
		
		self.var_corner = IntVar(root)
		radio = UpdatedRadiobutton(corners_frame, image = "join_miter",
									variable = self.var_corner,
									value = const.JoinMiter,
									command = self.update_pattern)
		radio.pack(side = TOP, anchor=W, pady=2)
		
		radio = UpdatedRadiobutton(corners_frame, image = "join_round",
									variable = self.var_corner,
									value = const.JoinRound,
									command = self.update_pattern)
		radio.pack(side = TOP, anchor=W, pady=2)
		
		radio = UpdatedRadiobutton(corners_frame, image = "join_bevel",
									variable = self.var_corner,
									value = const.JoinBevel,
									command = self.update_pattern)
		radio.pack(side = TOP, anchor=W, pady=2)

		
		########### LINE CAPS ###################################################
		
		label=TLabel(selection_frame, text=" "+_("Line caps:")+" ", style="FlatLabel")
		label.pack()
		
		caps_frame=TLabelframe(selection_frame, labelwidget=label, style='Labelframe', borderwidth=8)

		caps_frame.pack(side = RIGHT, fill=Y, pady=1, padx=1)
		
		self.var_caps = IntVar(root)
		radio = UpdatedRadiobutton(caps_frame, image = "cap_butt",
									variable = self.var_caps,
									value = const.CapButt,
									command = self.update_pattern)
		radio.pack(side = TOP, anchor=W, pady=2)
		
		radio = UpdatedRadiobutton(caps_frame, image = "cap_round",
									variable = self.var_caps,
									value = const.CapRound,
									command = self.update_pattern)
		radio.pack(side = TOP, anchor=W, pady=2)
		
		radio = UpdatedRadiobutton(caps_frame, image = "cap_projecting",
									variable = self.var_caps,
									value = const.CapProjecting,
									command = self.update_pattern)
		radio.pack(side = TOP, anchor=W, pady=2)
		self.var_caps.set(0)
		
		############ BOTTOM BUTTONS #############################################
		
		button_frame = TFrame(top, style='FlatFrame', borderwidth=1)
		button_frame.pack(side = BOTTOM, fill=X, pady=5)
		
		button = TButton(button_frame, style='TSmallbutton', text=' ', image='small_colorpicker', command = self.copy_from)
		button.pack(side = LEFT)
		tooltips.AddDescription(button, _("Copy From..."))
		
		button = TButton(button_frame, style='TSmallbutton', text=' ', image='restore_color', command = self.restore_properties)
		button.pack(side = LEFT, padx=5)
		tooltips.AddDescription(button, _("Restore properties"))
		
		self.var_autoupdate = IntVar(top)
		self.var_autoupdate.set(1)
		
		self.autoupdate_check = TCheckbutton(button_frame, text = _("Auto Update"), variable = self.var_autoupdate, 
											command=self.init_from_doc)
		self.autoupdate_check.pack(side = RIGHT, anchor=W, padx=10)
		#######################################################################
		
		
		self.set_default_style()

		self.init_from_doc()
		self.subscribe_receivers()
Пример #10
0
    def __init__(self, parent):
        CtxSubPanel.__init__(self, parent)
        self.var_reference = StringVar(self.mw.root, 'left')
        self.var_stub = StringVar(self.mw.root)

        radio = UpdatedRadiobutton(self.panel,
                                   value='left',
                                   image='context_text_left',
                                   command=self.applyProperties,
                                   variable=self.var_reference,
                                   style='ToolbarRadiobutton')
        radio.pack(side=LEFT)
        tooltips.AddDescription(radio, _('Left alignment'))
        radio = UpdatedRadiobutton(self.panel,
                                   value='center',
                                   image='context_text_center',
                                   command=self.applyProperties,
                                   variable=self.var_reference,
                                   style='ToolbarRadiobutton')
        radio.pack(side=LEFT)
        tooltips.AddDescription(radio, _('Center alignment'))
        radio = UpdatedRadiobutton(self.panel,
                                   value='right',
                                   image='context_text_right',
                                   command=self.applyProperties,
                                   variable=self.var_reference,
                                   style='ToolbarRadiobutton')
        radio.pack(side=LEFT)
        tooltips.AddDescription(radio, _('Right alignment'))
        #		radio = UpdatedRadiobutton(self.panel, value = 'justify', image='context_text_justify_disabled',
        #								command=self.applyProperties, variable = self.var_stub, style='ToolbarRadiobutton', state='disabled')
        #		radio.pack(side=LEFT)
        #		tooltips.AddDescription(radio, _('Justify'))

        self.ReSubscribe()
Пример #11
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)
Пример #12
0
    def init(self, master):
        PluginPanel.init(self, master)

        root = self.mw.root

        top = TFrame(self.panel, style='FlatFrame', borderwidth=5)
        top.pack(side=TOP, fill=BOTH)

        ########### APPLY BUTTON ################################################
        button = UpdatedButton(top,
                               text=_("Apply"),
                               command=self.apply_properties,
                               sensitivecb=self.is_correct_selection)
        button.pack(side=BOTTOM, expand=1, fill=X)
        self.Subscribe(SELECTION, button.Update)

        ########### COLOR BUTTON ################################################

        color_frame = TFrame(top, style='FlatFrame', borderwidth=3)
        color_frame.pack(side=TOP)

        label = TLabel(color_frame, style='FlatLabel', text=_('Color:'))
        label.pack(side=LEFT, padx=5)

        self.color_button = TColorButton(color_frame,
                                         command=self.show_outline_color)
        self.color_button.pack(side=LEFT, padx=5)
        self.color_button.set_color((255, 0, 0))

        ########### LINE WIDTH ##################################################

        self.var_width_number = DoubleVar(root)

        self.var_width_base = DoubleVar(root)

        var_width_unit = StringVar(root)

        unit = config.preferences.default_unit

        self.var_width = LengthVar(10, unit, self.var_width_number,
                                   var_width_unit)

        line_width_frame = TFrame(top, style='FlatFrame', borderwidth=3)
        line_width_frame.pack(side=TOP, fill=BOTH)

        self.labelwunit = TLabel(line_width_frame,
                                 style='FlatLabel',
                                 text=self.var_width.unit)
        self.labelwunit.pack(side=RIGHT, padx=5)

        self.entry_width = TSpinbox(line_width_frame,
                                    var=0,
                                    vartype=1,
                                    textvariable=self.var_width_number,
                                    min=0,
                                    max=50000,
                                    step=.1,
                                    width=8,
                                    command=self.update_pattern)
        self.entry_width.pack(side=RIGHT)

        label = TLabel(line_width_frame,
                       style='FlatLabel',
                       text=_('Line width:'))
        label.pack(side=RIGHT, padx=5)
        ########### LINE STYLE #################################################
        style_frame = TFrame(top, style='FlatFrame', borderwidth=5)
        style_frame.pack(side=TOP, fill=X)

        for item in range(1, 12):
            self.dashlist.append("dash%d" % (item))

        self.style_button = TOptionMenu(style_frame,
                                        self.dashlist,
                                        command=self.set_dash,
                                        entry_type='image',
                                        style='TComboSmall')
        self.style_button.pack(side=RIGHT, fill=X)

        label = TLabel(style_frame, style='FlatLabel', text=_('Style:'))
        label.pack(side=RIGHT, padx=5)

        ########################################################################
        selection_frame = TFrame(top, style='FlatFrame', borderwidth=1)
        selection_frame.pack(side=TOP)

        ########### CORNERS #####################################################

        label = TLabel(selection_frame,
                       text=" " + _("Corners:") + " ",
                       style="FlatLabel")
        label.pack()

        corners_frame = TLabelframe(selection_frame,
                                    labelwidget=label,
                                    style='Labelframe',
                                    borderwidth=8)

        corners_frame.pack(side=LEFT, fill=Y, pady=1, padx=1)

        self.var_corner = IntVar(root)
        radio = UpdatedRadiobutton(corners_frame,
                                   image="join_miter",
                                   variable=self.var_corner,
                                   value=const.JoinMiter,
                                   command=self.update_pattern)
        radio.pack(side=TOP, anchor=W, pady=2)

        radio = UpdatedRadiobutton(corners_frame,
                                   image="join_round",
                                   variable=self.var_corner,
                                   value=const.JoinRound,
                                   command=self.update_pattern)
        radio.pack(side=TOP, anchor=W, pady=2)

        radio = UpdatedRadiobutton(corners_frame,
                                   image="join_bevel",
                                   variable=self.var_corner,
                                   value=const.JoinBevel,
                                   command=self.update_pattern)
        radio.pack(side=TOP, anchor=W, pady=2)

        ########### LINE CAPS ###################################################

        label = TLabel(selection_frame,
                       text=" " + _("Line caps:") + " ",
                       style="FlatLabel")
        label.pack()

        caps_frame = TLabelframe(selection_frame,
                                 labelwidget=label,
                                 style='Labelframe',
                                 borderwidth=8)

        caps_frame.pack(side=RIGHT, fill=Y, pady=1, padx=1)

        self.var_caps = IntVar(root)
        radio = UpdatedRadiobutton(caps_frame,
                                   image="cap_butt",
                                   variable=self.var_caps,
                                   value=const.CapButt,
                                   command=self.update_pattern)
        radio.pack(side=TOP, anchor=W, pady=2)

        radio = UpdatedRadiobutton(caps_frame,
                                   image="cap_round",
                                   variable=self.var_caps,
                                   value=const.CapRound,
                                   command=self.update_pattern)
        radio.pack(side=TOP, anchor=W, pady=2)

        radio = UpdatedRadiobutton(caps_frame,
                                   image="cap_projecting",
                                   variable=self.var_caps,
                                   value=const.CapProjecting,
                                   command=self.update_pattern)
        radio.pack(side=TOP, anchor=W, pady=2)
        self.var_caps.set(0)

        ############ BOTTOM BUTTONS #############################################

        button_frame = TFrame(top, style='FlatFrame', borderwidth=1)
        button_frame.pack(side=BOTTOM, fill=X, pady=5)

        button = TButton(button_frame,
                         style='TSmallbutton',
                         text=' ',
                         image='small_colorpicker',
                         command=self.copy_from)
        button.pack(side=LEFT)
        tooltips.AddDescription(button, _("Copy From..."))

        button = TButton(button_frame,
                         style='TSmallbutton',
                         text=' ',
                         image='restore_color',
                         command=self.restore_properties)
        button.pack(side=LEFT, padx=5)
        tooltips.AddDescription(button, _("Restore properties"))

        self.var_autoupdate = IntVar(top)
        self.var_autoupdate.set(1)

        self.autoupdate_check = TCheckbutton(button_frame,
                                             text=_("Auto Update"),
                                             variable=self.var_autoupdate,
                                             command=self.init_from_doc)
        self.autoupdate_check.pack(side=RIGHT, anchor=W, padx=10)
        #######################################################################

        self.set_default_style()

        self.init_from_doc()
        self.subscribe_receivers()