本文整理匯總了Python中qtpy.QtWidgets.QStackedWidget類的典型用法代碼示例。如果您正苦於以下問題:Python QStackedWidget類的具體用法?Python QStackedWidget怎麽用?Python QStackedWidget使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QStackedWidget類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: 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]
示例2: 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.combo.currentIndexChanged.connect(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 configuration per file"))
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)
示例3: _init_ui
def _init_ui(self):
# Widgets
self._combobox = QComboBox()
self._stack = QStackedWidget()
# Layouts
layout = ParameterWidget._init_ui(self)
layout.addRow(self._combobox)
layout.addRow(self._stack)
# Register classes
self._widget_indexes = {}
for entry_point in iter_entry_points('pyhmsa_gui.spec.condition.calibration'):
widget_class = entry_point.load(require=False)
widget = widget_class()
self._combobox.addItem(widget.accessibleName().title())
self._widget_indexes[widget.CLASS] = self._stack.addWidget(widget)
widget.edited.connect(self.edited)
# Signals
self._combobox.currentIndexChanged.connect(self._on_combo_box)
self._combobox.currentIndexChanged.connect(self.edited)
return layout
示例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.combo.currentIndexChanged.connect(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 configuration per file"))
示例5: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.main = parent
# Widgets
self.pages_widget = QStackedWidget()
self.pages_widget.setMinimumWidth(600)
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)
self.contents_widget.setMinimumWidth(220)
self.contents_widget.setMinimumHeight(400)
# Layout
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
hsplitter.setStretchFactor(0, 1)
hsplitter.setStretchFactor(1, 2)
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
if self.main:
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())
示例6: __init__
def __init__(self, parent):
SpyderPluginWidget.__init__(self, parent)
# Widgets
self.stack = QStackedWidget(self)
self.shellwidgets = {}
# Layout
layout = QGridLayout(self)
layout.addWidget(self.stack)
# Initialize plugin
self.initialize_plugin()
示例7: __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()
示例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)
示例9: MixerPanel
#.........這裏部分代碼省略.........
self.gamma = gamma
# layout
self.gamma_widget = QWidget()
self.gamma_widget.layout = QGridLayout(self.gamma_widget)
self.gamma_widget.layout.addWidget(self.gamma, 0, 0)
#---------------------------------------------------------------
# Sigmoid Gamma sliders
#---------------------------------------------------------------
# sliders
alpha = IntelligentSlider('alpha', 0.011, 1, self.sig_gamma_changed)
beta = IntelligentSlider('beta', 0.012, 0, self.sig_gamma_changed)
self.a_gamma = alpha
self.b_gamma = beta
# layout
self.sig_gamma_widget = QWidget()
self.sig_gamma_widget.layout = QGridLayout(self.sig_gamma_widget)
self.sig_gamma_widget.layout.addWidget(self.a_gamma, 0, 0)
self.sig_gamma_widget.layout.addWidget(self.b_gamma, 0, 1)
#---------------------------------------------------------------
# Buttons
#---------------------------------------------------------------
self.commit_button = QPushButton('Commit')
self.commit_button.clicked.connect(self.commit_changes)
self.revert_button = QPushButton('Revert')
self.revert_button.clicked.connect(self.revert_changes)
#---------------------------------------------------------------
# Mixer Layout
#---------------------------------------------------------------
self.sliders = QStackedWidget()
self.sliders.addWidget(self.rgb_widget)
self.sliders.addWidget(self.hsv_widget)
self.sliders.addWidget(self.bright_widget)
self.sliders.addWidget(self.gamma_widget)
self.sliders.addWidget(self.sig_gamma_widget)
self.layout = QGridLayout(self)
self.layout.addWidget(self.combo_box, 0, 0)
self.layout.addWidget(self.sliders, 1, 0)
self.layout.addWidget(self.commit_button, 2, 0)
self.layout.addWidget(self.revert_button, 3, 0)
#---------------------------------------------------------------
# State Initialization
#---------------------------------------------------------------
self.combo_box.setCurrentIndex(0)
self.rgb_mul.setChecked(True)
self.hsv_mul.setChecked(True)
def set_callback(self, callback):
self.callback = callback
def combo_box_changed(self, index):
self.sliders.setCurrentIndex(index)
self.reset()
def rgb_radio_changed(self):
self.reset()
def hsv_radio_changed(self):
self.reset()
示例10: Plots
class Plots(SpyderPluginWidget):
"""Plots plugin."""
CONF_SECTION = 'plots'
CONFIGWIDGET_CLASS = PlotsConfigPage
DISABLE_ACTIONS_WHEN_HIDDEN = False
sig_option_changed = Signal(str, object)
def __init__(self, parent):
SpyderPluginWidget.__init__(self, parent)
# Widgets
self.stack = QStackedWidget(self)
self.shellwidgets = {}
# Layout
layout = QGridLayout(self)
layout.addWidget(self.stack)
# Initialize plugin
self.initialize_plugin()
def get_settings(self):
"""Retrieve all Plots configuration settings."""
return {name: self.get_option(name) for name in
['mute_inline_plotting', 'show_plot_outline']}
# ---- Stack accesors
def set_current_widget(self, fig_browser):
"""
Set the currently visible fig_browser in the stack widget, refresh the
actions of the cog menu button and move it to the layout of the new
fig_browser.
"""
self.stack.setCurrentWidget(fig_browser)
# We update the actions of the options button (cog menu) and
# we move it to the layout of the current widget.
self.refresh_actions()
fig_browser.setup_options_button()
def current_widget(self):
return self.stack.currentWidget()
def count(self):
return self.stack.count()
def remove_widget(self, fig_browser):
self.stack.removeWidget(fig_browser)
def add_widget(self, fig_browser):
self.stack.addWidget(fig_browser)
# ---- Public API
def add_shellwidget(self, shellwidget):
"""
Register shell with figure explorer.
This function opens a new FigureBrowser for browsing the figures
in the shell.
"""
shellwidget_id = id(shellwidget)
if shellwidget_id not in self.shellwidgets:
self.options_button.setVisible(True)
fig_browser = FigureBrowser(
self, options_button=self.options_button,
background_color=MAIN_BG_COLOR)
fig_browser.set_shellwidget(shellwidget)
fig_browser.setup(**self.get_settings())
fig_browser.sig_option_changed.connect(
self.sig_option_changed.emit)
fig_browser.thumbnails_sb.redirect_stdio.connect(
self.main.redirect_internalshell_stdio)
self.add_widget(fig_browser)
self.shellwidgets[shellwidget_id] = fig_browser
self.set_shellwidget_from_id(shellwidget_id)
return fig_browser
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:
fig_browser = self.shellwidgets.pop(shellwidget_id)
self.remove_widget(fig_browser)
fig_browser.close()
def set_shellwidget_from_id(self, shellwidget_id):
if shellwidget_id in self.shellwidgets:
fig_browser = self.shellwidgets[shellwidget_id]
self.set_current_widget(fig_browser)
# ---- SpyderPluginWidget API
def get_plugin_title(self):
"""Return widget title"""
return _('Plots')
def get_plugin_icon(self):
"""Return plugin icon"""
return ima.icon('hist')
def get_focus_widget(self):
#.........這裏部分代碼省略.........
示例11: 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 spyder.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(filenames=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()):
#.........這裏部分代碼省略.........
示例12: CalibrationWidget
class CalibrationWidget(ParameterWidget):
def __init__(self, parent=None):
ParameterWidget.__init__(self, _Calibration, parent)
def _init_ui(self):
# Widgets
self._combobox = QComboBox()
self._stack = QStackedWidget()
# Layouts
layout = ParameterWidget._init_ui(self)
layout.addRow(self._combobox)
layout.addRow(self._stack)
# Register classes
self._widget_indexes = {}
for entry_point in iter_entry_points('pyhmsa_gui.spec.condition.calibration'):
widget_class = entry_point.load(require=False)
widget = widget_class()
self._combobox.addItem(widget.accessibleName().title())
self._widget_indexes[widget.CLASS] = self._stack.addWidget(widget)
widget.edited.connect(self.edited)
# Signals
self._combobox.currentIndexChanged.connect(self._on_combo_box)
self._combobox.currentIndexChanged.connect(self.edited)
return layout
def _on_combo_box(self):
# Old values
oldwidget = self._stack.currentWidget()
try:
quantity = oldwidget._txt_quantity.text()
except:
quantity = None
try:
unit = oldwidget._txt_unit.text()
except:
unit = None
# Change widget
current_index = self._combobox.currentIndex()
self._stack.setCurrentIndex(current_index)
# Update values
widget = self._stack.currentWidget()
widget._txt_quantity.setText(quantity)
widget._txt_unit.setText(unit)
def parameter(self):
return self._stack.currentWidget().calibration()
def setParameter(self, calibration):
index = self._widget_indexes[type(calibration)]
self._combobox.setCurrentIndex(index)
self._stack.setCurrentIndex(index)
self._stack.currentWidget().setParameter(calibration)
def calibration(self):
return self.parameter()
def setCalibration(self, calibration):
self.setParameter(calibration)
def setReadOnly(self, state):
ParameterWidget.setReadOnly(self, state)
self._combobox.setEnabled(not state)
self._stack.currentWidget().setReadOnly(state)
def isReadOnly(self):
return ParameterWidget.isReadOnly(self) and \
not self._combobox.isEnabled() and \
self._stack.currentWidget().isReadOnly()
def hasAcceptableInput(self):
return ParameterWidget.hasAcceptableInput(self) and \
self._stack.currentWidget().hasAcceptableInput()
示例13: 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.pages_widget.setMinimumWidth(600)
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)
self.contents_widget.setMinimumWidth(220)
self.contents_widget.setMinimumHeight(400)
# Layout
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
hsplitter.setStretchFactor(0, 1)
hsplitter.setStretchFactor(1, 2)
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
if self.main:
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()
#.........這裏部分代碼省略.........
示例14: VariableExplorer
class VariableExplorer(SpyderPluginWidget):
"""Variable Explorer plugin."""
CONF_SECTION = 'variable_explorer'
CONFIGWIDGET_CLASS = VariableExplorerConfigPage
DISABLE_ACTIONS_WHEN_HIDDEN = False
INITIAL_FREE_MEMORY_TIME_TRIGGER = 60 * 1000 # ms
SECONDARY_FREE_MEMORY_TIME_TRIGGER = 180 * 1000 # ms
sig_option_changed = Signal(str, object)
def __init__(self, parent):
SpyderPluginWidget.__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()
def get_settings(self):
"""
Retrieve all Variable Explorer configuration settings.
Specifically, return the settings in CONF_SECTION with keys in
REMOTE_SETTINGS, and the setting 'dataframe_format'.
Returns:
dict: settings
"""
settings = {}
for name in REMOTE_SETTINGS:
settings[name] = self.get_option(name)
# dataframe_format is stored without percent sign in config
# to avoid interference with ConfigParser's interpolation
name = 'dataframe_format'
settings[name] = '%{0}'.format(self.get_option(name))
return settings
@Slot(str, object)
def change_option(self, option_name, new_value):
"""
Change a config option.
This function is called if sig_option_changed is received. If the
option changed is the dataframe format, then the leading '%' character
is stripped (because it can't be stored in the user config). Then,
the signal is emitted again, so that the new value is saved in the
user config.
"""
if option_name == 'dataframe_format':
assert new_value.startswith('%')
new_value = new_value[1:]
self.sig_option_changed.emit(option_name, new_value)
@Slot()
def free_memory(self):
"""Free memory signal."""
self.main.free_memory()
QTimer.singleShot(self.INITIAL_FREE_MEMORY_TIME_TRIGGER,
lambda: self.main.free_memory())
QTimer.singleShot(self.SECONDARY_FREE_MEMORY_TIME_TRIGGER,
lambda: self.main.free_memory())
# ----- Stack accesors ----------------------------------------------------
def set_current_widget(self, nsb):
self.stack.setCurrentWidget(nsb)
# We update the actions of the options button (cog menu) and we move
# it to the layout of the current widget.
self.refresh_actions()
nsb.setup_options_button()
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):
"""
Register shell with variable explorer.
This function opens a new NamespaceBrowser for browsing the variables
in the shell.
"""
shellwidget_id = id(shellwidget)
#.........這裏部分代碼省略.........
示例15: __init__
#.........這裏部分代碼省略.........
self.rgb_widget.layout.addWidget(self.gs, 2, 1)
self.rgb_widget.layout.addWidget(self.bs, 2, 2)
#---------------------------------------------------------------
# HSV sliders
#---------------------------------------------------------------
# radio buttons
self.hsv_add = QRadioButton('Additive')
self.hsv_mul = QRadioButton('Multiplicative')
self.hsv_mul.toggled.connect(self.hsv_radio_changed)
self.hsv_mul.toggled.connect(self.hsv_radio_changed)
# sliders
hs = IntelligentSlider('H', 0.36, -180, self.hsv_changed)
ss = IntelligentSlider('S', 0.002, 0, self.hsv_changed)
vs = IntelligentSlider('V', 0.002, 0, self.hsv_changed)
self.hs = hs
self.ss = ss
self.vs = vs
self.hsv_widget = QWidget()
self.hsv_widget.layout = QGridLayout(self.hsv_widget)
self.hsv_widget.layout.addWidget(self.hsv_add, 0, 0, 1, 3)
self.hsv_widget.layout.addWidget(self.hsv_mul, 1, 0, 1, 3)
self.hsv_widget.layout.addWidget(self.hs, 2, 0)
self.hsv_widget.layout.addWidget(self.ss, 2, 1)
self.hsv_widget.layout.addWidget(self.vs, 2, 2)
#---------------------------------------------------------------
# Brightness/Contrast sliders
#---------------------------------------------------------------
# sliders
cont = IntelligentSlider('x', 0.002, 0, self.bright_changed)
bright = IntelligentSlider('+', 0.51, -255, self.bright_changed)
self.cont = cont
self.bright = bright
# layout
self.bright_widget = QWidget()
self.bright_widget.layout = QGridLayout(self.bright_widget)
self.bright_widget.layout.addWidget(self.cont, 0, 0)
self.bright_widget.layout.addWidget(self.bright, 0, 1)
#----------------------------------------------------------------------
# Gamma Slider
#----------------------------------------------------------------------
gamma = IntelligentSlider('gamma', 0.005, 0, self.gamma_changed)
self.gamma = gamma
# layout
self.gamma_widget = QWidget()
self.gamma_widget.layout = QGridLayout(self.gamma_widget)
self.gamma_widget.layout.addWidget(self.gamma, 0, 0)
#---------------------------------------------------------------
# Sigmoid Gamma sliders
#---------------------------------------------------------------
# sliders
alpha = IntelligentSlider('alpha', 0.011, 1, self.sig_gamma_changed)
beta = IntelligentSlider('beta', 0.012, 0, self.sig_gamma_changed)
self.a_gamma = alpha
self.b_gamma = beta
# layout
self.sig_gamma_widget = QWidget()
self.sig_gamma_widget.layout = QGridLayout(self.sig_gamma_widget)
self.sig_gamma_widget.layout.addWidget(self.a_gamma, 0, 0)
self.sig_gamma_widget.layout.addWidget(self.b_gamma, 0, 1)
#---------------------------------------------------------------
# Buttons
#---------------------------------------------------------------
self.commit_button = QPushButton('Commit')
self.commit_button.clicked.connect(self.commit_changes)
self.revert_button = QPushButton('Revert')
self.revert_button.clicked.connect(self.revert_changes)
#---------------------------------------------------------------
# Mixer Layout
#---------------------------------------------------------------
self.sliders = QStackedWidget()
self.sliders.addWidget(self.rgb_widget)
self.sliders.addWidget(self.hsv_widget)
self.sliders.addWidget(self.bright_widget)
self.sliders.addWidget(self.gamma_widget)
self.sliders.addWidget(self.sig_gamma_widget)
self.layout = QGridLayout(self)
self.layout.addWidget(self.combo_box, 0, 0)
self.layout.addWidget(self.sliders, 1, 0)
self.layout.addWidget(self.commit_button, 2, 0)
self.layout.addWidget(self.revert_button, 3, 0)
#---------------------------------------------------------------
# State Initialization
#---------------------------------------------------------------
self.combo_box.setCurrentIndex(0)
self.rgb_mul.setChecked(True)
self.hsv_mul.setChecked(True)