Python gi.repository.Gdk 模块,RGBA 实例源码

我们从Python开源项目中,提取了以下43个代码示例,用于说明如何使用gi.repository.Gdk.RGBA

项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def parse_rgba(col):
    """
    Parses color specified by #RRGGBBAA string.
    '#' and 'AA' is optional.
    """
    # Because GTK can parse everything but theese :(
    alpha = "FF"
    if not col.startswith("#"):
        col = "#" + col
    if len(col) > 7:
        col, alpha = col[0:7], col[7:]
    rgba = Gdk.RGBA()
    if not rgba.parse(col):
        log.warning("Failed to parse RGBA color: %s", col)
    rgba.alpha = float(int(alpha, 16)) / 255.0
    return rgba
项目:mcg    作者:coderkun    | 项目源码 | 文件源码
def set_fullscreen(self, active):
        if active:
            self._change_tracklist_size(TracklistSize.HIDDEN, False, False)
            self._cover_box.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1))
            GObject.idle_add(self._resize_image)
            # Hide curser
            self._appwindow.get_window().set_cursor(
                Gdk.Cursor.new_from_name(Gdk.Display.get_default(), "none")
            )
        else:
            self._change_tracklist_size(self._tracklist_size, False, False)
            self._cover_box.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0))
            GObject.idle_add(self._resize_image)
            # Reset cursor
            self._appwindow.get_window().set_cursor(
                Gdk.Cursor.new_from_name(Gdk.Display.get_default(), "default")
            )
项目:razerCommander    作者:GabMus    | 项目源码 | 文件源码
def onVirtKeyClick(self, eventbox, eventbtn):
        key = self.rkb.getKey(eventbox.keyx, eventbox.keyy)
        if not key.isGhost:
            if self.pipetteTBtn.get_active():
                color = key.color
                self.customColorPicker.set_rgba(color)
                self.pipetteTBtn.set_active(False)
            elif self.clearTBtn.get_active():
                key.color = Gdk.RGBA(0, 0, 0)
                black_rgba = Gdk.RGBA(0, 0, 0)
                eventbox.override_background_color(
                    Gtk.StateType.NORMAL,
                    black_rgba
                )
            else:
                key.color = self.customColorPicker.get_rgba()
                eventbox.override_background_color(
                    Gtk.StateType.NORMAL,
                    self.customColorPicker.get_rgba()
                )
