当前位置: 首页>>代码示例>>Python>>正文


Python Gdk.RGBA属性代码示例

本文整理汇总了Python中gi.repository.Gdk.RGBA属性的典型用法代码示例。如果您正苦于以下问题:Python Gdk.RGBA属性的具体用法?Python Gdk.RGBA怎么用?Python Gdk.RGBA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gi.repository.Gdk的用法示例。


在下文中一共展示了Gdk.RGBA属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def __init__(
            self, colours, max_colour_val, num_rows, num_cols, horizontal, 
            selected_handler):
        Gtk.Grid.__init__(self)
        row = 0
        col = 0
        (ret, width, height) = Gtk.icon_size_lookup(Gtk.IconSize.BUTTON)
        rgba = Gdk.RGBA()
        for c in colours:
            rgba.parse(c)
            colour_square = ColourPaletteSquare(
                rgba, width, height, max_colour_val)
            colour_square.connect("button-release-event", selected_handler)
            self.attach(colour_square, col, row, 1, 1)
            if horizontal:
                col += 1
                if col == num_cols:
                    col = 0
                    row += 1
            else:
                row += 1
                if row == num_rows:
                    row = 0
                    col += 1 
开发者ID:trackmastersteve,项目名称:alienfx,代码行数:26,代码来源:colour_palette.py

示例2: gtk_style_context_get_color

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def gtk_style_context_get_color(sc, color_name, default=None):
	"""
	Look up a color by it's name in the :py:class:`Gtk.StyleContext` specified
	in *sc*, and return it as an :py:class:`Gdk.RGBA` instance if the color is
	defined. If the color is not found, *default* will be returned.

	:param sc: The style context to use.
	:type sc: :py:class:`Gtk.StyleContext`
	:param str color_name: The name of the color to lookup.
	:param default: The default color to return if the specified color was not found.
	:type default: str, :py:class:`Gdk.RGBA`
	:return: The color as an RGBA instance.
	:rtype: :py:class:`Gdk.RGBA`
	"""
	found, color_rgba = sc.lookup_color(color_name)
	if found:
		return color_rgba
	if isinstance(default, str):
		color_rgba = Gdk.RGBA()
		color_rgba.parse(default)
		return color_rgba
	elif isinstance(default, Gdk.RGBA):
		return default
	return 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:26,代码来源:gui_utilities.py

示例3: get_tags_and_table

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def get_tags_and_table(self, obj):
        """
        Return html tags table for obj (person or family).
        """
        tag_table = ''
        tags = []

        for tag_handle in obj.get_tag_list():
            tags.append(self.dbstate.db.get_tag_from_handle(tag_handle))

        # prepare html table of tags
        if tags:
            tag_table = ('<TABLE BORDER="0" CELLBORDER="0" '
                         'CELLPADDING="5"><TR>')
            for tag in tags:
                rgba = Gdk.RGBA()
                rgba.parse(tag.get_color())
                value = '#%02x%02x%02x' % (int(rgba.red * 255),
                                           int(rgba.green * 255),
                                           int(rgba.blue * 255))
                tag_table += '<TD BGCOLOR="%s"></TD>' % value
            tag_table += '</TR></TABLE>'

        return tags, tag_table 
开发者ID:gramps-project,项目名称:addons-source,代码行数:26,代码来源:graphview.py

示例4: date_changed

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def date_changed(self, widget, data):
        try:
            Date.parse(widget.get_text())
            valid = True
        except ValueError:
            valid = False

        if valid:
            # If the date is valid, we write with default color in the widget
            # "none" will set the default color.
            widget.override_color(Gtk.StateType.NORMAL, None)
            widget.override_background_color(Gtk.StateType.NORMAL, None)
        else:
            # We should write in red in the entry if the date is not valid
            text_color = Gdk.RGBA()
            text_color.parse("#F00")
            widget.override_color(Gtk.StateType.NORMAL, text_color)

            bg_color = Gdk.RGBA()
            bg_color.parse("#F88")
            widget.override_background_color(Gtk.StateType.NORMAL, bg_color) 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:23,代码来源:editor.py

