Beispiel #1
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)

        self.check_values()
        self.create_label()

        self.value = self.data["value"]
        self.field = Gtk.ComboBoxText()
        self.field.set_property("margin-left", 20)
        self.field.set_entry_text_column(0)

        for value in self.data["values"]:
            self.field.append_text(value)
        if self.value in self.data["values"]:
            index = self.data["values"].index(self.value)
            self.field.set_active(index)
        if event is not None:
            self.field.connect("changed", event)
        self.add(self.field)
        self.show_all()
Beispiel #2
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)

        self.check_values()
        self.create_label()

        self.set_homogeneous(False)
        self.set_spacing(10)
        scrolled_window = Gtk.ScrolledWindow()

        scrolled_window.set_min_content_height(self.data["height"])
        scrolled_window.set_min_content_width(self.data["width"])

        scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN)

        self.field = Gtk.TextView()
        self.field.set_left_margin(10)
        self.field.set_right_margin(10)
        self.field.set_wrap_mode(Gtk.WrapMode.WORD)
        if event is not None:
            self.field.connect("focus-out-event", event)

        self.text_buffer = self.field.get_buffer()
        self.text_buffer.set_text(self.data["value"])
        scrolled_window.add(self.field)

        self.add(scrolled_window)
        self.show_all()
Beispiel #3
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)

        self.check_values()
        self.create_label()

        self.file = self.data["value"]
        self.parent_window = None

        box = Gtk.HBox()
        self.field = Gtk.Entry()
        self.field.set_property("margin-left", 20)
        self.field.set_text(self.file)
        if event is not None:
            self.field.connect("changed", event)
        box.pack_start(self.field, True, True, 0)

        button = Gtk.Button.new_from_icon_name("gtk-file", Gtk.IconSize.BUTTON)
        button.connect("clicked", self.__on_choose_file)
        box.pack_start(button, False, False, 0)
        self.add(box)
        self.show_all()
Beispiel #4
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.HBox.__init__(self, True)

        self.check_values()

        self.set_name(self.data["name"])

        self.label = Gtk.Label(self.data["label"])
        self.label.set_property("halign", Gtk.Align.START)
        self.add(self.label)

        adjustment = Gtk.Adjustment(value=float(self.data["value"]),
                                    lower=int(self.data["lower"]),
                                    upper=int(self.data["upper"]),
                                    step_incr=int(self.data["step"]),
                                    page_incr=int(self.data["page_inc"]),
                                    page_size=int(self.data["page_size"]))
        self.field = Gtk.SpinButton()
        self.field.set_adjustment(adjustment)
        self.field.set_value(float(self.data["value"]))

        if event is not None:
            self.field.connect("changed", event)
            self.field.connect("value-changed", event)
            self.field.connect("change-value", event)
        self.add(self.field)
        self.show_all()
Beispiel #5
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.HBox.__init__(self, True)

        self.check_values()

        self.set_name(self.data["name"])
        self.parent_window = None
        self.event = event
        self.set_value(self.data["value"])
        self.label = Gtk.Label(self.data["label"])
        self.format = self.data["format"]
        self.add(self.label)
        self.label.set_property("halign", Gtk.Align.START)

        self.color_block = Gtk.DrawingArea()
        self.color_block.modify_bg(Gtk.StateType.NORMAL, self.color)
        self.add(self.color_block)

        button = Gtk.Button.new_from_icon_name("gtk-select-color",
                                               Gtk.IconSize.BUTTON)
        button.connect("clicked", self.on_choose_color)
        self.add(button)
        self.show_all()
Beispiel #6
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.HBox.__init__(self, True)

        self.check_values()

        self.set_name(self.data["name"])
        self.label = Gtk.Label(self.data["label"])
        self.label.set_property("halign", Gtk.Align.START)
        self.add(self.label)

        self.field = Gtk.Switch()

        if isinstance(self.data["value"], str) \
                or isinstance(self.data["value"], unicode):
            if self.data["value"] == "True":
                self.field.set_active(True)
            else:
                self.field.set_active(False)
        elif isinstance(self.data["value"], bool):
            self.field.set_active(self.data["value"])

        if event is not None:
            self.field.connect("notify::active", event)
        self.add(self.field)
        self.show_all()