项目:razerCommander    作者:GabMus    | 项目源码 | 文件源码
def build_keyrow_box(row, colors, signal_handler, prof_index):
    box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
    for key in row.keylist:
        if not key.isGhost:
            k_col = Gdk.RGBA(
                colors[prof_index][0],
                colors[prof_index][1],
                colors[prof_index][2]
            )
        else:
            k_col = Gdk.RGBA(0, 0, 0)
        keybox = build_key_box(
            key,
            k_col,
            signal_handler
        )
        if not key.isGhost:
            prof_index += 1
        box.pack_start(keybox, True, True, 0)
    return {'row': box, 'prof_index': prof_index}
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def cell_in_translation_table_changed(self, text_buffer_object, segment_index):
        if not self.REC_button.get_active():
            self.save_post_editing_changes_button.show()
        elif segment_index != self.last_segment_changed:
            self.save_function()
            self.last_segment_changed = segment_index

        def fix_text(text):
            #in case the user deleted the endline character at the end of the text segment
            new_line_index = text.rfind("\n")
            if new_line_index == -1:
                text += "\n"
            return text
        text = fix_text(text_buffer_object.get_text(text_buffer_object.get_start_iter(),text_buffer_object.get_end_iter(),True) )
        self.tables_content[self.reference_text_lines][segment_index] = text
        self.translation_reference_text_TextViews_modified_flag[segment_index] = text
        self.tables_content[self.reference_text_views][segment_index].override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.7, 249, 249, 240))
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def create_cell(self, text_line_type, text_view_type, row_index, editable):
        cell = Gtk.TextView()
        cell.set_editable(editable)
        cell.set_cursor_visible(editable)
        cellTextBuffer = cell.get_buffer()
        index = row_index + self.tables_content[self.table_index]
        text = textwrap.fill(self.tables_content[text_line_type][index].rstrip('\n'), width=40)
        cellTextBuffer.set_text(text)
        cellTextBuffer.create_tag("#F8CBCB",background="#F8CBCB")
        cellTextBuffer.create_tag("#A6F3A6",background="#A6F3A6")
        self.tables_content[text_view_type][index] = cell
        if self.table_type == "translation_table":
            cellTextBuffer.connect("changed", self.cell_in_translation_table_changed, index)
            cell.connect("button-press-event", self.cell_in_translation_table_is_being_focused, index)
            if index in self.translation_reference_text_TextViews_modified_flag:
                self.tables_content[self.reference_text_views][index].override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.7, 249, 249, 240))

        cell.set_right_margin(20)
        cell.show()
        self.table.attach(
        cell,
        text_line_type + 1,
        text_line_type + 2,
        row_index + 1,
        row_index + 2)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def mix(fgcolor, bgcolor, mix_alpha):
    """ Creates a composite rgb of a foreground rgba and a background rgb.

         - fgcolor: an rgb of floats
         - bgcolor: an rgb of floats
         - mix_alpha: (0.0 - 1.0) the proportion of fgcolor mixed
                      into bgcolor
    """

    src_r, src_g, src_b = fgcolor.red, fgcolor.green, fgcolor.blue
    bg_r, bg_g, bg_b = bgcolor.red, bgcolor.green, bgcolor.blue

    # Source: http://en.wikipedia.org/wiki/Alpha_compositing
    r = ((1 - mix_alpha) * bg_r) + (mix_alpha * src_r)
    g = ((1 - mix_alpha) * bg_g) + (mix_alpha * src_g)
    b = ((1 - mix_alpha) * bg_b) + (mix_alpha * src_b)
    return Gdk.RGBA(red=r, green=g, blue=b)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def mix(fgcolor, bgcolor, mix_alpha):
    """ Creates a composite rgb of a foreground rgba and a background rgb.

         - fgcolor: an rgb of floats
         - bgcolor: an rgb of floats
         - mix_alpha: (0.0 - 1.0) the proportion of fgcolor mixed
                      into bgcolor
    """

    src_r, src_g, src_b = fgcolor.red, fgcolor.green, fgcolor.blue
    bg_r, bg_g, bg_b = bgcolor.red, bgcolor.green, bgcolor.blue

    # Source: http://en.wikipedia.org/wiki/Alpha_compositing
    r = ((1 - mix_alpha) * bg_r) + (mix_alpha * src_r)
    g = ((1 - mix_alpha) * bg_g) + (mix_alpha * src_g)
    b = ((1 - mix_alpha) * bg_b) + (mix_alpha * src_b)
    return Gdk.RGBA(red=r, green=g, blue=b)
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def parse_goglib_colors(self):
        self.goglib_include_rgba = Gdk.RGBA()
        self.goglib_include_rgba.parse(self.goglib_include_color)
        self.goglib_exclude_rgba = Gdk.RGBA()
        self.goglib_exclude_rgba.parse(self.goglib_exclude_color)
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def parse_mylib_colors(self):
        self.mylib_include_rgba = Gdk.RGBA()
        self.mylib_include_rgba.parse(self.mylib_include_color)
        self.mylib_exclude_rgba = Gdk.RGBA()
        self.mylib_exclude_rgba.parse(self.mylib_exclude_color)
项目:aniwall    作者:worron    | 项目源码 | 文件源码
def hex_from_rgba(rgba):
    """Translate color from Gdk.RGBA to html hex format"""
    return "#%02X%02X%02X" % tuple([int(getattr(rgba, name) * 255) for name in ("red", "green", "blue")])
