• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python QtWidgets.QApplication类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qtpy.QtWidgets.QApplication的典型用法代码示例。如果您正苦于以下问题:Python QApplication类的具体用法?Python QApplication怎么用?Python QApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了QApplication类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_builtin_shift_del_and_ins

def test_builtin_shift_del_and_ins(editor_bot):
    """
    Test that the builtin key sequences Ctrl+Ins, Shit+Del and Shift+Ins result
    in copy, cut and paste actions in Windows and Linux.

    Regression test for issue #5035, #4947, and #5973.
    """
    editorstack, qtbot = editor_bot
    editor = editorstack.get_current_editor()
    QApplication.clipboard().clear()

    # Select the first line of the editor.
    qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1'

    # Copy the selection with Ctrl+Ins.
    qtbot.keyClick(editor, Qt.Key_Insert, modifier=Qt.ControlModifier)
    assert QApplication.clipboard().text() == 'Line1'

    # Paste the copied text at the end of the line with Shift+Ins.
    qtbot.keyClick(editor, Qt.Key_End)
    qtbot.keyClick(editor, Qt.Key_Insert, modifier=Qt.ShiftModifier)
    assert editor.toPlainText() == 'Line1Line1\nLine2\nLine3\nLine4\n'

    # Select the second line in the editor again.
    qtbot.keyClick(editor, Qt.Key_Home, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1Line1'

    # Cut the selection with Shift+Del.
    qtbot.keyClick(editor, Qt.Key_Delete, modifier=Qt.ShiftModifier)
    assert QApplication.clipboard().text() == 'Line1Line1'
    assert editor.toPlainText() == '\nLine2\nLine3\nLine4\n'
开发者ID:burrbull,项目名称:spyder,代码行数:32,代码来源:test_shortcuts.py


示例2: test_copy_cut_paste_shortcuts

def test_copy_cut_paste_shortcuts(editor_bot):
    """
    Test that the copy, cut, and paste keyboard shortcuts are working as
    expected with the default Spyder keybindings.
    """
    editorstack, qtbot = editor_bot
    editor = editorstack.get_current_editor()
    QApplication.clipboard().clear()

    # Select and Copy the first line in the editor.
    qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1'

    qtbot.keyClick(editor, Qt.Key_C, modifier=Qt.ControlModifier)
    assert QApplication.clipboard().text() == 'Line1'

    # Paste the selected text.
    qtbot.keyClick(editor, Qt.Key_Home)
    qtbot.keyClick(editor, Qt.Key_V, modifier=Qt.ControlModifier)
    assert editor.toPlainText() == 'Line1Line1\nLine2\nLine3\nLine4\n'

    # Select and Cut the first line in the editor.
    qtbot.keyClick(editor, Qt.Key_Home)
    qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1Line1'

    qtbot.keyClick(editor, Qt.Key_X, modifier=Qt.ControlModifier)
    assert QApplication.clipboard().text() == 'Line1Line1'
    assert editor.toPlainText() == '\nLine2\nLine3\nLine4\n'
开发者ID:burrbull,项目名称:spyder,代码行数:29,代码来源:test_shortcuts.py


示例3: ending_long_process

 def ending_long_process(self, message=""):
     """
     Clear main window's status bar and restore mouse cursor.
     """
     QApplication.restoreOverrideCursor()
     self.show_message(message, timeout=2000)
     QApplication.processEvents()
开发者ID:impact27,项目名称:spyder,代码行数:7,代码来源:plugins.py


示例4: main

    def main(self):
        """
        Main function to process input and call smoothing function
        """
        success = self.input_validation()

        if not success:
            return

        self.hide()
        self.abort_window = AbortWindow(self)
        QApplication.processEvents()

        # Add smoothing parameters

        self.smooth_cube.abort_window = self.abort_window
        if self.smooth_cube.parent is None and self.parent is not self.smooth_cube:
            self.smooth_cube.parent = self.parent
        if self.parent is not self.smooth_cube:
            self.smooth_cube.data = self.data
        self.smooth_cube.smoothing_axis = self.current_axis
        self.smooth_cube.kernel_type = self.current_kernel_type
        if self.current_kernel_type == "median":
            self.smooth_cube.kernel_size = int(self.k_size.text())
        else:
            self.smooth_cube.kernel_size = float(self.k_size.text())
        self.smooth_cube.component_id = str(self.component_combo.currentText())
        self.smooth_cube.output_as_component = True

        if self.is_preview_active:
            self.parent.end_smoothing_preview()
            self.is_preview_active = False
        self.smooth_cube.multi_threading_smooth()
        return
开发者ID:spacetelescope,项目名称:cube-tools,代码行数:34,代码来源:smoothing.py


示例5: resize_to_contents

 def resize_to_contents(self):
     """Resize cells to contents"""
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     self.resizeColumnsToContents()
     self.model().fetch_more(columns=True)
     self.resizeColumnsToContents()
     QApplication.restoreOverrideCursor()
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:7,代码来源:arrayeditor.py


示例6: __init__

    def __init__(self, parent=None,  job_name='', script_to_run=None, thread_index=-1):
        self.parent = parent

        if self.parent.job_monitor_interface is None:
            job_ui = JobMonitorInterface(parent=self.parent)
            job_ui.show()
            QApplication.processEvents()
            self.parent.job_monitor_interface = job_ui
            job_ui.launch_logbook_thread()
        else:
            self.parent.job_monitor_interface.activateWindow()
            job_ui = self.parent.job_monitor_interface

        if job_name == '':
            return

        job_list = self.parent.job_list
        p = subprocess.Popen(script_to_run.split())

        new_job = {'job_name': job_name,
                   'time': self.get_launch_time(),
                   'status': 'processing',
                   'pid': p.pid,
                   'subprocess': p}
        job_list.append(new_job)
        self.parent.job_list = job_list

        job_ui.refresh_table(job_list)
开发者ID:neutrons,项目名称:FastGR,代码行数:28,代码来源:job_status_handler.py


示例7: test_pydmdrawing_paintEvent

def test_pydmdrawing_paintEvent(qtbot, signals, alarm_sensitive_content):
    """
    Test the paintEvent handling of the widget. This test method will also execute PyDMDrawing alarm_severity_changed
    and draw_item().

    Expectations:
    The paintEvent will be triggered, and the widget's brush color is correctly set.
    
    NOTE: This test depends on the default stylesheet having different values for 'qproperty-brush' for different alarm states of PyDMDrawing.

    Parameters
    ----------
    qtbot : fixture
        Window for widget testing
    signals : fixture
        The signals fixture, which provides access signals to be bound to the appropriate slots
    alarm_sensitive_content : bool
        True if the widget will be redraw with a different color if an alarm is triggered; False otherwise.
    """
    QApplication.instance().make_main_window()
    main_window = QApplication.instance().main_window
    qtbot.addWidget(main_window)
    pydm_drawing = PyDMDrawing(parent=main_window, init_channel='fake://tst')
    qtbot.addWidget(pydm_drawing)
    pydm_drawing.alarmSensitiveContent = alarm_sensitive_content
    brush_before = pydm_drawing.brush.color().name()
    signals.new_severity_signal.connect(pydm_drawing.alarmSeverityChanged)
    signals.new_severity_signal.emit(PyDMWidget.ALARM_MAJOR)

    brush_after = pydm_drawing.brush.color().name()
    if alarm_sensitive_content:
        assert brush_before != brush_after
    else:
        assert brush_before == brush_after
开发者ID:slaclab,项目名称:pydm,代码行数:34,代码来源:test_drawing.py


示例8: show_data

    def show_data(self, justanalyzed=False):
        if not justanalyzed:
            self.output = None
        self.log_button.setEnabled(self.output is not None
                                   and len(self.output) > 0)
        self.kill_if_running()
        filename = to_text_string(self.filecombo.currentText())
        if not filename:
            return

        if self.stopped:
            self.datelabel.setText(_('Run stopped by user.'))
            self.datatree.initialize_view()
            return

        self.datelabel.setText(_('Sorting data, please wait...'))
        QApplication.processEvents()

        self.datatree.load_data(self.DATAPATH)
        self.datatree.show_tree()

        text_style = "<span style=\'color: %s\'><b>%s </b></span>"
        date_text = text_style % (self.text_color,
                                  time.strftime("%Y-%m-%d %H:%M:%S",
                                                time.localtime()))
        self.datelabel.setText(date_text)
开发者ID:burrbull,项目名称:spyder,代码行数:26,代码来源:profilergui.py


示例9: copy

 def copy(self):
     """
     Reimplement Qt method
     Copy text to clipboard with correct EOL chars
     """
     if self.get_selected_text():
         QApplication.clipboard().setText(self.get_selected_text())
开发者ID:impact27,项目名称:spyder,代码行数:7,代码来源:base.py


示例10: closeEvent

 def closeEvent(self, *args, **kwargs):
     self.save_settings()
     # Enable paste of clipboard after termination
     clipboard = QApplication.clipboard()
     event = QEvent(QEvent.Clipboard)
     QApplication.sendEvent(clipboard, event)
     return QMainWindow.closeEvent(self, *args, **kwargs)
开发者ID:madsmpedersen,项目名称:MMPE,代码行数:7,代码来源:QtGuiLoader.py


示例11: _wrapper

 def _wrapper(self):
     global QAPP
     if not QAPP:
         setup_library_paths()
         QAPP = QApplication([''])
     test_method(self)
     QAPP.closeAllWindows()
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:__init__.py


示例12: eventFilter

 def eventFilter(self, obj, event):
     status = self._connected
     if event.type() == QEvent.Leave:
         QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
     elif event.type() == QEvent.Enter and not status:
         QApplication.setOverrideCursor(QCursor(Qt.ForbiddenCursor))
     return False
开发者ID:slaclab,项目名称:pydm,代码行数:7,代码来源:waveformtable.py


示例13: set_splash

 def set_splash(self, msg=None):
     if not self.splash:
         return
     if msg:
         self.splash.showMessage(msg, Qt.AlignBottom | Qt.AlignLeft | Qt.AlignAbsolute,
                                 QColor(Qt.black))
     QApplication.processEvents(QEventLoop.AllEvents)
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:mainwindow.py


示例14: load

    def load(self):

        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)

        o_table = TableRowHandler(main_window=self.parent)

        if self.parent.clear_master_table_before_loading:
            TableHandler.clear_table(self.table_ui)

        for _row, _key in enumerate(self.json.keys()):

            _entry = self.json[_key]

            run_number = _key
            title = _entry['title']
            chemical_formula = _entry['resolved_conflict']['chemical_formula']
            # geometry = _entry['resolved_conflict']['geometry']
            mass_density = _entry['resolved_conflict']['mass_density']
            # sample_env_device = _entry['resolved_conflict']['sample_env_device']

            o_table.insert_row(row=_row,
                               title=title,
                               sample_runs=run_number,
                               sample_mass_density=mass_density,
                               sample_chemical_formula=chemical_formula)

        QApplication.restoreOverrideCursor()