Beispiel #7
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)

        self.check_values()
        self.create_label()

        adjustment = Gtk.Adjustment(value=float(self.data["value"]),
                                    lower=int(self.data["lower"]),
                                    upper=int(self.data["upper"]),
                                    step_increment=int(self.data["step"]),
                                    page_increment=int(
                                        self.data["page_increment"]),
                                    page_size=int(self.data["page_size"]))
        self.field = Gtk.SpinButton()
        self.field.set_property("margin-left", 20)
        self.field.set_adjustment(adjustment)
        self.field.set_value(float(self.data["value"]))

        if event is not None:
            self.field.connect("changed", event)
            self.field.connect("value-changed", event)
            self.field.connect("change-value", event)
        self.add(self.field)
        self.show_all()
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)

        self.check_values()
        self.create_label()

        box = Gtk.HBox()
        self.color_block = Gtk.Frame()
        box.add(self.color_block)

        button = Gtk.Button.new_from_icon_name("gtk-select-color",
                                               Gtk.IconSize.BUTTON)
        button.connect("clicked", self.on_choose_color)
        box.add(button)
        self.add(box)

        self.parent_window = None
        self.event = event
        self.set_value(self.data["value"])
        self.format = self.data["format"]

        self.show_all()
Beispiel #9
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)

        self.check_values()
        self.create_label()

        self.field = Gtk.Switch()
        self.field.set_property("margin-left", 20)

        if isinstance(self.data["value"], str) \
                or isinstance(self.data["value"], unicode):
            if self.data["value"] == "True":
                self.field.set_active(True)
            else:
                self.field.set_active(False)
        elif isinstance(self.data["value"], bool):
            self.field.set_active(self.data["value"])

        if event is not None:
            self.field.connect("notify::active", event)
        self.add(self.field)
        self.show_all()
Beispiel #10
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.HBox.__init__(self, True)

        self.check_values()
        self.set_name(self.data["name"])
        self.value = self.data["value"]
        self.label = Gtk.Label(self.data["label"])
        self.label.set_property("halign", Gtk.Align.START)
        self.add(self.label)

        self.field = Gtk.ComboBoxText()
        self.field.set_entry_text_column(0)

        for value in self.data["values"]:
            self.field.append_text(value)
        if self.value in self.data["values"]:
            index = self.data["values"].index(self.value)
            self.field.set_active(index)
        if event is not None:
            self.field.connect("changed", event)
        self.add(self.field)
        self.show_all()
Beispiel #11
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.HBox.__init__(self, False)

        self.check_values()

        self.set_name(self.data["name"])

        self.file = self.data["value"]
        self.parent_window = None
        self.label = Gtk.Label(self.data["label"])
        self.label.set_property("halign", Gtk.Align.START)
        self.add(self.label)

        self.field = Gtk.Entry()
        self.field.set_text(self.file)
        if event is not None:
            self.field.connect("changed", event)
        self.add(self.field)

        button = Gtk.Button.new_from_icon_name("gtk-file", Gtk.IconSize.BUTTON)
        button.connect("clicked", self.on_choose_file)
        self.add(button)
        self.show_all()
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        self.check_values()
        self.create_label()

        self.field = Gtk.Entry()
        self.field.set_text(self.data["value"])
        self.field.set_property("max-length", int(self.data["maxlength"]))
        if event is not None:
            self.field.connect("changed", event)
        self.add(self.field)
        self.show_all()