项目:aniwall    作者:worron    | 项目源码 | 文件源码
def rgba_from_hex(hex_):
    """Translate color from html hex to Gdk.RGBA"""
    color = Gdk.RGBA()
    color.parse(hex_)
    return color
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def set_date(self):
        self.headerbar.set_subtitle(self.adate.strftime('%B - %Y'))
        fdom = first_day_of_month(self.adate)
        adate = self.adate.replace(day=1)
        for row in range(1, 7):
            wd = adate + datetime.timedelta(days=7 * (row - 1))
            self.week_days[row].set_text(str(wd.isocalendar()[1]))
        max = {'position': -1, 'value': 0}
        med = {'position': -1, 'value': 1}
        min = {'position': -1, 'value': 1}
        for contador in range(0, 42):
            if contador < fdom:
                tadate = adate - datetime.timedelta(days=(fdom - contador))
            else:
                tadate = adate + datetime.timedelta(days=(contador - fdom))
            self.days[contador].set_date(tadate)
            if tadate.month != adate.month:
                self.days[contador].override_background_color(
                    Gtk.StateFlags.NORMAL, Gdk.RGBA(.5, .5, .5, 1))
            elif tadate.date() == datetime.datetime.today().date():
                self.days[contador].override_background_color(
                    Gtk.StateFlags.NORMAL, Gdk.RGBA(1.0, 0.0, 0.0, 1))
            else:
                self.days[contador].override_background_color(
                    Gtk.StateFlags.NORMAL, Gdk.RGBA(1., 1., 1., 1))
            if tadate.month == adate.month:
                if self.days[contador].get_position() >= max['value']:
                    max['position'] = contador
                    max['value'] = self.days[contador].get_position()
                if self.days[contador].get_position() <= min['value']:
                    min['position'] = contador
                    min['value'] = self.days[contador].get_position()
                if abs(float(self.days[contador].get_position()) - .5) <=\
                        (med['value']):
                    med['position'] = contador
                    med['value'] = abs(float(
                        self.days[contador].get_position()) - 0.5)
        self.days[med['position']].override_background_color(
            Gtk.StateFlags.NORMAL, Gdk.RGBA(0.0, 0.5, 0.0, 1))
        self.days[min['position']].override_background_color(
            Gtk.StateFlags.NORMAL, Gdk.RGBA(0.5, 0.0, 0.5, 1))
项目:nvim-pygtk3    作者:rliang    | 项目源码 | 文件源码
def update_color(self, bg_color: str, is_dark: bool):
        """Updates the widget's background color and theme.

        :bg_color: string representing the color, or 'None'.
        :is_dark: whether the background is dark, see `:h background`.

        """
        self.get_settings().props.gtk_application_prefer_dark_theme = is_dark
        if bg_color != 'None':
            rgba = Gdk.RGBA()
            rgba.parse(bg_color)
            self.set_color_background(rgba)
        else:
            GLib.idle_add(self.reset_color)