示例5: change_fg_colour

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def change_fg_colour(self, lc, cell, model, m_iter, data):
        """
        :Description: Changes the foreground colour of a cell

        :param lc: :class:`Gtk.TreeViewColumn` The column we are interested in
        :param cell: :class:`Gtk.CellRenderer` The cell we want to change
        :param model: :class:`Gtk.TreeModel`
        :param iter: :class:`Gtk.TreeIter`
        :param data: :py:class:`dict` (key=int,value=bool) value is true if channel already highlighted
        :return: None
        """

        for chan in data:
            if model[m_iter][0] == chan:
                if data[chan]:
                    cell.set_property('foreground_rgba',
                                      Gdk.RGBA(0.9, 0.2, 0.2, 1))
                else:
                    cell.set_property('foreground_rgba', Gdk.RGBA(0, 0, 0, 1)) 
开发者ID:pychess,项目名称:pychess,代码行数:21,代码来源:ChannelsPanel.py

示例6: cb_realized

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def cb_realized(self, widget, *a):
		context = widget.get_style_context()
		color = context.get_background_color(Gtk.StateFlags.SELECTED)
		# Dark color: Gdk.RGBA(red=0.223529, green=0.247059, blue=0.247059, alpha=1.000000)
		# Light color: Gdk.RGBA(red=0.929412, green=0.929412, blue=0.929412, alpha=1.000000)
		light_color = False
		for c in list(color)[0:3]:
			if c > 0.75: light_color = True
		if not light_color:
			# Set dark color based on current window background
			self.dark_color = (color.red, color.green, color.blue, 1.0)
			# Recolor all boxes
			for box in self.folders.values():
				box.set_dark_color(*self.dark_color)
			for box in self.devices.values():
				box.set_dark_color(*self.dark_color) 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:18,代码来源:app.py

示例7: init_grid

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def init_grid(self):
		# Create widgets
		self.grid = Gtk.Grid()
		self.rev = RevealerClass()
		align = Gtk.Alignment()
		self.eb = Gtk.EventBox()
		# Set values
		self.grid.set_row_spacing(1)
		self.grid.set_column_spacing(3)
		self.rev.set_reveal_child(False)
		align.set_padding(2, 2, 5, 5)
		self.eb.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.background))
		self.grid.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.background))
		# Connect signals
		self.eb.connect("button-release-event", self.on_grid_release)
		self.eb.connect("button-press-event", self.on_grid_click)
		self.eb.connect('enter-notify-event', self.on_enter_notify)
		self.eb.connect('leave-notify-event', self.on_leave_notify)
		# Pack together
		align.add(self.grid)
		self.eb.add(align)
		self.rev.add(self.eb)
		self.add(self.rev)
	
	### GtkWidget-related stuff 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:27,代码来源:infobox.py

示例8: recolor

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def recolor(self, *a):
		"""
		Called to computes actual color every time when self.color or
		self.hilight_factor changes.
		"""
		if self.dark_color is None:
			self.real_color = tuple([ min(1.0, x + HILIGHT_INTENSITY * math.sin(self.hilight_factor)) for x in self.color])
		else:
			# Darken colors when dark background is enabled
			self.real_color = tuple([ min(1.0, DARKEN_FACTOR * (x + HILIGHT_INTENSITY * math.sin(self.hilight_factor))) for x in self.color])
		gdkcol = Gdk.RGBA(*self.real_color)
		self.header.override_background_color(Gtk.StateType.NORMAL, gdkcol)
		try:
			self.header.get_children()[0].override_background_color(Gtk.StateFlags.NORMAL, gdkcol)
		except IndexError:
			# Happens when recolor is called before header widget is created
			pass

		self.queue_draw()
	
	### Translated events 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:23,代码来源:infobox.py

示例9: add_value

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def add_value(self, key, icon, title, value="", visible=True):
		""" Adds new line with provided properties """
		wIcon = self._prepare_icon(icon)
		wTitle, wValue = Gtk.Label(), Gtk.Label()
		self.value_widgets[key] = (wValue, wIcon, wTitle)
		self.set_value(key, value)
		self.icons[key] = icon
		wTitle.set_text(title)
		wTitle.set_alignment(0.0, 0.5)
		wValue.set_alignment(1.0, 0.5)
		wValue.set_ellipsize(Pango.EllipsizeMode.START)
		wTitle.set_property("expand", True)
		line = len(self.value_widgets)
		self.grid.attach(wIcon, 0, line, 1, 1)
		self.grid.attach_next_to(wTitle, wIcon, Gtk.PositionType.RIGHT, 1, 1)
		self.grid.attach_next_to(wValue, wTitle, Gtk.PositionType.RIGHT, 1, 1)
		for w in self.value_widgets[key]:
			w.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(*self.background))
			w.override_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(*self.text_color))
			if not visible:
				w.set_no_show_all(True) 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:23,代码来源:infobox.py

