示例#1
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    print("Press Ctrl+Shift+A any where. Ctrl+Shift+E exits the app.")

    # Setup a global keyboard shortcut to print "Hello World" on pressing
    # the shortcut
    keybinder.init()

    def callback():
        print("hello world")
    def exit_app():
        window.close()
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+E", exit_app)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    app.exec_()
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+E")
示例#2
0
文件: tray.py 项目: sailist/QJango
    def __init__(self):
        sys.excepthook = self.excepthook
        self.app = QApplication([])
        self.app.setQuitOnLastWindowClosed(False)
        self.icon = QIcon("./src/favicon.ico")

        self.tray = QSystemTrayIcon()
        self.tray.setIcon(self.icon)
        self.tray.setVisible(True)
        self.tray.messageClicked.connect(lambda *args: print(args))

        self.menu = QMenu()
        self._actions = []
        quit = QAction("Quit")
        quit.triggered.connect(self.app.quit)
        self._actions.append(quit)
        # self.menu.addAction(quit)
        self.tray.setContextMenu(self.menu)

        keybinder.init()
        self.win_event_filter = WinEventFilter(keybinder)
        self.event_dispatcher = QAbstractEventDispatcher.instance()
        self.event_dispatcher.installNativeEventFilter(self.win_event_filter)

        handler.on(GEvents.on_make_toast, self.on_make_toast)
示例#3
0
def main():
    default_settings = {
        "window_height": "all",  # all, half
        "result_format": "latex",  # latex, word
        "use_dev_api": False,
        "shot_hot_key": "Alt+D",
        "ocr_hot_key": "Alt+S",
        "link": "",  # "",
        "account": "",  # 手机号或者开发者账号
        "passwd": ""  # 动态密码或者开发者密码
    }
    welcom_msg = '''
    Pacoo 公式识别桌面版
    【在 2020.10.31 下载使用本软件可向客服(微信号:pacoo1614)领取66次免费识别次数。】
    
    使用说明:
    1. 按下快捷键:Alt+D
    2. 框出要识别的公式
    3. 在需要插入公式的地方粘贴
    '''
    print(welcom_msg)
    op.play_sound("welcome")
    try:
        homeDir = os.path.expanduser("~")
        with open(homeDir + "\\pacoo.conf", "r") as f:
            settings = json.load(f)
    except:
        settings = default_settings
    app = QApplication(sys.argv)
    window = MyWin(settings)

    keybinder.init()
    unregistered = False

    def callback():
        print("hello world")

    def start_oct():
        window.click_btn()

    def exit_app():
        window.close()

    def unregister():
        keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
        print("unregister and register previous binding")
        keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)

    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)
    keybinder.register_hotkey(window.winId(), "Alt+D", start_oct)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    sys.exit(app.exec_())
示例#4
0
    def run(self):
        """Start application loop."""
        # Install a native event filter to receive events from the OS
        win_event_filter = WinEventFilter(self.keybinder)
        event_dispatcher = QAbstractEventDispatcher.instance()
        event_dispatcher.installNativeEventFilter(win_event_filter)

        self._timer_window.show()
        self.exec_()
示例#5
0
def activeHotkeys(h1, h2, h3, h4):
    keybinder.register_hotkey(window.winId(), h1,
                              window.widget.getMousePosition)
    keybinder.register_hotkey(window.winId(), h2, stopAction)
    keybinder.register_hotkey(window.winId(), h3, start)
    keybinder.register_hotkey(window.winId(), h4, exit_app)
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)
示例#6
0
文件: qtapp.py 项目: codito/pomito
    def run(self):
        """Start application loop."""
        # Install a native event filter to receive events from the OS
        win_event_filter = WinEventFilter(self.keybinder)
        event_dispatcher = QAbstractEventDispatcher.instance()
        event_dispatcher.installNativeEventFilter(win_event_filter)

        self._timer_window.show()
        self.exec_()
示例#7
0
def main():
    app = QApplication(sys.argv)
    keybinder.init()
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window = MainWindow()
    window.show()
    sys.exit(app.exec_())
示例#8
0
    def on_quit(self):
        if self.worker.quit:
            return

        print(self.name, "WorkerFacade.on_quit()")
        # This signal won't be received until all work is done!!!!
        self.sig_quit_requested.emit()

        # Thus notify worker via sidechannel to stop doing it's job
        self.worker.quit = True

        # waiting for the thread to finish
        print(self.name, "evdi waiting")
        evdi = QAbstractEventDispatcher.instance()
        while self.thread.wait(10) is False:
            evdi.processEvents(QEventLoop.AllEvents)
        print(self.name, "evdi waiting: done")
