Python PyQt5.QtWidgets.QApplication 模块,instance() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtWidgets.QApplication.instance()

项目:rteeg    作者:kaczmarj    | 项目源码 | 文件源码
def _loop_analysis_show_window(self):
        """Show feedback window. This window updates the feedback at an interval
        defined by the user.

        If this function is called, `func` must return a string to be displayed
        in the feedback window. This string can include HTML and CSS, though not
        all CSS is supported. See PyQt's stylesheet.
        """
        app = QApplication.instance()
        if not app:
            app = QApplication(sys.argv)
        self.window = MainWindow(self.stream, self.func,
                                 self.args, self.buffer_len,
                                 self._kill_signal)
        self.window.show()
        # Stop the analysis loop if MainWindow is closed.
        app.aboutToQuit.connect(self.stop)
        sys.exit(app.exec_())
项目:CRIkit2    作者:CoherentRamanNIST    | 项目源码 | 文件源码
def closeEvent(self, event):
        print('Closing')
        app = _QApplication.instance()
        app.closeAllWindows()
        app.quit()
        self.bcpre.pop_to_last(all=True)

        del_flag = 0

        for count in self.bcpre.cut_list:
            try:
                _os.remove(count + '.pickle')
            except:
                print('Error in deleting old pickle files')
            else:
                del_flag += 1
        if del_flag == len(self.bcpre.cut_list):
            del self.bcpre.cut_list
        else:
            print('Did not delete pickle file cut list... Something went wrong')
项目:Py2DSpectroscopy    作者:SvenBo90    | 项目源码 | 文件源码
def __init__(self, parent=None):

        # call widget init
        QWidget.__init__(self, parent)

        # link app
        self._app = QApplication.instance()

        # dictionary for remove background widgets
        self._background_widgets = {}

        # set fixed size
        self.setFixedWidth(320)
        self.setFixedHeight(321)

        # set window title
        self.setWindowTitle("Remove Background")
项目:Py2DSpectroscopy    作者:SvenBo90    | 项目源码 | 文件源码
def __init__(self, parent=None):

        # call widget init
        QWidget.__init__(self, parent)

        # link app
        self._app = QApplication.instance()

        # dictionary for spectrum widgets
        self._spectrum_widgets = {}
        self._current_widget = None

        # set fixed size
        self.setFixedWidth(480)
        self.setFixedHeight(415)

        # set window title
        self.setWindowTitle("Spectrum")
项目:Py2DSpectroscopy    作者:SvenBo90    | 项目源码 | 文件源码
def __init__(self, parent, map_handle):

        # call widget init
        QWidget.__init__(self, parent)

        # link app
        self._app = QApplication.instance()

        # link map handle
        self._map = map_handle

        # load and set up UI
        self.ui = UiPixelInformationWidget(self)

        # set fixed size
        self.setFixedWidth(320)
        self.setFixedHeight(240)
