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


Python Gdk.Event方法代码示例

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


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

示例1: on_pointer_motion

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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

示例2: on_pointer_motion

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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

示例3: on_pointer_motion

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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

示例4: test_button_click

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [as 别名]
def test_button_click(self):
        """Click mouse button."""
        self.vimiv["library"].file_select(None, Gtk.TreePath(1), None, True)
        image_before = self.vimiv.get_path()
        event = Gdk.Event().new(Gdk.EventType.BUTTON_PRESS)
        event.button = 1
        self.vimiv["window"].emit("button_press_event", event)
        image_after = self.vimiv.get_path()
        self.assertNotEqual(image_before, image_after)
        # Double click should not work
        event = Gdk.Event().new(Gdk.EventType.DOUBLE_BUTTON_PRESS)
        event.button = 1
        self.vimiv["window"].emit("button_press_event", event)
        self.assertEqual(image_after, self.vimiv.get_path())
        # Focus library via mouse click
        event = Gdk.Event().new(Gdk.EventType.BUTTON_PRESS)
        event.button = 2
        self.vimiv["window"].emit("button_press_event", event)
        self.assertTrue(self.vimiv["library"].is_focus()) 
开发者ID:karlch,项目名称:vimiv,代码行数:21,代码来源:eventhandler_test.py

示例5: on_quit1_activate

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [as 别名]
def on_quit1_activate(self, widget, *args):
        perspective = perspective_manager.get_perspective("games")
        if isinstance(widget, Gdk.Event):
            if len(perspective.gamewidgets) == 1 and conf.get("hideTabs"):
                gmwidg = perspective.cur_gmwidg()
                perspective.closeGame(gmwidg, gmwidg.gamemodel)
                return True
            elif len(perspective.gamewidgets) >= 1 and conf.get("closeAll"):
                perspective.closeAllGames(perspective.gamewidgets)
                return True
        if perspective.closeAllGames(perspective.gamewidgets) in (
                Gtk.ResponseType.OK, Gtk.ResponseType.YES):
            ICLogon.stop()
            self.app.loop.stop()
            self.app.quit()
        else:
            return True

    # View Menu 
开发者ID:pychess,项目名称:pychess,代码行数:21,代码来源:Main.py

示例6: on_configure_da

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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 Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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 Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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_scroll

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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

示例10: track_motions

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [as 别名]
def track_motions(self, widget, event):
        """ Track mouse motion events.

        Handles mouse motions on the "about" menu.

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

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

示例11: track_scribble

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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

示例12: toggle_scribble

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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

示例13: on_scroll

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [as 别名]
def on_scroll(self, widget, event):
        """ Try scrolling the annotations window.

        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
        """
        adj = self.scrolled_window.get_vadjustment()
        if event.direction == Gdk.ScrollDirection.UP:
            adj.set_value(adj.get_value() - adj.get_step_increment())
        elif event.direction == Gdk.ScrollDirection.DOWN:
            adj.set_value(adj.get_value() + adj.get_step_increment())
        else:
            return False
        return True 
开发者ID:Cimbali,项目名称:pympress,代码行数:20,代码来源:extras.py

示例14: track_zoom_target

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [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: on_button_press

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Event [as 别名]
def on_button_press(self, _dummy, event):
        """
        Called when a mouse button is clicked.
        @param _dummy: This widget.  Unused.
        @type _dummy: Gtk.Widget
        @param event: An event.
        @type event: Gdk.Event
        """
        if (event.button == 1 and
                event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS and
                self.__active != -1):
            self.emit('clicked', self.__active) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:14,代码来源:dna.py


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