本文整理汇总了Python中spyderlib.qt.QtGui.QStackedWidget类的典型用法代码示例。如果您正苦于以下问题:Python QStackedWidget类的具体用法?Python QStackedWidget怎么用?Python QStackedWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QStackedWidget类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent):
QStackedWidget.__init__(self, parent)
SpyderPluginMixin.__init__(self, parent)
self.shellwidgets = {}
# Initialize plugin
self.initialize_plugin()
开发者ID:jromang,项目名称:retina-old,代码行数:7,代码来源:variableexplorer.py
示例2: FormComboWidget
class FormComboWidget(QWidget):
update_buttons = Signal()
def __init__(self, datalist, comment="", parent=None):
QWidget.__init__(self, parent)
layout = QVBoxLayout()
self.setLayout(layout)
self.combobox = QComboBox()
layout.addWidget(self.combobox)
self.stackwidget = QStackedWidget(self)
layout.addWidget(self.stackwidget)
self.combobox.currentIndexChanged.connect(
self.stackwidget.setCurrentIndex)
self.widgetlist = []
for data, title, comment in datalist:
self.combobox.addItem(title)
widget = FormWidget(data, comment=comment, parent=self)
self.stackwidget.addWidget(widget)
self.widgetlist.append(widget)
def setup(self):
for widget in self.widgetlist:
widget.setup()
def get(self):
return [ widget.get() for widget in self.widgetlist]
开发者ID:ming-hai,项目名称:spyder,代码行数:28,代码来源:formlayout.py
示例3: RunConfigDialog
class RunConfigDialog(BaseRunConfigDialog):
"""Run configuration dialog box: multiple file version"""
def __init__(self, parent=None):
BaseRunConfigDialog.__init__(self, parent)
self.file_to_run = None
self.combo = None
self.stack = None
def run_btn_clicked(self):
"""Run button was just clicked"""
self.file_to_run = to_text_string(self.combo.currentText())
def setup(self, fname):
"""Setup Run Configuration dialog with filename *fname*"""
combo_label = QLabel(_("Select a run configuration:"))
self.combo = QComboBox()
self.combo.setMaxVisibleItems(20)
self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.stack = QStackedWidget()
configurations = _get_run_configurations()
for index, (filename, options) in enumerate(configurations):
if fname == filename:
break
else:
# There is no run configuration for script *fname*:
# creating a temporary configuration that will be kept only if
# dialog changes are accepted by the user
configurations.insert(0, (fname, RunConfiguration(fname).get()))
index = 0
for filename, options in configurations:
widget = RunConfigOptions(self)
widget.set(options)
self.combo.addItem(filename)
self.stack.addWidget(widget)
self.connect(self.combo, SIGNAL("currentIndexChanged(int)"),
self.stack.setCurrentIndex)
self.combo.setCurrentIndex(index)
self.add_widgets(combo_label, self.combo, 10, self.stack)
self.add_button_box(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
self.setWindowTitle(_("Run Settings"))
def accept(self):
"""Reimplement Qt method"""
configurations = []
for index in range(self.stack.count()):
filename = to_text_string(self.combo.itemText(index))
runconfigoptions = self.stack.widget(index)
if index == self.stack.currentIndex() and\
not runconfigoptions.is_valid():
return
options = runconfigoptions.get()
configurations.append( (filename, options) )
_set_run_configurations(configurations)
QDialog.accept(self)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:59,代码来源:runconfig.py
示例4: setup
def setup(self, fname):
"""Setup Run Configuration dialog with filename *fname*"""
combo_label = QLabel(_("Select a run configuration:"))
self.combo = QComboBox()
self.combo.setMaxVisibleItems(20)
self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.stack = QStackedWidget()
configurations = _get_run_configurations()
for index, (filename, options) in enumerate(configurations):
if fname == filename:
break
else:
# There is no run configuration for script *fname*:
# creating a temporary configuration that will be kept only if
# dialog changes are accepted by the user
configurations.insert(0, (fname, RunConfiguration(fname).get()))
index = 0
for filename, options in configurations:
widget = RunConfigOptions(self)
widget.set(options)
self.combo.addItem(filename)
self.stack.addWidget(widget)
self.connect(self.combo, SIGNAL("currentIndexChanged(int)"),
self.stack.setCurrentIndex)
self.combo.setCurrentIndex(index)
self.add_widgets(combo_label, self.combo, 10, self.stack)
self.add_button_box(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
self.setWindowTitle(_("Run Settings"))
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:33,代码来源:runconfig.py
示例5: __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())
开发者ID:gyenney,项目名称:Tools,代码行数:53,代码来源:configdialog.py
示例6: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
SpyderPluginMixin.__init__(self, parent)
# Widgets
self.stack = QStackedWidget(self)
self.shellwidgets = {}
# Layout
layout = QVBoxLayout()
layout.addWidget(self.stack)
self.setLayout(layout)
# Initialize plugin
self.initialize_plugin()
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:15,代码来源:variableexplorer.py
示例7: __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"))
开发者ID:jromang,项目名称:spyderlib,代码行数:45,代码来源:configdialog.py
示例8: __init__
def __init__(self, datalist, comment="", parent=None):
QWidget.__init__(self, parent)
layout = QVBoxLayout()
self.setLayout(layout)
self.combobox = QComboBox()
layout.addWidget(self.combobox)
self.stackwidget = QStackedWidget(self)
layout.addWidget(self.stackwidget)
self.combobox.currentIndexChanged.connect(
self.stackwidget.setCurrentIndex)
self.widgetlist = []
for data, title, comment in datalist:
self.combobox.addItem(title)
widget = FormWidget(data, comment=comment, parent=self)
self.stackwidget.addWidget(widget)
self.widgetlist.append(widget)
开发者ID:ming-hai,项目名称:spyder,代码行数:18,代码来源:formlayout.py
示例9: __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.file_to_run = None
combo_label = QLabel(_("Select a run configuration:"))
self.combo = QComboBox()
self.combo.setMaxVisibleItems(20)
self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.stack = QStackedWidget()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
run_btn = bbox.addButton(_("Run"), QDialogButtonBox.AcceptRole)
self.connect(run_btn, SIGNAL("clicked()"), self.run_btn_clicked)
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(combo_label)
layout.addWidget(self.combo)
layout.addSpacing(10)
layout.addWidget(self.stack)
layout.addLayout(btnlayout)
self.setLayout(layout)
self.setWindowTitle(_("Run configurations"))
self.setWindowIcon(get_icon("run.png"))
开发者ID:jromang,项目名称:retina-old,代码行数:40,代码来源:runconfig.py
示例10: __init__
def __init__(self, parent, max_entries=100):
"Initialize Various list objects before assignment"
displaylist = []
displaynamelist = []
infixmod = []
infixlist = []
desclist = []
parameternamelist = []
parameterdesclist = []
parameterstringlist = []
paramcountlist = []
buttonlist = []
xmldoc = minidom.parse('C:\\Users\\Jayit\\.spyder2\\ratelaw2_0_3.xml')
#xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml')
lawlistxml = xmldoc.getElementsByTagName('law')
o = 0
for s in lawlistxml:
o = o + 1
parameternamelistlist = [0 for x in range(o)]
parameterdesclistlist = [0 for x in range(o)]
"""i is the number of laws currently in the xml file"""
i = 0
"""
Parsing xml: Acquiring rate law name, description, and list of parameter information
"""
for s in lawlistxml:
#RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n"
"""Gets Latec Expression"""
displaylist.append(s.getAttribute('display'))
"""Gets Rate-Law Name"""
displaynamelist.append(s.getAttribute('displayName'))
""""Gets Raw Rate-Law expression"""
infixlist.append(s.getAttribute('infixExpression'))
"""Gets description statement"""
desclist.append(s.getAttribute('description'))
"""Gets listOfParameters Object"""
parameterlist = s.getElementsByTagName('listOfParameters')[0]
"""Gets a list of parameters within ListOfParameters object"""
parameters = parameterlist.getElementsByTagName('parameter')
for param in parameters:
parameternamelist.append(param.attributes['name'].value)
#print(param.attributes['name'].value)
parameterdesclist.append(param.attributes['description'].value)
parameternamelistlist[i] = parameternamelist
#print("break")
parameterdesclistlist[i] = parameterdesclist
parameternamelist = []
parameterdesclist = []
i = i + 1
SLElistlist = [ 0 for x in range(i)]
PLElistlist = [ 0 for x in range(i)]
ILElistlist = [ 0 for x in range(i)]
paramLElistlist = [ 0 for x in range(i)]
numlistlist = [ 0 for x in range(i)]
QWidget.__init__(self, parent)
self.setWindowTitle("Rate Law Library")
self.output = None
self.error_output = None
self._last_wdir = None
self._last_args = None
self._last_pythonpath = None
#self.textlabel = QLabel(RATE_LAW_MESSAGE)
self.lawlist = QListWidget()
self.lawpage = QStackedWidget()
index = 0
for j in range(i):
item = QListWidgetItem(displaynamelist[j])
self.lawlist.addItem(item)
self.lawdetailpage = QWidget()
setup_group = QGroupBox(displaynamelist[j])
infixmod.append(infixlist[j].replace("___"," "))
setup_label = QLabel(infixmod[j])
setup_label.setWordWrap(True)
desc_group = QGroupBox("Description")
desc_label = QLabel(desclist[j])
#.........这里部分代码省略.........
开发者ID:jayitb,项目名称:Spyderplugin_ratelaws,代码行数:101,代码来源:ratelawgui.py
示例11: ConfigDialog
class ConfigDialog(QDialog):
"""Spyder configuration ('Preferences') dialog box"""
# Signals
check_settings = Signal()
size_change = Signal(QSize)
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())
def get_current_index(self):
"""Return current page index"""
return self.contents_widget.currentRow()
def set_current_index(self, index):
"""Set current page index"""
self.contents_widget.setCurrentRow(index)
def get_page(self, index=None):
"""Return page widget"""
if index is None:
widget = self.pages_widget.currentWidget()
else:
widget = self.pages_widget.widget(index)
return widget.widget()
@Slot()
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)
def button_clicked(self, button):
if button is self.apply_btn:
# Apply button was clicked
configpage = self.get_page()
if not configpage.is_valid():
return
configpage.apply_changes()
def current_page_changed(self, index):
widget = self.get_page(index)
self.apply_btn.setVisible(widget.apply_callback is not None)
self.apply_btn.setEnabled(widget.is_modified)
#.........这里部分代码省略.........
开发者ID:gyenney,项目名称:Tools,代码行数:101,代码来源:configdialog.py
示例12: RunConfigDialog
class RunConfigDialog(QDialog, SizeMixin):
"""Run configuration dialog box: multiple file version"""
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.file_to_run = None
combo_label = QLabel(_("Select a run configuration:"))
self.combo = QComboBox()
self.combo.setMaxVisibleItems(20)
self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.stack = QStackedWidget()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
run_btn = bbox.addButton(_("Run"), QDialogButtonBox.AcceptRole)
self.connect(run_btn, SIGNAL("clicked()"), self.run_btn_clicked)
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(combo_label)
layout.addWidget(self.combo)
layout.addSpacing(10)
layout.addWidget(self.stack)
layout.addLayout(btnlayout)
self.setLayout(layout)
self.setWindowTitle(_("Run configurations"))
self.setWindowIcon(get_icon("run.png"))
def setup(self, fname):
configurations = _get_run_configurations()
for index, (filename, options) in enumerate(configurations):
if fname == filename:
break
else:
# There is no run configuration for script *fname*:
# creating a temporary configuration that will be kept only if
# dialog changes are accepted by the user
configurations.insert(0, (fname, RunConfiguration(fname).get()))
index = 0
for filename, options in configurations:
widget = RunConfigOptions(self)
widget.set(options)
self.combo.addItem(filename)
self.stack.addWidget(widget)
self.connect(self.combo, SIGNAL("currentIndexChanged(int)"), self.stack.setCurrentIndex)
self.combo.setCurrentIndex(index)
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)
def run_btn_clicked(self):
self.file_to_run = unicode(self.combo.currentText())
开发者ID:jromang,项目名称:retina-old,代码行数:78,代码来源:runconfig.py
示例13: ConfigDialog
class ConfigDialog(QDialog):
"""Spyder configuration ('Preferences') dialog box"""
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"))
def get_current_index(self):
"""Return current page index"""
return self.contents_widget.currentRow()
def set_current_index(self, index):
"""Set current page index"""
self.contents_widget.setCurrentRow(index)
def get_page(self, index=None):
"""Return page widget"""
if index is None:
widget = self.pages_widget.currentWidget()
else:
widget = self.pages_widget.widget(index)
return widget.widget()
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)
def button_clicked(self, button):
if button is self.apply_btn:
# Apply button was clicked
configpage = self.get_page()
if not configpage.is_valid():
return
configpage.apply_changes()
def current_page_changed(self, index):
widget = self.get_page(index)
self.apply_btn.setVisible(widget.apply_callback is not None)
self.apply_btn.setEnabled(widget.is_modified)
def add_page(self, widget):
self.connect(self, SIGNAL('check_settings()'), widget.check_settings)
self.connect(widget, SIGNAL('show_this_page()'),
lambda row=self.contents_widget.count():
self.contents_widget.setCurrentRow(row))
self.connect(widget, SIGNAL("apply_button_enabled(bool)"),
self.apply_btn.setEnabled)
scrollarea = QScrollArea(self)
scrollarea.setWidgetResizable(True)
scrollarea.setWidget(widget)
self.pages_widget.addWidget(scrollarea)
item = QListWidgetItem(self.contents_widget)
item.setIcon(widget.get_icon())
item.setText(widget.get_name())
#.........这里部分代码省略.........
开发者ID:jromang,项目名称:spyderlib,代码行数:101,代码来源:configdialog.py
示例14: setup_and_check
def setup_and_check(self, data, title='', readonly=False,
xlabels=None, ylabels=None):
"""
Setup ArrayEditor:
return False if data is not supported, True otherwise
"""
self.data = data
is_record_array = data.dtype.names is not None
is_masked_array = isinstance(data, np.ma.MaskedArray)
if data.size == 0:
self.error(_("Array is empty"))
return False
if data.ndim > 2:
self.error(_("Arrays with more than 2 dimensions "
"are not supported"))
return False
if xlabels is not None and len(xlabels) != self.data.shape[1]:
self.error(_("The 'xlabels' argument length "
"do no match array column number"))
return False
if ylabels is not None and len(ylabels) != self.data.shape[0]:
self.error(_("The 'ylabels' argument length "
"do no match array row number"))
return False
if not is_record_array:
dtn = data.dtype.name
if dtn not in SUPPORTED_FORMATS and not dtn.startswith('string') \
and not dtn.startswith('unicode'):
arr = _("%s arrays") % data.dtype.name
self.error(_("%s are currently not supported") % arr)
return False
self.layout = QGridLayout()
self.setLayout(self.layout)
self.setWindowIcon(get_icon('arredit.png'))
if title:
title = to_text_string(title) # in case title is not a string
else:
title = _("Array editor")
if readonly:
title += ' (' + _('read only') + ')'
self.setWindowTitle(title)
self.resize(600, 500)
# Stack widget
self.stack = QStackedWidget(self)
if is_record_array:
for name in data.dtype.names:
self.stack.addWidget(ArrayEditorWidget(self, data[name],
readonly, xlabels, ylabels))
elif is_masked_array:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.mask, readonly,
xlabels, ylabels))
else:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.arraywidget = self.stack.currentWidget()
self.connect(self.stack, SIGNAL('currentChanged(int)'),
self.current_widget_changed)
self.layout.addWidget(self.stack, 1, 0)
# Buttons configuration
btn_layout = QHBoxLayout()
if is_record_array or is_masked_array:
if is_record_array:
btn_layout.addWidget(QLabel(_("Record array fields:")))
names = []
for name in data.dtype.names:
field = data.dtype.fields[name]
text = name
if len(field) >= 3:
title = field[2]
if not is_text_string(title):
title = repr(title)
text += ' - '+title
names.append(text)
else:
names = [_('Masked data'), _('Data'), _('Mask')]
ra_combo = QComboBox(self)
self.connect(ra_combo, SIGNAL('currentIndexChanged(int)'),
self.stack.setCurrentIndex)
ra_combo.addItems(names)
btn_layout.addWidget(ra_combo)
if is_masked_array:
label = QLabel(_("<u>Warning</u>: changes are applied separately"))
label.setToolTip(_("For performance reasons, changes applied "\
"to masked array won't be reflected in "\
"array's data (and vice-versa)."))
btn_layout.addWidget(label)
btn_layout.addStretch()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
btn_layout.addWidget(bbox)
self.layout.addLayout(btn_layout, 2, 0)
#.........这里部分代码省略.........
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:101,代码来源:arrayeditor.py
示例15: ArrayEditor
class ArrayEditor(QDialog):
"""Array Editor Dialog"""
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
def setup_and_check(self, data, title='', readonly=False,
xlabels=None, ylabels=None):
"""
Setup ArrayEditor:
return False if data is not supported, True otherwise
"""
self.data = data
is_record_array = data.dtype.names is not None
is_masked_array = isinstance(data, np.ma.MaskedArray)
if data.size == 0:
self.error(_("Array is empty"))
return False
if data.ndim > 3:
self.error(_("Arrays with more than 3 dimensions are not supported"))
return False
if xlabels is not None and len(xlabels) != self.data.shape[1]:
self.error(_("The 'xlabels' argument length do no match array "
"column number"))
return False
if ylabels is not None and len(ylabels) != self.data.shape[0]:
self.error(_("The 'ylabels' argument length do no match array row "
"number"))
return False
if not is_record_array:
dtn = data.dtype.name
if dtn not in SUPPORTED_FORMATS and not dtn.startswith('str') \
and not dtn.startswith('unicode'):
arr = _("%s arrays") % data.dtype.name
self.error(_("%s are currently not supported") % arr)
return False
self.layout = QGridLayout()
self.setLayout(self.layout)
self.setWindowIcon(ima.icon('arredit'))
if title:
title = to_text_string(title) + " - " + _("NumPy array")
else:
title = _("Array editor")
if readonly:
title += ' (' + _('read only') + ')'
self.setWindowTitle(title)
self.resize(600, 500)
# Stack widget
self.stack = QStackedWidget(self)
if is_record_array:
for name in data.dtype.names:
self.stack.addWidget(ArrayEditorWidget(self, data[name],
readonly, xlabels, ylabels))
elif is_masked_array:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.mask, readonly,
xlabels, ylabels))
elif data.ndim == 3:
pass
else:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.arraywidget = self.stack.currentWidget()
self.stack.currentChanged.connect(self.current_widget_changed)
self.layout.addWidget(self.stack, 1, 0)
# Buttons configuration
btn_layout = QHBoxLayout()
if is_record_array or is_masked_array or data.ndim == 3:
if is_record_array:
btn_layout.addWidget(QLabel(_("Record array fields:")))
names = []
for name in data.dtype.names:
field = data.dtype.fields[name]
text = name
if len(field) >= 3:
title = field[2]
if not is_text_string(title):
title = repr(title)
text += ' - '+title
names.append(text)
else:
#.........这里部分代码省略.........
开发者ID:da-woods,项目名称:spyder,代码行数:101,代码来源:arrayeditor.py
示例16: VariableExplorer
class VariableExplorer(QWidget, SpyderPluginMixin):
"""
Variable Explorer Plugin
"""
CONF_SECTION = 'variable_explorer'
CONFIGWIDGET_CLASS = VariableExplorerConfigPage
sig_option_changed = Signal(str, object)
def __init__(self, parent):
QWidget.__init__(self, parent)
SpyderPluginMixin.__init__(self, parent)
# Widgets
self.stack = QStackedWidget(self)
self.shellwidgets = {}
# Layout
layout = QVBoxLayout()
layout.addWidget(self.stack)
self.setLayout(layout)
# Initialize plugin
self.initialize_plugin()
@staticmethod
def get_settings():
"""
Return Variable Explorer settings dictionary
(i.e. namespace browser settings according to Spyder's configuration file)
"""
settings = {}
# CONF.load_from_ini() # necessary only when called from another process
for name in REMOTE_SETTINGS:
settings[name] = CONF.get(VariableExplorer.CONF_SECTION, name)
return settings
# ----- Stack accesors ----------------------------------------------------
def set_current_widget(self, nsb):
self.stack.setCurrentWidget(nsb)
def current_widget(self):
return self.stack.currentWidget()
def count(self):
return self.stack.count()
def remove_widget(self, nsb):
self.stack.removeWidget(nsb)
def add_widget(self, nsb):
self.stack.addWidget(nsb)
# ----- Public API --------------------------------------------------------
def add_shellwidget(self, shellwidget):
shellwidget_id = id(shellwidget)
# Add shell only once: this method may be called two times in a row
# by the External console plugin (dev. convenience)
from spyderlib.widgets.externalshell import systemshell
if isinstance(shellwidget, systemshell.ExternalSystemShell):
return
if shellwidget_id not in self.shellwidgets:
nsb = NamespaceBrowser(self)
nsb.set_shellwidget(shellwidget)
nsb.setup(**VariableExplorer.get_settings())
nsb.sig_option_changed.connect(self.sig_option_changed.emit)
self.add_widget(nsb)
self.shellwidgets[shellwidget_id] = nsb
self.set_shellwidget_from_id(shellwidget_id)
return nsb
def remove_shellwidget(self, shellwidget_id):
# If shellwidget_id is not in self.shellwidgets, it simply means
# that shell was not a Python-based console (it was a terminal)
if shellwidget_id in self.shellwidgets:
nsb = self.shellwidgets.pop(shellwidget_id)
self.remove_widget(nsb)
nsb.close()
def set_shellwidget_from_id(self, shellwidget_id):
if shellwidget_id in self.shellwidgets:
nsb = self.shellwidgets[shellwidget_id]
self.set_current_widget(nsb)
if self.isvisible:
nsb.visibility_changed(True)
def import_data(self, fname):
"""Import data in current namespace"""
if self.count():
nsb = self.current_widget()
nsb.refresh_table()
nsb.import_data(filename=fname)
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.raise_()
#------ SpyderPluginMixin API ---------------------------------------------
def visibility_changed(self, enable):
"""DockWidget visibility has changed"""
SpyderPluginMixin.visibility_changed(self, enable)
for nsb in list(self.shellwidgets.values()):
#.........这里部分代码省略.........
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:101,代码来源:variableexplorer.py
示例17: __init__
def __init__(self, parent, max_entries=100):
""" Creates a very basic window with some text """
"""
RATE_LAW_MESSAGE = \
"The Plugins for Spyder consists out of three main classes: \n\n" \
|
请发表评论