예제 #1
0
 def __init__(self, parent=None):
     super(TemplateLabelEditor, self).__init__(parent=parent)
     self._template = None
     self.member_groups = {group: TemplateLabelGroup(group) for group in members}
     self.style_editor = TextStyleEditorWidget()
     self.style_editor.savePressed.connect(self.save_style)
     for group, widget in self.member_groups.iteritems():
         widget.labelUpdated.connect(self.labelUpdated.emit)
         widget.moveLabel.connect(self.moveLabel.emit)
         widget.editStyle.connect(self.edit_style)
         scroll = QtGui.QScrollArea()
         scroll.setWidget(widget)
         self.addTab(scroll, unicode(group[0].upper() + group[1:]))
     self.current_member = None
예제 #2
0
class TemplateLabelEditor(QtGui.QTabWidget):
    labelUpdated = QtCore.Signal()
    moveLabel = QtCore.Signal(float, float, object)

    def __init__(self, parent=None):
        super(TemplateLabelEditor, self).__init__(parent=parent)
        self._template = None
        self.member_groups = {group: TemplateLabelGroup(group) for group in members}
        self.style_editor = TextStyleEditorWidget()
        self.style_editor.savePressed.connect(self.save_style)
        for group, widget in self.member_groups.iteritems():
            widget.labelUpdated.connect(self.labelUpdated.emit)
            widget.moveLabel.connect(self.moveLabel.emit)
            widget.editStyle.connect(self.edit_style)
            scroll = QtGui.QScrollArea()
            scroll.setWidget(widget)
            self.addTab(scroll, unicode(group[0].upper() + group[1:]))
        self.current_member = None

    def edit_style(self, member, style):
        self.current_member = member
        style = str(style)
        tc = vcs.createtextcombined(Tt_source=style, To_source=style)
        self.style_editor.setTextObject(tc)
        self.style_editor.show()
        self.style_editor.raise_()

    def save_style(self, style):
        current_obj = self.style_editor.textObject
        style = str(style)
        if style == current_obj.name:
            to_name = current_obj.To_name
            to_src = "default"
            tt_name = current_obj.Tt_name
            tt_src = "default"
        else:
            to_name = style
            to_src = current_obj.To_name
            tt_name = style
            tt_src = current_obj.Tt_name
        try:
            to = vcs.gettextorientation(to_name)
        except ValueError:
            to = vcs.createtextorientation(name=to_name, source=to_src)
        try:
            tt = vcs.gettexttable(tt_name)
        except ValueError:
            tt = vcs.createtexttable(name=tt_name, source=tt_src)
        get_textstyles().updated(tt_name)
        self.current_member.texttable = tt
        self.current_member.textorientation = to
        self.current_member = None
        self.sync()
        self.labelUpdated.emit()

    @property
    def template(self):
        return self._template

    @template.setter
    def template(self, value):
        self._template = value
        self.sync()

    def sync(self):
        """Retrieve all values from the template and update the GUI."""
        for member_group in members:
            for member in members[member_group]:
                attr = getattr(self._template, member)
                self.member_groups[member_group].get(member).setLabel(attr)
예제 #3
0
def editors():
    edit1 = TextStyleEditorWidget()
    t = vcs.createtext()
    t.name = "header"
    edit1.setTextObject(t)

    edit2 = TextStyleEditorWidget()
    t = vcs.createtext()
    t.name = "header"
    t.valign = 0
    t.halign = 1
    edit2.setTextObject(t)

    edit3 = TextStyleEditorWidget()
    t = vcs.createtext()
    t.name = "header"
    t.valign = 4
    t.halign = 2
    edit3.setTextObject(t)

    return edit1, edit2, edit3