示例#9
0
    def on_quit(self):
        if self.worker.quit:
            return

        print(self.name, "WorkerFacade.on_quit()")
        # This signal won't be received until all work is done!!!!
        self.sig_quit_requested.emit()

        # Thus notify worker via sidechannel to stop doing it's job
        self.worker.quit = True

        # waiting for the thread to finish
        print(self.name, "evdi waiting")
        evdi = QAbstractEventDispatcher.instance()
        while self.thread.wait(10) is False:
            evdi.processEvents(QEventLoop.AllEvents)
        print(self.name, "evdi waiting: done")
示例#10
0
    def create_shortcut_connections(self):
        keybinder.init()
        # Are certain keys impossible to shortcut with pyqtkeybind
        # keybinder.register_hotkey(self.winId(), "MediaTogglePlayPause", self.music_control_box.toggle_play_pause)
        # keybinder.register_hotkey(self.winId(), "MediaPlay", self.music_control_box.play_button.plb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaPause", self.music_control_box.pause_button.pb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaNext", self.music_control_box.next_button.nb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaPrevious", self.music_control_box.previous_button.prb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaStop", self.music_control_box.stop_button.sb_clicked)

        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Home", self.music_control_box.toggle_play_pause)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Up", self.music_control_box.volume_slider.increase_volume)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Down", self.music_control_box.volume_slider.decrease_volume)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Right", self.music_control_box.next_button.nb_clicked)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Left", self.music_control_box.previous_button.prb_clicked)

        self.win_event_filter = util.WinEventFilter(keybinder)
        self.event_dispatcher = QAbstractEventDispatcher.instance()
        self.event_dispatcher.installNativeEventFilter(self.win_event_filter)
示例#11
0
def main() -> None:
    import sys

    app = QApplication(sys.argv)
    screen_count = QDesktopWidget().screenCount()

    info_app = InfoPad(screen_count)

    # Register hotkeys
    keybinder.init()
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F13", info_app.grid_sd)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F14", info_app.grid_su)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F15", info_app.grid_9)

    keybinder.register_hotkey(info_app.winId(), "Ctrl+F16", info_app.grid_1)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F17", info_app.grid_2)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F18", info_app.grid_3)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F19", info_app.grid_4)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F20", info_app.grid_5)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F21", info_app.grid_6)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F22", info_app.grid_7)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F23", info_app.grid_8)

    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F13", info_app.grid_home)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F14", info_app.grid_mm)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F15", info_app.grid_ou)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F16", info_app.grid_od)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F17", info_app.grid_view_o)

    # Install native event filter
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    # If three monitors detected, move window to thirds screen and make it fullscreen
    if screen_count == 3:
        monitor = QDesktopWidget().screenGeometry(2)
        info_app.move(monitor.left(), monitor.top())
        info_app.showFullScreen()

    sys.exit(app.exec_())
示例#12
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    print("Sample app for pyqtkeybind:")
    print("\tPress Ctrl+Shift+A any where to trigger a callback.")
    print("\tCtrl+Shift+F unregisters and re-registers previous callback.")
    print("\tCtrl+Shift+E exits the app.")

    # Setup a global keyboard shortcut to print "Hello World" on pressing
    # the shortcut
    keybinder.init()
    unregistered = False

    def callback():
        print("hello world")

    def exit_app():
        window.close()

    def unregister():
        keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
        print("unregister and register previous binding")
        keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)

    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+E", exit_app)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F", unregister)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    app.exec_()
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+E")
示例#13
0
def main():
    import sys

    app = QApplication(sys.argv)

    widget = MyWidget()
    win = MainWindow(widget)

    def callback():
        widget.show()

    if 'Darwin' not in platform.system():
        from pyqtkeybind import keybinder
        keybinder.init()
        keybinder.register_hotkey(win.winId(), "Ctrl+Shift+1", callback)

        # Install a native event filter to receive events from the OS
        win_event_filter = WinEventFilter(keybinder)
        event_dispatcher = QAbstractEventDispatcher.instance()
        event_dispatcher.installNativeEventFilter(win_event_filter)

        keybinder.unregister_hotkey(win.winId(), 0x0, 0x0)
    sys.exit(app.exec())
