本文整理汇总了Python中qtpy.QtCore.QEventLoop.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QEventLoop.exec_方法的具体用法?Python QEventLoop.exec_怎么用?Python QEventLoop.exec_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore.QEventLoop
的用法示例。
在下文中一共展示了QEventLoop.exec_方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_value
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def get_value(self, name):
"""Ask kernel for a value"""
# Don't ask for values while reading (ipdb) is active
if self._reading:
raise ValueError(_("Inspecting and setting values while debugging "
"in IPython consoles is not supported yet by "
"Spyder."))
# Wait until the kernel returns the value
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_execute("get_ipython().kernel.get_value('%s')" % name)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
# Handle exceptions
if self._kernel_value is None:
if self._kernel_reply:
msg = self._kernel_reply[:]
self._kernel_reply = None
raise ValueError(msg)
return self._kernel_value
示例2: get_value
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def get_value(self, name):
"""Ask kernel for a value"""
code = u"get_ipython().kernel.get_value('%s')" % name
if self._reading:
method = self.kernel_client.input
code = u'!' + code
else:
method = self.silent_execute
# Wait until the kernel returns the value
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
method(code)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
# Handle exceptions
if self._kernel_value is None:
if self._kernel_reply:
msg = self._kernel_reply[:]
self._kernel_reply = None
raise ValueError(msg)
return self._kernel_value
示例3: silent_exec_input
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def silent_exec_input(self, code):
"""Silently execute code through stdin"""
self._hidden = True
# Wait until the kernel returns an answer
wait_loop = QEventLoop()
self.sig_input_reply.connect(wait_loop.quit)
self.kernel_client.iopub_channel.flush()
self.kernel_client.input(code)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_input_reply.disconnect(wait_loop.quit)
wait_loop = None
# Restore hidden state
self._hidden = False
# Emit signal
if 'pdb_step' in code and self._input_reply is not None:
fname = self._input_reply['fname']
lineno = self._input_reply['lineno']
self.sig_pdb_step.emit(fname, lineno)
elif 'get_namespace_view' in code:
view = self._input_reply
self.sig_namespace_view.emit(view)
elif 'get_var_properties' in code:
properties = self._input_reply
self.sig_var_properties.emit(properties)
示例4: get_source
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def get_source(self, objtxt):
"""Get object source"""
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_exec_method("get_ipython().kernel.get_source('%s')" % objtxt)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
return self._kernel_reply
示例5: write_to_stdin
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def write_to_stdin(self, line):
"""Send raw characters to the IPython kernel through stdin"""
wait_loop = QEventLoop()
self.sig_prompt_ready.connect(wait_loop.quit)
self.kernel_client.input(line)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_prompt_ready.disconnect(wait_loop.quit)
wait_loop = None
# Run post exec commands
self._post_exec_input(line)
示例6: save_namespace
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def save_namespace(self, filename):
# Wait until the kernel tries to save the file
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_exec_method("get_ipython().kernel.save_namespace('%s')" %
filename)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
return self._kernel_reply
示例7: load_data
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def load_data(self, filename, ext):
# Wait until the kernel tries to load the file
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_exec_method(
"get_ipython().kernel.load_data('%s', '%s')" % (filename, ext))
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
return self._kernel_reply
示例8: get_doc
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def get_doc(self, objtxt):
"""Get object documentation dictionary"""
if self._reading:
return
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_exec_method("get_ipython().kernel.get_doc('%s')" % objtxt)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
return self._kernel_reply
示例9: is_defined
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def is_defined(self, objtxt, force_import=False):
"""Return True if object is defined"""
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_exec_method(
"get_ipython().kernel.is_defined('%s', force_import=%s)"
% (objtxt, force_import))
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
return self._kernel_reply
示例10: save_namespace
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def save_namespace(self, filename):
if self._reading:
message = _("Saving data while debugging is not supported.")
QMessageBox.warning(self, _("Warning"), message)
return
# Wait until the kernel tries to save the file
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_exec_method(r"get_ipython().kernel.save_namespace('%s')" %
filename)
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
return self._kernel_reply
示例11: load_data
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
def load_data(self, filename, ext):
if self._reading:
message = _("Loading this kind of data while debugging is not "
"supported.")
QMessageBox.warning(self, _("Warning"), message)
return
# Wait until the kernel tries to load the file
wait_loop = QEventLoop()
self.sig_got_reply.connect(wait_loop.quit)
self.silent_exec_method(
r"get_ipython().kernel.load_data('%s', '%s')" % (filename, ext))
wait_loop.exec_()
# Remove loop connection and loop
self.sig_got_reply.disconnect(wait_loop.quit)
wait_loop = None
return self._kernel_reply
示例12: InternalShell
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
#.........这里部分代码省略.........
self.interpreter.exit_flag = True
if self.multithreaded:
self.interpreter.stdin_write.write(to_binary_string('\n'))
self.interpreter.restore_stds()
def edit_script(self, filename, external_editor):
filename = to_text_string(filename)
if external_editor:
self.external_editor(filename)
else:
self.parent().edit_script(filename)
def stdout_avail(self):
"""Data is available in stdout, let's empty the queue and write it!"""
data = self.interpreter.stdout_write.empty_queue()
if data:
self.write(data)
def stderr_avail(self):
"""Data is available in stderr, let's empty the queue and write it!"""
data = self.interpreter.stderr_write.empty_queue()
if data:
self.write(data, error=True)
self.flush(error=True)
#------Raw input support
def wait_input(self, prompt=''):
"""Wait for input (raw_input support)"""
self.new_prompt(prompt)
self.setFocus()
self.input_mode = True
self.input_loop = QEventLoop()
self.input_loop.exec_()
self.input_loop = None
def end_input(self, cmd):
"""End of wait_input mode"""
self.input_mode = False
self.input_loop.exit()
self.interpreter.widget_proxy.end_input(cmd)
#----- Menus, actions, ...
def setup_context_menu(self):
"""Reimplement PythonShellWidget method"""
PythonShellWidget.setup_context_menu(self)
self.help_action = create_action(self, _("Help..."),
icon=ima.icon('DialogHelpButton'),
triggered=self.help)
self.menu.addAction(self.help_action)
@Slot()
def help(self):
"""Help on Spyder console"""
QMessageBox.about(self, _("Help"),
"""<b>%s</b>
<p><i>%s</i><br> edit foobar.py
<p><i>%s</i><br> xedit foobar.py
<p><i>%s</i><br> run foobar.py
<p><i>%s</i><br> clear x, y
<p><i>%s</i><br> !ls
<p><i>%s</i><br> object?
<p><i>%s</i><br> result = oedit(object)
""" % (_('Shell special commands:'),
_('Internal editor:'),
示例13: PyChopGui
# 需要导入模块: from qtpy.QtCore import QEventLoop [as 别名]
# 或者: from qtpy.QtCore.QEventLoop import exec_ [as 别名]
#.........这里部分代码省略.........
self.frqaxes2.set_ylabel('Elastic Resolution FWHM (meV)')
line, = self.frqaxes2.plot(freqs, elres, 'o-')
line.set_label('%s "%s" Ei = %5.3f meV' % (inst, chop, ei))
lg = self.frqaxes2.legend()
lg.draggable()
self.frqaxes2.set_xlim([0, np.max(freqs)])
self.frqcanvas.draw()
def instSciCB(self):
"""
Callback function for the "Instrument Scientist Mode" menu option
"""
# MERLIN is a special case - want to hide ability to change phase from users
if 'MERLIN' in self.engine.instname and 'G' in self.engine.getChopper():
if self.instSciAct.isChecked():
self.widgets['Chopper2Phase']['Edit'].show()
self.widgets['Chopper2Phase']['Label'].show()
self.widgets['Chopper2Phase']['Edit'].setText('1500')
self.widgets['Chopper2Phase']['Label'].setText('Disk chopper phase delay time')
else:
self.widgets['Chopper2Phase']['Edit'].hide()
self.widgets['Chopper2Phase']['Label'].hide()
if self.instSciAct.isChecked():
self.tabs.insertTab(self.scrtabID, self.scrtab, 'ScriptOutput')
self.scrtab.show()
else:
self.tabs.removeTab(self.scrtabID)
self.scrtab.hide()
def errormessage(self, message):
msg = QMessageBox()
msg.setText(str(message))
msg.setStandardButtons(QMessageBox.Ok)
msg.exec_()
def loadYaml(self):
yaml_file = QFileDialog().getOpenFileName(self.mainWidget, 'Open Instrument YAML File', self.folder, 'Files (*.yaml)')
if isinstance(yaml_file, tuple):
yaml_file = yaml_file[0]
yaml_file = str(yaml_file)
new_folder = os.path.dirname(yaml_file)
if new_folder != self.folder:
self.folder = new_folder
try:
new_inst = Instrument(yaml_file)
except (RuntimeError, AttributeError, ValueError) as err:
self.errormessage(err)
newname = new_inst.name
if newname in self.instruments.keys() and not self.overwriteload.isChecked():
overwrite, newname = self._ask_overwrite()
if overwrite == 1:
return
elif overwrite == 0:
newname = new_inst.name
self.instruments[newname] = new_inst
self.choppers[newname] = new_inst.getChopperNames()
self.minE[newname] = max([new_inst.emin, 0.01])
self.maxE[newname] = new_inst.emax
self.updateInstrumentList()
combo = self.widgets['InstrumentCombo']['Combo']
idx = [i for i in range(combo.count()) if str(combo.itemText(i)) == newname]
combo.setCurrentIndex(idx[0])
self.setInstrument(newname)
def _ask_overwrite(self):
msg = QDialog()