本文整理汇总了Python中qtpy.QtWidgets.QVBoxLayout.insertWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.insertWidget方法的具体用法?Python QVBoxLayout.insertWidget怎么用?Python QVBoxLayout.insertWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.insertWidget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PythonFileInterpreter
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import insertWidget [as 别名]
class PythonFileInterpreter(QWidget):
sig_editor_modified = Signal(bool)
sig_filename_modified = Signal(str)
sig_progress = Signal(int)
sig_exec_error = Signal(object)
sig_exec_success = Signal(object)
def __init__(self, font=None, content=None, filename=None,
parent=None):
"""
:param font: A reference to the font to be used by the editor. If not supplied use the system default
:param content: An optional string of content to pass to the editor
:param filename: The file path where the content was read.
:param parent: An optional parent QWidget
"""
super(PythonFileInterpreter, self).__init__(parent)
self.parent = parent
# layout
font = font if font is not None else QFont()
self.editor = CodeEditor("AlternateCSPython", font, self)
self.find_replace_dialog = None
self.status = QStatusBar(self)
self.layout = QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.editor)
self.layout.addWidget(self.status)
self.setLayout(self.layout)
self._setup_editor(content, filename)
self._presenter = PythonFileInterpreterPresenter(self, PythonCodeExecution(content))
self.code_commenter = CodeCommenter(self.editor)
self.editor.modificationChanged.connect(self.sig_editor_modified)
self.editor.fileNameChanged.connect(self.sig_filename_modified)
self.setAttribute(Qt.WA_DeleteOnClose, True)
# Connect the model signals to the view's signals so they can be accessed from outside the MVP
self._presenter.model.sig_exec_progress.connect(self.sig_progress)
self._presenter.model.sig_exec_error.connect(self.sig_exec_error)
self._presenter.model.sig_exec_success.connect(self.sig_exec_success)
def closeEvent(self, event):
self.deleteLater()
if self.find_replace_dialog:
self.find_replace_dialog.close()
super(PythonFileInterpreter, self).closeEvent(event)
def show_find_replace_dialog(self):
if self.find_replace_dialog is None:
self.find_replace_dialog = EmbeddedFindReplaceDialog(self, self.editor)
self.layout.insertWidget(0, self.find_replace_dialog.view)
self.find_replace_dialog.show()
def hide_find_replace_dialog(self):
if self.find_replace_dialog is not None:
self.find_replace_dialog.hide()
@property
def filename(self):
return self.editor.fileName()
def confirm_close(self):
"""Confirm the widget can be closed. If the editor contents are modified then
a user can interject and cancel closing.
:return: True if closing was considered successful, false otherwise
"""
return self.save(prompt_for_confirmation=self.parent.confirm_on_save)
def abort(self):
self._presenter.req_abort()
def execute_async(self, ignore_selection=False):
return self._presenter.req_execute_async(ignore_selection)
def execute_async_blocking(self):
self._presenter.req_execute_async_blocking()
def save(self, prompt_for_confirmation=False, force_save=False):
if self.editor.isModified():
io = EditorIO(self.editor)
return io.save_if_required(prompt_for_confirmation, force_save)
else:
return True
def save_as(self):
io = EditorIO(self.editor)
new_filename = io.ask_for_filename()
if new_filename:
return io.write(save_as=new_filename), new_filename
else:
return False, None
def set_editor_readonly(self, ro):
self.editor.setReadOnly(ro)
def set_status_message(self, msg):
#.........这里部分代码省略.........