def main():
    global tagselector
    app = QApplication(sys.argv)
    nonShownMainWindow = QMainWindow()
    print('Tag File is at: "%s"' % TAGFILE)
    print('global shortcut to raise the tag selector window is: "%s"' %
          GLOBAL_SHOW_HOTKEY)

    tagselector = FuzzySearchDialog()
    tagselector.show()  #initial loading takes quite long so do it now
    tagselector.hide()

    #when I extracted this to a new class and a different file this didn't work in 2019-05.
    keybinder.init()
    filter = WinEventFilter(keybinder)
    keybinder.register_hotkey(nonShownMainWindow.winId(), GLOBAL_SHOW_HOTKEY,
                              onGlobalShowHotkey)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(filter)

    app.exec_()
    keybinder.unregister_hotkey(nonShownMainWindow.winId(),
                                GLOBAL_SHOW_HOTKEY)  #necessary?
示例#15
0
def main():
    logging.config.fileConfig("conf/logging.conf")
    app = qt.QApplication(sys.argv)
    window = QuickAddWindow(NotionNotesRepository(sys.argv[1]))

    keybinder.init()
    set_global_shortcut(window, "Ctrl+T")
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()

    menu = QMenu()
    quit_action = menu.addAction("Quit")
    quit_action.triggered.connect(app.quit)

    icon = QIcon("media/icon.png")
    tray_icon = qt.QSystemTrayIcon(icon, parent=app)
    tray_icon.setToolTip("An amazing quick add for notion")
    tray_icon.show()
    tray_icon.setContextMenu(menu)

    sys.exit(app.exec_())
示例#16
0
文件: qtutils.py 项目: yssoe/splash
 def __init__(self, *args):
     super(QApp, self).__init__(*args)
     if verbose:
         disp = QAbstractEventDispatcher.instance()
         disp.aboutToBlock.connect(self.aboutToBlock)
         disp.awake.connect(self.awake)
示例#17
0
if __name__ == "__main__":
    app = QApplication(sys.argv)

    hotkeysList = getHotkeys()
    window = MainWindow()

    def add(item):
        window.addItem(item)

    def start():
        window.startButton.click()

    def stopAction():
        window.thStop()

    def exit_app():
        window.stop_threads = True
        window.close()
        sys.exit(app.exec())

    keybinder.init()
    activeHotkeys(*hotkeysList)

    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    sys.exit(app.exec())
    deactiveHotkeys(*hotkeysList)
示例#18
0
 def __del__(self):
     QAbstractEventDispatcher.instance().removeNativeEventFilter(self)
示例#19
0
 def __init__(self, hotKey=None):
     QAbstractNativeEventFilter.__init__(self)
     QAbstractEventDispatcher.instance().installNativeEventFilter(self)
     self.hotKey = hotKey
     self.enable = True
     self.count = 0
示例#20
0
def main():
    # sys._excepthook = sys.excepthook
    #
    # def exception_hook(exctype, value, traceback):
    #     print(exctype, value, traceback)
    #     sys._excepthook(exctype, value, traceback)
    #     sys.exit(1)
    #
    # sys.excepthook = exception_hook

    app = QtWidgets.QApplication(sys.argv)
    window = MainWindow()

    print(
        "This will show a quick view of your keybindings (corsair only currently)."
    )
    print("Until I can figure out how to hide this window, just minimize it.")
    print("\tPress Ctrl+Shift+F10 any where to trigger a callback.")
    # print("\tCtrl+Shift+F unregisters and re-registers previous callback.")
    print("\tCtrl+Shift+E exits the app.")

    # Setup a global keyboard shortcut to print "Hello World" on pressing
    # the shortcut
    keybinder.init()
    unregistered = False

    def on_toggle():

        global latch
        nonlocal window

        if latch:
            window.show()
            latch = False
            print("worked On")
        else:
            window.hide()
            latch = True
            print("worked Off")

    def exit_app():
        window.close()

    def unregister():
        keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F10")
        print("unregister and register previous binding")
        keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F10", on_toggle)

    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F10", on_toggle)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+E", exit_app)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F", unregister)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    app.exec_()
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F10")
    # keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+E")
示例#21
0
 def __init__(self, *args):
     super(QApp, self).__init__(*args)
     if verbose:
         disp = QAbstractEventDispatcher.instance()
         disp.aboutToBlock.connect(self.aboutToBlock)
         disp.awake.connect(self.awake)