项目:mcg    作者:coderkun    | 项目源码 | 文件源码
def __init__(self, builder):
        GObject.GObject.__init__(self)

        self._current_album = None
        self._cover_pixbuf = None
        self._timer = None
        self._properties = {}
        self._tracklist_size = TracklistSize.LARGE
        self._icon_theme = Gtk.IconTheme.get_default()

        # Widgets
        self._appwindow = builder.get_object('appwindow')
        self._panel = builder.get_object('cover-panel')
        self._toolbar = builder.get_object('cover-toolbar')
        # Toolbar menu
        self._toolbar_tracklist = builder.get_object('cover-toolbar-tracklist')
        self._toolbar_tracklist_buttons = {
            TracklistSize.LARGE: builder.get_object('cover-toolbar-tracklist-large'),
            TracklistSize.SMALL: builder.get_object('cover-toolbar-tracklist-small'),
            TracklistSize.HIDDEN: builder.get_object('cover-toolbar-tracklist-hidden')
        }
        # Cover
        self._cover_stack = builder.get_object('cover-stack')
        self._cover_spinner = builder.get_object('cover-spinner')
        self._cover_scroll = builder.get_object('cover-scroll')
        self._cover_box = builder.get_object('cover-box')
        self._cover_image = builder.get_object('cover-image')
        self._cover_stack.set_visible_child(self._cover_scroll)
        self._cover_pixbuf = self._get_default_image()
        # Album Infos
        self._info_revealer = builder.get_object('cover-info-revealer')
        self._info_box = builder.get_object('cover-info-box')
        self._album_title_label = builder.get_object('cover-album')
        self._album_date_label = builder.get_object('cover-date')
        self._album_artist_label = builder.get_object('cover-artist')
        # Songs
        self._songs_scale = builder.get_object('cover-songs')
        self._songs_scale.override_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1))

        # Initial actions
        GObject.idle_add(self._enable_tracklist)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def load_color_schema():
    if not os.path.exists(COLOR_SCHEMA):
        return []
    with open(COLOR_SCHEMA) as fh:
        color_list = json.load(fh)

    schema = []
    for color in color_list:
        rgba = Gdk.RGBA()
        rgba.red = int(color[:2], base=16) / 255
        rgba.green = int(color[2:4], base=16) / 255
        rgba.blue = int(color[4:6], base=16) / 255
        rgba.alpha = int(color[6:], base=16) / 255
        schema.append(rgba)
    return schema
项目:luminance    作者:craigcabrey    | 项目源码 | 文件源码
def hsv_to_gdk_rgb(hue, sat, bri):
    rgb = colorsys.hsv_to_rgb(
        hue / 65535,
        sat / 255,
        bri / 255
    )

    return Gdk.RGBA(red=rgb[0], green=rgb[1], blue=rgb[2])
项目:XFWM_theme_creator    作者:Sjc1000    | 项目源码 | 文件源码
def __init__(self):
        Gtk.ColorButton.__init__(self)
        self.set_rgba(Gdk.RGBA(0, 0, 0, 1))
        self.connect('color-set', self.color_set)
项目:XFWM_theme_creator    作者:Sjc1000    | 项目源码 | 文件源码
def __init__(self):
        Gtk.ColorButton.__init__(self)
        self.set_rgba(Gdk.RGBA(1, 1, 1, 1))
        self.connect('color-set', self.color_set)
项目:cavalcade    作者:worron    | 项目源码 | 文件源码
def color_setup(self, conn, flag):
        """Read data from resent calculation and transform it to rgba color"""
        if flag == GLib.IO_IN:
            color_values = conn.recv()
            rgba = Gdk.RGBA(*color_values, self.config["color"]["autofg"].alpha)
            self.emit("ac-update", rgba)
            return True
        else:
            logger.error("Autocolor multiprocessing error: connection was unexpectedy terminated")
            self.watcher = None
项目:cavalcade    作者:worron    | 项目源码 | 文件源码
def _set_bgpaint(self, value):
        """Use solid color or transparent background"""
        self.config["window"]["bgpaint"] = value
        rgba = self.config["color"]["bg"] if value else Gdk.RGBA(0, 0, 0, 0)
        self.set_bg_rgba(rgba)
项目:cavalcade    作者:worron    | 项目源码 | 文件源码
def str_to_rgba(hex_):
    """Translate color from hex string to Gdk.RGBA"""
    purehex = hex_.lstrip("#")
    nums = [int(purehex[i:i + 2], 16) / 255.0 for i in range(0, 7, 2)]
    return Gdk.RGBA(*nums)
项目:cavalcade    作者:worron    | 项目源码 | 文件源码
def rgba_to_str(rgba):
    """Translate color from Gdk.RGBA to hex format"""
    return "#%02X%02X%02X%02X" % tuple(int(getattr(rgba, name) * 255) for name in ("red", "green", "blue", "alpha"))
