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


Python GObject.Object方法代码示例

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


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

示例1: gobject_get_value

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def gobject_get_value(gobject, gtype=None):
	"""
	Retrieve the value of a GObject widget. Only objects with corresponding
	entries present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by
	this function.

	:param gobject: The object to retrieve the value for.
	:type gobject: :py:class:`GObject.Object`
	:param str gtype: An explicit type to treat *gobject* as.
	:return: The value of *gobject*.
	:rtype: str
	"""
	gtype = (gtype or gobject.__class__.__name__)
	gtype = gtype.lower()
	if isinstance(GOBJECT_PROPERTY_MAP[gtype], (list, tuple)):
		try:
			value = GOBJECT_PROPERTY_MAP[gtype][1](gobject)
		except AttributeError:
			return None
	else:
		value = gobject.get_property(GOBJECT_PROPERTY_MAP[gtype])
	return value 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:24,代码来源:gui_utilities.py

示例2: gobject_set_value

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def gobject_set_value(gobject, value, gtype=None):
	"""
	Set the value of a GObject widget. Only objects with corresponding entries
	present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by this
	function.

	:param gobject: The object to set the value for.
	:type gobject: :py:class:`GObject.Object`
	:param value: The value to set for the object.
	:param str gtype: An explicit type to treat *gobject* as.
	"""
	gtype = (gtype or gobject.__class__.__name__)
	gtype = gtype.lower()
	if gtype not in GOBJECT_PROPERTY_MAP:
		raise ValueError('unsupported gtype: ' + gtype)
	if isinstance(GOBJECT_PROPERTY_MAP[gtype], (list, tuple)):
		GOBJECT_PROPERTY_MAP[gtype][0](gobject, value)
	else:
		gobject.set_property(GOBJECT_PROPERTY_MAP[gtype], value) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:21,代码来源:gui_utilities.py

示例3: signal_connector

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def signal_connector(self, builder, object, signal_name, handler_name, connect_object, flags, *user_data):
        """ Callback for signal connection. Implements the `~Gtk.BuilderConnectFunc` function interface.

        Args:
            builder (:class:`~pympress.builder.Builder`): The builder, unused
            object (:class:`~GObject.Object`): The object (usually a wiget) that has a signal to be connected
            signal_name (`str`): The name of the signal
            handler_name (`str`): The name of the function to be connected to the signal
            connect_object (:class:`~GObject.Object`): unused
            flags (:class:`~GObject.ConnectFlags`): unused
            user_data (`tuple`): supplementary positional arguments to be passed to the handler
        """
        try:
            handler = self.get_callback_handler(handler_name)
            object.connect(signal_name, handler, *user_data)

        except Exception:
            logger.critical('Impossible to connect signal {} from object {} to handler {}'
                            .format(signal_name, object, handler_name), exc_info = True) 
开发者ID:Cimbali,项目名称:pympress,代码行数:21,代码来源:builder.py

示例4: gobject_signal_blocked

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def gobject_signal_blocked(gobject, signal_name):
	"""
	This is a context manager that can be used with the 'with' statement
	to execute a block of code while *signal_name* is blocked.

	:param gobject: The object to block the signal on.
	:type gobject: :py:class:`GObject.Object`
	:param str signal_name: The name of the signal to block.
	"""
	signal_id = GObject.signal_lookup(signal_name, gobject.__class__)
	handler_id = GObject.signal_handler_find(gobject, GObject.SignalMatchType.ID, signal_id, 0, None, 0, 0)
	GObject.signal_handler_block(gobject, handler_id)
	yield
	GObject.signal_handler_unblock(gobject, handler_id) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:16,代码来源:gui_utilities.py

示例5: gtk_builder_get

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def gtk_builder_get(self, gobject_id, parent_name=None):
		"""
		Find the child GObject with name *gobject_id* from the GTK builder.

		:param str gobject_id: The object name to look for.
		:param str parent_name: The name of the parent object in the builder data file.
		:return: The GObject as found by the GTK builder.
		:rtype: :py:class:`GObject.Object`
		"""
		parent_name = parent_name or self.dependencies.name
		gtkbuilder_id = "{0}.{1}".format(parent_name, gobject_id)
		self.logger.debug('loading GTK builder object with id: ' + gtkbuilder_id)
		return self.gtk_builder.get_object(gtkbuilder_id) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:15,代码来源:gui_utilities.py

示例6: __init__

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __init__(self):
        """ Initialisation is important.
        """
        GObject.Object.__init__(self) 
开发者ID:fossfreedom,项目名称:indicator-sysmonitor,代码行数:6,代码来源:budgiesysmonitor.py

示例7: __init__

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __init__(self):
        """
        Initialises the preferences, getting an instance of the settings saved
        by Gio.
        """
        GObject.Object.__init__(self)
        self.gs = GSetting()
        self.plugin_settings = self.gs.get_setting(self.gs.Path.PLUGIN) 
开发者ID:fossfreedom,项目名称:alternative-toolbar,代码行数:10,代码来源:alttoolbar_preferences.py

示例8: __init__

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __init__(self):
        """
        Initialises the plugin object.
        """
        GObject.Object.__init__(self)
        self.appshell = None
        self.sh_psc = self.sh_op = self.sh_pc = None 
开发者ID:fossfreedom,项目名称:alternative-toolbar,代码行数:9,代码来源:alternative-toolbar.py

