示例#1
0
 def __init__(self, name):
     """
     Creates a NexTThread instance with a name. If this is not the main thread, create a corresponding
     QThread and start it (i.e., the event loop).
     :param name: name of the thread
     """
     super().__init__()
     self._filters = {}
     self._filter2name = {}
     self._mockups = {}
     self._name = name
     try:
         self._profsrv = Services.getService("Profiling")
         if hasattr(self._profsrv, "data") and self._profsrv.data() is None:
             self._profsrv = None
     except KeyError:
         self._profsrv = None
     if not self.thread() is QCoreApplication.instance().thread():
         raise NexTInternalError("unexpected thread")
     if name == "main":
         self._qthread = QCoreApplication.instance().thread()
         self._qthread.setObjectName(name)
     else:
         self._qthread = self.ThreadWithCoverage(parent=self)
         self._qthread.setObjectName(name)
         self._qthread.start()
     self.moveToThread(self._qthread)
     self.cleanUpCalled = False
示例#2
0
    def __init__(self, title="", content="", _parent=None):
        super(DetailedView, self).__init__(overview.Overview.get_instance())

        self._parent = _parent
        self.widget_resolution = overview.Overview.get_instance().frameGeometry()

        QCoreApplication.instance()
        # init
        self.layout = QVBoxLayout()

        self.lable_title = QLabel(title)
        self.lable_content = QLabel(content)

        # font
        title_font = self.lable_title.font()
        title_font.setPixelSize(self.title_text_size)
        content_font = self.lable_content.font()
        content_font.setPixelSize(self.content_text_size)

        self.lable_title.setFont(title_font)
        self.lable_content.setFont(content_font)

        # layout
        self.layout.addWidget(self.lable_title)
        self.layout.addWidget(self.lable_content)

        self.setLayout(self.layout)

        # flags
        self.setMouseTracking(True)
示例#3
0
 def _execute(self):
     """Executes this task."""
     try:
         status = self._open_and_execute_project()
         QCoreApplication.instance().exit(status)
     except Exception:
         QCoreApplication.instance().exit(_Status.ERROR)
         raise
示例#4
0
 def onDone(self, output_file, loadOK):
     if not loadOK:
         print("Could not load page")
         return
     self.page().settings().setAttribute(
         QWebEngineSettings.ScreenCaptureEnabled, True)
     self.grab().save("page.png")
     QCoreApplication.instance().quit()
示例#5
0
 def _cancel_clicked(self):
     self._ok_to_close = True
     '''Close aborting any changes'''
     self.prefs['qt_geometry'] = self.saveGeometry().toHex().data().decode(
         'ascii')
     self.prefs['check_for_updates'] = self.checkbox_get_updates.isChecked()
     self.prefs['debug'] = self.checkbox_debug.isChecked()
     self.bk.savePrefs(self.prefs)
     QCoreApplication.instance().quit()
示例#6
0
 def activate(self):
     """
     puts this application to active
     :return: None
     """
     logger.internal("entering activate")
     self.unactivate()
     Application.activeApplication = ActiveApplication(self._graph)
     QCoreApplication.instance().aboutToQuit.connect(
         Application.activeApplication.shutdown)
     logger.internal("leaving activate")
示例#7
0
    def __init__(self, manager: "GameManager"):
        super().__init__()
        self.manager = manager
        self.open_app = []
        self.notifier = AutoNotifier()
        self.app_store = AppStore()
        self.tray_icon = TrayIcon(self)
        self.setting_dialog = SettingsDialog(self)
        self.tray_icon.show()

        QCoreApplication.instance().aboutToQuit.connect(self.on_before_quit)
        self.app_store.app_change.connect(self.tray_icon.update_menu)
        self.tray_icon.on_settings.connect(self.open_settings)
示例#8
0
 def __init__(self):
     self.boton_salir_login.clicked.connect(
         QCoreApplication.instance().quit)
     self.boton_salir_register.clicked.connect(
         QCoreApplication.instance().quit)
     self.boton_crear_sesion_login.clicked.connect(
         self.__event_show_crear_sesion)
     self.boton_volver_register.clicked.connect(self.__event_show_volver)
     self.boton_iniciar_sesion_login.clicked.connect(
         self.__event_iniciar_sesion)
     self.input_password_login.returnPressed.connect(
         self.__event_iniciar_sesion)
     self.input_email_login.returnPressed.connect(
         self.__event_iniciar_sesion)
