本文整理汇总了Python中PySide.QtGui.QComboBox.removeItem方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.removeItem方法的具体用法?Python QComboBox.removeItem怎么用?Python QComboBox.removeItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.removeItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import removeItem [as 别名]
#.........这里部分代码省略.........
def generate_password(self):
if not self.kgk_manager.has_kgk():
self.kgk_manager.create_new_kgk()
self.kgk_manager.create_and_save_new_kgk_block()
if not self.kgk_manager.kgk_crypter or not self.kgk_manager.salt:
self.kgk_manager.get_kgk_crypter(self.master_password_edit.text().encode('utf-8'),
self.kgk_manager.get_kgk_crypter_salt())
if self.setting_dirty:
self.setting.new_salt()
self.setting.calculate_template()
self.settings_manager.set_setting(self.setting)
if not self.setting.get_legacy_password():
generator = CtSesam(self.setting.get_domain(),
self.setting.get_username(),
self.kgk_manager.get_kgk(),
self.setting.get_salt(),
self.setting.get_iterations())
password = generator.generate(self.setting)
else:
password = self.setting.get_legacy_password()
self.password.setText(password)
self.password.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard)
self.clipboard_button.setVisible(True)
self.settings_manager.store_local_settings(self.kgk_manager)
self.setting_dirty = False
def copy_to_clipboard(self):
QApplication.clipboard().setText(self.password.text())
def username_changed(self):
if self.setting:
if self.setting.get_username() != self.username_edit.text():
self.setting.set_username(self.username_edit.text())
self.setting_dirty = True
self.generate_password()
def strength_changed(self, complexity, length):
if self.setting:
if self.setting.get_length() != length:
self.setting.set_length(length)
self.setting_dirty = True
if self.setting.get_complexity() != complexity:
self.setting.set_complexity(complexity)
self.setting_dirty = True
self.generate_password()
def migrate_local_domains(self, new_kgk_manager):
for domain in self.settings_manager.get_domain_list():
setting = self.settings_manager.get_setting(domain)
generator = CtSesam(setting.get_domain(),
setting.get_username(),
self.kgk_manager.get_kgk(),
setting.get_salt(),
setting.get_iterations())
setting.set_legacy_password(generator.generate(setting))
self.settings_manager.set_setting(setting)
self.kgk_manager = new_kgk_manager
self.settings_manager.store_local_settings(self.kgk_manager)
# noinspection PyUnresolvedReferences
def sync_clicked(self):
self.masterpassword_entered()
if not self.settings_manager.sync_manager.has_settings():
self.show_sync_settings()
else:
pull_successful, data = self.settings_manager.sync_manager.pull()
if pull_successful and len(data) > 0:
remote_kgk_manager = KgkManager()
remote_kgk_manager.update_from_blob(self.master_password_edit.text().encode('utf-8'), b64decode(data))
if len(self.preference_manager.get_kgk_block()) == 112 and \
remote_kgk_manager.has_kgk() and self.kgk_manager.has_kgk() and \
self.kgk_manager.get_kgk() != remote_kgk_manager.get_kgk():
if len(self.settings_manager.get_domain_list()) > 0:
print("Lokal und auf dem Server gibt es unterschiedliche KGKs. Das ist ein Problem!")
self.migrate_local_domains(remote_kgk_manager)
else:
if len(self.preference_manager.get_kgk_block()) != 112:
self.kgk_manager = remote_kgk_manager
self.kgk_manager.set_preference_manager(self.preference_manager)
self.kgk_manager.store_local_kgk_block()
self.settings_manager.update_from_export_data(remote_kgk_manager, b64decode(data))
self.domain_edit.blockSignals(True)
current_domain = self.domain_edit.lineEdit().text()
for i in reversed(range(self.domain_edit.count())):
self.domain_edit.removeItem(i)
self.domain_edit.insertItems(0, self.settings_manager.get_domain_list())
self.domain_edit.blockSignals(False)
self.domain_edit.setEditText(current_domain)
self.settings_manager.store_settings(self.kgk_manager)
# noinspection PyUnresolvedReferences
def show_sync_settings(self, url=None, username=None, password=None):
self.settings_window = SettingsWindow(
self.settings_manager.sync_manager,
self.nam,
url=self.settings_manager.sync_manager.server_address,
username=self.settings_manager.sync_manager.username,
password=self.settings_manager.sync_manager.password,
certificate=self.settings_manager.sync_manager.certificate)
self.settings_window.finished.connect(self.sync_clicked)
示例2: GeometryWizardPage
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import removeItem [as 别名]
class GeometryWizardPage(_ExpandableOptionsWizardPage):
def __init__(self, options, parent=None):
_ExpandableOptionsWizardPage.__init__(self, options, parent)
self.setTitle('Geometry')
def _initUI(self):
# Variables
self._widgets = {}
# Widgets
self._cb_geometry = QComboBox()
self._wdg_geometry = QStackedWidget()
policy = self._wdg_geometry.sizePolicy()
policy.setVerticalStretch(True)
self._wdg_geometry.setSizePolicy(policy)
# Layouts
layout = _ExpandableOptionsWizardPage._initUI(self)
layout.addRow("Type of geometry", self._cb_geometry)
layout.addRow(self._wdg_geometry)
# Signals
self._cb_geometry.currentIndexChanged.connect(self._onGeometryChanged)
self._cb_geometry.currentIndexChanged.connect(self.valueChanged)
return layout
def _onGeometryChanged(self):
newindex = self._cb_geometry.currentIndex()
oldwidget = self._wdg_geometry.currentWidget()
newwidget = self._wdg_geometry.widget(newindex)
if newwidget is None:
return
try:
newwidget.setValue(oldwidget.value())
except:
newwidget.setValue(self.options().geometry)
self._wdg_geometry.setCurrentIndex(newindex)
# See https://qt-project.org/faq/answer/how_can_i_get_a_qstackedwidget_to_automatically_switch_size_depending_on_th
oldwidget.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
newwidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self._wdg_geometry.adjustSize()
def _find_material_class(self, programs):
highest_class = Material
for program in programs:
converter = program.converter_class
for clasz in converter.MATERIALS:
if issubclass(clasz, highest_class):
highest_class = clasz
return highest_class
def initializePage(self):
_ExpandableOptionsWizardPage.initializePage(self)
# Clear
self._widgets.clear()
for i in reversed(range(self._cb_geometry.count())):
self._cb_geometry.removeItem(i)
self._wdg_geometry.removeWidget(self._wdg_geometry.widget(i))
# Populate combo box
it = self._iter_widgets('pymontecarlo.ui.gui.options.geometry',
'GEOMETRIES')
for clasz, widget_class, programs in it:
widget = widget_class()
widget.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
widget.setMaterialClass(self._find_material_class(programs))
self._widgets[clasz] = widget
program_text = ', '.join(map(attrgetter('name'), programs))
text = '{0} ({1})'.format(widget.accessibleName(), program_text)
self._cb_geometry.addItem(text)
self._wdg_geometry.addWidget(widget)
widget.valueChanged.connect(self.valueChanged)
# Select geometry
geometry = self.options().geometry
widget = self._widgets.get(geometry.__class__)
if widget is None:
widget = next(iter(self._widgets.values()))
widget.setValue(geometry)
self._wdg_geometry.setCurrentWidget(widget)
self._cb_geometry.setCurrentIndex(self._wdg_geometry.currentIndex())
def validatePage(self):
if not self._wdg_geometry.currentWidget().hasAcceptableInput():
return False
#.........这里部分代码省略.........
示例3: BeamWizardPage
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import removeItem [as 别名]
class BeamWizardPage(_ExpandableOptionsWizardPage):
def __init__(self, options, parent=None):
_ExpandableOptionsWizardPage.__init__(self, options, parent)
self.setTitle("Beam")
def _initUI(self):
# Variables
self._widgets = {}
# Widgets
self._cb_beam = QComboBox()
self._wdg_beam = QStackedWidget()
# Layouts
layout = _ExpandableOptionsWizardPage._initUI(self)
layout.addRow("Type of beam", self._cb_beam)
layout.addRow(self._wdg_beam)
# Signals
self._cb_beam.currentIndexChanged.connect(self._onBeamChanged)
self._cb_beam.currentIndexChanged.connect(self.valueChanged)
return layout
def _onBeamChanged(self):
newindex = self._cb_beam.currentIndex()
oldwidget = self._wdg_beam.currentWidget()
newwidget = self._wdg_beam.widget(newindex)
if newwidget is None:
return
try:
newwidget.setValue(oldwidget.value())
except:
newwidget.setValue(self.options().beam)
self._wdg_beam.setCurrentIndex(newindex)
def initializePage(self):
_ExpandableOptionsWizardPage.initializePage(self)
# Clear
self._widgets.clear()
for i in reversed(range(self._cb_beam.count())):
self._cb_beam.removeItem(i)
self._wdg_beam.removeWidget(self._wdg_beam.widget(i))
# Populate combo box
it = self._iter_widgets("pymontecarlo.ui.gui.options.beam", "BEAMS")
for clasz, widget_class, programs in it:
widget = widget_class()
self._widgets[clasz] = widget
program_text = ", ".join(map(attrgetter("name"), programs))
text = "{0} ({1})".format(widget.accessibleName(), program_text)
self._cb_beam.addItem(text)
self._wdg_beam.addWidget(widget)
widget.setParticlesEnabled(False)
for program in programs:
converter = program.converter_class
for particle in converter.PARTICLES:
widget.setParticleEnabled(particle, True)
widget.valueChanged.connect(self.valueChanged)
# Select beam
beam = self.options().beam
widget = self._widgets.get(beam.__class__)
if widget is None:
widget = next(iter(self._widgets.values()))
widget.setValue(beam)
self._wdg_beam.setCurrentWidget(widget)
self._cb_beam.setCurrentIndex(self._wdg_beam.currentIndex())
def validatePage(self):
if not self._wdg_beam.currentWidget().hasAcceptableInput():
return False
self.options().beam = self._wdg_beam.currentWidget().value()
return True
def expandCount(self):
try:
return len(expand(self._wdg_beam.currentWidget().value()))
except:
return 0