项目:cavalcade    作者:worron    | 项目源码 | 文件源码
def __init__(self, name, pattern={}):
        self.name = name
        self.pattern = pattern
        self.is_fallback = False

        # read functions
        self.reader = {
            int: lambda section, option: self.parser.getint(section, option),
            bool: lambda section, option: self.parser.getboolean(section, option),
            str: lambda section, option: self.parser.get(section, option),
            float: lambda section, option: self.parser.getfloat(section, option),
            "ilist": lambda section, option: [int(v.strip()) for v in self.parser.get(section, option).split(";")],
            "hint": lambda section, option: getattr(Gdk.WindowTypeHint, self.parser.get(section, option)),
            Gdk.RGBA: lambda section, option: str_to_rgba(self.parser.get(section, option)),
        }

        # write functions
        self.writer = {
            int: lambda value: str(value),
            bool: lambda value: str(int(value)),
            str: lambda value: value,
            float: lambda value: "{:.2f}".format(value),
            "ilist": lambda value: ";".join(str(i) for i in value),
            "hint": lambda value: value.value_nick.upper(),
            Gdk.RGBA: lambda value: rgba_to_str(value),
        }

        # init
        self._init_config_file()
        self._load_config_file()
项目:paperwork-backend    作者:openpaperwork    | 项目源码 | 文件源码
def _get_color(self):
        color = Gdk.RGBA()
        color.parse(self._color)
        return color
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def hex_from_rgba(rgba):
    """Translate color from Gdk.RGBA to html hex format"""
    return "#%02X%02X%02X" % tuple([int(getattr(rgba, name) * 255) for name in ("red", "green", "blue")])
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def build_data_stores(self):
        """Build stores for GUI dataviews"""
        self.store = dict()

        # custom icons
        self.ied = {'Name': 0, 'State': 1}
        self.store['custom_icons'] = Gtk.ListStore(str, bool)
        self.store['custom_icons'].append(["Simple Icon Group", False])

        renderer_toggle = Gtk.CellRendererToggle()
        renderer_toggle.connect("toggled", self.on_custom_icon_toggled)

        self.gui['custom_icons_treeview'].append_column(Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0))
        self.gui['custom_icons_treeview'].append_column(Gtk.TreeViewColumn("State", renderer_toggle, active=1))
        self.gui['custom_icons_treeview'].set_model(self.store['custom_icons'])

        # color list
        self.ced = {'Color': 0, 'Alpha': 1, 'Offset': 2, 'RGBA': 3}
        colorstore_visible_keys = [k for k in self.ced.keys() if k != 'RGBA']

        self.store['colorlist'] = Gtk.ListStore(str, float, int, str)
        for key in sorted(colorstore_visible_keys, key=lambda k: self.ced[k]):
            self.gui['colorlist_treeview'].append_column(
                Gtk.TreeViewColumn(key, Gtk.CellRendererText(), text=self.ced[key])
            )
        self.gui['colorlist_treeview'].set_model(self.store['colorlist'])

        # gradient direction
        self.ded = {'Coord': 0, 'Value': 1}
        self.store['direction'] = Gtk.ListStore(str, int)
        self.gui['renderer_spin'] = Gtk.CellRendererSpin(editable=True, adjustment=Gtk.Adjustment(0, 0, 100, 5, 0, 0))
        self.signals['direction_edited'] = self.gui['renderer_spin'].connect("edited", self.on_direction_edited)

        self.gui['direction_treeview'].append_column(Gtk.TreeViewColumn("Coord", Gtk.CellRendererText(), text=0))
        self.gui['direction_treeview'].append_column(Gtk.TreeViewColumn("Value", self.gui['renderer_spin'], text=1))
        self.gui['direction_treeview'].set_model(self.store['direction'])
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def on_color_selection_changed(self, selection):
        model, sel = selection.get_selected()

        if sel is not None:
            self.color_selected = sel
            rgba = Gdk.RGBA()
            rgba.parse(model[sel][self.ced['RGBA']])
            rgba.alpha = model[sel][self.ced['Alpha']]
            self.gui['color_selector'].set_current_rgba(rgba)

            offset = model[sel][self.ced['Offset']]
            self.gui['offset_scale'].set_value(offset)
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def on_color_change(self, *args):
        rgba = self.gui['color_selector'].get_current_rgba()
        self.store['colorlist'].set_value(self.color_selected, self.ced['Color'], hex_from_rgba(rgba))
        self.store['colorlist'].set_value(self.color_selected, self.ced['Alpha'], rgba.alpha)
        self.store['colorlist'].set_value(self.color_selected, self.ced['RGBA'], rgba.to_string())
        self.refresh()
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def gui_settler_color(self, button, color, alpha=None):
        """GUI setup helper - color"""
        rgba = Gdk.RGBA()
        rgba.parse(self.param[color].match())
        if alpha is not None:
            rgba.alpha = float(self.param[alpha].match())
        self.gui[button].set_rgba(rgba)

    # Handler generators
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def cell_in_translation_table_is_being_focused(self, a, b, segment_index):
        if self.last_cell_focused is not None:
            if self.last_cell_focused_index in self.translation_reference_text_TextViews_modified_flag.keys():
                self.last_cell_focused.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.7, 249, 249, 240))
            else:
                self.last_cell_focused.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(1.0, 1.0, 1.0, 1.0))
        self.last_cell_focused = self.tables_content[self.reference_text_views][segment_index]
        self.last_cell_focused.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.9, 1, 1, 1))
        self.last_cell_focused_index = segment_index