示例10: __init__

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def __init__(self):
        super(QueryLog, self).__init__()
        model = Gtk.ListStore(str, Gdk.RGBA)
        self.set_model(model)
        column = Gtk.TreeViewColumn(
            '', Gtk.CellRendererText(), markup=0, foreground_rgba=1)
        self.append_column(column)
        self.set_headers_visible(False)
        self.set_reorderable(False)
        self.set_enable_search(False)
        lbl = Gtk.Label()
        context = lbl.get_style_context()
        self.dimmed_fg = context.get_color(Gtk.StateFlags.INSENSITIVE)
        self.col_error = self.dimmed_fg.copy()
        self.col_error.red = max(self.col_error.red * 1.7, 1)
        self.col_error.green *= 0.7
        self.col_error.blue *= 0.7
        font_desc = Pango.FontDescription.from_string('Ubuntu Mono 12')
        self.modify_font(font_desc) 
开发者ID:andialbrecht,项目名称:runsqlrun,代码行数:21,代码来源:results.py

示例11: onVirtKeyClick

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
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()
                ) 
开发者ID:GabMus,项目名称:razerCommander,代码行数:22,代码来源:__main__.py

示例12: build_keyrow_box

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
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} 
开发者ID:GabMus,项目名称:razerCommander,代码行数:22,代码来源:custom_kb_builder.py

示例13: configure_transparency

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def configure_transparency(c):
    c.set_visual(c.get_screen().get_rgba_visual())
    c.override_background_color(gtk.StateFlags.ACTIVE, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.BACKDROP, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.DIR_LTR, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.DIR_RTL, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.FOCUSED, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.INCONSISTENT, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.INSENSITIVE, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.PRELIGHT, Gdk.RGBA(0, 0, 0, 0))
    c.override_background_color(gtk.StateFlags.SELECTED, Gdk.RGBA(0, 0, 0, 0))
    transparentWindowStyleProvider = gtk.CssProvider()
    transparentWindowStyleProvider.load_from_data(b"""
        GtkWindow {
            background-color:rgba(0,0,0,0);
            background-image:none;
        }""")
    c.get_style_context().add_provider(transparentWindowStyleProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) 
开发者ID:r0x0r,项目名称:pywebview,代码行数:21,代码来源:gtk.py

示例14: on_release_on_area

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def on_release_on_area(self, event, surface, event_x, event_y):
		rgba_vals = utilities_get_rgba_for_xy(surface, event_x, event_y)
		if rgba_vals is None:
			return # click outside of the surface
		r = rgba_vals[0] / 255
		g = rgba_vals[1] / 255
		b = rgba_vals[2] / 255
		a = rgba_vals[3] / 255
		color = Gdk.RGBA(red=r, green=g, blue=b, alpha=a)
		if event.button == 1:
			self.window.options_manager.set_left_color(color)
		elif event.button == 3:
			self.window.options_manager.set_right_color(color)
		self.window.back_to_previous()

	############################################################################
################################################################################ 
开发者ID:maoschanz,项目名称:drawing,代码行数:19,代码来源:tool_picker.py

示例15: create_window

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import RGBA [as 别名]
def create_window(self):

        app_icon = GdkPixbuf.Pixbuf.new_from_file(sys.path[0] + '/images/icon.png')

        self.login_window = Gtk.Window(
            title = "Games Nebula",
            type = Gtk.WindowType.TOPLEVEL,
            window_position = Gtk.WindowPosition.CENTER_ALWAYS,
            icon = app_icon,
            width_request = 390,
            height_request = 496,
            resizable = True
        )
        self.login_window.connect('delete-event', self.quit_app)

        self.setup_cookies()

        content_manager = self.new_content_manager()
        self.webpage = WebKit2.WebView(user_content_manager=content_manager)
        self.webpage.connect('load_changed', self.webpage_loaded)

        self.webpage_color = Gdk.RGBA(
            red = 0.149019,
            green = 0.149019,
            blue = 0.149019,
            alpha = 1.0,
        )
        self.webpage.set_background_color(self.webpage_color)

        auth_url = get_auth_url()
        self.webpage.load_uri(auth_url)

        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.add(self.webpage)

        self.login_window.add(self.scrolled_window)
        self.login_window.show_all() 
开发者ID:yancharkin,项目名称:games_nebula,代码行数:39,代码来源:pygogauth.py


注:本文中的gi.repository.Gdk.RGBA属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。