本文整理汇总了Python中PyQt5.Qt.QSpinBox.value方法的典型用法代码示例。如果您正苦于以下问题:Python QSpinBox.value方法的具体用法?Python QSpinBox.value怎么用?Python QSpinBox.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QSpinBox
的用法示例。
在下文中一共展示了QSpinBox.value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BulkSeries
# 需要导入模块: from PyQt5.Qt import QSpinBox [as 别名]
# 或者: from PyQt5.Qt.QSpinBox import value [as 别名]
class BulkSeries(BulkBase):
def setup_ui(self, parent):
self.make_widgets(parent, EditWithComplete)
values = self.all_values = list(self.db.all_custom(num=self.col_id))
values.sort(key=sort_key)
self.main_widget.setSizeAdjustPolicy(self.main_widget.AdjustToMinimumContentsLengthWithIcon)
self.main_widget.setMinimumContentsLength(25)
self.widgets.append(QLabel('', parent))
w = QWidget(parent)
layout = QHBoxLayout(w)
layout.setContentsMargins(0, 0, 0, 0)
self.remove_series = QCheckBox(parent)
self.remove_series.setText(_('Remove series'))
layout.addWidget(self.remove_series)
self.idx_widget = QCheckBox(parent)
self.idx_widget.setText(_('Automatically number books'))
layout.addWidget(self.idx_widget)
self.force_number = QCheckBox(parent)
self.force_number.setText(_('Force numbers to start with '))
layout.addWidget(self.force_number)
self.series_start_number = QSpinBox(parent)
self.series_start_number.setMinimum(1)
self.series_start_number.setMaximum(9999999)
self.series_start_number.setProperty("value", 1)
layout.addWidget(self.series_start_number)
layout.addItem(QSpacerItem(20, 10, QSizePolicy.Expanding, QSizePolicy.Minimum))
self.widgets.append(w)
self.idx_widget.stateChanged.connect(self.check_changed_checkbox)
self.force_number.stateChanged.connect(self.check_changed_checkbox)
self.series_start_number.valueChanged.connect(self.check_changed_checkbox)
self.remove_series.stateChanged.connect(self.check_changed_checkbox)
self.ignore_change_signals = False
def check_changed_checkbox(self):
self.a_c_checkbox.setChecked(True)
def initialize(self, book_id):
self.idx_widget.setChecked(False)
self.main_widget.set_separator(None)
self.main_widget.update_items_cache(self.all_values)
self.main_widget.setEditText('')
self.a_c_checkbox.setChecked(False)
def getter(self):
n = unicode(self.main_widget.currentText()).strip()
i = self.idx_widget.checkState()
f = self.force_number.checkState()
s = self.series_start_number.value()
r = self.remove_series.checkState()
return n, i, f, s, r
def commit(self, book_ids, notify=False):
if not self.a_c_checkbox.isChecked():
return
val, update_indices, force_start, at_value, clear = self.gui_val
val = None if clear else self.normalize_ui_val(val)
if clear or val != '':
extras = []
for book_id in book_ids:
if clear:
extras.append(None)
continue
if update_indices:
if force_start:
s_index = at_value
at_value += 1
elif tweaks['series_index_auto_increment'] != 'const':
s_index = self.db.get_next_cc_series_num_for(val, num=self.col_id)
else:
s_index = 1.0
else:
s_index = self.db.get_custom_extra(book_id, num=self.col_id,
index_is_id=True)
extras.append(s_index)
self.db.set_custom_bulk(book_ids, val, extras=extras,
num=self.col_id, notify=notify)
示例2: ConfigWidget
# 需要导入模块: from PyQt5.Qt import QSpinBox [as 别名]
# 或者: from PyQt5.Qt.QSpinBox import value [as 别名]
#.........这里部分代码省略.........
backup_options_group.setLayout(options_layout)
self.do_daily_backp_checkbox = QCheckBox(_('Backup the device database daily'), self)
self.do_daily_backp_checkbox.setToolTip(_('If this is selected the plugin will backup the device database the first time it is connected each day.'))
self.do_daily_backp_checkbox.setCheckState(Qt.Checked if do_daily_backup else Qt.Unchecked)
self.do_daily_backp_checkbox.clicked.connect(self.do_daily_backp_checkbox_clicked)
options_layout.addWidget(self.do_daily_backp_checkbox, 0, 0, 1, 3)
self.dest_directory_label = QLabel(_("Destination:"), self)
self.dest_directory_label.setToolTip(_("Select the destination the annotations files are to be backed up in."))
self.dest_directory_edit = QLineEdit(self)
self.dest_directory_edit.setMinimumSize(150, 0)
self.dest_directory_edit.setText(dest_directory)
self.dest_directory_label.setBuddy(self.dest_directory_edit)
self.dest_pick_button = QPushButton(_("..."), self)
self.dest_pick_button.setMaximumSize(24, 20)
self.dest_pick_button.clicked.connect(self._get_dest_directory_name)
options_layout.addWidget(self.dest_directory_label, 1, 0, 1, 1)
options_layout.addWidget(self.dest_directory_edit, 1, 1, 1, 1)
options_layout.addWidget(self.dest_pick_button, 1, 2, 1, 1)
self.copies_to_keep_checkbox = QCheckBox(_('Copies to keep'), self)
self.copies_to_keep_checkbox.setToolTip(_("Select this to limit the number of backup kept. If not set, the backup files must be manually deleted."))
self.copies_to_keep_spin = QSpinBox(self)
self.copies_to_keep_spin.setMinimum(2)
self.copies_to_keep_spin.setToolTip(_("The number of backup copies of the database to keep. The minimum is 2."))
options_layout.addWidget(self.copies_to_keep_checkbox, 1, 3, 1, 1)
options_layout.addWidget(self.copies_to_keep_spin, 1, 4, 1, 1)
self.copies_to_keep_checkbox.clicked.connect(self.copies_to_keep_checkbox_clicked)
if copies_to_keep == -1:
self.copies_to_keep_checkbox.setCheckState(not Qt.Checked)
else:
self.copies_to_keep_checkbox.setCheckState(Qt.Checked)
self.copies_to_keep_spin.setProperty('value', copies_to_keep)
self.do_daily_backp_checkbox_clicked(do_daily_backup)
other_options_group = QGroupBox(_('Other Options'), self)
layout.addWidget(other_options_group )
options_layout = QGridLayout()
other_options_group.setLayout(options_layout)
library_default_label = QLabel(_('&Library Button default:'), self)
library_default_label.setToolTip(_('If plugin is placed as a toolbar button, choose a default action when clicked on'))
self.library_default_combo = KeyComboBox(self, self.plugin_action.library_actions_map, unicode(get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_BUTTON_ACTION_LIBRARY)))
library_default_label.setBuddy(self.library_default_combo)
options_layout.addWidget(library_default_label, 0, 0, 1, 1)
options_layout.addWidget(self.library_default_combo, 0, 1, 1, 2)
device_default_label = QLabel(_('&Device Button default:'), self)
device_default_label.setToolTip(_('If plugin is placed as a toolbar button, choose a default action when clicked on'))
self.device_default_combo = KeyComboBox(self, self.plugin_action.device_actions_map, unicode(get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_BUTTON_ACTION_DEVICE)))
device_default_label.setBuddy(self.device_default_combo)
options_layout.addWidget(device_default_label, 1, 0, 1, 1)
options_layout.addWidget(self.device_default_combo, 1, 1, 1, 2)
keyboard_shortcuts_button = QPushButton(_('Keyboard shortcuts...'), self)
keyboard_shortcuts_button.setToolTip(_('Edit the keyboard shortcuts associated with this plugin'))
keyboard_shortcuts_button.clicked.connect(self.edit_shortcuts)
layout.addWidget(keyboard_shortcuts_button)
layout.addStretch(1)
def store_on_connect_checkbox_clicked(self, checked):
self.prompt_to_store_checkbox.setEnabled(checked)
self.store_if_more_recent_checkbox.setEnabled(checked)
self.do_not_store_if_reopened_checkbox.setEnabled(checked)
示例3: AddEmptyBookDialog
# 需要导入模块: from PyQt5.Qt import QSpinBox [as 别名]
# 或者: from PyQt5.Qt.QSpinBox import value [as 别名]
class AddEmptyBookDialog(QDialog):
def __init__(self, parent, db, author, series=None):
QDialog.__init__(self, parent)
self.db = db
self.setWindowTitle(_('How many empty books?'))
self._layout = QGridLayout(self)
self.setLayout(self._layout)
self.qty_label = QLabel(_('How many empty books should be added?'))
self._layout.addWidget(self.qty_label, 0, 0, 1, 2)
self.qty_spinbox = QSpinBox(self)
self.qty_spinbox.setRange(1, 10000)
self.qty_spinbox.setValue(1)
self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2)
self.author_label = QLabel(_('Set the author of the new books to:'))
self._layout.addWidget(self.author_label, 2, 0, 1, 2)
self.authors_combo = EditWithComplete(self)
self.authors_combo.setSizeAdjustPolicy(
self.authors_combo.AdjustToMinimumContentsLengthWithIcon)
self.authors_combo.setEditable(True)
self._layout.addWidget(self.authors_combo, 3, 0, 1, 1)
self.initialize_authors(db, author)
self.clear_button = QToolButton(self)
self.clear_button.setIcon(QIcon(I('trash.png')))
self.clear_button.setToolTip(_('Reset author to Unknown'))
self.clear_button.clicked.connect(self.reset_author)
self._layout.addWidget(self.clear_button, 3, 1, 1, 1)
self.series_label = QLabel(_('Set the series of the new books to:'))
self._layout.addWidget(self.series_label, 4, 0, 1, 2)
self.series_combo = EditWithComplete(self)
self.authors_combo.setSizeAdjustPolicy(
self.authors_combo.AdjustToMinimumContentsLengthWithIcon)
self.series_combo.setEditable(True)
self._layout.addWidget(self.series_combo, 5, 0, 1, 1)
self.initialize_series(db, series)
self.sclear_button = QToolButton(self)
self.sclear_button.setIcon(QIcon(I('trash.png')))
self.sclear_button.setToolTip(_('Reset series'))
self.sclear_button.clicked.connect(self.reset_series)
self._layout.addWidget(self.sclear_button, 5, 1, 1, 1)
self.create_epub = c = QCheckBox(_('Create an empty EPUB file as well'))
c.setChecked(gprefs.get('create_empty_epub_file', False))
c.setToolTip(_('Also create an empty EPUB file that you can subsequently edit'))
self._layout.addWidget(c, 6, 0, 1, -1)
button_box = self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
self._layout.addWidget(button_box, 7, 0, 1, -1)
self.resize(self.sizeHint())
def accept(self):
oval = gprefs.get('create_empty_epub_file', False)
if self.create_epub.isChecked() != oval:
gprefs['create_empty_epub_file'] = self.create_epub.isChecked()
return QDialog.accept(self)
def reset_author(self, *args):
self.authors_combo.setEditText(_('Unknown'))
def reset_series(self):
self.series_combo.setEditText('')
def initialize_authors(self, db, author):
au = author
if not au:
au = _('Unknown')
self.authors_combo.show_initial_value(au.replace('|', ','))
self.authors_combo.set_separator('&')
self.authors_combo.set_space_before_sep(True)
self.authors_combo.set_add_separator(tweaks['authors_completer_append_separator'])
self.authors_combo.update_items_cache(db.all_author_names())
def initialize_series(self, db, series):
self.series_combo.show_initial_value(series or '')
self.series_combo.update_items_cache(db.all_series_names())
self.series_combo.set_separator(None)
@property
def qty_to_add(self):
return self.qty_spinbox.value()
@property
def selected_authors(self):
return string_to_authors(unicode(self.authors_combo.text()))
@property
def selected_series(self):
#.........这里部分代码省略.........
示例4: AddEmptyBookDialog
# 需要导入模块: from PyQt5.Qt import QSpinBox [as 别名]
# 或者: from PyQt5.Qt.QSpinBox import value [as 别名]
class AddEmptyBookDialog(QDialog):
def __init__(self, parent, db, author, series=None, title=None):
QDialog.__init__(self, parent)
self.db = db
self.setWindowTitle(_('How many empty books?'))
self._layout = QGridLayout(self)
self.setLayout(self._layout)
self.qty_label = QLabel(_('How many empty books should be added?'))
self._layout.addWidget(self.qty_label, 0, 0, 1, 2)
self.qty_spinbox = QSpinBox(self)
self.qty_spinbox.setRange(1, 10000)
self.qty_spinbox.setValue(1)
self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2)
self.author_label = QLabel(_('Set the author of the new books to:'))
self._layout.addWidget(self.author_label, 2, 0, 1, 2)
self.authors_combo = EditWithComplete(self)
self.authors_combo.setSizeAdjustPolicy(
self.authors_combo.AdjustToMinimumContentsLengthWithIcon)
self.authors_combo.setEditable(True)
self._layout.addWidget(self.authors_combo, 3, 0, 1, 1)
self.initialize_authors(db, author)
self.clear_button = QToolButton(self)
self.clear_button.setIcon(QIcon(I('trash.png')))
self.clear_button.setToolTip(_('Reset author to Unknown'))
self.clear_button.clicked.connect(self.reset_author)
self._layout.addWidget(self.clear_button, 3, 1, 1, 1)
self.series_label = QLabel(_('Set the series of the new books to:'))
self._layout.addWidget(self.series_label, 4, 0, 1, 2)
self.series_combo = EditWithComplete(self)
self.series_combo.setSizeAdjustPolicy(
self.authors_combo.AdjustToMinimumContentsLengthWithIcon)
self.series_combo.setEditable(True)
self._layout.addWidget(self.series_combo, 5, 0, 1, 1)
self.initialize_series(db, series)
self.sclear_button = QToolButton(self)
self.sclear_button.setIcon(QIcon(I('trash.png')))
self.sclear_button.setToolTip(_('Reset series'))
self.sclear_button.clicked.connect(self.reset_series)
self._layout.addWidget(self.sclear_button, 5, 1, 1, 1)
self.title_label = QLabel(_('Set the title of the new books to:'))
self._layout.addWidget(self.title_label, 6, 0, 1, 2)
self.title_edit = QLineEdit(self)
self.title_edit.setText(title or '')
self._layout.addWidget(self.title_edit, 7, 0, 1, 1)
self.tclear_button = QToolButton(self)
self.tclear_button.setIcon(QIcon(I('trash.png')))
self.tclear_button.setToolTip(_('Reset title'))
self.tclear_button.clicked.connect(self.title_edit.clear)
self._layout.addWidget(self.tclear_button, 7, 1, 1, 1)
self.format_label = QLabel(_('Also create an empty ebook in format:'))
self._layout.addWidget(self.format_label, 8, 0, 1, 2)
c = self.format_value = QComboBox(self)
from calibre.ebooks.oeb.polish.create import valid_empty_formats
possible_formats = [''] + sorted(x.upper() for x in valid_empty_formats)
c.addItems(possible_formats)
c.setToolTip(_('Also create an empty book format file that you can subsequently edit'))
if gprefs.get('create_empty_epub_file', False):
# Migration of the check box
gprefs.set('create_empty_format_file', 'epub')
del gprefs['create_empty_epub_file']
use_format = gprefs.get('create_empty_format_file', '').upper()
try:
c.setCurrentIndex(possible_formats.index(use_format))
except Exception:
pass
self._layout.addWidget(c, 9, 0, 1, 1)
button_box = self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
self._layout.addWidget(button_box, 10, 0, 1, -1)
self.resize(self.sizeHint())
def accept(self):
gprefs['create_empty_format_file'] = self.format_value.currentText().lower()
return QDialog.accept(self)
def reset_author(self, *args):
self.authors_combo.setEditText(_('Unknown'))
def reset_series(self):
self.series_combo.setEditText('')
def initialize_authors(self, db, author):
au = author
#.........这里部分代码省略.........
示例5: ConfigWidget
# 需要导入模块: from PyQt5.Qt import QSpinBox [as 别名]
# 或者: from PyQt5.Qt.QSpinBox import value [as 别名]
class ConfigWidget(QWidget):
"""Configuration widget for managing calibre-comicvine config."""
def __init__(self):
QWidget.__init__(self)
self.layout = QGridLayout()
self.layout.setSpacing(10)
self.setLayout(self.layout)
self.index = 0
self.api_key = QLineEdit(self)
self.api_key.setText(PREFS['api_key'])
self.add_labeled_widget('&API key:', self.api_key)
# Worker threads is the maximum number of worker threads to spawn.
# Restricted to 1+
self.worker_threads = QSpinBox(self)
self.worker_threads.setMinimum(1)
self.worker_threads.setValue(PREFS['worker_threads'])
self.add_labeled_widget('&Worker threads:', self.worker_threads)
# Request interval represents wait time between batches of requests.
self.request_interval = QSpinBox(self)
self.request_interval.setMinimum(0)
self.request_interval.setValue(PREFS['request_interval'])
self.add_labeled_widget('&Request interval (seconds):',
self.request_interval)
# Request batch is the maximum number of requests to run at a time.
# Restricted to 1+
self.request_batch_size = QSpinBox(self)
self.request_batch_size.setMinimum(1)
self.request_batch_size.setValue(PREFS['request_batch_size'])
self.add_labeled_widget('&Request batch size:', self.request_batch_size)
# Retries is the number of times to retry if we get any error
# from comicvine besides a rate limit error.
self.retries = QSpinBox(self)
self.retries.setMinimum(0)
self.retries.setValue(PREFS['retries'])
self.add_labeled_widget('&Retries:', self.retries)
# Search volume limit is the max number of volumes to return from
# a volume search.
self.search_volume_limit = QSpinBox(self)
self.search_volume_limit.setMinimum(10)
self.search_volume_limit.setMaximum(10000)
self.search_volume_limit.setSingleStep(10)
self.search_volume_limit.setValue(PREFS['search_volume_limit'])
self.add_labeled_widget('&search_volume_limit:',
self.search_volume_limit)
def add_labeled_widget(self, label_text, widget):
"""
Add a configuration widget, incrementing the index for the next widget.
"""
self.index += 1
label = QLabel(label_text)
label.setBuddy(widget)
self.layout.addWidget(label, self.index, 0)
self.layout.addWidget(widget, self.index, 1)
def save_settings(self):
"""Apply new settings value."""
PREFS['api_key'] = unicode(self.api_key.text())
PREFS['worker_threads'] = self.worker_threads.value()
PREFS['request_interval'] = self.request_interval.value()
PREFS['request_batch_size'] = self.request_batch_size.value()
PREFS['retries'] = self.retries.value()
PREFS['search_volume_limit'] = self.search_volume_limit.value()