當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。