Example #1
0
    def new_session_dialog(self):
        """Show the layout-selection dialog"""
        try:
            # Prompt the user for a new layout
            dialog = LayoutSelect()
            if dialog.exec_() != QDialog.Accepted:
                if self._layout is None:
                    # If the user close the dialog, and no layout exists
                    # the application is closed
                    self.finalize()
                    qApp.quit()
                    exit()
                else:
                    return

            # If a valid file is selected load it, otherwise load the layout
            if exists(dialog.filepath):
                self._load_from_file(dialog.filepath)
            else:
                self._new_session(dialog.selected())

        except Exception as e:
            logging.exception('Startup error', e)
            qApp.quit()
            exit(-1)
Example #2
0
 def click_menu(self, menu_id, state):
     if menu_id == "quit":
         qApp.quit()
     elif menu_id == "wizard":
         pass
     elif menu_id == "about":
         pass
     elif menu_id == "settings":
         self.showSettingView.emit()
     elif menu_id == "lang":
         src_lang = setting_config.get_translate_config("src_lang")
         dst_lang = setting_config.get_translate_config("dst_lang")
         setting_config.update_translate_config("src_lang", dst_lang)
         setting_config.update_translate_config("dst_lang", src_lang)
         
         self.menu.setItemText("lang", self.get_lang_value())
         
         setting_view.updateLang.emit()
     else:
         if menu_id == "pause":
             if not state:
                 delete_selection()
             
             self.set_menu_active(state)    
             
         setting_config.update_trayicon_config(menu_id, state)
         
         self.set_trayicon()
Example #3
0
    def parse(self, argv):  # NEED: RFC
        args = self._psArg.parse(argv[1:])
        self._psArg.apply(args)  # Set gvars
        cfg = yml.parse(yml.G_CONFIG_PATH)
        self.sty = yml.parse(yml.G_STYLE_PATH)

        if args.kill:
            print("kill:")
            self.quit.emit()

        self._psArg.apply(args)  # Set gvars
        self._set_args_from_command_line(cfg, args)

        entries = args.buds if args.buds else str(cfg['Bud']['default'])
        Bud_Ps = BudParser()
        try:
            bud = Bud_Ps.parse(entries)
        except BudError as e:
            print("Error:", e)
            if not self.bud:  # NOTE: work must go on if client args are bad
                qApp.quit()

        # TODO: Make 'bReload' as tuple to distinguish necessary refreshes.
        bReload = {}
        bReload['toggle'] = bool(0 == len(argv))
        bReload['Window'] = bool(self.cfg and cfg['Window'] != self.cfg['Window'])

        self.cfg = cfg
        self.bud = bud
        # TODO: ret whole new current state?
        return bReload
Example #4
0
 def keyPressEvent(self, e):
     # Tab, Space -- out of questions as used by Qt (and me in future)
     #   to choose/press UI elements
     if e.key() in [Qt.Key_Escape, Qt.Key_Return]:
         qApp.quit()
     if e.modifiers() == Qt.ShiftModifier and e.key() == Qt.Key_K:
         print("K")
         e.accept()
Example #5
0
 def contextMenuEvent(self, event):
   cmenu = QMenu(self)
   newAct = cmenu.addAction("New")
   opnAct = cmenu.addAction("Open")
   quitAct = cmenu.addAction("Quit")
   action = cmenu.exec_(self.mapToGlobal(event.pos()))
   
   if action == quitAct:
     qApp.quit()
Example #6
0
    def exit(self):
        confirm = QMessageBox.Yes
        if not ActionsHandler().is_saved():
            confirm = QMessageBox.question(self, 'Exit',
                                           'The current session is not saved. '
                                           'Exit anyway?')

        if confirm == QMessageBox.Yes:
            qApp.quit()
