本文整理汇总了Python中qtpy.QtWidgets.QApplication.processEvents方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.processEvents方法的具体用法?Python QApplication.processEvents怎么用?Python QApplication.processEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QApplication
的用法示例。
在下文中一共展示了QApplication.processEvents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_splash
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
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)
示例2: save_data
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def save_data(self, filename=None):
"""Save data"""
if filename is None:
filename = self.filename
if filename is None:
filename = getcwd_or_home()
filename, _selfilter = getsavefilename(self, _("Save data"),
filename,
iofunctions.save_filters)
if filename:
self.filename = filename
else:
return False
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
error_message = self.shellwidget.save_namespace(self.filename)
self.shellwidget._kernel_reply = None
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if error_message is not None:
if 'Some objects could not be saved:' in error_message:
save_data_message = (
_('<b>Some objects could not be saved:</b>')
+ '<br><br><code>{obj_list}</code>'.format(
obj_list=error_message.split(': ')[1]))
else:
save_data_message = _(
'<b>Unable to save current workspace</b>'
'<br><br>Error message:<br>') + error_message
QMessageBox.critical(self, _("Save data"), save_data_message)
self.save_button.setEnabled(self.filename is not None)
示例3: show_data
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
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)
示例4: ending_long_process
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
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()
示例5: save_data
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def save_data(self, filename=None):
"""Save data"""
if filename is None:
filename = self.filename
if filename is None:
filename = getcwd()
filename, _selfilter = getsavefilename(self, _("Save data"),
filename,
iofunctions.save_filters)
if filename:
self.filename = filename
else:
return False
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
if self.is_internal_shell:
wsfilter = self.get_internal_shell_filter('picklable',
check_all=True)
namespace = wsfilter(self.shellwidget.interpreter.namespace).copy()
error_message = iofunctions.save(namespace, filename)
else:
settings = self.get_view_settings()
error_message = monitor_save_globals(self._get_sock(),
settings, filename)
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if error_message is not None:
QMessageBox.critical(self, _("Save data"),
_("<b>Unable to save current workspace</b>"
"<br><br>Error message:<br>%s") % error_message)
self.save_button.setEnabled(self.filename is not None)
示例6: main
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
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
示例7: __init__
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
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)
示例8: save_data
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def save_data(self, filename=None):
"""Save data"""
if filename is None:
filename = self.filename
if filename is None:
filename = getcwd_or_home()
filename, _selfilter = getsavefilename(self, _("Save data"),
filename,
iofunctions.save_filters)
if filename:
self.filename = filename
else:
return False
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
error_message = self.shellwidget.save_namespace(self.filename)
self.shellwidget._kernel_reply = None
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if error_message is not None:
QMessageBox.critical(self, _("Save data"),
_("<b>Unable to save current workspace</b>"
"<br><br>Error message:<br>%s") % error_message)
self.save_button.setEnabled(self.filename is not None)
示例9: starting_long_process
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
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()
示例10: run_script
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def run_script(self, script):
with self.gui.wait_cursor():
self.set_output("")
self.ui.labelLineNumber.setText("")
QApplication.processEvents()
sys.stdout = self
starttime = -time.time()
line_added=0
try:
self.output = []
try:
self.scriptRunner.run(script)
except NameError as e:
s = str(e).split("'")
if len(s) == 3 and ((s[0] == "global name " and s[2] == " is not defined") or
(s[0] == "name " and s[2] == " is not defined")): #python 3.5
lines = script.split("\n")
if "# auto global" in lines[0] and s[1] in lines[0]:
pass
else:
if self.gui.get_confirmation("Add global variable", "The variable '%s' seems to be missing in a scope. \nDo you want to add declare it as global?"%s[1])==True:
if "# auto global" in lines[0] and s[1] not in lines[0].replace("# auto global","").replace("global",""):
lines[0] = lines[0].replace(" # auto global", ", %s # auto global" % s[1])
else:
lines[0] = "global %s # auto global\n%s" % (s[1], lines[0])
line_added = 1
script = "\n".join(lines)
self.ui.tabWidget.currentWidget().set_script(script)
raise
self.set_output("".join(self.output))
beep(1000, 50)
except (Warning, Exception) as inst:
try:
limit = -["exec(script_code, globals(), locals())" in traceback.format_exc(limit=-i) for i in range(100)].index(True)-1
except:
limit=None
traceback.print_exc(file=sys.stdout, limit=limit)
self.set_output("".join(self.output))
sys.stdout = sys.__stdout__
try:
linenr = self.output[[self.output.index(l) for l in self.output if "File \"<string>\", line " in l][-1]]
linenr = linenr[23:]
if "," in linenr:
linenr = int(linenr[:linenr.index(",")])
else:
linenr = int(linenr)
self.selectLine(linenr - 1+line_added)
except IndexError:
pass
print ('-' * 60)
beep(500, 50)
finally:
sys.stdout = sys.__stdout__
self.ui.labelLineNumber.setText("Script executed in %d seconds" % (time.time() + starttime))
示例11: __next__
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def __next__(self):
if self.n % self.update_every == 0:
if self.allow_cancel and self.QtProgressInformation._progressDialog.wasCanceled():
raise CancelWarning()
self.QtProgressInformation._progressDialog.setValue(self.n)
QApplication.processEvents()
self.n += 1
return next(self.generator)
示例12: write_error
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def write_error(self):
if os.name == 'nt':
#---This is apparently necessary only on Windows (not sure though):
# emptying standard output buffer before writing error output
self.process.setReadChannel(QProcess.StandardOutput)
if self.process.waitForReadyRead(1):
self.write_output()
self.shell.write_error(self.get_stderr())
QApplication.processEvents()
示例13: test_deleted_on_close
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def test_deleted_on_close(self):
ws = CreateSampleWorkspace()
pres = SampleLogs(ws)
self.assert_widget_created()
pres.view.close()
QApplication.processEvents()
self.assert_no_toplevel_widgets()
示例14: exec_long_guitask
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def exec_long_guitask(self, text, task, *args, **kwargs):
self.__show(text, False)
QApplication.processEvents()
task(*args, **kwargs)
self.__hide()
return self.taskThread.result
示例15: test_deletes_on_close
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import processEvents [as 别名]
def test_deletes_on_close(self):
with MockWorkspaceWidget() as temp_widget:
widget = SettingsPresenter(temp_widget)
self.assert_widget_created()
self.assert_widget_exists("GeneralSettings", expected_count=1)
widget.view.close()
QApplication.processEvents()
self.assert_no_toplevel_widgets()