项目:lightdm-settings    作者:linuxmint    | 项目源码 | 文件源码
def __init__(self, keyfile, settings, key):
        self.key = key
        self.keyfile = keyfile
        try:
            self.value = keyfile.get_string(GROUP_NAME, key)
        except:
            self.value = settings.get_string(key)
        Gtk.ColorButton.__init__(self)
        rgba = Gdk.RGBA()
        rgba.parse(self.value)
        self.set_rgba(rgba)
        self.connect("color-set", self.on_color_set)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def color_floats(spec):
    rgba = Gdk.RGBA()
    rgba.parse(spec)
    return rgba.red, rgba.green, rgba.blue
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def color_floats(spec):
    rgba = Gdk.RGBA()
    rgba.parse(spec)
    return rgba.red, rgba.green, rgba.blue
项目:htmlDE    作者:freundTech    | 项目源码 | 文件源码
def __init__(self, url, posx, posy, width, height, transparent):
        Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL, title='')
        self.transparent = transparent
        self.move(posx, posy)
        self.set_default_size(width, height)
        self.set_decorated(False)


        self.webview = WebKit2.WebView()

        settings = self.webview.get_settings()
        settings.set_allow_file_access_from_file_urls(True)
        settings.set_allow_universal_access_from_file_urls(True)
        settings.set_enable_webgl(True)
        self.webview.set_settings(settings)

        self.add(self.webview)

        if (self.transparent):
            self.webview.set_background_color(Gdk.RGBA(0, 0, 0, 0))
            self.installTransparency(self)
            self.installTransparency(self.webview)

        self.connect("delete_event", self.close_application)

        self.webview.connect("context-menu", self.context_menu)
        self.webview.connect("decide-policy", self.navigation_requested)
        self.webview.connect("resource-load-started", self.resource_load_started)

        self.webview.load_uri(url)
        inject_libraries(self.webview)
