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