开发者ID:neutrons,项目名称:FastGR,代码行数:27,代码来源:load_into_master_table.py


示例15: eventFilter

    def eventFilter(self, obj, event):
        """
        Filters events on this object.

        Params
        ------
        object : QObject
            The object that is being handled.
        event : QEvent
            The event that is happening.

        Returns
        -------
        bool
            True to stop the event from being handled further; otherwise
            return false.
        """
        channel = getattr(self, 'channel', None)
        if is_channel_valid(channel):
            status = self._write_access and self._connected

            if event.type() == QEvent.Leave:
                QApplication.restoreOverrideCursor()

            if event.type() == QEvent.Enter and not status:
                QApplication.setOverrideCursor(QCursor(Qt.ForbiddenCursor))

        return PyDMWidget.eventFilter(self, obj, event)
开发者ID:slaclab,项目名称:pydm,代码行数:28,代码来源:base.py


示例16: yDOLLAR

 def yDOLLAR(self, repeat):
     editor = self._widget.editor()
     cursor = editor.textCursor()
     cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor,
                         repeat)
     text = cursor.selectedText()
     QApplication.clipboard().setText(text)
开发者ID:Nodd,项目名称:spyder.vim,代码行数:7,代码来源:vim_widget.py


示例17: qapplication

def qapplication():
    """Either return a reference to an existing application instance
    or create a new one
    :return: A reference to the QApplication object
    """
    app = QApplication.instance()
    if app is None:
        QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
        argv = sys.argv[:]
        argv[0] = APPNAME  # replace application name
        # Workaround a segfault with the IPython console when using Python 3.5 + PyQt 5
        # Without this using this fix the above combination causes a segfault when the IPython
        # console is started
        # The workaround mentioned in https://groups.google.com/forum/#!topic/leo-editor/ghiIN7irzY0
        # is to ensure readline is imported before the QApplication object is created
        if sys.version_info[0] == 3 and sys.version_info[1] == 5:
            importlib.import_module("readline")
        app = QApplication(argv)
        app.setOrganizationName(ORGANIZATION)
        app.setOrganizationDomain(ORG_DOMAIN)
        app.setApplicationName(APPNAME)
        app.setApplicationVersion(mantid_version_str())
        # Spin up the usage service and set the name for the usage reporting
        # The report is sent when the FrameworkManager kicks up
        UsageService.setApplicationName(APPNAME)

    return app