项目:Py2DSpectroscopy    作者:SvenBo90    | 项目源码 | 文件源码
def __init__(self, parent=None):

        # call widget init
        QWidget.__init__(self, parent)

        # link app
        self._app = QApplication.instance()

        # dictionary for pixel information widgets
        self._pixel_information_widgets = {}
        self._current_widget = None

        # set fixed size
        self.setFixedWidth(320)
        self.setFixedHeight(240)

        # set window title
        self.setWindowTitle("Pixel Information")
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def execute(self):

        # Define this here to give users something to look at.
        qApp = QApplication.instance()

        self.expression = self.text()
        try:
            result = str(eval(str(self.expression)))

            # Emit the result of the evaluated expression.
            self.pythonOutput.emit(result)

            # Clear the line edit, append the successful expression to the
            # history, and update the current command index.
            self.clear()
            self.history.append(self.expression)
            self.current = len(self.history)
        except:
            pass
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(ShapedClock, self).__init__(parent,
                Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)

        timer = QTimer(self)
        timer.timeout.connect(self.update)
        timer.start(1000)

        quitAction = QAction("E&xit", self, shortcut="Ctrl+Q",
                triggered=QApplication.instance().quit)
        self.addAction(quitAction)

        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setToolTip("Drag the clock with the left mouse button.\n"
                "Use the right mouse button to open a context menu.")
        self.setWindowTitle(self.tr("Shaped Analog Clock"))
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def execute(self):

        # Define this here to give users something to look at.
        qApp = QApplication.instance()

        self.expression = self.text()
        try:
            result = str(eval(str(self.expression)))

            # Emit the result of the evaluated expression.
            self.pythonOutput.emit(result)

            # Clear the line edit, append the successful expression to the
            # history, and update the current command index.
            self.clear()
            self.history.append(self.expression)
            self.current = len(self.history)
        except:
            pass
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(ShapedClock, self).__init__(parent,
                Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)

        timer = QTimer(self)
        timer.timeout.connect(self.update)
        timer.start(1000)

        quitAction = QAction("E&xit", self, shortcut="Ctrl+Q",
                triggered=QApplication.instance().quit)
        self.addAction(quitAction)

        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setToolTip("Drag the clock with the left mouse button.\n"
                "Use the right mouse button to open a context menu.")
        self.setWindowTitle(self.tr("Shaped Analog Clock"))