示例#9
0
    def __init__(self, parent=None):
        super().__init__(parent)
        path = os.path.join('mygui', 'main.ui')
        file = QFile(path)
        file.open(QFile.ReadOnly)
        loader = QtUiTools.QUiLoader()
        self.window = loader.load(file, self)
        file.close()
        #return self.window
        #self.window = uic.loadUi(path, self)
        self.polzovatel = ''

        #создаём сокет
        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        #подключаемся к нужному адресу
        self.s.connect(('localhost', 8888))

        #назначим подксказки
        self.window.btn_login.setToolTip('Кнопка для заполнения списка.')
        self.window.textEdit.setToolTip('Окно для <b>выбранных</b> друзей.')

        #назначим действия для объектов
        self.window.btn_login.clicked.connect(self.login)
        self.window.contactView.clicked.connect(self.set_text)
        self.window.select_exit.toggled.connect(
            QCoreApplication.instance().quit)
        self.window.btn_add_friend.clicked.connect(self.add_friend)
示例#10
0
    def registerThread(self):
        """
        This slot shall be called from each activated nexxT thread with a direct connection.

        :return:
        """
        t = QThread.currentThread()
        logger.internal("registering thread %s", t.objectName())
        with self._lockThreadSpecific:
            if not t in self._threadSpecificProfiling:
                self._threadSpecificProfiling[t] = ThreadSpecificProfItem()
                self._threadSpecificProfiling[t].timer = QTimer(
                    parent=self.sender())
                self._threadSpecificProfiling[t].timer.timeout.connect(
                    self._generateRecord, Qt.DirectConnection)
                self._threadSpecificProfiling[t].timer.setInterval(
                    int(ThreadSpecificProfItem.THREAD_PROFILING_PERIOD_SEC *
                        1e3))
                self.stopTimers.connect(
                    self._threadSpecificProfiling[t].timer.stop)
                self.startTimers.connect(
                    self._threadSpecificProfiling[t].timer.start)
                if self._loadMonitoringEnabled:
                    self._threadSpecificProfiling[t].timer.start()

            tmain = QCoreApplication.instance().thread()
            if self._mi is None and not tmain in self._threadSpecificProfiling:
                self._mi = MethodInvoker(
                    dict(object=self, method="registerThread", thread=tmain),
                    Qt.QueuedConnection)
示例#11
0
	def refresh(self) -> None:
		"""
		Refresh the GUI to show the right widgets.
		
		:return: None
		:rtype: NoneType
		"""
		app = QCoreApplication.instance()
		
		self.sync()
		i=0
		for msg in self.allMessages:
			i+=1
			if msg.level in self.showLevels:
				if not msg.widget.isVisible():
					msg.widget.show()
					self._visibleCount += 1
				
			else:
				if msg.widget.isVisible():
					msg.widget.hide()
					self._visibleCount -= 1
				
			self.ui.messageCountLabel.setText(str(self._visibleCount))
			
			# process events every 10th iteration to not freeze GUI.
			if i % 10:
				app.processEvents()
示例#12
0
 def displayMessageIcon(self, text="", widget=None):
     text = self.text if text == "" else text
     if widget is None:
         app = QCoreApplication.instance()
         widget = app.activeWindow()
     dialog = QMessageBox(widget, text=text)
     dialog.show()
