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) self.field.set_property("halign", Gtk.Align.END) if isinstance(self.data["value"], str) \ or isinstance(self.data["value"], bytes): 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()
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()
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() box.set_property("margin-left", 20) self.add(box) 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.parent_window = None self.event = event self.set_value(self.data["value"]) self.format = self.data["format"] 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.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()
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()
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()
class TestField(unittest.TestCase): def setUp(self): Field(None, None) self.field = Field({"label": "test", "value": "False"}, None) self.field = Field({"label": "test", "value": "True"}, None) self.field = Field({}, self.test_value) def test_value(self): self.field.set_value(1) self.field.get_value()
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_property("margin-left", 20) self.field.set_text(self.data["value"]) self.field.set_property("max-length", 1) if event is not None: self.field.connect("changed", 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() 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()
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) 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(2) self.field.set_right_margin(2) 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()
def setUp(self): Field(None, None) self.field = Field({"label": "test", "value": "False"}, None) self.field = Field({"label": "test", "value": "True"}, None) self.field = Field({}, self.test_value)