项目:htmlDE    作者:freundTech    | 项目源码 | 文件源码
def installTransparency(self, component):
        component.set_visual(component.get_screen().get_rgba_visual())

        component.override_background_color(Gtk.StateFlags.ACTIVE, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.BACKDROP, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.DIR_LTR, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.DIR_RTL, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.FOCUSED, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.INCONSISTENT, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.INSENSITIVE, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.PRELIGHT, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.SELECTED, Gdk.RGBA(0, 0, 0, 0))
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def bindGSettingsValueToWidget( self, settings, setting_type, key, widget, changeEvent, setter, getter ):
        settings.notifyAdd( key, self.callSetter, args = [ setting_type, setter ] )
        if setting_type == "color":
            color = Gdk.RGBA()
            color.parse( settings.get( setting_type, key ) )
            setter( color )
        else:
            setter( settings.get( setting_type, key ) )
        widget.connect( changeEvent, lambda *args: self.callGetter( settings, setting_type, key, getter ) )
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def callSetter( self, settings, key, args ):
        if args[0] == "bool":
            args[1]( settings.get_boolean(key) )
        elif args[0] == "string":
            args[1]( settings.get_string(key) )
        elif args[0] == "int":
            args[1]( settings.get_int(key) )
        elif args[0] == "color":
            color = Gdk.RGBA()
            color.parse( settings.get_string(key) )
            args[1]( color )
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def SetPaneColors( self, items, color = None ):
        for item in items:
            context = item.get_style_context()
            if self.usecustomcolor:
                bgColor = Gdk.RGBA()
                bgColor.parse( self.customcolor )
                item.override_background_color( context.get_state(), bgColor )
            elif color is not None:
                item.override_background_color( context.get_state(), color )
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def onWindowDraw(self, widget, cr):
        if self.usecustomcolor:
            borderColor = Gdk.RGBA()
            borderColor.parse(self.custombordercolor)
            Gdk.cairo_set_source_rgba(cr, borderColor)
            cr.paint()
        else:
            style = widget.get_style_context()
            req = widget.get_preferred_size()[0]
            Gtk.render_background(style, cr, 0, 0, req.width, req.height)
            Gtk.render_frame(style, cr, 0, 0, req.width, req.height)
        return False
项目:fux-terminal    作者:fuxprojesi    | 项目源码 | 文件源码
def main(self):
        """
        main: Ana S?n?f?n, Ana Fonksiyonu
        """
        # VTE'nin tan?mlamalar? ve sinyalleri
        terminal.drag_dest_set(0, [], 0)
        terminal.connect("drag_motion", DragDrop.motion_cb)
        terminal.connect("drag_drop", DragDrop.drop_cb)
        terminal.connect("drag_data_received", DragDrop.got_data_cb)
        terminal.connect("button-press-event", RightClick.on_button_press_event)
        terminal.connect("child-exited", Gtk.main_quit)

        # VTE e? zamanl? görüntüleme için bash kabu?u kullan?larak kullan?c? dizinine ayarlan?yor
        terminal.spawn_sync(Vte.PtyFlags.DEFAULT, os.environ["HOME"], 
                            ["/bin/bash"], [], 
                            GLib.SpawnFlags.DO_NOT_REAP_CHILD, 
                            None, None)

        # VTE'nin arkaplan rengi siyah, %90 opak - %10 transparan
        terminal.set_color_background(Gdk.RGBA(0, 0, 0, 0.9))
        # VTE'nin yaz? rengi beyaz ve opak
        terminal.set_color_foreground(Gdk.RGBA(1, 1, 1, 1.0))

        # Font ve Kodlama atamas?
        font = Pango.FontDescription("Monospace Regular 11")
        terminal.set_font(font)
        terminal.set_encoding("UTF-8")

        # Ana pencere tan?mlan?yor
        win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
        win.connect("delete-event", Gtk.main_quit)
        win.connect("draw", FuxTerminal.area_draw)

        win.set_default_size(765, 360)
        win.set_title("Fux Terminal")
        win.set_position(Gtk.WindowPosition.CENTER)
        win.set_icon_name("utilities-terminal")
        win.set_app_paintable(True)

        # Sadece VTE'nin veya sadece pencere'nin transparan olmas? yeterli de?il
        # ?kiside ayn? arkaplan rengi ve ayn? opakl?kta olmal? ki istedi?imiz
        # Transparan özellikte olsun
        win.screen = win.get_screen()
        win.visual = win.screen.get_rgba_visual()
        win.set_visual(win.visual)

        # Pencere'ye VTE ekleniyor ve gösteriliyor
        win.add(terminal)
        win.show_all()

        Gtk.main()