开发者ID:samueljackson92,项目名称:mantid,代码行数:27,代码来源:mainwindow.py


示例18: show_context_menu

 def show_context_menu(self, widget, pos, pause=0):
     QTest.mouseMove(widget, pos)
     yield pause
     QTest.mouseClick(widget, Qt.RightButton, Qt.NoModifier, pos)
     yield pause
     ev = QMouseEvent(QEvent.ContextMenu, pos, Qt.RightButton, Qt.NoButton, Qt.NoModifier)
     QApplication.postEvent(widget, ev)
     yield self.wait_for_popup()
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:gui_window_test.py


示例19: starting_long_process

 def starting_long_process(self, message):
     """
     Showing message in main window's status bar
     and changing mouse cursor to Qt.WaitCursor
     """
     self.__show_message(message)
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     QApplication.processEvents()
开发者ID:DLlearn,项目名称:spyder,代码行数:8,代码来源:__init__.py


示例20: main

def main(args=sys.argv):
    app = QApplication(args)

    widget = SpellCheckTextEdit('Type here')
    widget.show()
    widget.raise_()

    return app.exec_()
开发者ID:blackkensai,项目名称:git-cola,代码行数:8,代码来源:spellcheck.py



注:本文中的qtpy.QtWidgets.QApplication类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python QtWidgets.QCheckBox类代码示例发布时间:2022-05-26
下一篇:
Python QtWidgets.QAction类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap