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


Python Gtk.ColorButton方法代码示例

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


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

示例1: on_colorbutton_choose_line_color_color_set

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ColorButton [as 别名]
def on_colorbutton_choose_line_color_color_set(self, color_button):
        """
        Triggered when the line color is changed. The function receives
        a Gtk.ColorButton instance. Queues up the new line color in the
        list of changes.
        """
        rgba = color_button.get_rgba()
        rgb_str = rgba.to_string()
        red, green, blue = rgb_str[4:-1].split(",")
        color_list = [int(red)/255, int(green)/255, int(blue)/255]
        new_line_color_hex = colors.rgb2hex(color_list)
        self.changes.append(lambda: self.layer.set_line_color(
                                                new_line_color_hex)) 
开发者ID:innstereo,项目名称:innstereo,代码行数:15,代码来源:layer_properties.py

示例2: update_color

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ColorButton [as 别名]
def update_color(self, widget):
        """ Callback for the color chooser button, to set scribbling color.

        Args:
            widget (:class:`~Gtk.ColorButton`):  the clicked button to trigger this event, if any
        """
        self.scribble_color = widget.get_rgba()
        self.config.set('scribble', 'color', self.scribble_color.to_string()) 
开发者ID:Cimbali,项目名称:pympress,代码行数:10,代码来源:scribble.py

示例3: page_builder_images

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ColorButton [as 别名]
def page_builder_images(self):
		"""Adds the widget to the grid of the 'images' page."""
		self.set_current_grid(self.page_images)

		self.add_section_title(_("New images"))
		self.add_adj(_("Default width"), 'default-width', self.adj_width)
		self.add_adj(_("Default height"), 'default-height', self.adj_height)
		bg_color_btn = Gtk.ColorButton(use_alpha=True)
		background_rgba = self._settings.get_strv('background-rgba')
		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)
		bg_color_btn.set_rgba(color)
		bg_color_btn.connect('color-set', self.on_background_changed)
		self.add_row(_("Default background"), bg_color_btn)

		self.add_section_separator()
		self.add_section_title(_("Images saving"))
		self.add_help(_("JPEG and BMP images can't handle transparency.") + \
		        " " + _("If you save your images in these formats, what " + \
		                  "do want to use to replace transparent pixels?"))
		alpha_dict = {
			'white': _("White"),
			'black': _("Black"),
			'checkboard': _("Checkboard"),
			'nothing': _("Nothing"),
			'ask': _("Ask before saving")
		}
		self.add_radio_flowbox('replace-alpha', alpha_dict)

		self.add_section_separator()
		self.add_section_title(_("Zoom"))
		zoom_help = _("You can zoom with Ctrl+scrolling, or only scrolling.") + \
		  " " + _("Using keyboard shortcuts or touch gestures is possible too.")
		self.add_help(zoom_help)
		self.add_switch(_("Use 'Ctrl' to zoom"), 'ctrl-zoom') 
开发者ID:maoschanz,项目名称:drawing,代码行数:40,代码来源:preferences.py

示例4: __getitem__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ColorButton [as 别名]
def __getitem__(self, key):
		if not key in self._keys:
			raise KeyError(key)
		elif key in self.widgets:
			widget = self.widgets[key]
			if isinstance(widget, LinkEntry):
				return widget.get_text() # Could be either page or file
			elif isinstance(widget, (PageEntry, NamespaceEntry)):
				return widget.get_path()
			elif isinstance(widget, FSPathEntry):
				return widget.get_path()
			elif isinstance(widget, InputEntry):
				return widget.get_text()
			elif isinstance(widget, Gtk.CheckButton):
				return widget.get_active()
			elif isinstance(widget, Gtk.ComboBox):
				if hasattr(widget, 'zim_key_mapping'):
					label = widget.get_active_text()
					return widget.zim_key_mapping.get(label) or label
				else:
					return widget.get_active_text()
			elif isinstance(widget, Gtk.SpinButton):
				return int(widget.get_value())
			elif isinstance(widget, Gtk.ColorButton):
				return widget.get_rgba().to_string()
			else:
				raise TypeError(widget.__class__.name)
		else:
			# Group of RadioButtons
			for name, widget in self._get_radiogroup(key):
				if widget.get_active():
					x, name = name.rsplit(':', 1)
						# using rsplit to assure another ':' in the
						# group name is harmless
					return name 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:37,代码来源:widgets.py

示例5: __setitem__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ColorButton [as 别名]
def __setitem__(self, key, value):
		if not key in self._keys:
			raise KeyError(key)
		elif key in self.widgets:
			widget = self.widgets[key]
			if isinstance(widget, LinkEntry):
				assert isinstance(value, str)
				widget.set_text(value)
			elif isinstance(widget, (PageEntry, NamespaceEntry)):
				if isinstance(value, Path):
					widget.set_path(value)
				else:
					widget.set_text(value or '')
			elif isinstance(widget, FSPathEntry):
				if isinstance(value, (File, Dir)):
					widget.set_path(value)
				else:
					widget.set_text(value or '')
			elif isinstance(widget, InputEntry):
				value = value or ''
				widget.set_text(value)
			elif isinstance(widget, Gtk.CheckButton):
				widget.set_active(value)
			elif isinstance(widget, Gtk.ComboBox):
				if hasattr(widget, 'zim_key_mapping'):
					for key, v in list(widget.zim_key_mapping.items()):
						if v == value:
							gtk_combobox_set_active_text(widget, key)
							break
					else:
						gtk_combobox_set_active_text(widget, value)
				else:
					gtk_combobox_set_active_text(widget, value)
			elif isinstance(widget, Gtk.SpinButton):
				widget.set_value(value)
			elif isinstance(widget, Gtk.ColorButton):
				rgba = Gdk.RGBA()
				rgba.parse(value)
				widget.set_rgba(rgba)
			else:
				raise TypeError(widget.__class__.name)
		else:
			# RadioButton
			widget = self.widgets[key + ':' + value]
			widget.set_active(True) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:47,代码来源:widgets.py


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