项目:QQ_ucics    作者:hustdebug    | 项目源码 | 文件源码
def closeEvent(self, event):
        # ????,??????
        with open("pos.dat", "wb") as fp:
            pickle.dump(cache.globalPos, fp)
        QApplication.instance().quit()
        # return QWidget.closeEvent(self, event)

    # def eventFilter(self, s, e):
        # print(s, e)
        # if s == self.headLabel and e.type() == QEvent.Enter:
            # t = ToolTip(self, "?oo???o?", "resources/icon.ico", "", "data/head/1.png" "data/head/2.png" "data/head/3.png").show(s, self.frameGeometry().topLeft().x(), e.globalPos().y(), self.width(), self.dheight)
            # t.move(938, 120)
            # t.show()
        # return super(Ucics, self).eventFilter(s, e)

    # ??????
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_close_all(self):
        self.add_signal_to_form("esaver.complex")
        self.assertEqual(self.form.signal_tab_controller.num_frames, 1)
        self.form.close_all()
        QApplication.instance().processEvents()
        QTest.qWait(self.CLOSE_TIMEOUT)
        self.assertEqual(self.form.signal_tab_controller.num_frames, 0)

        # Add a bunch of signals
        num_frames = 5
        for _ in range(num_frames):
            self.add_signal_to_form("esaver.complex")

        self.assertEqual(self.form.signal_tab_controller.num_frames, num_frames)

        self.form.close_all()
        QApplication.instance().processEvents()
        QTest.qWait(self.CLOSE_TIMEOUT)

        self.add_signal_to_form("ask.complex")
        self.assertEqual(self.form.signal_tab_controller.num_frames, 1)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_zoom(self):
        self.add_signal_to_form("esaver.complex")
        frame = self.form.signal_tab_controller.signal_frames[0]
        QApplication.instance().processEvents()
        x_zoom = frame.ui.spinBoxXZoom.value()
        self.assertIn(x_zoom, range(100, 111))

        for _ in range(10):
            frame.ui.gvSignal.zoom(1.1)
            self.assertGreater(frame.ui.spinBoxXZoom.value(), x_zoom)
            x_zoom = frame.ui.spinBoxXZoom.value()

        for _ in range(10):
            frame.ui.gvSignal.zoom(0.99)
            self.assertLess(frame.ui.spinBoxXZoom.value(), x_zoom)
            x_zoom = frame.ui.spinBoxXZoom.value()

        samples_in_view = frame.ui.lSamplesInView.text()
        frame.ui.spinBoxXZoom.setValue(frame.ui.spinBoxXZoom.value() + 400)
        self.assertNotEqual(samples_in_view, frame.ui.lSamplesInView.text())
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def tearDown(self):
        if hasattr(self, "dialog"):
            self.dialog.close()
        if hasattr(self, "form"):
            self.form.close_all()
            QApplication.instance().processEvents()
            QTest.qWait(self.CLOSE_TIMEOUT)

            self.form.close()
            QApplication.instance().processEvents()
            QTest.qWait(self.CLOSE_TIMEOUT)

            sip.delete(self.form)
            self.form = None

        QApplication.instance().processEvents()
        QTest.qWait(self.CLOSE_TIMEOUT)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def setUp(self):
        super().setUp()
        QApplication.instance().processEvents()
        QTest.qWait(self.WAIT_TIMEOUT_BEFORE_NEW)
        self.form.add_protocol_file(get_path_for_data_file("protocol.proto.xml"))

        self.cframe = self.form.compare_frame_controller

        self.cframe.add_protocol_label(9, 19, 0, 0, edit_label_name=False)  # equals 10-20 in view
        self.cframe.add_protocol_label(39, 54, 1, 0, edit_label_name=False) # equals 40-55 in view

        self.assertEqual(len(self.cframe.proto_analyzer.protocol_labels), 2)
        self.dialog = ProtocolLabelController(preselected_index=1,
                                              message=self.cframe.proto_analyzer.messages[0],
                                              viewtype=0, parent=self.cframe)

        if self.SHOW:
            self.dialog.show()
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def __make_setting(self, signal_frame, pause_threshold=None, message_divisor_length=None):
        def accept_dialog():
            for widget in QApplication.instance().topLevelWidgets():
                if isinstance(widget, AdvancedModulationOptionsController):
                    if pause_threshold is not None:
                        widget.ui.spinBoxPauseThreshold.setValue(pause_threshold)
                    if message_divisor_length is not None:
                        widget.ui.spinBoxMessageLengthDivisor.setValue(message_divisor_length)
                    widget.ui.buttonBox.accepted.emit()
                    return

        timer = QTimer()
        timer.setSingleShot(True)
        timer.timeout.connect(accept_dialog)
        timer.setInterval(10)
        timer.start()

        signal_frame.ui.btnAdvancedModulationSettings.click()
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_create_context_menu(self):
        self.add_signal_to_form("esaver.complex")
        self.form.signal_tab_controller.signal_frames[0].ui.cbProtoView.setCurrentIndex(2)

        logger.debug("Get text edit")
        text_edit = self.form.signal_tab_controller.signal_frames[0].ui.txtEdProto

        menu = text_edit.create_context_menu()
        QApplication.instance().processEvents()
        line_wrap_action = next(action for action in menu.actions() if action.text().startswith("Linewrap"))
        checked = line_wrap_action.isChecked()
        line_wrap_action.trigger()

        menu = text_edit.create_context_menu()
        QApplication.instance().processEvents()
        line_wrap_action = next(action for action in menu.actions() if action.text().startswith("Linewrap"))
        self.assertNotEqual(checked, line_wrap_action.isChecked())
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_table_selection(self):
        self.form.ui.tabWidget.setCurrentIndex(1)
        self.cfc.ui.cbProtoView.setCurrentIndex(0)
        self.cfc.ui.tblViewProtocol.selectRow(1)
        QApplication.instance().processEvents()
        self.assertEqual(self.cfc.ui.lBitsSelection.text(), self.cfc.proto_analyzer.messages[1].plain_bits_str)

        self.cfc.ui.tblViewProtocol.clearSelection()
        QApplication.instance().processEvents()
        self.assertEqual("", self.cfc.ui.lBitsSelection.text())

        self.cfc.ui.tblViewProtocol.select(0, 0, 0, 3)
        QApplication.instance().processEvents()
        self.assertEqual("1010", self.cfc.ui.lBitsSelection.text())
        self.cfc.ui.cbProtoView.setCurrentIndex(1)
        QApplication.instance().processEvents()

        min_row, max_row, start, end = self.cfc.ui.tblViewProtocol.selection_range()
        self.assertEqual(min_row, 0)
        self.assertEqual(max_row, 0)
        self.assertEqual(start, 0)
        self.assertEqual(end, 1)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_hide_row(self):
        num_messages = len(self.cfc.proto_analyzer.messages)
        self.form.ui.tabWidget.setCurrentIndex(1)
        self.assertGreater(num_messages, 0)
        self.assertEqual(self.cfc.protocol_model.rowCount(), num_messages)
        self.cfc.ui.tblViewProtocol.hide_row(0)
        self.assertTrue(self.cfc.ui.tblViewProtocol.isRowHidden(0))
        self.assertEqual(len(self.cfc.protocol_model.hidden_rows), 1)

        for msg in range(1, num_messages):
            self.assertFalse(self.cfc.ui.tblViewProtocol.isRowHidden(msg))

        self.form.ui.tabWidget.setCurrentIndex(2)
        QApplication.instance().processEvents()
        self.form.ui.tabWidget.setCurrentIndex(1)
        QApplication.instance().processEvents()
        self.assertEqual(self.cfc.protocol_model.rowCount(), num_messages)
        self.assertTrue(self.cfc.ui.tblViewProtocol.isRowHidden(0))

        for msg in range(1, num_messages):
            self.assertFalse(self.cfc.ui.tblViewProtocol.isRowHidden(msg))

        self.assertEqual(len(self.cfc.protocol_model.hidden_rows), 1)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def draw_sine_wave(self):
        if self.dialog_ui.graphicsViewSineWave.scene_manager:
            self.dialog_ui.graphicsViewSineWave.scene_manager.clear_path()

        QApplication.instance().setOverrideCursor(Qt.WaitCursor)
        self.__set_status_of_editable_elements(enabled=False)
        t = np.arange(0, self.num_samples) / self.sample_rate
        arg = ((2 * np.pi * self.frequency * t + self.phase) * 1j).astype(np.complex64)
        self.complex_wave = self.amplitude * np.exp(arg)  # type: np.ndarray
        self.draw_data = np.insert(self.original_data, self.position, self.complex_wave).imag.astype(np.float32)
        y, h = self.dialog_ui.graphicsViewSineWave.view_rect().y(), self.dialog_ui.graphicsViewSineWave.view_rect().height()
        self.insert_indicator.setRect(self.position, y - h, self.num_samples, 2 * h + abs(y))

        self.__set_status_of_editable_elements(enabled=True)
        QApplication.instance().restoreOverrideCursor()
        self.dialog_ui.graphicsViewSineWave.plot_data(self.draw_data)
        self.dialog_ui.graphicsViewSineWave.show_full_scene()
