コード例 #1
0
    def _parse_group(self, node, attributes):
        group = Container.constructor(int(attributes.get('col', 4)),
                                      attributes.get('homogeneous', False))
        self.parse_child(node, group)

        if 'name' in attributes and attributes['name'] == self.exclude_field:
            self.container.add(None, attributes)
            return

        can_expand = attributes.get('expandable')
        if can_expand:
            widget = Expander(label=attributes.get('string'), attrs=attributes)
            widget.add(group.container)
            widget.set_expanded(can_expand == '1')
            self.view.expandables.append(widget)
        else:
            widget = Frame(label=attributes.get('string'), attrs=attributes)
            widget.add(group.container)

        widget.set_halign(
            get_align(attributes.get('xalign', 0.5),
                      bool(attributes.get('xexpand', True))))
        widget.set_valign(
            get_align(attributes.get('yalign', 0.5),
                      bool(attributes.get('yexpand'))))
        self.view.state_widgets.append(widget)
        self.container.add(widget, attributes)
コード例 #2
0
ファイル: form.py プロジェクト: masking/tryton
    def _parse_field(self, node, attributes):
        name = attributes['name']
        if name and name == self.exclude_field:
            self.container.add(None, attributes)
            return

        widget = self.WIDGETS[attributes['widget']](self.view, attributes)
        self.view.widgets[name].append(widget)

        if widget.expand:
            attributes.setdefault('yexpand', True)
            attributes.setdefault('yfill', True)

        if attributes.get('height') or attributes.get('width'):
            widget.widget.set_size_request(int(attributes.get('width', -1)),
                                           int(attributes.get('height', -1)))

        widget.widget.set_halign(
            get_align(attributes.get('xalign', 0.5),
                      bool(attributes.get('xexpand', True))))
        widget.widget.set_valign(
            get_align(attributes.get('yalign', 0.5),
                      bool(attributes.get('yexpand'))))
        self.container.add(widget.widget, attributes)

        if name in self._mnemonics and widget.mnemonic_widget:
            label = self._mnemonics.pop(name)
            label.set_label(set_underline(label.get_label()))
            label.set_use_underline(True)
            label.set_mnemonic_widget(widget.mnemonic_widget)
コード例 #3
0
 def _parse_separator(self, node, container, attributes):
     vbox = Gtk.VBox()
     if attributes.get('string'):
         label = Gtk.Label(label=attributes['string'])
         label.set_halign(get_align(attributes.get('xalign', 0.0)))
         label.set_valign(get_align(attributes.get('yalign', 0.5)))
         vbox.pack_start(label, expand=True, fill=True, padding=0)
     vbox.pack_start(Gtk.HSeparator(), expand=True, fill=True, padding=0)
     container.add(vbox, attributes)
コード例 #4
0
 def _parse_label(self, node, container, attributes):
     if not attributes.get('string'):
         container.add(None, attributes)
         return
     label = Gtk.Label(label=attributes['string'])
     label.set_halign(get_align(attributes.get('xalign', 0.0)))
     label.set_halign(get_align(attributes.get('yalign', 0.5)))
     label.set_angle(int(attributes.get('angle', 0)))
     attributes.setdefault('xexpand', 0)
     container.add(label, attributes)
コード例 #5
0
 def _parse_separator(self, node, attributes):
     vbox = VBox(attrs=attributes)
     if attributes.get('string'):
         label = Label(label=attributes['string'], attrs=attributes)
         label.set_halign(get_align(attributes.get('xalign', 0.0)))
         label.set_valign(get_align(attributes.get('yalign', 0.5)))
         vbox.pack_start(label, expand=True, fill=True, padding=0)
         self.view.state_widgets.append(label)
     vbox.pack_start(Gtk.HSeparator(), expand=True, fill=True, padding=0)
     self.view.state_widgets.append(vbox)
     self.container.add(vbox, attributes)
コード例 #6
0
    def _parse_label(self, node, attributes):
        name = attributes.get('name')
        if name and name == self.exclude_field:
            self.container.add(None, attributes)
            return
        if CONFIG['client.modepda']:
            attributes['xalign'] = 0.0

        label = Label(label=attributes.get('string', ''), attrs=attributes)
        label.set_halign(get_align(attributes.get('xalign', 1.0)))
        label.set_valign(get_align(attributes.get('yalign', 0.5)))
        label.set_angle(int(attributes.get('angle', 0)))
        attributes.setdefault('xexpand', 0)
        self.view.state_widgets.append(label)
        self.container.add(label, attributes)
        if name:
            self._mnemonics[name] = label
コード例 #7
0
 def _parse_separator(self, node, attributes):
     name = attributes.get('name')
     if name and name == self.exclude_field:
         self.container.add(None, attributes)
         return
     vbox = VBox(attrs=attributes)
     if attributes.get('string'):
         label = Label(label=attributes['string'], attrs=attributes)
         label.set_halign(
             get_align(attributes.get('xalign', 0.0),
                       bool(attributes.get('xexpand', True))))
         label.set_valign(
             get_align(attributes.get('yalign', 0.5),
                       bool(attributes.get('yexpand', False))))
         vbox.pack_start(label, expand=True, fill=True, padding=0)
         self.view.state_widgets.append(label)
         if name:
             self._mnemonics[name] = label
     vbox.pack_start(Gtk.HSeparator(), expand=True, fill=True, padding=0)
     self.view.state_widgets.append(vbox)
     self.container.add(vbox, attributes)
コード例 #8
0
    def _parse_field(self, node, attributes):
        name = attributes['name']
        if name and name == self.exclude_field:
            self.container.add(None, attributes)
            return

        # RSE Display more useful info when trying to display unexisting field
        if 'widget' not in attributes:
            raise Exception('Unknown field %s' % attributes['name'])
        widget = self.WIDGETS[attributes['widget']](self.view, attributes)
        self.view.widgets[name].append(widget)

        if attributes.get('group'):
            group = attributes['group']

        if widget.expand:
            attributes.setdefault('yexpand', True)
            attributes.setdefault('yfill', True)

        if attributes.get('height') or attributes.get('width'):
            widget.widget.set_size_request(int(attributes.get('width', -1)),
                                           int(attributes.get('height', -1)))

        widget.widget.set_halign(
            get_align(attributes.get('xalign', 0.5),
                      bool(attributes.get('xexpand', True))))
        widget.widget.set_valign(
            get_align(attributes.get('yalign', 0.5),
                      bool(attributes.get('yexpand'))))
        self.container.add(widget.widget, attributes)

        if name in self._mnemonics and widget.mnemonic_widget:
            label = self._mnemonics.pop(name)
            label.set_label(set_underline(label.get_label()))
            label.set_use_underline(True)
            label.set_mnemonic_widget(widget.mnemonic_widget)