Beispiel #13
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.HBox.__init__(self, True)

        self.check_values()

        self.set_name(self.data["name"])
        self.value = self.data["value"]
        self.values = []
        self.label = Gtk.Label(self.data["label"])
        self.label.set_property("halign", Gtk.Align.START)
        self.add(self.label)

        self.liststore = Gtk.ListStore(Pixbuf, str)
        # List system stock icons
        ids = Gtk.stock_list_ids()
        ids.sort()
        for stock_id in ids:
            try:
                pixbuf = Gtk.IconTheme.get_default().load_icon(stock_id, 16, 0)
                self.liststore.append([pixbuf, stock_id])
                self.values.append(stock_id)
            except:
                pass

        self.field = Gtk.ComboBox.new_with_model(self.liststore)

        renderer = Gtk.CellRendererPixbuf()
        self.field.pack_start(renderer, False)
        self.field.add_attribute(renderer, "pixbuf", 0)

        renderer = Gtk.CellRendererText()
        self.field.pack_start(renderer, True)
        self.field.add_attribute(renderer, "text", 1)

        if event is not None:
            self.field.connect("changed", event)
        self.add(self.field)
        self.show_all()
Beispiel #14
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.VBox.__init__(self)

        self.check_values()

        self.set_name(self.data["name"])

        self.set_homogeneous(False)
        self.set_spacing(10)
        scrolled_window = Gtk.ScrolledWindow()

        scrolled_window.set_min_content_height(self.data["height"])
        scrolled_window.set_min_content_width(self.data["width"])

        scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN)

        self.label = Gtk.Label(self.data["label"])
        self.label.set_property("halign", Gtk.Align.START)
        self.pack_start(self.label, False, False, 0)

        lang_manager = GtkSource.LanguageManager()
        self.text_buffer = GtkSource.Buffer.new_with_language(
            lang_manager.get_language(self.data["language"]))
        self.field = GtkSource.View.new_with_buffer(self.text_buffer)
        self.field.set_show_line_numbers(True)
        self.field.set_left_margin(10)
        self.field.set_right_margin(10)
        self.field.get_buffer().set_text(self.data["value"])

        self.field.set_wrap_mode(Gtk.WrapMode.WORD)
        if event is not None:
            self.field.connect("focus-out-event", event)

        scrolled_window.add(self.field)

        self.pack_start(scrolled_window, True, True, 0)
        self.show_all()
Beispiel #15
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        self.check_values()
        self.create_label()

        self.field = Gtk.Label()
        self.field.set_property("halign", Gtk.Align.START)
        self.field.set_property("margin-left", 20)
        value = "None"
        if (self.data["value"] is not None):
            value = self.data["value"]
        self.field.set_text(value)
        self.add(self.field)
        self.show_all()
Beispiel #16
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)
        Gtk.HBox.__init__(self, True)

        self.check_values()

        self.set_name(self.data["name"])
        self.label = Gtk.Label(self.data["label"])
        self.label.set_property("halign", Gtk.Align.START)
        self.add(self.label)

        self.field = Gtk.Entry()
        self.field.set_text(self.data["value"])
        self.field.set_property("max-length", int(self.data["maxlength"]))
        if event is not None:
            self.field.connect("changed", event)
        self.add(self.field)
        self.show_all()
Beispiel #17
0
    def __init__(self, data, event):
        """
        This method is the constructor.
        """
        if not isinstance(data, dict):
            return
        Field.__init__(self, data, event)

        self.check_values()
        self.create_label()

        value = 0

        try:
            value = float(self.data["value"])
        except:
            pass

        adjustment = Gtk.Adjustment(value=value,
                                    lower=float(self.data["lower"]),
                                    upper=float(self.data["upper"]),
                                    step_incr=float(self.data["step"]),
                                    page_incr=float(self.data["page_inc"]),
                                    page_size=float(self.data["page_size"]))

        self.field = Gtk.SpinButton.new(adjustment, float(self.data["step"]),
                                        float(self.data["digits"]))

        self.field.set_value(value)

        if event is not None:
            self.field.connect("changed", event)
            self.field.connect("value-changed", event)
            self.field.connect("change-value", event)
        self.add(self.field)
        self.show_all()