项目:songscreen    作者:maccesch    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(ScreenSelectWidget, self).__init__(*args, **kwargs)

        self._active_screen = -1

        self._buttons = []


        layout = QVBoxLayout()
#        layout.addStretch(1)
        layout.addWidget(QLabel(self.tr("Lyrics screen")))
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.refresh_widget()

        desktop = QApplication.desktop()
        desktop.screenCountChanged.connect(self.refresh_widget)
        # TODO : update to qt 5.6 and uncomment the next line
        # QApplication.instance().primaryScreenChanged.connect(self.refresh_widget)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def execute(self):

        # Define this here to give users something to look at.
        qApp = QApplication.instance()

        self.expression = self.text()
        try:
            result = str(eval(str(self.expression)))

            # Emit the result of the evaluated expression.
            self.pythonOutput.emit(result)

            # Clear the line edit, append the successful expression to the
            # history, and update the current command index.
            self.clear()
            self.history.append(self.expression)
            self.current = len(self.history)
        except:
            pass
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(ShapedClock, self).__init__(parent,
                Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)

        timer = QTimer(self)
        timer.timeout.connect(self.update)
        timer.start(1000)

        quitAction = QAction("E&xit", self, shortcut="Ctrl+Q",
                triggered=QApplication.instance().quit)
        self.addAction(quitAction)

        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setToolTip("Drag the clock with the left mouse button.\n"
                "Use the right mouse button to open a context menu.")
        self.setWindowTitle(self.tr("Shaped Analog Clock"))
