python类Cursor()的实例源码

multithread.py 文件源码 项目:ACYLS 作者: worron 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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
gtk.py 文件源码 项目:kickoff-player 作者: jonian 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
stickies.py 文件源码 项目:sticky-notes 作者: rubyAce71697 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
whereami.py 文件源码 项目:my-weather-indicator 作者: atareao 项目源码 文件源码 阅读 43 收藏 0 点赞 0 评论 0
def set_wait_cursor(self):
        self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
        while Gtk.events_pending():
            Gtk.main_iteration()
whereami.py 文件源码 项目:my-weather-indicator 作者: atareao 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:national-geographic-wallpaper 作者: atareao 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:national-geographic-wallpaper 作者: atareao 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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()
xdot.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
xdot.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def start(self):
        self.dot_widget.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.FLEUR))
emoji_picker.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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()
emoji_picker.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
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))
autotype.py 文件源码 项目:keepass-menu 作者: frostidaho 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号