示例9: __init__

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __init__(self, shell, toggle_button):
        """
        :param shell: the plugin object
        :param toggle_button: button that controls the repeat functions
        """
        GObject.Object.__init__(self)

        # use this to start the repeat-one-song capability (if True)
        self.repeat_song = False
        self.toggle_button = toggle_button
        self.song_changed = self.SONG_CHANGED_MANUAL

        player = shell.props.shell_player
        # EOS signal means that the song changed because the song is over.
        # ie. the user did not manually change the song.
        # https://developer.gnome.org/rhythmbox/unstable/RBPlayer.html#RBPlayer-eos
        player.props.player.connect('eos', self.on_gst_player_eos)
        player.connect('playing-song-changed', self.on_song_change)
        # This hack is no longer needed when the above signal handlers
        # work. For more details, refer to the comments above the
        # definition of method on_elapsed_change.
        # player.connect('elapsed-changed', self.on_elapsed_change)

        try:
            popover = Gtk.Popover.new(toggle_button)
        except AttributeError:
            # use our custom Popover equivalent for Gtk+3.10 folks
            popover = CustomPopover(toggle_button)
        else:
            popover.set_modal(False)
        finally:
            repeat = RepeatPopContainer(popover, toggle_button)
            popover.add(repeat)

        toggle_button.connect('toggled', self._on_toggle, popover, repeat)
        repeat.connect('repeat-type-changed', self._on_repeat_type_changed)

        self._on_repeat_type_changed(repeat, repeat.get_repeat_type()) 
开发者ID:fossfreedom,项目名称:alternative-toolbar,代码行数:40,代码来源:alttoolbar_repeat.py

示例10: __init__

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __init__(self):
        GObject.Object.__init__(self)
        self._instances = {} 
开发者ID:nymanjens,项目名称:gedit-intelligent-text-completion,代码行数:5,代码来源:intelligent_text_completion.py

示例11: __init__

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __init__(self):
        GObject.Object.__init__(self)
        self.completion_provider = None 
开发者ID:isamert,项目名称:gedi,代码行数:5,代码来源:gedi.py

示例12: __translate_widget_strings

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __translate_widget_strings(a_widget):
        """ Calls gettext on all strings we can find in a_widgets.

        Args:
            a_widget (:class:`~GObject.Object`): an object built by the builder, usually a widget
        """
        for str_prop in (prop.name for prop in a_widget.props if prop.value_type == GObject.TYPE_STRING):
            try:
                str_val = getattr(a_widget.props, str_prop)
                if str_val:
                    setattr(a_widget.props, str_prop, _(str_val))
            except TypeError:
                # Thrown when a string property is not readable
                pass 
开发者ID:Cimbali,项目名称:pympress,代码行数:16,代码来源:builder.py

示例13: __recursive_translate_widgets

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __recursive_translate_widgets(a_widget):
        """ Calls gettext on all strings we can find in widgets, and recursively on its children.

        Args:
            a_widget (:class:`~GObject.Object`): an object built by the builder, usually a widget
        """
        Builder.__translate_widget_strings(a_widget)

        if issubclass(type(a_widget), Gtk.Container):
            # NB: Parent-loop in widgets would cause infinite loop here, but that's absurd (right?)
            # NB2: maybe forall instead of foreach if we miss some strings?
            a_widget.foreach(Builder.__recursive_translate_widgets)

        if issubclass(type(a_widget), Gtk.MenuItem) and a_widget.get_submenu() is not None:
            Builder.__recursive_translate_widgets(a_widget.get_submenu()) 
开发者ID:Cimbali,项目名称:pympress,代码行数:17,代码来源:builder.py

示例14: __init__

# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import Object [as 别名]
def __init__(self):
        GObject.Object.__init__(self)
        if dbus.SessionBus().request_name('es.atareao.MyWeatherIndicator') !=\
                dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
            print("application already running")
            exit(0)
        #
        self.weather_updater = 0
        self.widgets_updater = 0
        self.internet_updater = 0
        self.internet_connection = False
        self.menus = []
        self.indicators = []
        self.notifications = []
        self.widgets = []
        self.weatherservices = []
        self.weathers = []
        self.current_conditions = []
        self.preferences = []
        self.last_update_time = 0
        # Iniciate variables
        for i in range(INDICATORS):
            self.menus.append(None)
            self.indicators.append(None)
            self.notifications.append(None)
            self.widgets.append(None)
            self.weatherservices.append(None)
            self.weathers.append(None)
            self.current_conditions.append(None)
            self.preferences.append(None)
        #
        status = appindicator.IndicatorCategory.APPLICATION_STATUS
        self.notifications[0] = Notify.Notification.new('', '', None)
        self.indicators[0] = appindicator.Indicator.new(
            'My-Weather-Indicator', 'My-Weather-Indicator', status)
        self.notifications[1] = Notify.Notification.new('', '', None)
        self.indicators[1] = appindicator.Indicator.new(
            'My-Weather-Indicator2', 'My-Weather-Indicator', status)
        for i in range(INDICATORS):
            self.create_menu(i)
        for i in range(INDICATORS):
            self.widgets[i] = None
        self.load_preferences() 
开发者ID:atareao,项目名称:my-weather-indicator,代码行数:45,代码来源:myweatherindicator.py


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