项目:RRPam-WDS    作者:asselapathirana    | 项目源码 | 文件源码
def draw_network(self, nodes, links):
        app = QApplication.instance()
        logger = logging.getLogger()
        # we are plotting wholesale. So, disable signals temporily
        with u.updates_disabled_temporarily(self.get_plot()):

            if(nodes):
                logger.info("Drawing nodes")
                app.processEvents()
                self.draw_nodes(nodes)
            # we don't want users to select grid, or nodes and they should not appear in the item list.
            # So lock'em up.
            self.set_all_private()

            if(links):
                logger.info("Drawing links")
                app.processEvents()
                self.draw_links(links)
        self.get_plot().do_autoscale(replot=True)
项目:binja_dynamics    作者:nccgroup    | 项目源码 | 文件源码
def init_gui():
    """ Tries to find the main Binja window. If we've already found it, does nothing.
    Call this as many times as you want, just in case. """
    global main_window
    if main_window is None:
        app = QApplication.instance()
        main_window = [x for x in app.allWidgets() if x.__class__ is QMainWindow][0]
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def get_qt_application_instance():
        q_app = QApplication.instance()
        if q_app is None:
            q_app = QApplication([])
            q_app.lastWindowClosed.connect(QtManager.empty_windows_list)
        return q_app
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def center_window(window):
    """Center the given window on the screen.

    Args:
        q_app (QApplication): for desktop information
        window (QMainWindow): the window to center
    """
    q_app = QApplication.instance()

    frame_gm = window.frameGeometry()
    screen = q_app.desktop().screenNumber(q_app.desktop().cursor().pos())
    center_point = q_app.desktop().screenGeometry(screen).center()
    frame_gm.moveCenter(center_point)
    window.move(frame_gm.topLeft())
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def __init__(self, attribute_name):
        """Descriptor that will emit a state_updated_signal at each update.

        This accesses from the instance the attribute name prepended with an underscore (_).
        """
        self._attribute_name = attribute_name
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def __get__(self, instance, owner):
        return getattr(instance, '_' + self._attribute_name)
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def __set__(self, instance, value):
        setattr(instance, '_' + self._attribute_name, value)
        instance.state_updated_signal.emit(self._attribute_name)
项目:binja_dynamics    作者:ehennenfent    | 项目源码 | 文件源码
def init_gui():
    """ Tries to find the main Binja window. If we've already found it, does nothing.
    Call this as many times as you want, just in case. """
    global main_window
    if main_window is None:
        app = QApplication.instance()
        main_window = [x for x in app.allWidgets() if x.__class__ is QMainWindow][0]
