def __init__(self, parent=None):
QtGui.QSpinBox.__init__(self, parent)
self.setStyleSheet('''
QSpinBox
{
border:0px;
}
''')
python类QSpinBox()的实例源码
def addAbsoluteFrameFromSpinbox(self):
frame = self.sender().parent().findChild(QtGui.QSpinBox, 'absolute_add_spinBox').value()
self.addAbsoluteFrame(frame = frame)
#
def setupUi(self, setupAPI):
setupAPI.setObjectName("setupAPI")
setupAPI.resize(374, 188)
self.verticalLayout = QtGui.QVBoxLayout(setupAPI)
self.verticalLayout.setObjectName("verticalLayout")
self.apiFileLocationDisplay = QtGui.QLineEdit(setupAPI)
self.apiFileLocationDisplay.setDragEnabled(True)
self.apiFileLocationDisplay.setReadOnly(True)
self.apiFileLocationDisplay.setObjectName("apiFileLocationDisplay")
self.verticalLayout.addWidget(self.apiFileLocationDisplay)
self.groupBox = QtGui.QGroupBox(setupAPI)
self.groupBox.setObjectName("groupBox")
self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.portSpin = QtGui.QSpinBox(self.groupBox)
self.portSpin.setMinimum(1000)
self.portSpin.setMaximum(10000)
self.portSpin.setProperty("value", 1234)
self.portSpin.setObjectName("portSpin")
self.verticalLayout_2.addWidget(self.portSpin)
self.verticalLayout.addWidget(self.groupBox)
self.selectAPIFileButton = QtGui.QPushButton(setupAPI)
self.selectAPIFileButton.setObjectName("selectAPIFileButton")
self.verticalLayout.addWidget(self.selectAPIFileButton)
self.addAPIEntryButton = QtGui.QPushButton(setupAPI)
self.addAPIEntryButton.setObjectName("addAPIEntryButton")
self.verticalLayout.addWidget(self.addAPIEntryButton)
self.retranslateUi(setupAPI)
QtCore.QMetaObject.connectSlotsByName(setupAPI)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(186, 154)
Form.setMaximumSize(QtCore.QSize(200, 16777215))
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName("gridLayout")
self.label = QtGui.QLabel(Form)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 7, 0, 1, 2)
self.linkCombo = QtGui.QComboBox(Form)
self.linkCombo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.linkCombo.setObjectName("linkCombo")
self.gridLayout.addWidget(self.linkCombo, 7, 2, 1, 2)
self.autoPercentSpin = QtGui.QSpinBox(Form)
self.autoPercentSpin.setEnabled(True)
self.autoPercentSpin.setMinimum(1)
self.autoPercentSpin.setMaximum(100)
self.autoPercentSpin.setSingleStep(1)
self.autoPercentSpin.setProperty("value", 100)
self.autoPercentSpin.setObjectName("autoPercentSpin")
self.gridLayout.addWidget(self.autoPercentSpin, 2, 2, 1, 2)
self.autoRadio = QtGui.QRadioButton(Form)
self.autoRadio.setChecked(True)
self.autoRadio.setObjectName("autoRadio")
self.gridLayout.addWidget(self.autoRadio, 2, 0, 1, 2)
self.manualRadio = QtGui.QRadioButton(Form)
self.manualRadio.setObjectName("manualRadio")
self.gridLayout.addWidget(self.manualRadio, 1, 0, 1, 2)
self.minText = QtGui.QLineEdit(Form)
self.minText.setObjectName("minText")
self.gridLayout.addWidget(self.minText, 1, 2, 1, 1)
self.maxText = QtGui.QLineEdit(Form)
self.maxText.setObjectName("maxText")
self.gridLayout.addWidget(self.maxText, 1, 3, 1, 1)
self.invertCheck = QtGui.QCheckBox(Form)
self.invertCheck.setObjectName("invertCheck")
self.gridLayout.addWidget(self.invertCheck, 5, 0, 1, 4)
self.mouseCheck = QtGui.QCheckBox(Form)
self.mouseCheck.setChecked(True)
self.mouseCheck.setObjectName("mouseCheck")
self.gridLayout.addWidget(self.mouseCheck, 6, 0, 1, 4)
self.visibleOnlyCheck = QtGui.QCheckBox(Form)
self.visibleOnlyCheck.setObjectName("visibleOnlyCheck")
self.gridLayout.addWidget(self.visibleOnlyCheck, 3, 2, 1, 2)
self.autoPanCheck = QtGui.QCheckBox(Form)
self.autoPanCheck.setObjectName("autoPanCheck")
self.gridLayout.addWidget(self.autoPanCheck, 4, 2, 1, 2)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(186, 154)
Form.setMaximumSize(QtCore.QSize(200, 16777215))
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName("gridLayout")
self.label = QtGui.QLabel(Form)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 7, 0, 1, 2)
self.linkCombo = QtGui.QComboBox(Form)
self.linkCombo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.linkCombo.setObjectName("linkCombo")
self.gridLayout.addWidget(self.linkCombo, 7, 2, 1, 2)
self.autoPercentSpin = QtGui.QSpinBox(Form)
self.autoPercentSpin.setEnabled(True)
self.autoPercentSpin.setMinimum(1)
self.autoPercentSpin.setMaximum(100)
self.autoPercentSpin.setSingleStep(1)
self.autoPercentSpin.setProperty("value", 100)
self.autoPercentSpin.setObjectName("autoPercentSpin")
self.gridLayout.addWidget(self.autoPercentSpin, 2, 2, 1, 2)
self.autoRadio = QtGui.QRadioButton(Form)
self.autoRadio.setChecked(True)
self.autoRadio.setObjectName("autoRadio")
self.gridLayout.addWidget(self.autoRadio, 2, 0, 1, 2)
self.manualRadio = QtGui.QRadioButton(Form)
self.manualRadio.setObjectName("manualRadio")
self.gridLayout.addWidget(self.manualRadio, 1, 0, 1, 2)
self.minText = QtGui.QLineEdit(Form)
self.minText.setObjectName("minText")
self.gridLayout.addWidget(self.minText, 1, 2, 1, 1)
self.maxText = QtGui.QLineEdit(Form)
self.maxText.setObjectName("maxText")
self.gridLayout.addWidget(self.maxText, 1, 3, 1, 1)
self.invertCheck = QtGui.QCheckBox(Form)
self.invertCheck.setObjectName("invertCheck")
self.gridLayout.addWidget(self.invertCheck, 5, 0, 1, 4)
self.mouseCheck = QtGui.QCheckBox(Form)
self.mouseCheck.setChecked(True)
self.mouseCheck.setObjectName("mouseCheck")
self.gridLayout.addWidget(self.mouseCheck, 6, 0, 1, 4)
self.visibleOnlyCheck = QtGui.QCheckBox(Form)
self.visibleOnlyCheck.setObjectName("visibleOnlyCheck")
self.gridLayout.addWidget(self.visibleOnlyCheck, 3, 2, 1, 2)
self.autoPanCheck = QtGui.QCheckBox(Form)
self.autoPanCheck.setObjectName("autoPanCheck")
self.gridLayout.addWidget(self.autoPanCheck, 4, 2, 1, 2)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def createMessageGroupBox(self):
self.messageGroupBox = QtGui.QGroupBox("Balloon Message")
typeLabel = QtGui.QLabel("Type:")
self.typeComboBox = QtGui.QComboBox()
self.typeComboBox.addItem("None", QtGui.QSystemTrayIcon.NoIcon)
self.typeComboBox.addItem(self.style().standardIcon(
QtGui.QStyle.SP_MessageBoxInformation), "Information",
QtGui.QSystemTrayIcon.Information)
self.typeComboBox.addItem(self.style().standardIcon(
QtGui.QStyle.SP_MessageBoxWarning), "Warning",
QtGui.QSystemTrayIcon.Warning)
self.typeComboBox.addItem(self.style().standardIcon(
QtGui.QStyle.SP_MessageBoxCritical), "Critical",
QtGui.QSystemTrayIcon.Critical)
self.typeComboBox.setCurrentIndex(1)
self.durationLabel = QtGui.QLabel("Duration:")
self.durationSpinBox = QtGui.QSpinBox()
self.durationSpinBox.setRange(5, 60)
self.durationSpinBox.setSuffix(" s")
self.durationSpinBox.setValue(15)
durationWarningLabel = QtGui.QLabel("(some systems might ignore this "
"hint)")
durationWarningLabel.setIndent(10)
titleLabel = QtGui.QLabel("Title:")
self.titleEdit = QtGui.QLineEdit("Cannot connect to network")
bodyLabel = QtGui.QLabel("Body:")
self.bodyEdit = QtGui.QTextEdit()
self.bodyEdit.setPlainText("Don't believe me. Honestly, I don't have "
"a clue.\nClick this balloon for details.")
self.showMessageButton = QtGui.QPushButton("Show Message")
self.showMessageButton.setDefault(True)
messageLayout = QtGui.QGridLayout()
messageLayout.addWidget(typeLabel, 0, 0)
messageLayout.addWidget(self.typeComboBox, 0, 1, 1, 2)
messageLayout.addWidget(self.durationLabel, 1, 0)
messageLayout.addWidget(self.durationSpinBox, 1, 1)
messageLayout.addWidget(durationWarningLabel, 1, 2, 1, 3)
messageLayout.addWidget(titleLabel, 2, 0)
messageLayout.addWidget(self.titleEdit, 2, 1, 1, 4)
messageLayout.addWidget(bodyLabel, 3, 0)
messageLayout.addWidget(self.bodyEdit, 3, 1, 2, 4)
messageLayout.addWidget(self.showMessageButton, 5, 4)
messageLayout.setColumnStretch(3, 1)
messageLayout.setRowStretch(4, 1)
self.messageGroupBox.setLayout(messageLayout)
def init_left_pane(self):
self.left_pane = QtGui.QVBoxLayout()
# NICHE COMBO: make dropdown menu to select a fetish
self.niche_combo = QtGui.QComboBox(self)
keys = sorted(self.xpaths.keys())
for k in keys:
self.niche_combo.addItem(k)
self.niche_combo.setCurrentIndex(0)
self.niche = keys[0]
self.niche_combo.activated[str].connect(self.set_niche)
self.left_pane.addWidget(self.niche_combo)
# START PG AND PGS TO SCRAPE
self.left_pane.addSpacing(50)
self.init_page_btns()
self.left_pane.addSpacing(25)
# PROGRESS BAR: tracks the progress of the scraper
self.prog = QtGui.QProgressBar(self)
self.left_pane.addWidget(self.prog)
# SCRAPE: begin scraping
self.scrape_btn = QtGui.QPushButton("scrape", self)
self.scrape_btn.clicked.connect(self.scrape)
self.left_pane.addWidget(self.scrape_btn)
self.left_pane.addSpacing(25)
# LOAD URL: load a specific url, presumably for rating.
self.load_url_box = QtGui.QLineEdit()
self.load_url_box.setPlaceholderText("load a specific url")
self.feedback_spin = QtGui.QSpinBox()
self.feedback_spin.setMaximum(100) # (ratings must be between 0 and 100)
self.enter_btn = QtGui.QPushButton("save") # also on bottom is the enter/save button
self.enter_btn.clicked.connect(lambda: self.save_usr_url())
self.load_url_extra = QtGui.QHBoxLayout() # put feedback and enter in one row
self.load_url_extra.addWidget(self.feedback_spin)
self.load_url_extra.addWidget(self.enter_btn)
self.load_url_group = QtGui.QVBoxLayout() # group it all together
self.load_url_group.addWidget(self.load_url_box)
self.load_url_group.addLayout(self.load_url_extra)
self.left_pane.addLayout(self.load_url_group)
self.left_pane.addSpacing(25)
# RETRAIN: manual retraining of prediction algorithm
self.train_btn = QtGui.QPushButton("recalculate prediction model", self)
self.train_btn.clicked.connect(self.retrain)
self.left_pane.addWidget(self.train_btn)
self.left_pane.addSpacing(50)
# QUIT: make quit button
self.quit_btn = QtGui.QPushButton("quit", self)
self.quit_btn.clicked.connect(self.quit)
self.left_pane.addWidget(self.quit_btn)
self.layout.addLayout(self.left_pane)
def init_page_btns(self):
"""
Create the start page and pages to scrape buttons along
with their corresponding labels. Each label and spinbox
is first grouped together vertically, then put together
with the other spinbox horizontally and finally into the
main layout of our window.
"""
self.pg_spinboxes = QtGui.QHBoxLayout()
# START PG: spinbox to indicate the page to start scraping on
self.start_pg_group = QtGui.QVBoxLayout()
self.start_pg_group.setAlignment(QtCore.Qt.AlignTop)
self.start_lbl = QtGui.QLabel(self)
self.start_lbl.setText("start page")
self.start_pg_spn = QtGui.QSpinBox(self)
self.start_pg_spn.valueChanged[int].connect(self.set_start_pg)
self.start_pg_group.addWidget(self.start_lbl) # "start page"
self.start_pg_group.addWidget(self.start_pg_spn) # <spinbox>
self.pg_spinboxes.addLayout(self.start_pg_group)
self.pg_spinboxes.addSpacing(20)
# NUM PGS: spinbox to indicate the number of pages to scrape
self.n_pgs_group = QtGui.QVBoxLayout()
self.n_pgs_group.setAlignment(QtCore.Qt.AlignTop)
self.n_pgs_lbl = QtGui.QLabel(self)
self.n_pgs_lbl.setText("pages to scrape")
self.n_pgs_spn = QtGui.QSpinBox(self)
self.n_pgs_spn.valueChanged[int].connect(self.set_max_pgs)
self.n_pgs_spn.setMinimum(1)
self.n_pgs_group.addWidget(self.n_pgs_lbl) # "pages to scrape"
self.n_pgs_group.addWidget(self.n_pgs_spn) # <spinbox>
self.n_pgs_group.setAlignment(QtCore.Qt.Vertical)
self.pg_spinboxes.addLayout(self.n_pgs_group)
# Combine both in a box.
self.pg_spinboxes.setAlignment(QtCore.Qt.AlignTop)
self.left_pane.addLayout(self.pg_spinboxes)