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


Python Gtk.Widget方法代码示例

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


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

示例1: add_reference

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def add_reference(self, ref_object):
		"""
		Add *ref_object* to the :py:attr:`.references` so the object won't be
		garbage collected. The object must either be a
		:py:class:`.GladeGObject` or :py:class:`Gtk.Widget` instance so a
		cleanup function can be attached to a ``destroy`` signal to remove the
		reference automatically.

		:param ref_object: The object to store a reference to.
		:type ref_object: :py:class:`.GladeGObject`, :py:class:`Gtk.Widget`
		"""
		utilities.assert_arg_type(ref_object, (gui_utilities.GladeGObject, Gtk.Widget))
		self.references.append(ref_object)
		if isinstance(ref_object, gui_utilities.GladeGObject):
			widget = getattr(ref_object, ref_object.top_gobject)
		else:
			widget = ref_object
		widget.connect('destroy', self.signal_multi_destroy_remove_reference, ref_object) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:20,代码来源:application.py

示例2: on_pointer_motion

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_pointer_motion(self, _dummy, event):
        """
        Called when the pointer is moved.
        @param _dummy: This widget.  Unused.
        @type _dummy: Gtk.Widget
        @param event: An event.
        @type event: Gdk.Event
        """
        if self.__rects is None:
            return False
        active = -1
        for i, rect in enumerate(self.__rects):
            if (event.x > rect[0] and event.x < rect[0] + rect[2] and
                    event.y > rect[1] and event.y < rect[1] + rect[3]):
                active = i
        if self.__active != active:
            self.__active = active
            if active == -1:
                self.set_tooltip_text('')
            else:
                self.set_tooltip_text('%s cMs' % self.segments[active][4])

        return False 
开发者ID:gramps-project,项目名称:addons-source,代码行数:25,代码来源:dna.py

示例3: on_pointer_motion

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_pointer_motion(self, _dummy, event):
        """
        Called when the pointer is moved.
        @param _dummy: This widget.  Unused.
        @type _dummy: Gtk.Widget
        @param event: An event.
        @type event: Gdk.Event
        """
        if self.__rects is None:
            return False
        active = -1
        for i, rect in enumerate(self.__rects):
            if (event.x > rect[0] and event.x < rect[0] + rect[2] and
                    event.y > rect[1] and event.y < rect[1] + rect[3]):
                active = i
        if self.__active != active:
            self.__active = active
            if active == -1:
                self.set_tooltip_text('')
            else:
                self.set_tooltip_text(self.tag_list[active][0])

        return False 
开发者ID:gramps-project,项目名称:addons-source,代码行数:25,代码来源:taglist.py

示例4: on_pointer_motion

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_pointer_motion(self, _dummy, event):
        """
        Called when the pointer is moved.
        @param _dummy: This widget.  Unused.
        @type _dummy: Gtk.Widget
        @param event: An event.
        @type event: Gdk.Event
        """
        allocation = self.get_allocation()
        x = allocation.width / 2
        y = allocation.height / 2
        if (event.x > (x - NODE_SIZE) and event.x < (x + NODE_SIZE) and
            event.y > (y - NODE_SIZE) and event.y < (y + NODE_SIZE)):
            active = True
        else:
            active = False

        if self.__active != active:
            self.__active = active
            self.queue_draw()

        return False 
开发者ID:gramps-project,项目名称:addons-source,代码行数:24,代码来源:timeline.py

示例5: register_moved_control

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def register_moved_control(self, child, old_parent, new_parent=None):
        """
           convenience function to save the GTK child & parents when they are
           moved.
           we use this info to cleanup when quitting RB - we need to move
           stuff back because
           otherwise there are random crashes due to memory deallocation issues

        :param child: GTK Widget
        :param old_parent: original GTK container that the child was moved from
        :param new_parent: new GTK container that the child was added to (may
        just have removed without moving)
        :return:
        """

        # store as a tuple: child, new-parent, old-parent
        self._moved_controls.append((child, new_parent, old_parent)) 