项目:XFWM_theme_creator    作者:Sjc1000    | 项目源码 | 文件源码
def press(self, widget, event):
        """press
        Called when the user presses a mouse button.
        Left click: Paint the currently active foreground color.
        Right Click: Remove the pixel under the mouse.
        Middle Click: Fill with the active foreground color.
        """
        if self.image is None:
            return None
        main_window = self.get_toplevel()
        var_name = main_window.var_list.active
        image_width = len(self.image[0])
        image_height = len(self.image)
        x = math.floor((event.x)/self.scale)
        y = math.floor((event.y)/self.scale)
        if x+1 > image_width or y+1 > image_height or x < 0 or y < 0:
            return None

        if event.button == 2:
            r, g, b, a = main_window.paint_color.get_rgba()
            color = [Gdk.RGBA(r, g, b), var_name]
            original = self.image[y][x]
            for yi, y in enumerate(self.image):
                for xi, x in enumerate(y):
                    if str(self.image[yi][xi]) != str(original):
                        continue
                    self.image[yi][xi] = color
            self.view.queue_draw()
            return None

        elif event.button == 1 and self.get_color:
            color = self.image[y][x]
            main_window.var_list.active = None
            main_window.paint_color.set_rgba(color[0])
            for index, item in enumerate(main_window.var_list.list):
                path = Gtk.TreePath().new_from_string(str(index))
                if item[0] == color[1]:
                    item[1] = True
                    main_window.var_list.active = item[0]
                else:
                    item[1] = False

            return None
        if event.button == 1:
            color = main_window.paint_color.get_rgba()
        elif event.button == 3:
            color = None

        if self.last is not None and self.square:
            lx, ly = self.last
            for xi in range(image_width):
                for yi in range(image_height):
                    if ((x > lx and lx <= xi <= x or x < lx and lx >= xi >= x)
                            and (y > ly and ly <= yi <= y or y < ly
                            and ly >= yi >= y)):
                        self.image[yi][xi] = [color, var_name]
        else:
            self.image[y][x] = [color, var_name]
            self.last = [x, y]
        self.view.queue_draw()
        return None
项目:XFWM_theme_creator    作者:Sjc1000    | 项目源码 | 文件源码
def load_files(self, folder):
        global files
        new_files = OrderedDict()
        image_files = sorted(os.listdir(folder))
        if 'xfwm4' in image_files:
            self.load_files(folder + '/xfwm4')
            return None
        for name in image_files:
            if name == 'themerc':
                # I might build in themerc support.
                # for now, I skip this.
                continue
            if not name.endswith('.xpm'):
                continue
            with open('{}/{}'.format(folder, name), 'r') as f:
                data = f.read().replace('\n', '')
            content = data.split('{')[1]
            content = content.strip('{};').split(',')
            chars = {}

            # Parse the width / height / number of colors
            width, height, colors, _ = content[0].strip('"').split(' ')
            width = int(width)
            height = int(height)
            for i in range(int(colors)):
                color_info = content[i+1].strip('"')
                char, color = color_info.split('c', 1)
                char = char[0]
                if 's' in color:
                    color, var = color.split('s', 1)
                else:
                    var = None
                color = color.strip()
                if color.lower() == 'none':
                    color = None
                if var is not None:
                    var = var.strip()
                if color is not None:
                    color = color.lstrip('#')
                    color = Gdk.RGBA(*(x/255 for x in bytes.fromhex(color)))
                chars[char] = [color, var]
            image = [[[None, None] for x in range(width)] for y in range(height)]
            for yi, y in enumerate(content[len(chars)+1:]):
                for xi, x in enumerate(y.strip('"')):
                    image[yi][xi] = chars[x]
            filename = name.split('.')[0]
            new_files.update({filename: {'image': image,
                         'size': [width, height]}})
        for name in names:
            if name not in image_files:
                files.update({name: {'image': [[[None, None]]], 'size': [1, 1]}})

        for name in sorted(new_files):
            files.update({name: new_files[name]})

        self.file_selecter.active = None
        return None