本文整理汇总了Python中qtpy.QtWidgets.QApplication类的典型用法代码示例。如果您正苦于以下问题:Python QApplication类的具体用法?Python QApplication怎么用?Python QApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'
示例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'
示例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()
示例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
示例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()
示例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)
示例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
示例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)
示例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())
示例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)
示例11: _wrapper
def _wrapper(self):
global QAPP
if not QAPP:
setup_library_paths()
QAPP = QApplication([''])
test_method(self)
QAPP.closeAllWindows()
示例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
示例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)
示例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()
示例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)