本文整理汇总了Python中qtpy.QtCore.QEventLoop类的典型用法代码示例。如果您正苦于以下问题:Python QEventLoop类的具体用法?Python QEventLoop怎么用?Python QEventLoop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QEventLoop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_value
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
示例2: silent_exec_input
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)
示例3: get_value
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
示例4: get_source
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
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
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
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
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
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: onHelp
def onHelp(self):
"""
Shows the help page
"""
try:
from pymantidplot.proxies import showCustomInterfaceHelp
showCustomInterfaceHelp("PyChop")
except ImportError:
helpTxt = "PyChop is a tool to allow direct inelastic neutron\nscattering users to estimate the inelastic resolution\n"
helpTxt += "and incident flux for a given spectrometer setting.\n\nFirst select the instrument, chopper settings and\n"
helpTxt += "Ei, and then click 'Calculate and Plot'. Data for all\nthe graphs will be generated (may take 1-2s) and\n"
helpTxt += "all graphs will be updated. If the 'Hold current plot'\ncheck box is ticked, additional settings will be\n"
helpTxt += "overplotted on the existing graphs if they are\ndifferent from previous settings.\n\nMore in-depth help "
helpTxt += "can be obtained from the\nMantid help pages."
self.hlpwin = QDialog()
self.hlpedt = QLabel(helpTxt)
self.hlpbtn = QPushButton('OK')
self.hlpwin.layout = QVBoxLayout(self.hlpwin)
self.hlpwin.layout.addWidget(self.hlpedt)
self.hlpwin.layout.addWidget(self.hlpbtn)
self.hlpbtn.clicked.connect(self.hlpwin.deleteLater)
self.hlpwin.setWindowTitle('Help')
self.hlpwin.setWindowModality(Qt.ApplicationModal)
self.hlpwin.setAttribute(Qt.WA_DeleteOnClose)
self.hlpwin.setMinimumSize(370, 300)
self.hlpwin.resize(370, 300)
self.hlpwin.show()
self.hlploop = QEventLoop()
self.hlploop.exec_()
示例11: showText
def showText(self):
"""
Creates a dialog to show the generated text output.
"""
try:
generatedText = self.genText()
except ValueError:
return
self.txtwin = QDialog()
self.txtedt = QTextEdit()
self.txtbtn = QPushButton('OK')
self.txtwin.layout = QVBoxLayout(self.txtwin)
self.txtwin.layout.addWidget(self.txtedt)
self.txtwin.layout.addWidget(self.txtbtn)
self.txtbtn.clicked.connect(self.txtwin.deleteLater)
self.txtedt.setText(generatedText)
self.txtedt.setReadOnly(True)
self.txtwin.setWindowTitle('Resolution information')
self.txtwin.setWindowModality(Qt.ApplicationModal)
self.txtwin.setAttribute(Qt.WA_DeleteOnClose)
self.txtwin.setMinimumSize(400, 600)
self.txtwin.resize(400, 600)
self.txtwin.show()
self.txtloop = QEventLoop()
self.txtloop.exec_()
示例12: save_namespace
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
示例13: wait_input
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
示例14: load_data
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
示例15: InternalShell
#.........这里部分代码省略.........
"""Exit interpreter"""
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:'),