Example #7
0
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("new")
        openAct = cmenu.addAction("open")
        quitAct = cmenu.addAction("quit")

        action = cmenu.exec(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
    def response(self, action):

        if action.text() == "Open Input File":
            self.set_input_image()
            #self.window.open_input_file()
        elif action.text() == "Open Target File":
            self.window.open_target_file()
        elif action.text() == "Save File":
            self.window.save_file()
        elif action.text() == "Exit":
            print("Exita basıldı.")
            qApp.quit()
Example #9
0
def pic_cache(url):
    if os.path.exists(f"cache/{url.split('/')[-1]}"):
        pass
    else:
        pic = requests.get(url).content
        try:
            with open(f"cache/{url.split('/')[-1]}", "wb") as f:
                f.write(pic)
        except Exception as e:
            print(e)
            qApp.quit()
    return f"cache/{url.split('/')[-1]}"
Example #10
0
    def contextMenuEvent(self, QContextMenuEvent):
        c_menu = QMenu(self)

        new_act = c_menu.addAction('New')
        opn_act = c_menu.addAction('Open')
        quit_act = c_menu.addAction('Quit')
        action = c_menu.exec_(self.mapToGlobal(QContextMenuEvent.pos()))
        # 使用exec_()方法显示上下文菜单, 从事件对象获取鼠标指针的坐标
        # 该mapToGlobal()方法将窗口小部件坐标转换为全局屏幕坐标

        if action == quit_act:  # 如果从上下文菜单返回的操作等于退出操作, 则终止应用程序
            qApp.quit()
    def response(self, action):

        if action.text() == "Dosya Aç":
            self.pencere.dosya_ac()

        elif action.text() == "Dosya Kaydet":
            self.pencere.dosya_kaydet()
        elif action.text() == "Dosyayı Temizle":
            self.pencere.yaziyi_temizle()

        elif action.text() == "Çıkış":
            qApp.quit()
Example #12
0
 def contextMenuEvent(self, event):
        cmenu = QMenu(self)
        # 新建菜单 ,在此方法内的菜单都会出现在右键菜单中
        newAct = cmenu.addAction("新建") 
        opnAct = cmenu.addAction("打开")
        quitAct = cmenu.addAction("退出")
        # 加入空白action, 
        action = cmenu.exec_(self.mapToGlobal(event.pos()))
        # 使用exec_()方法显示菜单. 从鼠标右键事件对象中获得当前坐标。
        # mapToGlobal()方法把当前组件的相对坐标转换为窗口(window)的绝对坐标
        if action == quitAct:
            qApp.quit()
Example #13
0
    def response(self, action):

        if action.text() == "Open File":
            self.windows.FileOpen()

        elif action.text() == "Save As":
            self.windows.FileSave()
        elif action.text() == "Clear File":
            self.windows.ClearTextArea()

        elif action.text() == "Exit":
            qApp.quit()
Example #14
0
 def contextMenuEvent(self, event):
     cmenu = QMenu(self)
     updateAct = cmenu.addAction("Update")
     quitAct = cmenu.addAction("Quit")
     showAct = cmenu.addAction('data')
     action = cmenu.exec_(self.mapToGlobal(event.pos()))
     if action == quitAct:
         qApp.quit()
     if action == updateAct:
         self.update()
     if action == showAct:
         self.display()
Example #15
0
    def response(self,action):
        if action.text()== "dosya aç":
            self.pencere.dosya_ac()

        elif action.text()== "dosya kaydet":
            self.pencere.dosya_kaydet()

        elif action.text()== "temizle":
            self.pencere.yazitemizle()

        elif action.text()=="çıkış":
            qApp.quit()
Example #16
0
    def keyPressEvent(self, e, gs=None):
        # Tab, Space -- out of questions as used by Qt (and me in future)
        #   to choose/press UI elements
        if e.key() in [Qt.Key_Escape, Qt.Key_Return]:
            qApp.quit()
        if e.modifiers() == Qt.ShiftModifier and e.key() == Qt.Key_K:
            print("K")
            e.accept()
        logger.info("{:x} + {:x}".format(int(e.modifiers()), int(e.key())))

        a = actions.get(gs.kmp.get( (int(e.modifiers()), int( e.key() )) ))
        if hasattr(a, '__call__'): a()
Example #17
0
    def contextMenuEvent(self, e):
        cmenu = QMenu(self)

        newAct = cmenu.addAction('New')
        saveAct = cmenu.addAction('Save')
        quitAct = cmenu.addAction('Exit')
        # apply exec_() method to show context menu
        # and obtain mouse position from event object
        # mapToGlobal() method will transfer widget coordinate to global screen coordinate
        action = cmenu.exec_(self.mapToGlobal(e.pos()))
        if action == quitAct:
            qApp.quit()
Example #18
0
    def contextMenuEvent(self, QContextMenuEvent):
        rightClickMenu = QMenu(self)
        newMenu = rightClickMenu.addAction("新建")
        exitAction = rightClickMenu.addAction("退出")
        exitAction1 = rightClickMenu.addAction(self.exitAction())

        # 监听点击事件
        # 右键菜单,这才是关键
        action = rightClickMenu.exec_(self.mapToGlobal(
            QContextMenuEvent.pos()))
        if action == exitAction:
            qApp.quit()
Example #19
0
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        opnAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        # 使用exec_()方法显示菜单,从鼠标右键事件对象中获得当前坐标,mapToGlobal()方法把当前组件的相对坐标转换为窗口
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        opnAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        action = cmenu.exec_(self.mapToGlobal(
            event.pos()))  # 从鼠标右键事件对象中获得当前坐标event.pos()。
        # mapToGlobal() 把当前组件的相对坐标转换为窗口(window)的绝对坐标。

        if action == quitAct:
            qApp.quit()
    def main_quit(self):
        """
        Shuts down the program (and threads) gracefully.
        :return:
        """

        if self._debug:
            print("DEBUG: Called main_quit")

        self._mainWindow.destroy()  # Close the window
        qApp.quit()  # Quit the application

        return 0
Example #22
0
    def contextMenuEvent(self, event):
        cmenu = QMenu(self)

        newAct = cmenu.addAction('New')
        opnAct = cmenu.addAction('Open')
        quitAct = cmenu.addAction('Quit')

        # 使用exec_()方法显示菜单。从鼠标右键事件对象中获得当前坐标。
        # mapToGlobal()方法把当前组件的相对坐标转换为窗口(window)的绝对坐标。
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        opnAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        action = cmenu.exec_(
            self.mapToGlobal(event.pos())
        )  #The mapToGlobal() method translates the widget coordinates to the global screen coordinates.

        if action == quitAct:
            qApp.quit()
Example #24
0
    def contextMenuEvent(self, event):
        cmenu = QMenu(self)

        newACt = cmenu.addAction("New")
        opnAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        #the context menu is displayed with the exec_().
        #get the coordinates of the mouse pointer from the event object
        #the mapToGlobal() method translates the widget coordinates to the global screen coordinates
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
Example #25
0
    def contextMenuEvent(self, event):
        """
        右键菜单事件
        """
        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        openAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
Example #26
0
 def closeEvent(self, QCloseEvent):
     reply = QMessageBox.question(self, '退出程序', "确认要退出吗?",
                                  QMessageBox.Yes | QMessageBox.No,
                                  QMessageBox.No)
     if reply == QMessageBox.Yes:
         self.sock.close()
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         sock.connect((serverIP, serverport))
         sock.send('logout{}'.format(self.uid).encode('utf-8'))
         QCloseEvent.accept()
         qApp.quit()
     else:
         QCloseEvent.ignore()
Example #27
0
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        opnAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
        elif action == opnAct:
            print('open something')
    def response(self, action):

        if action.text() == "Open File":
            self.window.open_file()

        elif action.text() == "Save file":
            self.window.save_file()

        elif action.text() == "Clear":
            self.window.cleanse()

        elif action.text() == "Quit":
            qApp.quit()
Example #29
0
    def contextMenuEvent(self, event):
        contextMenu = QMenu()
        newAct = contextMenu.addAction('New')
        openAct = contextMenu.addAction('Open')
        quitAct = contextMenu.addAction('Quit')

        action = contextMenu.exec_(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
        if action == newAct:
            pass
        if action == openAct:
            pass
Example #30
0
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        opnAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")

        # 使用exec_()方法显示菜单。从鼠标右键事件对象中获得当前坐标。mapToGlobal()方法把当前组件的相对坐标转换为窗口(window)的绝对坐标
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        # 如果右键菜单里触发了事件,也就触发了退出事件,执行关闭菜单行为
        if action == quitAct:
            qApp.quit()
    def closeWindow(self):
        self.enable_zone()
        unregister_service()
        self.close()

        if self._settings.showOSD:
            if not self._osdShowed:
                self.showHotKeyOSD()
            elif self._osdShowing:
                self._quitOnOsdTimeout = True
            else:
                qApp.quit()
        else:
            qApp.quit()
Example #32
0
    def contextMenuEvent(self, event):
        """
        Create a context menu that will show up on a right click anywhere in
        the window.
        """
        cmenu = QMenu(self)

        newAct = cmenu.addAction("&New")
        openAct = cmenu.addAction("&Open")
        quitAct = cmenu.addAction("&Quit")
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        if action == quitAct:
            qApp.quit()
Example #33
0
 def quitApplication(self):
     #Перед выходом необходимо удалить временную папку с проектом
     shutil.rmtree(os.path.join(self.projectDir, 'tmp'), ignore_errors=True)
     shutil.rmtree(os.path.join(self.projectDir, 'tmp2'),
                   ignore_errors=True)
     try:
         os.remove(
             os.path.join(self.projectDir, 'temporaryfilelogtodel.txt'))
     except Exception:
         pass
     if sys.platform == 'win32':
         qApp.quit()
     else:
         sys.exit()
Example #34
0
        def contextMenuEvent(self, event):
            """
            重写 contextMenuEvent 事件
            """
            # 创建菜单并绑定选项
            cmenu = QMenu(self)
            newAct = cmenu.addAction("New")
            opnAct = cmenu.addAction("Open")
            quitAct = cmenu.addAction("Quit")
            # 使菜单展示在鼠标右击的位置
            action = cmenu.exec_(self.mapToGlobal(event.pos()))

            if action == quitAct:
                qApp.quit()
Example #35
0
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction('New')
        opnAct = cmenu.addAction('Open')
        quitAct = cmenu.addAction('Quit')
        # to get the coordinates of mouse click
        # and thus display contextmenu accordingly
        action = cmenu.exec_(self.mapToGlobal(event.pos()))

        # defining the action outcome from the context menu
        if action == quitAct:
            qApp.quit()
Example #36
0
    def close_app(self):
        """Cierra completamente la aplicación.

        Primero se pregunta si se desea salir. Luego esconde el icono de bandeja y cierra la aplica-
        ción.
        """
        self.show()
        response = QuestionDialog.open_question("¿Deseas salir?",
                                                "¿Realmente deseas salir?",
                                                self)
        if response == 1:
            self.tray_icon.hide()
            qApp.quit()
        return
Example #37
0
    def contextMenuEvent(self, event):
        m = QMenu()
        new_action = m.addAction("New ...")
        find_action = m.addAction("Find ...")
        m.addSeparator()
        logout_action = m.addAction("Logout")
        quit_action = m.addAction("Shutdown")

        action = m.exec_(self.mapToGlobal(event.pos()))
        if action == new_action:
            self.on_factory()
        elif action == find_action:
            self.on_selector()
        elif action == quit_action:
            qApp.quit()
Example #38
0
 def contextMenuEvent(self, QContextMenuEvent):
     # print(QContextMenuEvent.pos())
     # print(QContextMenuEvent.x())
     # print(QContextMenuEvent.y())
     # print(self.mapToGlobal(QContextMenuEvent.pos()))
     # mapToGlobal 은 local 한 app 좌표에서 전체 화면으로 환산해줌
     # 순간적으로 menu라는 qwidget 을 화면에 띄운다고 생각하면 됨
     menu = QMenu(self)
     quit = menu.addAction("Quit")
     action = menu.exec_(self.mapToGlobal(QContextMenuEvent.pos()))
     print("action", action)
     print('quit', quit)
     if action == quit:
         qApp.quit()
         print('일치 ')
Example #39
0
    def impl(self):
        try:
            # Change the visibility of the *selected* layer
            self.o2.visible = False

            # Make sure the GUI is caught up on paint events
            QApplication.processEvents()

            # We must sleep for the screenshot to be right.
            time.sleep(0.1)

            self.w.repaint()

            screen = QGuiApplication.primaryScreen()

            # Capture the window before we change anything
            beforeImg = screen.grabWindow(self.w.winId()).toImage()

            # Change the visibility of the *selected* layer
            self.o2.visible = True

            self.w.repaint()

            # Make sure the GUI is caught up on paint events
            QApplication.processEvents()

            # We must sleep for the screenshot to be right.
            time.sleep(0.1)

            # Capture the window now that we've changed a layer.
            afterImg = screen.grabWindow(self.w.winId()).toImage()

            # Optional: Save the files so we can inspect them ourselves...
            # beforeImg.save('before.png')
            # afterImg.save('after.png')

            # Before and after should NOT match.
            assert beforeImg != afterImg
        except:
            # Catch all exceptions and print them
            # We must finish so we can quit the app.
            import traceback

            traceback.print_exc()
            TestLayerWidget.errors = True

        qApp.quit()
def _actionInvoked(notificationId, actionId):
    global view
    global _fileSaveLocation

    if _notificationId == notificationId:
        if actionId == ACTION_ID_OPEN:
            subprocess.call(["xdg-open", os.path.dirname(_fileSaveLocation)])
        view.closeWindow() if view else qApp.quit()
Example #41
0
 def click_menu(self, menu_id, state):
     if menu_id == "quit":
         qApp.quit()
     elif menu_id == "wizard":
         pass
     elif menu_id == "about":
         pass
     elif menu_id == "settings":
         self.showSettingView.emit()
     else:
         if menu_id == "pause":
             if not state:
                 delete_selection()
             
             self.set_menu_active(state)    
             
         setting_config.update_trayicon_config(menu_id, state)
Example #42
0
    def _layout_dialog(self):
        ''' Show the layout-selection dialog '''
        try:
            select = LayoutSelect()
            select.exec_()
        except Exception as e:
            QMessageBox.critical(None, 'Fatal error', str(e))
            qApp.quit()
            exit(-1)

        if select.result() != QDialog.Accepted:
            qApp.quit()
            exit()

        if exists(select.filepath):
            self._load_from_file(select.filepath)
        else:
            self._create_layout(select.slected())
Example #43
0
 def quitGame():
     #退出信号槽函数
     reply = QMessageBox.question(self,'问题','想要退出吗',QMessageBox.Yes,QMessageBox.No)
     if reply == QMessageBox.Yes:
         qApp.quit()
Example #44
0
 def closeEvent(self, ev):
     qApp.quit()
Example #45
0
 def quit(self):
     self.save_data()
     qApp.quit()
Example #46
0
 def onQuit(self, widget):
     qApp.quit()
Example #47
0
 def quit(self):
     app.quit()
Example #48
0
 def shutdown(self):  # TODO
     qApp.quit()
Example #49
0
 def on_quit(self):
     self.thread.tcp_server.event_loop.call_soon_threadsafe(self.thread.tcp_server.event_loop.stop)
     self.thread.join()
     self.mixer.mute(False)
     qApp.quit()
Example #50
0
 def _exit(self):
     if self._check_saved():
         qApp.quit()
Example #51
0
 def quit(self):
     for win in assets.windows:
         win.close()
     qApp.quit()
Example #52
0
 def onLeave(self, details):
     from twisted.internet import reactor
     if reactor.threadpool is not None:
         reactor.threadpool.stop()
     qApp.quit()
 def _handleOSDTimeout(self):
     self._osdShowing = False
     if self._quitOnOsdTimeout:
         qApp.quit()
Example #54
0
	def closeApp(self):
		self.tray.hide()
		qApp.quit()
Example #55
0
 def exit_app(self):
     qApp.quit()
Example #56
0
 def __onQuit(self):
     self.hide()
     qApp.quit()
     sys.exit(0)
Example #57
0
 def quit(self):
     self.__disconnect()
     qApp.quit()
 def _checkContexts(self):
     if (self.contexts) or self._osdVisible:
         self._quitTimer.start()
     else:
         qApp.quit()
def _notificationClosed( notificationId, reason):
    global view
    if _notificationId == notificationId:
        view.closeWindow() if view else qApp.quit()
Example #60
0
def quitApp():
    if qApp is not None:
        qApp.quit()