开发者ID:fossfreedom,项目名称:alternative-toolbar,代码行数:19,代码来源:alttoolbar_type.py

示例6: on_configure_da

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_configure_da(self, widget, event):
        """ Manage "configure" events for all drawing areas, e.g. resizes.

        We tell the local :class:`~pympress.surfacecache.SurfaceCache` cache about it, so that it can
        invalidate its internal cache for the specified widget and pre-render next pages at a correct size.

        Warning: Some not-explicitly sent signals contain wrong values! Just don't resize in that case,
        since these always seem to happen after a correct signal that was sent explicitly.

        Args:
            widget (:class:`~Gtk.Widget`):  the widget which has been resized
            event (:class:`~Gdk.Event`):  the GTK event, which contains the new dimensions of the widget
        """
        # Don't trust those
        if not event.send_event:
            return

        self.cache.resize_widget(widget.get_name(), event.width, event.height)

        if widget is self.c_da:
            self.medias.resize('content')
        elif widget is self.p_da_cur:
            self.medias.resize('presenter') 
开发者ID:Cimbali,项目名称:pympress,代码行数:25,代码来源:ui.py

示例7: on_configure_win

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_configure_win(self, widget, event):
        """ Manage "configure" events for both window widgets.

        Args:
            widget (:class:`~Gtk.Widget`):  the window which has been moved or resized
            event (:class:`~Gdk.Event`):  the GTK event, which contains the new dimensions of the widget
        """
        if widget is self.p_win:
            p_monitor = self.p_win.get_screen().get_monitor_at_window(self.p_central.get_parent_window())
            self.config.set('presenter', 'monitor', str(p_monitor))
            cw = self.p_central.get_allocated_width()
            ch = self.p_central.get_allocated_height()
            self.scribbler.off_render.set_size_request(cw, ch)

        elif widget is self.c_win:
            c_monitor = self.c_win.get_screen().get_monitor_at_window(self.c_frame.get_parent_window())
            self.config.set('content', 'monitor', str(c_monitor)) 
开发者ID:Cimbali,项目名称:pympress,代码行数:19,代码来源:ui.py

示例8: on_pane_event

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_pane_event(self, widget, evt):
        """ Signal handler for gtk.paned events.

        This function allows one to delay drawing events when resizing, and to speed up redrawing when
        moving the middle pane is done (which happens at the end of a mouse resize)

        Args:
            widget (:class:`~Gtk.Widget`):  the widget in which the event occurred (ignored)
            evt (:class:`~Gdk.Event`):  the event that occurred
        """
        if type(evt) == Gdk.EventButton and evt.type == Gdk.EventType.BUTTON_RELEASE:
            self.redraw_panes()
        elif type(evt) == GObject.GParamSpec and evt.name == "position":
            self.resize_panes = True
            if self.redraw_timeout:
                GLib.Source.remove(self.redraw_timeout)
            self.redraw_timeout = GLib.timeout_add(200, self.redraw_panes)


    ############################################################################
    ############################  Program lifetime  ############################
    ############################################################################ 
开发者ID:Cimbali,项目名称:pympress,代码行数:24,代码来源:ui.py

示例9: on_drag_drop

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_drag_drop(self, widget, drag_context, x, y, data, info, time):
        """ Receive the drag-drops (as text only). If a file is dropped, open it.

        Args:
            widget (:class:`~Gtk.Widget`): The widget on which the dragged item was dropped
            drag_context (:class:`~Gdk.DragContext`):
            x (`float`): position of the drop
            y (`float`):  position of the drop
            data (:class:`~Gtk.SelectionData`): container for the dropped data
            info (`int`): info on the target
            time (`int`): time of the drop
        """
        received = data.get_text()
        if received.startswith('file://'):
            received = received[len('file://'):]

        if os.path.isfile(received) and received.lower().endswith('.pdf'):
            self.swap_document(os.path.abspath(received)) 
开发者ID:Cimbali,项目名称:pympress,代码行数:20,代码来源:ui.py

