Python gi.repository.Gdk 模块,Cursor() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用gi.repository.Gdk.Cursor()

项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def multithread(handler):
    """Multithread decorator"""
    def action(*args, **kwargs):
        with global_threading_lock:
            try:
                result = handler(*args, **kwargs)
                GLib.idle_add(on_done, result, args[0])
            except Exception as e:
                print("Error in multithreading:\n%s" % str(e))

    def on_done(result, inst):
        set_cursor(inst)
        if callable(result):
            result()

    def wrapper(*args, **kwargs):
        set_cursor(args[0], Gdk.Cursor(Gdk.CursorType.WATCH))

        thread = threading.Thread(target=action, args=args, kwargs=kwargs)
        thread.daemon = True
        thread.start()

    return wrapper
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def toggle_cursor(widget, hide=False):
  window = widget.get_window()

  if window:
    blank  = Gdk.CursorType.BLANK_CURSOR
    cursor = Gdk.Cursor(blank) if hide else None
    GLib.idle_add(window.set_cursor, cursor)
项目:sticky-notes    作者:rubyAce71697    | 项目源码 | 文件源码
def on_textview2_motion_notify_event( self, widget, event):
        logger.info("Mouse moving in text view")
        """ used to change cursors pointer when mouse over a link.
        Changed from http://download.gna.org/nfoview/doc/api/nfoview.view_source.html
        as returns False now so we can still select content """
        window = Gtk.TextWindowType.WIDGET
        x, y = widget.window_to_buffer_coords(window, int(event.x), int(event.y))
        logger.debug("cordinates: " + str(x) + " " + str(y))
        window = widget.get_window(Gtk.TextWindowType.TEXT)
        for tag in widget.get_iter_at_location(x, y).get_tags():
            logger.debug(" in loop tag = " + tag.url)
            #print event.get_state()
            if hasattr(tag, "url") and event.get_state() == Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD2_MASK:
                logger.debug(" Cordinates have tag url")
                window.set_cursor(Gdk.Cursor(cursor_type=Gdk.CursorType.HAND2))
                return False # to not call the default handler.
        window.set_cursor(Gdk.Cursor(cursor_type=Gdk.CursorType.XTERM))

        return False
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def set_wait_cursor(self):
        self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
        while Gtk.events_pending():
            Gtk.main_iteration()
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def set_normal_cursor(self):
        self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW))
        while Gtk.events_pending():
            Gtk.main_iteration()
项目:national-geographic-wallpaper    作者:atareao    | 项目源码 | 文件源码
def set_autostart_activate(self):
        if self.switch.get_active():
            self.croni.set_jobs()
            self.autostart.set_autostart(True)
            self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
            change_wallpaper()
            self.get_window().set_cursor(None)
        else:
            self.croni.unset_jobs()
            self.autostart.set_autostart(False)
项目:national-geographic-wallpaper    作者:atareao    | 项目源码 | 文件源码
def change_wallpaper(self):

        def on_change_wallpaper_done(result, error):
            self.get_window().set_cursor(None)

        @async_function(on_done=on_change_wallpaper_done)
        def do_change_wallpaper_in_thread():
            self.save_preferences()
            change_wallpaper()
            return True

        self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
        do_change_wallpaper_in_thread()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def on_motion_notify(self, event):
        if event.is_hint:
            window, x, y, state = event.window.get_device_position(event.device)
        else:
            x, y, state = event.x, event.y, event.state
        dot_widget = self.dot_widget
        item = dot_widget.get_url(x, y)
        if item is None:
            item = dot_widget.get_jump(x, y)
        if item is not None:
            dot_widget.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2))
            dot_widget.set_highlight(item.highlight)
        else:
            dot_widget.get_window().set_cursor(None)
            dot_widget.set_highlight(None)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def start(self):
        self.dot_widget.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.FLEUR))
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def _busy_start(self):
        '''
        Show that this program is busy
        '''
        self._spinner.start()
        # self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
        # Gdk.flush()
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def _busy_stop(self):
        '''
        Stop showing that this program is busy
        '''
        self._spinner.stop()
        # self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW))
项目:keepass-menu    作者:frostidaho    | 项目源码 | 文件源码
def _grab_seat(seat, win, cursor_type=CursorType.CROSSHAIR):
    "Grab the pointers and keyboard"
    cursor = Gdk.Cursor(cursor_type)
    prep_func = None
    prep_data = None
    events = None
    # capabilities = Gdk.SeatCapabilities.ALL_POINTING
    capabilities = (Gdk.SeatCapabilities.ALL_POINTING |
                    Gdk.SeatCapabilities.KEYBOARD)
    owner_events = False
    gb = seat.grab(win, capabilities, owner_events, cursor, events,
                   prep_func, prep_data)
    return gb