def init_ui(self): BaseDialog.init_ui(self) self.grid.attach(Gtk.Label.new(_('Theme light:')), 0, 0, 1, 1) self.theme_light = Gtk.Switch.new() self.grid.attach(self.theme_light, 1, 0, 1, 1) self.grid.attach(Gtk.Label.new(_('Start actived:')), 0, 1, 1, 1) self.start_actived = Gtk.Switch.new() self.grid.attach(self.start_actived, 1, 1, 1, 1) self.grid.attach(Gtk.Label.new(_('Autostart:')), 0, 2, 1, 1) self.autostart = Gtk.Switch.new() self.grid.attach(self.autostart, 1, 2, 1, 1) self.grid.attach(Gtk.Label.new(_('Colors')), 0, 3, 2, 1) self.grid.attach(Gtk.Label.new(_('Distance')), 0, 4, 1, 1) color = Gdk.RGBA() color.parse('#445c3c') self.distance_color = Gtk.ColorButton() self.grid.attach(self.distance_color, 1, 4, 1, 1) self.grid.attach(Gtk.Label.new(_('Clics')), 0, 5, 1, 1) color.parse('#445c3c') self.clics_color = Gtk.ColorButton.new_with_rgba(color) self.grid.attach(self.clics_color, 1, 5, 1, 1) self.grid.attach(Gtk.Label.new(_('Keys')), 0, 6, 1, 1) color.parse('#445c3c') self.keys_color = Gtk.ColorButton() self.keys_color.set_rgba(color) self.grid.attach(self.keys_color, 1, 6, 1, 1)
def __init__(self, name, properties): SizedObjectForm.__init__(self, name, properties) self.canvas = properties.canvas self.add_section(_("Color")) entry = Options() entry.add_option(_("Color")) entry.add_option(_("Gradient")) entry.add_option(_("Pattern")) #entry = Gtk.HButtonBox() #entry.set_layout(Gtk.ButtonBoxStyle.SPREAD) #entry.set_spacing(10) #entry.add(Gtk.ToggleButton(_("Color"))) #entry.add(Gtk.ToggleButton(_("Gradient"))) #entry.add(Gtk.ToggleButton(_("Pattern"))) self.add_entry(_("Fill style"), entry, "fill_style") entry = Gtk.ColorButton() entry.set_use_alpha(True) entry.connect("color-set", self.set_stroke_color) self.add_entry(_("Stroke"), entry, "foreground") entry = Gtk.ColorButton() entry.set_use_alpha(True) entry.connect("color-set", self.set_fill_color) self.add_entry(_("Fill"), entry, "background") entry = LinearGradientEditor() entry.connect("update", self.set_gradient) self.add_entry(_("Gradient"), entry, "gradient")
def PluginPreferences(cls, window): vb = Gtk.VBox(spacing=6) vb.set_border_width(6) t = Gtk.Table(n_rows=5, n_columns=2, homogeneous=True) t.set_col_spacings(6) t.set_row_spacings(3) clr_section = Gtk.Label() clr_section.set_markup("<b>" + _("Colors") + "</b>") t.attach(clr_section, 0, 2, 0, 1) l = Gtk.Label(label=_("Text:")) l.set_alignment(xalign=1.0, yalign=0.5) t.attach(l, 0, 1, 1, 2, xoptions=Gtk.AttachOptions.FILL) c = Gdk.RGBA() c.parse(cls._get_text_color()) b = Gtk.ColorButton(rgba=c) t.attach(b, 1, 2, 1, 2) b.connect('color-set', cls._set_text_color) l = Gtk.Label(label=_("Background:")) l.set_alignment(xalign=1.0, yalign=0.5) t.attach(l, 0, 1, 2, 3, xoptions=Gtk.AttachOptions.FILL) c = Gdk.RGBA() c.parse(cls._get_background_color()) b = Gtk.ColorButton(rgba=c) t.attach(b, 1, 2, 2, 3) b.connect('color-set', cls._set_background_color) l = Gtk.Label(label=_("Highlight")) l.set_alignment(xalign=1.0, yalign=0.5) t.attach(l, 0, 1, 3, 4, xoptions=Gtk.AttachOptions.FILL) c = Gdk.RGBA() c.parse(cls._get_highlight_color()) b = Gtk.ColorButton(rgba=c) t.attach(b, 1, 2, 3, 4) b.connect('color-set', cls._set_highlight_color) font_section = Gtk.Label() font_section.set_markup("<b>" + _("Font") + "</b>") t.attach(font_section, 0, 2, 4, 5) l = Gtk.Label(label=_("Size (px):")) l.set_alignment(xalign=1.0, yalign=0.5) t.attach(l, 0, 1, 5, 6, xoptions=Gtk.AttachOptions.FILL) a = Gtk.Adjustment.new(cls._get_font_size(), 10, 72, 2, 3, 0) s = Gtk.SpinButton(adjustment=a) s.set_numeric(True) s.set_text(str(cls._get_font_size())) t.attach(s, 1, 2, 5, 6) s.connect('value-changed', cls._set_font_size) vb.pack_start(t, False, False, 0) return vb
def __init__(self): Gtk.Window.__init__(self, title=NAME) self.set_border_width(10) vBoxMain = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.add(vBoxMain) ###STACK self.stack = Gtk.Stack() self.stack.set_transition_type( Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.stack.set_transition_duration(1000) ###STATIC TAB vBoxStatic = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.staticColorButton = Gtk.ColorButton() vBoxStatic.add(self.staticColorButton) self.stack.add_titled(vBoxStatic, "static", "Static") ###CYCLE TAB vBoxCycle = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.adjCycle = Gtk.Adjustment(5000, 500, 65535, 100, 100, 0) self.sbCycle = Gtk.SpinButton() self.sbCycle.set_adjustment(self.adjCycle) vBoxCycle.add(self.sbCycle) self.stack.add_titled(vBoxCycle, "cycle", "Cycle") ###BREATHE TAB vBoxBreathe = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.breatheColorButton = Gtk.ColorButton() vBoxBreathe.add(self.breatheColorButton) self.adjBCycle = Gtk.Adjustment(5000, 500, 65535, 100, 100, 0) self.sbBCycle = Gtk.SpinButton() self.sbBCycle.set_adjustment(self.adjBCycle) vBoxBreathe.add(self.sbBCycle) self.stack.add_titled(vBoxBreathe, "breathe", "Breathe") ###SEGMENTS TAB hBoxSegments = Gtk.Box(spacing=5) self.segmentColorBtns = [Gtk.ColorButton() for _ in range(5)] for btn in self.segmentColorBtns: hBoxSegments.pack_start(btn, True, True, 0) self.stack.add_titled(hBoxSegments, "segments", "Segments") ###STACK self.stack_switcher = Gtk.StackSwitcher() self.stack_switcher.set_stack(self.stack) vBoxMain.pack_start(self.stack_switcher, True, True, 0) vBoxMain.pack_start(self.stack, True, True, 0) ###OK BUTTON btnOk = Gtk.Button.new_with_label("OK") btnOk.connect("clicked", self.on_ok_button_clicked) vBoxMain.pack_start(btnOk, True, True, 0)
def __init__(self, app): Gtk.Window.__init__(self, title="ColorButton", application=app) self.set_default_size(150, 50) self.set_border_width(10) # a colorbutton (which opens a dialogue window in # which we choose a color) self.button = Gtk.ColorButton() # with a default color (blue, in this instance) color = Gdk.RGBA() color.red = 0.0 color.green = 0.0 color.blue = 1.0 color.alpha = 0.5 self.button.set_rgba(color) # choosing a color in the dialogue window emits a signal self.button.connect("color-set", self.on_color_chosen) # a label label = Gtk.Label() label.set_text("Click to choose a color") # a grid to attach button and label grid = Gtk.Grid() grid.attach(self.button, 0, 0, 2, 1) grid.attach(label, 0, 1, 2, 1) self.add(grid)
def create_theme_palette(self, data): theme_pallete_grid = Gtk.VBox() flowbox = Gtk.FlowBox() flowbox.set_valign(Gtk.Align.START) flowbox.set_min_children_per_line(4) flowbox.set_max_children_per_line(4) flowbox.set_selection_mode(Gtk.SelectionMode.NONE) area = Gtk.DrawingArea() area.set_size_request(170, 40) if data.has_key('background_color'): theme_pallete_grid.modify_bg(0, color = Gdk.color_parse(data['background_color'])) for color in data['palette'].split(":")[0:8]: btn = Gtk.ColorButton() btn.set_color(color = Gdk.color_parse(color)) flowbox.add(btn) theme_pallete_grid.pack_start (area, True, True,0) theme_pallete_grid.pack_start (flowbox, True,True,0) return theme_pallete_grid
def _create_dialog(self): """ Create a dialog box to enter a new tag. """ # pylint: disable-msg=E1101 if self.tag.get_handle(): title = _('Tag: %s') % self.tag.get_name() else: title = _('New Tag') top = Gtk.Dialog(_("%(title)s - Gramps") % {'title': title}) top.set_default_size(300, 100) top.set_modal(True) top.set_transient_for(self.parent_window) top.vbox.set_spacing(5) hbox = Gtk.Box() top.vbox.pack_start(hbox, False, False, 10) label = Gtk.Label(label=_('Tag Name:')) self.entry = Gtk.Entry() self.entry.set_text(self.tag.get_name()) self.color = Gtk.ColorButton() rgba = Gdk.RGBA() rgba.parse(self.tag.get_color()) self.color.set_rgba(rgba) title = _("%(title)s - Gramps") % {'title': _("Pick a Color")} self.color.set_title(title) hbox.pack_start(label, False, False, 5) hbox.pack_start(self.entry, True, True, 5) hbox.pack_start(self.color, False, False, 5) top.add_button(_('_OK'), Gtk.ResponseType.OK) top.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL) top.show_all() return top
def __init__(self, name): self.label = Gtk.Label("%s Chart Color: " % name) self.picker = Gtk.ColorButton() self.actor = Gtk.HBox() self.actor.add(self.label) self.actor.add(self.picker) self.picker.set_use_alpha(True)
def _create_color_buttons(self): self.primary_color_button = Gtk.ColorButton() self.primary_color_button.set_use_alpha(True) self.primary_color_button.connect("color-set", self._primary_color_changed) self.attach(self.primary_color_button, 0, 8, 1, 1) self.set_primary_color((0, 0, 0, 1)) self.secondary_color_button = Gtk.ColorButton() self.secondary_color_button.set_use_alpha(True) self.secondary_color_button.connect("color-set", self._secondary_color_changed) self.attach(self.secondary_color_button, 1, 8, 1, 1) self.set_secondary_color((1, 1, 1, 1))
def _create_dialog(self): """ Create a dialog box to enter a new tag. """ # pylint: disable-msg=E1101 top = Gtk.Dialog(parent=self.parent_window) top.vbox.set_spacing(5) hbox = Gtk.Box() top.vbox.pack_start(hbox, False, False, 10) label = Gtk.Label(label=_('Tag Name:')) self.entry = Gtk.Entry() self.entry.set_text(self.tag.get_name()) self.color = Gtk.ColorButton() rgba = Gdk.RGBA() rgba.parse(self.tag.get_color()) self.color.set_rgba(rgba) title = _("%(title)s - Gramps") % {'title': _("Pick a Color")} self.color.set_title(title) hbox.pack_start(label, False, False, 5) hbox.pack_start(self.entry, True, True, 5) hbox.pack_start(self.color, False, False, 5) top.add_button(_('_Help'), Gtk.ResponseType.HELP) top.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL) top.add_button(_('_OK'), Gtk.ResponseType.OK) return top
def __init__(self, name): self.label = Gtk.Label(_('{} Chart Color: '.format(name))) self.picker = Gtk.ColorButton() self.actor = Gtk.HBox() self.actor.add(self.label) self.actor.add(self.picker) self.picker.set_use_alpha(True)
def __init__(self): GObject.GObject.__init__(self) from .canvas import Canvas self.canvas = Canvas() table = Gtk.Table(4, 4, False) self.pack_start(table, True, True, 0) self.combobox = Gtk.ComboBoxText() table.attach(self.combobox, 1, 2, 0, 1, Gtk.AttachOptions.FILL, 0) gradient = Gradient() self.gl = GradientLine(self.moving_callback, self.color_callback, gradient) table.attach(self.gl, 1, 2, 1, 2, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0) new_color = Gtk.Button() image = Gtk.Image() image.set_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU) new_color.add(image) table.attach(new_color, 2, 3, 0, 1, 0, 0, 0) button = Gtk.Button() image = Gtk.Image() image.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.MENU) button.add(image) button.connect("clicked", self.forward) table.attach(button, 2, 3, 1, 2, 0, Gtk.AttachOptions.FILL, 0) button = Gtk.Button() image = Gtk.Image() image.set_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.MENU) button.add(image) button.connect("clicked", self.back) table.attach(button, 0, 1, 1, 2, 0, Gtk.AttachOptions.FILL, 0) hbox = Gtk.HBox() label = Gtk.Label(label=_("Color:")) hbox.pack_start(label, True, True, 0) self.color_button = Gtk.ColorButton() self.color_button.set_use_alpha(True) self.color_button.connect("color-set", self.set_gradient_color) hbox.pack_start(self.color_button, True, True, 0) label = Gtk.Label(label=_("Position:")) hbox.pack_start(label, True, True, 0) self.sel_position = Gtk.SpinButton(climb_rate=0.00001, digits=5) self.sel_position.set_range(0.0, 1.0) self.sel_position.set_wrap(True) self.sel_position.set_increments(0.00001, 0.1) self.sel_position.connect("value-changed", self.move_color) hbox.pack_start(self.sel_position, True, True, 0) table.attach(hbox, 1, 2, 2, 3, Gtk.AttachOptions.FILL, 0, 0) self.install_signal("update") self.show_all()
def __init__(self, layer): super(Toolbox, self).__init__(label="Herramientas", margin=6) self.layer = layer self.layer.connect("button-press-event", self.layer_click) self.figure = None vbox = Gtk.VBox(margin=6) self.add(vbox) lbl = Gtk.Label(label="Ancho trazo:", xalign=0) vbox.pack_start(lbl, False, False, 0) self.spbtn = Gtk.SpinButton.new_with_range(0, 20, 0.1) self.spbtn.set_value(1.0) vbox.pack_start(self.spbtn, False, False, 0) lbl = Gtk.Label(label="Color trazo:", xalign=0) vbox.pack_start(lbl, False, False, 0) self.stroke_colbtn = Gtk.ColorButton(use_alpha=True, rgba=DEFAULT_STROKE_COLOR) vbox.pack_start(self.stroke_colbtn, False, False, 0) lbl = Gtk.Label(label="Color relleno:", xalign=0) vbox.pack_start(lbl, False, False, 0) self.fill_colbtn = Gtk.ColorButton(use_alpha=True, rgba=DEFAULT_FILL_COLOR) vbox.pack_start(self.fill_colbtn, False, False, 0) lbl = Gtk.Label(label="Figuras:", xalign=0) vbox.pack_start(lbl, False, False, 0) for file, tooltip, figure in ( ("rectangle.svg", "Rectángulo", Rectangle), ("ellipse.svg", "Elipse", Ellipse), ("line.svg", "Arco Ellíptico", ArcoEllipse), ("qbezier.svg", "Curva con Bezier", Curve), ): try: pxb = GdkPixbuf.Pixbuf.new_from_file_at_scale( file, -1, 32, True) img = Gtk.Image.new_from_pixbuf(pxb) except: img = Gtk.Image.new_from_file("invalid") btn = Gtk.Button(image=img, tooltip_text=tooltip, relief=Gtk.ReliefStyle.NONE) btn.connect("clicked", self.figure_selected, figure) vbox.pack_start(btn, False, False, 0)
def init_ui(self): BaseDialog.init_ui(self) self.grid.attach(Gtk.Label.new(_('Theme light:')), 0, 0, 1, 1) self.theme_light = Gtk.Switch.new() self.grid.attach(self.theme_light, 1, 0, 1, 1) self.grid.attach(Gtk.Label.new(_('Start actived:')), 0, 1, 1, 1) self.start_actived = Gtk.Switch.new() self.grid.attach(self.start_actived, 1, 1, 1, 1) self.grid.attach(Gtk.Label.new(_('Autostart:')), 0, 2, 1, 1) self.autostart = Gtk.Switch.new() self.grid.attach(self.autostart, 1, 2, 1, 1) self.grid.attach(Gtk.Separator(), 0, 3, 2, 1) label = Gtk.Label(_('Units')) label.set_alignment(0, 0.5) self.grid.attach(label, 0, 4, 1, 1) units_store = Gtk.ListStore(str, str) units_store.append([_('meters'), 'meters']) units_store.append([_('feets'), 'feets']) self.units = Gtk.ComboBox.new() self.units.set_model(units_store) cell1 = Gtk.CellRendererText() self.units.pack_start(cell1, True) self.units.add_attribute(cell1, 'text', 0) self.grid.attach(self.units, 1, 4, 1, 1) self.grid.attach(Gtk.Separator(), 0, 5, 2, 1) self.grid.attach(Gtk.Label.new(_('Colors')), 0, 6, 2, 1) self.grid.attach(Gtk.Label.new(_('Distance')), 0, 7, 1, 1) color = Gdk.RGBA() color.parse('#445c3c') self.distance_color = Gtk.ColorButton() self.grid.attach(self.distance_color, 1, 7, 1, 1) self.grid.attach(Gtk.Label.new(_('Clicks')), 0, 8, 1, 1) color.parse('#445c3c') self.clics_color = Gtk.ColorButton.new_with_rgba(color) self.grid.attach(self.clics_color, 1, 8, 1, 1) self.grid.attach(Gtk.Label.new(_('Keys')), 0, 9, 1, 1) color.parse('#445c3c') self.keys_color = Gtk.ColorButton() self.keys_color.set_rgba(color) self.grid.attach(self.keys_color, 1, 9, 1, 1)
def __init__(self): Gtk.Window.__init__(self) self.set_title('ColorButton') self.set_default_size(200, -1) self.connect('destroy', Gtk.main_quit) colorbutton = Gtk.ColorButton() colorbutton.connect('color-set', self.on_color_set) self.add(colorbutton)
def _init_color(self, color): color_button = Gtk.ColorButton() if color is not None: rgba = Gdk.RGBA() rgba.parse(color) color_button.set_rgba(rgba) color_button.set_halign(Gtk.Align.END) color_button.connect('color-set', self._on_color_set) self._box.add(color_button)
def _Init(self): StockSetting._Init(self) self.Button = Gtk.ColorButton() self.Button.set_size_request(100, -1) self.Button.set_use_alpha(True) self.Button.connect('color-set', self.Changed) self.Widget = Gtk.Alignment(xalign=1, yalign=0.5) self.Widget.add(self.Button) self.Box.pack_start(self.Widget, True, True, 0)
def _add_colour(self): if self.custom_colours.x!=2: self.custom_colours.buttons.append(Gtk.ColorButton()) self.custom_colours.attach(self.custom_colours.buttons[-1],self.custom_colours.x,self.custom_colours.y,1,1) self.custom_colours.buttons[-1].set_rgba(Gdk.RGBA(1,1,1,1)) self.custom_colours.buttons[-1].show() self.custom_colours.y+=1 if self.custom_colours.y==4: self.custom_colours.y=0 self.custom_colours.x+=1
def build_colors_widget(): t = Gtk.Table(n_rows=2, n_columns=2) t.set_col_spacings(6) t.set_row_spacings(3) b = Gtk.ColorButton(rgba=Gdk.RGBA( *map(__floattocol, self.Conf.text))) l = ConfigLabel(_("_Text:"), b) t.attach(l, 0, 1, 0, 1, xoptions=Gtk.AttachOptions.FILL) t.attach(b, 1, 2, 0, 1) b.connect('color-set', set_text) b = Gtk.ColorButton(color=Gdk.Color( *map(__floattocol, self.Conf.fill[0:3]))) b.set_use_alpha(True) b.set_alpha(__floattocol(self.Conf.fill[3])) b.connect('color-set', set_fill) l = ConfigLabel(_("_Fill:"), b) t.attach(l, 0, 1, 1, 2, xoptions=Gtk.AttachOptions.FILL) t.attach(b, 1, 2, 1, 2) return t
def add_colorbtn(self, label_text, key): color_btn = Gtk.ColorButton(use_alpha=True) background_rgba = self._settings.get_strv(key) r = float(background_rgba[0]) g = float(background_rgba[1]) b = float(background_rgba[2]) a = float(background_rgba[3]) color = Gdk.RGBA(red=r, green=g, blue=b, alpha=a) color_btn.set_rgba(color) color_btn.connect('color-set', self.on_colorbtn_changed, key) self.add_row(label_text, color_btn)
def __init__(self, text): Gtk.ListBoxRow.__init__(self) # инициализируем родителя self.checkButton = Gtk.CheckButton() # входящий в строку checkButton self.checkButton.set_label( '') # checkButton специально без текста, если текст помещать в нее # она захватывает большую часть пространства self.checkButton.set_property("margin_left", 5) # ставим отступы со всех сторон self.checkButton.set_property("margin_top", 2) self.checkButton.set_property("margin_bottom", 2) self.label = Gtk.Label() self.label.set_text(text) self.label.set_property("margin_right", 5) self.label.set_property("margin_top", 2) self.label.set_property("margin_bottom", 2) # эти строки - плод страданий self.label.modify_font( Pango.FontDescription("Tahoma 10")) # размер и стиль шрифта # self.label.set_property("max_width_chars", 25) # максимальная ширина метки в символах self.label.set_property( "ellipsize", Pango.EllipsizeMode.END) # метка будет сжиматься в конце self.label.set_property("xalign", 0) # метка выравнивается по левую сторону self.colorButton = Gtk.ColorButton() self.colorButton.set_property("margin_top", 2) self.colorButton.set_property("margin_bottom", 2) self.colorButton.connect( "color-set", self.onColorChosen) # вызывается ф-ия, при смене цвета image = Gtk.Image( stock=Gtk.STOCK_REMOVE) # картинка на кнопку с удалением строки self.deleteRowButton = Gtk.Button( label=None, image=image) # кнопка удаления строки self.deleteRowButton.set_property("margin_left", 5) # ставим отступы со всех сторон self.deleteRowButton.set_property("margin_right", 5) self.deleteRowButton.set_property("margin_top", 2) self.deleteRowButton.set_property("margin_bottom", 2) self.deleteRowButton.connect("clicked", self.deleteRowButton_Click) box = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL) # коробка для внутреностей box.pack_start(self.checkButton, False, False, 0) # упаковываем checkbutton и кнопку удаления box.pack_start(self.label, False, False, 0) box.pack_end(self.deleteRowButton, False, False, 0) # пакуем с конца box.pack_end(self.colorButton, False, False, 0) # упаковываем цветную метку self.add(box) # добавляем коробку в строку
def new_tag(self, *p): """Enter a new tag. """ d = Gtk.Dialog(title=_("New tag name"), parent=self.controller.gui.gui.win, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK, )) l = Gtk.Label(label=_("Enter a new tag name and select its color.")) d.vbox.pack_start(l, False, True, 0) hb = Gtk.HBox() hb.pack_start(Gtk.Label(_("Name")), False, False, 0) tagname = Gtk.Entry() hb.pack_start(tagname, False, True, 0) d.vbox.pack_start(hb, False, True, 0) hb = Gtk.HBox() hb.pack_start(Gtk.Label(_("Color")), False, False, 0) colorbutton = Gtk.ColorButton() colorbutton.set_color(Gdk.color_parse('red')) hb.pack_start(colorbutton, False, True, 0) d.vbox.pack_start(hb, False, True, 0) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res = d.run() if res == Gtk.ResponseType.OK: try: tag = tagname.get_text() except ValueError: tag = None color = colorbutton.get_color() else: tag = None d.destroy() if tag and not tag in self.tags: if not re.match(r'^[\w\d_]+$', tag): dialog.message_dialog(_("The tag contains invalid characters"), icon=Gtk.MessageType.ERROR) return True self.tags.append(tag) self.controller.package._tag_colors[tag] = "#%04x%04x%04x" % ( color.red, color.green, color.blue) self.controller.notify('TagUpdate', tag=tag) self.refresh() return True
def _create_control_button(self, label: str, alignment: Gtk.Align = Gtk.Align.CENTER) -> Tuple[Gtk.ColorButton, Gtk.Label]: button = Gtk.ColorButton() label_component = Gtk.Label.new(label) button.set_halign(alignment) button.set_valign(Gtk.Align.CENTER) button.set_size_request(75, 50) button.connect("clicked", self.on_button_clicked) button.connect("color-set", self.on_color_activated, label.lower()) return button, label_component
def __init__(self, config, gui): self.config = config self.gui = gui self.parser = ThemeParser(self.config) self.NO_PARENT = "Select parent" # Fill up GUI self.color_buttons = dict() self.parent_buttons = dict() self.pattern_checks = dict() self.bsignals = dict() self.gui["colors_box"].pack_start(Gtk.Separator(), False, False, 0) # colors list current_pattents = self.config.get_list("Pattern", "colors") for key, value in self.config.colors.items(): box = Gtk.Box(spacing=8) label = Gtk.Label(key) # init row elements self.color_buttons[key] = Gtk.ColorButton() self.parent_buttons[key] = Gtk.Button() self.pattern_checks[key] = Gtk.CheckButton() # set color button self.set_color_button_state(key, value) self.bsignals[key] = self.color_buttons[key].connect( "color_set", self.on_color_changed, key) # set pattern check self.pattern_checks[key].set_active(key in current_pattents) self.pattern_checks[key].connect("toggled", self.on_pattern_check_toggled, key) # set parent button self.parent_buttons[key].set_property("width-request", 300) self.set_parent_button_state(self.config["Colors"][key], key) self.parent_buttons[key].connect("clicked", self.on_parent_color_click, key) # built color settins row box.pack_start(label, False, False, 0) box.pack_end(self.pattern_checks[key], False, False, 0) box.pack_end(self.color_buttons[key], False, False, 0) box.pack_end(self.parent_buttons[key], False, False, 0) self.gui["colors_box"].pack_start(box, False, False, 0) self.gui["colors_box"].pack_start(Gtk.Separator(), False, False, 0) # Mainpage buttnons hanlers self.mhandlers = dict() self.mhandlers['build_button'] = self.rebuild_theme
def __init__(self, *args): GenericSetting.__init__(self, *args) rgba = Gdk.RGBA() rgba.parse(self.setting_value) self.color_button = Gtk.ColorButton() self.color_button.set_rgba(rgba) self.color_button.connect('color-set', self.on_color_set) self.color_button.set_valign(Gtk.Align.CENTER) self.color_button.set_halign(Gtk.Align.END) self.setting_box.pack_end(self.color_button, True, True, 0) self.show_all()
def create_ui(self): vbox = Gtk.VBox() self.vbox.add(vbox) interface_vbox = Gtk.VBox() self.custom_widgets_checkbutton = Gtk.CheckButton('Use custom widgets') self.custom_widgets_checkbutton.set_active( self.app.gui_factory.get_use_custom_widgets()) self.custom_widgets_checkbutton.connect('toggled', self.on_custom_widget_toggled) interface_vbox.pack_start(self.custom_widgets_checkbutton, True, True, 0) self.vumeter_color_checkbutton = Gtk.CheckButton('Use custom vumeter color') self.vumeter_color_checkbutton.set_active( self.app.gui_factory.get_vumeter_color_scheme() == 'solid') self.vumeter_color_checkbutton.connect('toggled', self.on_vumeter_color_change) interface_vbox.pack_start(self.vumeter_color_checkbutton, True, True, 0) hbox = Gtk.HBox() interface_vbox.pack_start(hbox, True, True, 0) self.custom_color_box = hbox self.custom_color_box.set_sensitive( self.vumeter_color_checkbutton.get_active() == True) hbox.pack_start(Gtk.Label('Custom color:'), True, True, 0) self.vumeter_color_picker = Gtk.ColorButton() self.vumeter_color_picker.set_color(Gdk.color_parse( self.app.gui_factory.get_vumeter_color())) self.vumeter_color_picker.connect('color-set', self.on_vumeter_color_change) hbox.pack_start(self.vumeter_color_picker, True, True, 0) vbox.pack_start(self.create_frame('Interface', interface_vbox), True, True, 0) table = Gtk.Table(2, 2, False) table.set_row_spacings(5) table.set_col_spacings(5) table.attach(Gtk.Label(label='Meter scale'), 0, 1, 0, 1) self.meter_scale_combo = self.create_meter_store_and_combo() table.attach(self.meter_scale_combo, 1, 2, 0, 1) table.attach(Gtk.Label(label='Slider scale'), 0, 1, 1, 2) self.slider_scale_combo = self.create_slider_store_and_combo() table.attach(self.slider_scale_combo, 1, 2, 1, 2) vbox.pack_start(self.create_frame('Scales', table), True, True, 0) self.vbox.show_all() self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
def __init__(self, label, schema, key, dep_key=None, size_group=None): super(GSettingsColorChooser, self).__init__(dep_key=dep_key) self.label = Gtk.Label(label) self.content_widget = Gtk.ColorButton() self.pack_start(self.label, False, False, 0) self.pack_end(self.content_widget, False, False, 0) self.settings = self.get_settings(schema) self.settings.bind_with_mapping(key, self.content_widget, "color", Gio.SettingsBindFlags.DEFAULT, Gdk.color_parse, Gdk.Color.to_string) if size_group: self.add_to_size_group(size_group)
def windowFromFile(fileName, gui): """Open a color map window with the color map initialized from .pal file""" templateFile = 'colormap_window_template.ui' try: f = open(fileName) colorMap = f.read().splitlines() if colorMap[0] != 'JASC-PAL': raise Exception('Unknown type file ' + content[0] + '. Expected : JASC-PAL') # 4 first lines are useless colorMap = colorMap[4:] # We remove the last lines that are values '1 0 1' while colorMap[-1] == '1 0 1': colorMap.pop() gui.builder.add_from_file( os.path.dirname(fileName) + '/../ui/' + templateFile) # the vert box containing hori boxes of colorbuttons boxBtn = gui.builder.get_object('boxColorMapBtn') # how many rows of 8 btn do we need to show them all ? btnRows = math.ceil(len(colorMap) / 8) # lets build one horizontal box per row and put the buttons inside for row in range(btnRows): box = Gtk.Box() box.set_visible(True) boxBtn.pack_start(box, True, True, 0) for rgbColorCode in colorMap[row * 8:row * 8 + 7]: RGBAstr = 'rgb(' + ','.join(rgbColorCode.split()) + ')' color = Gdk.RGBA() Gdk.RGBA.parse(color, RGBAstr) btn = Gtk.ColorButton() btn.set_rgba(color) btn.set_visible(True) box.pack_start(btn, True, True, 0) cm_window = gui.builder.get_object('window_color_map') cm_window.set_visible(True) except Exception as e: print(e)
def __init__(self, key, settings_obj, uuid): BaseWidget.__init__(self, key, settings_obj, uuid) super(ColorChooser, self).__init__() self.label = Gtk.Label(self.get_desc()) self.chooser = Gtk.ColorButton() self.chooser.set_use_alpha(True) self.eyedropper = eyedropper.EyeDropper() self.pack_start(self.label, False, False, 2) self.pack_start(self.chooser, False, False, 2) self.pack_start(self.eyedropper, False, False, 2) self.eyedropper.connect("color-picked", self.on_eyedropper_picked) color = Gdk.RGBA() Gdk.RGBA.parse(color, self.get_val()) self.chooser.set_rgba(color) set_tt(self.get_tooltip(), self.label, self.chooser) self.handler = self.chooser.connect("color-set", self.on_my_value_changed)
def __init__(self, label, legacy_string=False, size_group=None, dep_key=None, tooltip=""): super(ColorChooser, self).__init__(dep_key=dep_key) # note: Gdk.Color is deprecated in favor of Gdk.RGBA, but as the hex format is still used # in some places (most notably the desktop background handling in cinnamon-desktop) we # still support it for now by adding the legacy_string argument self.legacy_string = legacy_string self.label = SettingsLabel(label) self.content_widget = Gtk.ColorButton() self.content_widget.set_use_alpha(True) self.pack_start(self.label, False, False, 0) self.pack_end(self.content_widget, False, False, 0) self.set_tooltip_text(tooltip) if size_group: self.add_to_size_group(size_group)