项目:HearthPacks    作者:Arzaroth    | 项目源码 | 文件源码
def initMenus(self):
        exitAction = QAction('&Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(QApplication.instance().quit)
        self.fileMenu.addAction(exitAction)
项目:SiebenApp    作者:ahitrin    | 项目源码 | 文件源码
def __init__(self, db):
        super().__init__()
        self.refresh.connect(self.reload_image)
        self.quit_app.connect(QApplication.instance().quit)
        self.db = db
        self.goals = load(db)
        self.use_dot = True
        self.force_refresh = True
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def _bootstrapGCCache(self):
    app = QApplication.instance()
    if not hasattr(app, "_windowCache"):
        app._windowCache = set()
    app._windowCache.add(self)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def _flushGCCache(self):
    app = QApplication.instance()
    try:
        app._windowCache.remove(self)
    except KeyError:
        # if self.close() is called more than once we'll end up
        # here. that's fine
        pass
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def run(self):
        app = QApplication.instance()
        if app is None:
            app = QApplication(['--platform', 'minimal'])
        # we need this call to correctly render images...
        app.processEvents()

        printer = QPrinter()
        if self.printer_name:
            printer.setPrinterName(self.printer_name)

        printer.setResolution(96)

        text_document = QTextDocument()

        printer.setFullPage(True)
        printer.setPageMargins(5, 5, 5, 5, QPrinter.Millimeter)

        page_size = QSizeF()
        page_size.setHeight(printer.height())
        page_size.setWidth(printer.width())
        text_document.setPageSize(page_size)
        text_document.setDocumentMargin(0.0)

        text_document.setHtml(self.html)
        text_document.print_(printer)
项目:Py2DSpectroscopy    作者:SvenBo90    | 项目源码 | 文件源码
def __init__(self, parent, map_handle):

        # call widget init
        QWidget.__init__(self, parent)

        # link app
        self._app = QApplication.instance()

        # link map handle
        self._map = map_handle

        # load and set up UI
        self.ui = UiSpectrumWidget(self)

        # visible flag used for the curser
        self._visible_flag = False

        # create plot canvas
        self._spectrum_canvas = SpectrumCanvas(self.ui.plot_widget, self._map)

        # add callbacks to map canvas
        self._spectrum_canvas.add_callback('button_press_event', self.cb_spectrum_button_press_event)

        # widget including the toolbar
        self._spectrum_canvas.add_toolbar(self.ui.toolbar_widget)

        # add callbacks
        self.ui.spectrum_check_box.stateChanged.connect(self.update_data)
        self.ui.initial_fit_check_box.stateChanged.connect(self.update_data)
        self.ui.initial_peaks_check_box.stateChanged.connect(self.update_data)
        self.ui.optimized_fit_check_box.stateChanged.connect(self.update_data)
        self.ui.optimized_peaks_check_box.stateChanged.connect(self.update_data)
项目:Py2DSpectroscopy    作者:SvenBo90    | 项目源码 | 文件源码
def __init__(self):

        # link app
        self._app = QApplication.instance()

        # create dictionary for maps
        self._maps = {}

        # set flags for selected map and map counter
        self._selected = None
        self._counter = 0
        self._id_counter = 0

        # call super init
        super(MapList, self).__init__()
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setupUi(self)

        headers = ("Title", "Description")

        file = QFile(':/default.txt')
        file.open(QIODevice.ReadOnly)
        model = TreeModel(headers, file.readAll())
        file.close()

        self.view.setModel(model)
        for column in range(model.columnCount()):
            self.view.resizeColumnToContents(column)

        self.exitAction.triggered.connect(QApplication.instance().quit)

        self.view.selectionModel().selectionChanged.connect(self.updateActions)

        self.actionsMenu.aboutToShow.connect(self.updateActions)
        self.insertRowAction.triggered.connect(self.insertRow)
        self.insertColumnAction.triggered.connect(self.insertColumn)
        self.removeRowAction.triggered.connect(self.removeRow)
        self.removeColumnAction.triggered.connect(self.removeColumn)
        self.insertChildAction.triggered.connect(self.insertChild)

        self.updateActions()
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self):
        super(ChatMainWindow, self).__init__()

        self.m_nickname = "nickname"
        self.m_messages = []

        self.setupUi(self)
        self.sendButton.setEnabled(False)

        self.messageLineEdit.textChanged.connect(self.textChangedSlot)
        self.sendButton.clicked.connect(self.sendClickedSlot)
        self.actionChangeNickname.triggered.connect(self.changeNickname)
        self.actionAboutQt.triggered.connect(self.aboutQt)
        QApplication.instance().lastWindowClosed.connect(self.exiting)

        # Add our D-Bus interface and connect to D-Bus.
        ChatAdaptor(self)
        QDBusConnection.sessionBus().registerObject('/', self)

        iface = ChatInterface('', '', QDBusConnection.sessionBus(), self)
        QDBusConnection.sessionBus().connect('', '', 'org.example.chat',
                'message', self.messageSlot)
        iface.action.connect(self.actionSlot)

        dialog = NicknameDialog()
        dialog.cancelButton.setVisible(False)
        dialog.exec_()
        self.m_nickname = dialog.nickname.text().strip()
        self.action.emit(self.m_nickname, "joins the chat")
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self):
        super(MainWindow, self).__init__()

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.nameLabel.setProperty('class', 'mandatory QLabel')
        self.styleSheetEditor = StyleSheetEditor(self)
        self.statusBar().addWidget(QLabel("Ready"))
        self.ui.exitAction.triggered.connect(QApplication.instance().quit)
        self.ui.aboutQtAction.triggered.connect(QApplication.instance().aboutQt)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setupUi(self)

        headers = ("Title", "Description")

        file = QFile(':/default.txt')
        file.open(QIODevice.ReadOnly)
        model = TreeModel(headers, file.readAll())
        file.close()

        self.view.setModel(model)
        for column in range(model.columnCount()):
            self.view.resizeColumnToContents(column)

        self.exitAction.triggered.connect(QApplication.instance().quit)

        self.view.selectionModel().selectionChanged.connect(self.updateActions)

        self.actionsMenu.aboutToShow.connect(self.updateActions)
        self.insertRowAction.triggered.connect(self.insertRow)
        self.insertColumnAction.triggered.connect(self.insertColumn)
        self.removeRowAction.triggered.connect(self.removeRow)
        self.removeColumnAction.triggered.connect(self.removeColumn)
        self.insertChildAction.triggered.connect(self.insertChild)

        self.updateActions()
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self):
        super(ChatMainWindow, self).__init__()

        self.m_nickname = "nickname"
        self.m_messages = []

        self.setupUi(self)
        self.sendButton.setEnabled(False)

        self.messageLineEdit.textChanged.connect(self.textChangedSlot)
        self.sendButton.clicked.connect(self.sendClickedSlot)
        self.actionChangeNickname.triggered.connect(self.changeNickname)
        self.actionAboutQt.triggered.connect(self.aboutQt)
        QApplication.instance().lastWindowClosed.connect(self.exiting)

        # Add our D-Bus interface and connect to D-Bus.
        ChatAdaptor(self)
        QDBusConnection.sessionBus().registerObject('/', self)

        iface = ChatInterface('', '', QDBusConnection.sessionBus(), self)
        QDBusConnection.sessionBus().connect('', '', 'org.example.chat',
                'message', self.messageSlot)
        iface.action.connect(self.actionSlot)

        dialog = NicknameDialog()
        dialog.cancelButton.setVisible(False)
        dialog.exec_()
        self.m_nickname = dialog.nickname.text().strip()
        self.action.emit(self.m_nickname, "joins the chat")
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self):
        super(MainWindow, self).__init__()

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.nameLabel.setProperty('class', 'mandatory QLabel')
        self.styleSheetEditor = StyleSheetEditor(self)
        self.statusBar().addWidget(QLabel("Ready"))
        self.ui.exitAction.triggered.connect(QApplication.instance().quit)
        self.ui.aboutQtAction.triggered.connect(QApplication.instance().aboutQt)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def setUp(self):
        super().setUp()
        self.form.ui.tabWidget.setCurrentIndex(2)

        logger.debug("Preparing Modulation dialog")
        self.dialog, _ = self.form.generator_tab_controller.prepare_modulation_dialog()
        QApplication.instance().processEvents()
        QTest.qWait(self.WAIT_TIMEOUT_BEFORE_NEW)

        if self.SHOW:
            self.dialog.show()

        logger.debug("Initializing Modulation dialog")
        self.form.generator_tab_controller.initialize_modulation_dialog("1111", self.dialog)
        logger.debug("Preparation success")
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_load_proto(self):
        QApplication.instance().processEvents()
        QTest.qWait(self.WAIT_TIMEOUT_BEFORE_NEW)
        self.form.add_files([get_path_for_data_file("protocol.proto.xml")])
        self.assertEqual(self.form.signal_tab_controller.signal_frames[0].ui.lSignalTyp.text(), "Protocol")
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_selection_sync(self):
        self.add_signal_to_form("esaver.complex")
        frame = self.form.signal_tab_controller.signal_frames[0]
        frame.ui.cbProtoView.setCurrentIndex(0)  # set to bit view
        frame.ui.gvSignal.selection_area.end = 128440
        frame.ui.gvSignal.selection_area.start = 89383
        frame.ui.gvSignal.sel_area_start_end_changed.emit(89383, 128440)
        QApplication.instance().processEvents()
        QTest.qWait(100)
        self.assertEqual(frame.proto_analyzer.messages[0].plain_bits_str, frame.ui.txtEdProto.selected_text.strip())
        frame.ui.txtEdProto.show_proto_clicked.emit()
        QApplication.instance().processEvents()
        self.assertAlmostEqual((128440 - 89383) / 1000000,
                               (frame.ui.gvSignal.view_rect().width()) / 1000000, places=1)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_demodulated_view(self):
        self.add_signal_to_form("esaver.complex")
        frame = self.form.signal_tab_controller.signal_frames[0]
        frame.ui.cbSignalView.setCurrentIndex(1)
        QApplication.instance().processEvents()
        self.assertEqual(frame.ui.gvSignal.scene_type, 1)
        if self.SHOW:
            self.assertTrue(frame.ui.gvLegend.isVisible())
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_uncompress_archives(self):
        temp_dir = tempfile.gettempdir()
        os.chdir(temp_dir)

        with tarfile.open("test.tar.gz", "w:gz") as tar:
            for name in ["1.complex", "2.complex", "3.complex"]:
                data = np.ndarray(10, dtype=np.complex64)
                data.tofile(name)
                tar.add(name)

        with ZipFile('test.zip', 'w') as zip:
            for name in ["4.complex", "5.complex"]:
                data = np.ndarray(10, dtype=np.complex64)
                data.tofile(name)
                zip.write(name)

        QApplication.instance().processEvents()
        QTest.qWait(self.WAIT_TIMEOUT_BEFORE_NEW)
        self.form.add_files(FileOperator.uncompress_archives(["test.tar.gz", "test.zip"], QDir.tempPath()))
        self.assertEqual(len(self.form.signal_tab_controller.signal_frames), 5)

        tar_md5 = hashlib.md5(open(os.path.join(temp_dir, "test.tar.gz"), 'rb').read()).hexdigest()
        self.form.signal_tab_controller.signal_frames[0].signal._fulldata = np.ones(5, dtype=np.complex64)
        self.form.signal_tab_controller.signal_frames[0].signal.changed = True
        self.form.signal_tab_controller.signal_frames[0].ui.btnSaveSignal.click()

        tar_md5_after_save = hashlib.md5(open(os.path.join(temp_dir, "test.tar.gz"), 'rb').read()).hexdigest()
        self.assertNotEqual(tar_md5, tar_md5_after_save)

        zip_md5 = hashlib.md5(open(os.path.join(temp_dir, "test.zip"), 'rb').read()).hexdigest()
        self.form.signal_tab_controller.signal_frames[4].signal._fulldata = np.ones(5, dtype=np.complex64)
        self.form.signal_tab_controller.signal_frames[4].signal.changed = True
        self.form.signal_tab_controller.signal_frames[4].ui.btnSaveSignal.click()

        zip_md5_after_save = hashlib.md5(open(os.path.join(temp_dir, "test.zip"), 'rb').read()).hexdigest()
        self.assertNotEqual(zip_md5, zip_md5_after_save)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_options_changed(self):
        self.add_signal_to_form("esaver.complex")
        self.form.on_options_changed({"show_pause_as_time": True, "default_view": 2})
        QApplication.instance().processEvents()
        self.assertEqual(self.form.signal_tab_controller.signal_frames[0].ui.cbProtoView.currentIndex(), 2)