本文整理汇总了Python中PyQt5.Qt.QRadioButton.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QRadioButton.setChecked方法的具体用法?Python QRadioButton.setChecked怎么用?Python QRadioButton.setChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QRadioButton
的用法示例。
在下文中一共展示了QRadioButton.setChecked方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SelectNames
# 需要导入模块: from PyQt5.Qt import QRadioButton [as 别名]
# 或者: from PyQt5.Qt.QRadioButton import setChecked [as 别名]
class SelectNames(QDialog): # {{{
def __init__(self, names, txt, parent=None):
QDialog.__init__(self, parent)
self.l = l = QVBoxLayout(self)
self.setLayout(l)
self.la = la = QLabel(_('Create a Virtual Library based on %s') % txt)
l.addWidget(la)
self._names = QListWidget(self)
self._names.addItems(sorted(names, key=sort_key))
self._names.setSelectionMode(self._names.ExtendedSelection)
l.addWidget(self._names)
self._or = QRadioButton(_('Match any of the selected %s names')%txt)
self._and = QRadioButton(_('Match all of the selected %s names')%txt)
self._or.setChecked(True)
l.addWidget(self._or)
l.addWidget(self._and)
self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
l.addWidget(self.bb)
self.resize(self.sizeHint())
@property
def names(self):
for item in self._names.selectedItems():
yield unicode(item.data(Qt.DisplayRole) or '')
@property
def match_type(self):
return ' and ' if self._and.isChecked() else ' or '
示例2: SchedulerDialog
# 需要导入模块: from PyQt5.Qt import QRadioButton [as 别名]
# 或者: from PyQt5.Qt.QRadioButton import setChecked [as 别名]
class SchedulerDialog(QDialog):
SCHEDULE_TYPES = OrderedDict([
('days_of_week', DaysOfWeek),
('days_of_month', DaysOfMonth),
('every_x_days', EveryXDays),
])
download = pyqtSignal(object)
def __init__(self, recipe_model, parent=None):
QDialog.__init__(self, parent)
self.commit_on_change = True
self.previous_urn = None
self.setWindowIcon(QIcon(I('scheduler.png')))
self.setWindowTitle(_("Schedule news download"))
self.l = l = QGridLayout(self)
# Left panel
self.h = h = QHBoxLayout()
l.addLayout(h, 0, 0, 1, 1)
self.search = s = SearchBox2(self)
self.search.initialize('scheduler_search_history')
self.search.setMinimumContentsLength(15)
self.go_button = b = QToolButton(self)
b.setText(_("Go"))
b.clicked.connect(self.search.do_search)
self.clear_search_button = cb = QToolButton(self)
self.clear_search_button.clicked.connect(self.search.clear_clicked)
cb.setIcon(QIcon(I('clear_left.png')))
h.addWidget(s), h.addWidget(b), h.addWidget(cb)
self.recipes = RecipesView(self)
l.addWidget(self.recipes, 1, 0, 1, 1)
self.recipe_model = recipe_model
self.recipe_model.do_refresh()
self.recipes.setModel(self.recipe_model)
self.recipes.setFocus(Qt.OtherFocusReason)
self.count_label = la = QLabel(_('%s news sources') % self.recipe_model.showing_count)
la.setAlignment(Qt.AlignCenter)
l.addWidget(la, 2, 0, 1, 1)
self.search.search.connect(self.recipe_model.search)
self.recipe_model.searched.connect(self.search.search_done, type=Qt.QueuedConnection)
self.recipe_model.searched.connect(self.search_done)
# Right Panel
self.scroll_area = sa = QScrollArea(self)
self.l.addWidget(sa, 0, 1, 2, 1)
sa.setFrameShape(QFrame.NoFrame)
sa.setWidgetResizable(True)
self.scroll_area_contents = sac = QWidget(self)
sa.setWidget(sac)
sac.v = v = QVBoxLayout(sac)
v.setContentsMargins(0, 0, 0, 0)
self.detail_box = QTabWidget(self)
self.detail_box.setVisible(False)
self.detail_box.setCurrentIndex(0)
v.addWidget(self.detail_box)
v.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
# First Tab (scheduling)
self.tab = QWidget()
self.detail_box.addTab(self.tab, _("&Schedule"))
self.tab.v = vt = QVBoxLayout(self.tab)
vt.setContentsMargins(0, 0, 0, 0)
self.blurb = la = QLabel('blurb')
la.setWordWrap(True), la.setOpenExternalLinks(True)
vt.addWidget(la)
vt.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.frame = f = QFrame(self.tab)
vt.addWidget(f)
f.setFrameShape(f.StyledPanel)
f.setFrameShadow(f.Raised)
f.v = vf = QVBoxLayout(f)
self.schedule = s = QCheckBox(_("&Schedule for download:"), f)
self.schedule.stateChanged[int].connect(self.toggle_schedule_info)
vf.addWidget(s)
f.h = h = QHBoxLayout()
vf.addLayout(h)
self.days_of_week = QRadioButton(_("&Days of week"), f)
self.days_of_month = QRadioButton(_("Da&ys of month"), f)
self.every_x_days = QRadioButton(_("Every &x days"), f)
self.days_of_week.setChecked(True)
h.addWidget(self.days_of_week), h.addWidget(self.days_of_month), h.addWidget(self.every_x_days)
self.schedule_stack = ss = QStackedWidget(f)
self.schedule_widgets = []
for key in reversed(self.SCHEDULE_TYPES):
self.schedule_widgets.insert(0, self.SCHEDULE_TYPES[key](self))
self.schedule_stack.insertWidget(0, self.schedule_widgets[0])
vf.addWidget(ss)
self.last_downloaded = la = QLabel(f)
la.setWordWrap(True)
vf.addWidget(la)
vt.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.account = acc = QGroupBox(self.tab)
acc.setTitle(_("&Account"))
vt.addWidget(acc)
acc.g = g = QGridLayout(acc)
acc.unla = la = QLabel(_("&Username:"))
self.username = un = QLineEdit(self)
#.........这里部分代码省略.........
示例3: Editor
# 需要导入模块: from PyQt5.Qt import QRadioButton [as 别名]
# 或者: from PyQt5.Qt.QRadioButton import setChecked [as 别名]
class Editor(QFrame): # {{{
editing_done = pyqtSignal(object)
def __init__(self, parent=None):
QFrame.__init__(self, parent)
self.setFocusPolicy(Qt.StrongFocus)
self.setAutoFillBackground(True)
self.capture = 0
self.setFrameShape(self.StyledPanel)
self.setFrameShadow(self.Raised)
self._layout = l = QGridLayout(self)
self.setLayout(l)
self.header = QLabel('')
l.addWidget(self.header, 0, 0, 1, 2)
self.use_default = QRadioButton('')
self.use_custom = QRadioButton(_('Custom'))
l.addWidget(self.use_default, 1, 0, 1, 3)
l.addWidget(self.use_custom, 2, 0, 1, 3)
self.use_custom.toggled.connect(self.custom_toggled)
off = 2
for which in (1, 2):
text = _('&Shortcut:') if which == 1 else _('&Alternate shortcut:')
la = QLabel(text)
la.setStyleSheet('QLabel { margin-left: 1.5em }')
l.addWidget(la, off+which, 0, 1, 3)
setattr(self, 'label%d'%which, la)
button = QPushButton(_('None'), self)
button.clicked.connect(partial(self.capture_clicked, which=which))
button.keyPressEvent = partial(self.key_press_event, which=which)
setattr(self, 'button%d'%which, button)
clear = QToolButton(self)
clear.setIcon(QIcon(I('clear_left.png')))
clear.clicked.connect(partial(self.clear_clicked, which=which))
setattr(self, 'clear%d'%which, clear)
l.addWidget(button, off+which, 1, 1, 1)
l.addWidget(clear, off+which, 2, 1, 1)
la.setBuddy(button)
self.done_button = doneb = QPushButton(_('Done'), self)
l.addWidget(doneb, 0, 2, 1, 1)
doneb.clicked.connect(lambda : self.editing_done.emit(self))
l.setColumnStretch(0, 100)
self.custom_toggled(False)
def initialize(self, shortcut, all_shortcuts):
self.header.setText('<b>%s: %s</b>'%(_('Customize'), shortcut['name']))
self.all_shortcuts = all_shortcuts
self.shortcut = shortcut
self.default_keys = [QKeySequence(k, QKeySequence.PortableText) for k
in shortcut['default_keys']]
self.current_keys = list(shortcut['keys'])
default = ', '.join([unicode(k.toString(k.NativeText)) for k in
self.default_keys])
if not default:
default = _('None')
current = ', '.join([unicode(k.toString(k.NativeText)) for k in
self.current_keys])
if not current:
current = _('None')
self.use_default.setText(_('Default: %(deflt)s [Currently not conflicting: %(curr)s]')%
dict(deflt=default, curr=current))
if shortcut['set_to_default']:
self.use_default.setChecked(True)
else:
self.use_custom.setChecked(True)
for key, which in zip(self.current_keys, [1,2]):
button = getattr(self, 'button%d'%which)
button.setText(key.toString(key.NativeText))
def custom_toggled(self, checked):
for w in ('1', '2'):
for o in ('label', 'button', 'clear'):
getattr(self, o+w).setEnabled(checked)
def capture_clicked(self, which=1):
self.capture = which
button = getattr(self, 'button%d'%which)
button.setText(_('Press a key...'))
button.setFocus(Qt.OtherFocusReason)
button.setStyleSheet('QPushButton { font-weight: bold}')
def clear_clicked(self, which=0):
button = getattr(self, 'button%d'%which)
button.setText(_('None'))
def key_press_event(self, ev, which=0):
if self.capture == 0:
return QWidget.keyPressEvent(self, ev)
sequence = keysequence_from_event(ev)
if sequence is None:
return QWidget.keyPressEvent(self, ev)
#.........这里部分代码省略.........