本文整理汇总了Python中spyderlib.qt.QtGui.QDialog类的典型用法代码示例。如果您正苦于以下问题:Python QDialog类的具体用法?Python QDialog怎么用?Python QDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resizeEvent
def resizeEvent(self, event):
"""
Reimplement Qt method to be able to save the widget's size from the
main application
"""
QDialog.resizeEvent(self, event)
self.emit(SIGNAL("size_change(QSize)"), self.size())
示例2: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
SizeMixin.__init__(self)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.filename = None
self.runconfigoptions = RunConfigOptions(self)
bbox = QDialogButtonBox(QDialogButtonBox.Cancel)
bbox.addButton(_("Run"), QDialogButtonBox.AcceptRole)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
btnlayout = QHBoxLayout()
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
layout = QVBoxLayout()
layout.addWidget(self.runconfigoptions)
layout.addLayout(btnlayout)
self.setLayout(layout)
self.setWindowIcon(get_icon("run.png"))
示例3: accept
def accept(self):
"""Reimplement Qt method"""
if not self.runconfigoptions.is_valid():
return
configurations = _get_run_configurations()
configurations.insert(0, (self.filename, self.runconfigoptions.get()))
_set_run_configurations(configurations)
QDialog.accept(self)
示例4: accept
def accept(self):
"""Reimplement Qt method"""
for index in range(self.pages_widget.count()):
configpage = self.get_page(index)
if not configpage.is_valid():
return
configpage.apply_changes()
QDialog.accept(self)
示例5: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.is_series = False
self.layout = None
示例6: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowIcon(get_icon("run_settings.png"))
layout = QVBoxLayout()
self.setLayout(layout)
示例7: accept
def accept(self):
"""Reimplement Qt method"""
configurations = []
for index in range(self.stack.count()):
filename = unicode(self.combo.itemText(index))
runconfigoptions = self.stack.widget(index)
if not runconfigoptions.is_valid():
return
options = runconfigoptions.get()
configurations.append((filename, options))
_set_run_configurations(configurations)
QDialog.accept(self)
示例8: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.main = parent
# Widgets
self.pages_widget = QStackedWidget()
self.contents_widget = QListWidget()
self.button_reset = QPushButton(_('Reset to defaults'))
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply |
QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
# Widgets setup
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle(_('Preferences'))
self.setWindowIcon(ima.icon('configure'))
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
self.contents_widget.setCurrentRow(0)
# Layout
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
btnlayout = QHBoxLayout()
btnlayout.addWidget(self.button_reset)
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
# Signals and slots
self.button_reset.clicked.connect(self.main.reset_spyder)
self.pages_widget.currentChanged.connect(self.current_page_changed)
self.contents_widget.currentRowChanged.connect(
self.pages_widget.setCurrentIndex)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
bbox.clicked.connect(self.button_clicked)
# Ensures that the config is present on spyder first run
CONF.set('main', 'interface_language', load_lang_conf())
示例9: keyPressEvent
def keyPressEvent(self, event):
"""Override Qt method"""
QToolTip.hideText()
ctrl = event.modifiers() & Qt.ControlModifier
if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
if ctrl:
self.process_text(array=False)
else:
self.process_text(array=True)
self.accept()
else:
QDialog.keyPressEvent(self, event)
示例10: __init__
def __init__(self, text, title='', font=None, parent=None,
readonly=False, size=(400, 300)):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.text = None
# Display text as unicode if it comes as bytes, so users see
# its right representation
if is_binary_string(text):
self.is_binary = True
text = to_text_string(text, 'utf8')
else:
self.is_binary = False
self.layout = QVBoxLayout()
self.setLayout(self.layout)
# Text edit
self.edit = QTextEdit(parent)
self.edit.textChanged.connect(self.text_changed)
self.edit.setReadOnly(readonly)
self.edit.setPlainText(text)
if font is None:
font = get_font()
self.edit.setFont(font)
self.layout.addWidget(self.edit)
# Buttons configuration
buttons = QDialogButtonBox.Ok
if not readonly:
buttons = buttons | QDialogButtonBox.Cancel
bbox = QDialogButtonBox(buttons)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
self.layout.addWidget(bbox)
# Make the dialog act as a window
self.setWindowFlags(Qt.Window)
self.setWindowIcon(ima.icon('edit'))
self.setWindowTitle(_("Text editor") + \
"%s" % (" - "+str(title) if str(title) else ""))
self.resize(size[0], size[1])
示例11: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.data = None
self.arraywidget = None
self.stack = None
self.layout = None
# Values for 3d array editor
self.dim_indexes = [{}, {}, {}]
self.last_dim = 0 # Adjust this for changing the startup dimension
示例12: __init__
def __init__(self, parent=None, pathlist=None, ro_pathlist=None, sync=True):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
assert isinstance(pathlist, list)
self.pathlist = pathlist
if ro_pathlist is None:
ro_pathlist = []
self.ro_pathlist = ro_pathlist
self.last_path = getcwd()
self.setWindowTitle(_("PYTHONPATH manager"))
self.setWindowIcon(get_icon('pythonpath.png'))
self.resize(500, 300)
self.selection_widgets = []
layout = QVBoxLayout()
self.setLayout(layout)
top_layout = QHBoxLayout()
layout.addLayout(top_layout)
self.toolbar_widgets1 = self.setup_top_toolbar(top_layout)
self.listwidget = QListWidget(self)
self.connect(self.listwidget, SIGNAL("currentRowChanged(int)"),
self.refresh)
layout.addWidget(self.listwidget)
bottom_layout = QHBoxLayout()
layout.addLayout(bottom_layout)
self.sync_button = None
self.toolbar_widgets2 = self.setup_bottom_toolbar(bottom_layout, sync)
# Buttons configuration
bbox = QDialogButtonBox(QDialogButtonBox.Close)
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
bottom_layout.addWidget(bbox)
self.update_list()
self.refresh()
示例13: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.contents_widget = QListWidget()
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
bbox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Apply
|QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"),
self.button_clicked)
self.pages_widget = QStackedWidget()
self.connect(self.pages_widget, SIGNAL("currentChanged(int)"),
self.current_page_changed)
self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"),
self.pages_widget.setCurrentIndex)
self.contents_widget.setCurrentRow(0)
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
btnlayout = QHBoxLayout()
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
self.setWindowTitle(_("Preferences"))
self.setWindowIcon(get_icon("configure.png"))
示例14: __init__
def __init__(self, text, title='', font=None, parent=None,
readonly=False, size=(400, 300)):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.text = None
self._conv = str if isinstance(text, str) else to_text_string
self.layout = QVBoxLayout()
self.setLayout(self.layout)
# Text edit
self.edit = QTextEdit(parent)
self.connect(self.edit, SIGNAL('textChanged()'), self.text_changed)
self.edit.setReadOnly(readonly)
self.edit.setPlainText(text)
if font is None:
font = get_font('texteditor')
self.edit.setFont(font)
self.layout.addWidget(self.edit)
# Buttons configuration
buttons = QDialogButtonBox.Ok
if not readonly:
buttons = buttons | QDialogButtonBox.Cancel
bbox = QDialogButtonBox(buttons)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
self.layout.addWidget(bbox)
# Make the dialog act as a window
self.setWindowFlags(Qt.Window)
self.setWindowIcon(get_icon('edit.png'))
self.setWindowTitle(_("Text editor") + \
"%s" % (" - "+str(title) if str(title) else ""))
self.resize(size[0], size[1])
示例15: __init__
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setWindowTitle("Spyder %s: %s" % (__version__, _("Optional Dependencies")))
self.setModal(True)
self.view = DependenciesTableView(self, [])
important_mods = ["rope", "pyflakes", "IPython", "matplotlib"]
self.label = QLabel(
_(
"Spyder depends on several Python modules to "
"provide additional functionality for its "
"plugins. The table below shows the required "
"and installed versions (if any) of all of "
"them.<br><br>"
"Although Spyder can work without any of these "
"modules, it's strongly recommended that at "
"least you try to install <b>%s</b> and "
"<b>%s</b> to have a much better experience."
)
% (", ".join(important_mods[:-1]), important_mods[-1])
)
self.label.setWordWrap(True)
self.label.setAlignment(Qt.AlignJustify)
self.label.setContentsMargins(5, 8, 12, 10)
btn = QPushButton(_("Copy to clipboard"))
self.connect(btn, SIGNAL("clicked()"), self.copy_to_clipboard)
bbox = QDialogButtonBox(QDialogButtonBox.Ok)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
hlayout = QHBoxLayout()
hlayout.addWidget(btn)
hlayout.addStretch()
hlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(self.label)
vlayout.addWidget(self.view)
vlayout.addLayout(hlayout)
self.setLayout(vlayout)
self.resize(560, 350)