示例#13
0
    def start_sniffer_thread(self):
        """
        开启嗅探线程
        """
        # 测试当前是否是root用户
        if not OtherToolFunctionSet.test_root_permission():
            user_input = QMessageBox.information(
                self, '需要ROOT权限', '请以ROOT权限重启程序以运行嗅探功能。',
                QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
            if user_input == QMessageBox.Yes:
                # 退出应用程序
                QCoreApplication.instance().quit()
            else:
                return

        # 开启网卡混杂模式
        if_turn_promisc_on = QMessageBox.question(
            self, '需要开启网卡混杂模式', '嗅探功能需要开启网卡混杂模式,是否开启?',
            QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
        if if_turn_promisc_on == QMessageBox.Yes:
            if not OtherToolFunctionSet.turn_net_card_promisc(True):
                QMessageBox.information(self, '开启结果', '开启混杂模式失败。',
                                        QMessageBox.Yes, QMessageBox.Yes)
                return
        else:
            self.statusBar().showMessage('停止嗅探,需要开启网卡混杂模式。')
            return

        self.ui.sniffer_tip_label.setHidden(True)

        # 设置表格数据源
        self._table_model.clear()
        self.ui.sniffer_table.setModel(self._table_model)
        self._table_model.setHorizontalHeaderLabels(['IP', 'MAC'])
        self._table_model.setColumnCount(2)

        # 开启嗅探线程
        self._sniffer_tool = NetSnifferTool()
        self._sniffer_tool.start_sniffer_thread(self._table_model,
                                                self.ui.sniffer_table,
                                                self.statusBar(),
                                                self.ui.sniffer_start_button,
                                                self.ui.sniffer_stop_button)

        # 修改控件状态
        self.ui.sniffer_stop_button.setEnabled(True)
        self.ui.sniffer_start_button.setEnabled(False)
示例#14
0
def executeDialog(itemList):
    app = QCoreApplication.instance()
    if app is None:
        app = QApplication(title)
    w = selectDialog(itemList)
    w.exec_()

    return w.selectList
示例#15
0
 def testPythonSlot(self):
     self._sucess = False
     view = View()
     view.called.connect(self.done)
     view.show()
     QTimer.singleShot(300, QCoreApplication.instance().quit)
     self.app.exec_()
     self.assertTrue(self._sucess)
示例#16
0
 def setUpClass(cls):
     if not QCoreApplication.instance():
         QCoreApplication()
     else:
         # Undo stack's cleanChanged signals might still be on their way if we're running all Toolbox's tests.
         # Here they cause trouble because they try to invoke a method in non-existent ToolboxUI object.
         # To remedy the situation we purge all events from the event queue here.
         QCoreApplication.removePostedEvents(None)
示例#17
0
 def Button_clicks(
         self):  # all Button click define here And call Further function
     self.window.Browse_JSON.clicked.connect(self.browseJson)
     self.window.Browse_Student_List.clicked.connect(
         self.browseStudent_list)
     self.window.OK_btn.clicked.connect(self.save_data)
     self.window.Cancel_btn.clicked.connect(
         QCoreApplication.instance().quit)  # cancel button define
示例#18
0
 def testPythonSlot(self):
     self._sucess = False
     view = View()
     view.called.connect(self.done)
     view.show()
     QTimer.singleShot(300, QCoreApplication.instance().quit)
     self.app.exec_()
     self.assertTrue(self._sucess)
示例#19
0
 def run(self):
     count = 0
     app = QCoreApplication.instance()
     while count < 5:
         print("C Increasing")
         time.sleep(1)
         count += 1
     app.quit()
示例#20
0
    def initUI(self):
        qbtn = QPushButton("Quit", self)
        qbtn.clicked.connect(QCoreApplication.instance().quit)
        qbtn.resize(qbtn.sizeHint())
        qbtn.move(50, 50)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle("Quit Button")
        self.show()
示例#21
0
 def testBlockingSignal(self):
     app = QCoreApplication.instance() or QCoreApplication([])
     eventloop = QEventLoop()
     emitter = Emitter()
     receiver = Receiver(eventloop)
     emitter.connect(emitter, SIGNAL("signal(int)"),
                     receiver.receive, Qt.BlockingQueuedConnection)
     emitter.start()
     retval = eventloop.exec_()
     emitter.wait()
     self.assertEqual(retval, 0)
示例#22
0
 def testBlockingSignal(self):
     app = QCoreApplication.instance() or QCoreApplication([])
     eventloop = QEventLoop()
     emitter = Emitter()
     receiver = Receiver(eventloop)
     emitter.connect(emitter, SIGNAL("signal(int)"), receiver.receive,
                     Qt.BlockingQueuedConnection)
     emitter.start()
     retval = eventloop.exec_()
     emitter.wait(2000)
     self.assertEqual(retval, 0)
示例#23
0
 def donebox(self):
     msgbox = QMessageBox(
         QMessageBox.Warning,
         "Done!",
         "Do you want to quit?",
         buttons=QMessageBox.Yes | QMessageBox.No,
         parent=self,
     )
     open_result = msgbox.addButton("Open Result Folder",
                                    QMessageBox.AcceptRole)
     msgbox.setDefaultButton(QMessageBox.Yes)
     close_yn = msgbox.exec_()
     if close_yn == QMessageBox.No:
         self.threadclass.wait()
         # debugpy.debug_this_thread()
         self.close()
         self.par.intiGUI()
     else:
         if close_yn == QMessageBox.AcceptRole:
             self.open_result()
         QCoreApplication.instance().quit()
示例#24
0
    def initUI(self):

        self.setGeometry(300, 300, 300, 300)
        self.setWindowTitle('button')
        self.setWindowIcon(QIcon('icon.jpg'))

        qbu = QPushButton('exit', self)
        qbu.clicked.connect(QCoreApplication.instance().quit)
        qbu.resize(70, 30)
        qbu.move(50, 50)

        self.show()
示例#25
0
def load_icon(path: str) -> QIcon:
    path = os.path.abspath(
        os.path.dirname(__file__) + os.path.sep + "resources" + os.path.sep +
        path)

    # check if dark mode is enabled
    base_color = QCoreApplication.instance().palette().color(QPalette.Base)
    if base_color.lightnessF() < 0.5:
        file, ext = os.path.splitext(path)
        path = file + "-dark" + ext

    icon = QIcon(path)
    return icon
示例#26
0
    def testPythonSlot(self):
        self._sucess = False
        view = View()

        # Connect first, then set the property.
        view.called.connect(self.done)
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_847.qml', __file__)))
        view.rootObject().setProperty('pythonObject', view)

        view.show()
        # Essentially a timeout in case method invocation fails.
        QTimer.singleShot(2000, QCoreApplication.instance().quit)
        self.app.exec_()
        self.assertTrue(self._sucess)
示例#27
0
def showLanguageList():

    usage = QCoreApplication.instance().arguments()[0]
    usage += " --language <" + QCoreApplication.translate(
        "main", "language code") + ">"

    print(
        QCoreApplication.translate("main", "Usage: {0}").format(usage) + "\n")
    print(QCoreApplication.translate("main", "Languages:"))

    for translation in findTranslations():
        print("  {0}  {1}".format(languageCode(translation),
                                  languageDescription(translation)))

    return 0
示例#28
0
    def __init__(self, bk, prefs):
        super().__init__()

        self.bk = bk
        self.prefs = prefs
        self.update = False

        # Install translator for the DOCXImport plugin dialog.
        # Use the Sigil language setting unless manually overridden.
        plugin_translator = QTranslator()
        if prefs['language_override'] is not None:
            print('Plugin preferences language override in effect')
            qmf = '{}_{}'.format(bk._w.plugin_name.lower(),
                                 prefs['language_override'])
        else:
            qmf = '{}_{}'.format(bk._w.plugin_name.lower(), bk.sigil_ui_lang)
        print(
            qmf,
            os.path.join(bk._w.plugin_dir, bk._w.plugin_name, 'translations'))
        plugin_translator.load(
            qmf,
            os.path.join(bk._w.plugin_dir, bk._w.plugin_name, 'translations'))
        print(QCoreApplication.instance().installTranslator(plugin_translator))

        self._ok_to_close = False

        self.FTYPE_MAP = {
            'smap': {
                'title': _translate('App', 'Select custom style-map file'),
                'defaultextension': '.txt',
                'filetypes': 'Text Files (*.txt);;All files (*.*)',
            },
            'css': {
                'title': _translate('App', 'Select custom CSS file'),
                'defaultextension': '.css',
                'filetypes': 'CSS Files (*.css)',
            },
            'docx': {
                'title': _translate('App', 'Select DOCX file'),
                'defaultextension': '.docx',
                'filetypes': 'DOCX Files (*.docx)',
            },
        }

        # Check online github files for newer version
        if self.prefs['check_for_updates']:
            self.update, self.newversion = self.check_for_update()
        self.initUI()
示例#29
0
    def test_controller_and_worker_better(self):
        app = QCoreApplication.instance() or QCoreApplication(sys.argv)
        controller = Controller()
        controller.worker.finished.connect(QCoreApplication.quit,
                                           type=Qt.QueuedConnection)

        timeout_timer = QTimer(parent=controller)
        timeout_timer.setInterval(3000)
        timeout_timer.setSingleShot(True)
        timeout_timer.timeout.connect(lambda: QCoreApplication.exit(-1))
        timeout_timer.start()

        with patch.object(controller, "on_worker_result") as on_result:
            controller.start()
            self.assertEqual(0, app.exec_())
            self.assertEqual(20, len(on_result.mock_calls))
示例#30
0
    def _setup_menu(self):
        if not hasattr(self, "menu"):
            self.menu = QMenu("RuneKit")

        self.menu.clear()

        self._setup_app_menu("", self.menu)

        self.menu.addSeparator()
        self.menu_settings = self.menu.addAction("Settings")
        self.menu_settings.triggered.connect(self.on_settings)
        self.menu.addAction(
            QIcon.fromTheme("application-exit"),
            "Exit",
            lambda: QCoreApplication.instance().quit(),
        )
示例#31
0
	def clear(self) -> None:
		"""
		Clear all the information/messages in the view.
		
		:return: None
		:rtype: NoneType
		"""
		
		# clear messages and create new infrastructure for displaying messages.
		self.allMessages = []
		self.ui.centralWidget = QWidget()
		self.ui.messageLayout = QVBoxLayout()
		self.ui.messageLayout.addStretch()
		self.ui.centralWidget.setLayout(self.ui.messageLayout)
		self.ui.scrollArea.setWidget(self.ui.centralWidget)
		
		# Set color of the central widget to the application's base color
		color = QCoreApplication.instance().palette().color(QPalette.ColorRole.Base)
		palette = self.ui.centralWidget.palette()
		palette.setColor(QPalette.ColorRole.Background, color)
		self.ui.centralWidget.setAutoFillBackground(True)
		self.ui.centralWidget.setPalette(palette)
		
		# reset progress bar and hide it.
		if self.ui.algorithmProgressBar.value() == 100:
			self.ui.algorithmProgressBar.setValue(0)
		self.ui.algorithmProgressBar.hide()
		
		# reset individual counts
		self._counts = {
			ValidatorMessage.Level.Error: 0,
			ValidatorMessage.Level.Warning: 0,
			ValidatorMessage.Level.Info: 0
		}
		self.ui.errorLabel.setText("0 Errors")
		self.ui.warningLabel.setText("0 Warnings")
		self.ui.infoLabel.setText("0 Info")
		
		# set visible count to 0.
		self._visibleCount = 0
		self.ui.messageCountLabel.setText(str(self._visibleCount))
		
		# set worst level to 0
		self._mostSevere = 0
		
		self.ui.clearButton.setEnabled(False)
示例#32
0
    def testPythonSlot(self):
        self._sucess = False
        view = View()

        # Connect first, then set the property.
        view.called.connect(self.done)
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_847.qml', __file__)))
        while view.status() == QQuickView.Loading:
            self.app.processEvents()
        self.assertEqual(view.status(), QQuickView.Ready)
        self.assertTrue(view.rootObject())
        view.rootObject().setProperty('pythonObject', view)

        view.show()
        while not view.isExposed():
            self.app.processEvents()

        # Essentially a timeout in case method invocation fails.
        QTimer.singleShot(30000, QCoreApplication.instance().quit)
        self.app.exec_()
        self.assertTrue(self._sucess)
 def testQCoreApplicationInstance(self):
     #Tests QCoreApplication.instance()
     self.assertEqual(QCoreApplication.instance(), None)
     app = QCoreApplication([])
     self.assertEqual(QCoreApplication.instance(), app)
示例#34
0
 def testMockQCoreApplication(self):
     mock = Mock()
     setattr(QCoreApplication, 'instance', mock)
     QCoreApplication.instance()
     self.assert_(mock.called)