示例10: on_scroll

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def on_scroll(self, widget, event):
        """ Manage scroll events.

        Args:
            widget (:class:`~Gtk.Widget`):  the widget in which the event occurred (ignored)
            event (:class:`~Gdk.Event`):  the event that occurred

        Returns:
            `bool`: whether the event was consumed
        """
        if event.type != Gdk.EventType.SCROLL:
            return False

        # send to spinner if it is active
        elif self.page_number.on_scroll(widget, event):
            return True
        elif self.annotations.on_scroll(widget, event):
            return True
        else:
            return False 
开发者ID:Cimbali,项目名称:pympress,代码行数:22,代码来源:ui.py

示例11: track_clicks

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def track_clicks(self, widget, event):
        """ Track mouse press and release events.

        Handles clicks on the slides.

        Args:
            widget (:class:`~Gtk.Widget`):  the widget that received the click
            event (:class:`~Gdk.Event`):  the GTK event containing the click position

        Returns:
            `bool`: whether the event was consumed
        """
        if self.zoom.toggle_zoom_target(widget, event):
            return True
        elif self.scribbler.toggle_scribble(widget, event):
            return True
        elif self.laser.toggle_pointer(widget, event):
            return True
        else:
            return self.click_link(widget, event) 
开发者ID:Cimbali,项目名称:pympress,代码行数:22,代码来源:ui.py

示例12: track_scribble

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def track_scribble(self, widget, event):
        """ Draw the scribble following the mouse's moves.

        Args:
            widget (:class:`~Gtk.Widget`):  the widget which has received the event.
            event (:class:`~Gdk.Event`):  the GTK event.

        Returns:
            `bool`: whether the event was consumed
        """
        if self.scribble_drawing:
            self.scribble_list[-1][2].append(self.get_slide_point(widget, event))

            self.redraw_current_slide()
            return True
        else:
            return False 
开发者ID:Cimbali,项目名称:pympress,代码行数:19,代码来源:scribble.py

示例13: toggle_scribble

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def toggle_scribble(self, widget, event):
        """ Start/stop drawing scribbles.

        Args:
            widget (:class:`~Gtk.Widget`):  the widget which has received the event.
            event (:class:`~Gdk.Event`):  the GTK event.

        Returns:
            `bool`: whether the event was consumed
        """
        if not self.scribbling_mode:
            return False

        if event.get_event_type() == Gdk.EventType.BUTTON_PRESS:
            self.scribble_list.append((self.scribble_color, self.scribble_width, []))
            self.scribble_drawing = True

            return self.track_scribble(widget, event)
        elif event.get_event_type() == Gdk.EventType.BUTTON_RELEASE:
            self.scribble_drawing = False
            return True

        return False 
开发者ID:Cimbali,项目名称:pympress,代码行数:25,代码来源:scribble.py

示例14: track_zoom_target

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def track_zoom_target(self, widget, event):
        """ Draw the zoom's target rectangle.

        Args:
            widget (:class:`~Gtk.Widget`):  the widget which has received the event.
            event (:class:`~Gdk.Event`):  the GTK event.

        Returns:
            `bool`: whether the event was consumed
        """
        if self.zoom_selecting and self.zoom_points:
            self.zoom_points[1] = self.get_slide_point(widget, event)

            self.redraw_current_slide()
            return True

        return False 
开发者ID:Cimbali,项目名称:pympress,代码行数:19,代码来源:extras.py

示例15: open_folder_prompt_create

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Widget [as 别名]
def open_folder_prompt_create(widget, folder):
	'''Open a folder and prompts to create it if it doesn't exist yet.
	@param widget: parent for new dialogs, C{Gtk.Widget} or C{None}
	@param folder: a L{Folder} object
	'''
	try:
		open_folder(widget, folder)
	except FileNotFoundError:
		if QuestionDialog(widget, (
			_('Create folder?'),
				# T: Heading in a question dialog for creating a folder
			_('The folder "%s" does not yet exist.\nDo you want to create it now?') % folder.basename
				# T: Text in a question dialog for creating a folder, %s will be the folder base name
		)).run():
			folder.touch()
			open_folder(widget, folder) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:18,代码来源:applications.py


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