Python——GUI编程(python programming)
import sys from math import * from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Form(QDialog): def __init__(self,parent=None): super().__init__(parent) layout = QVBoxLayout() self.setLayout(layout) def updateUi(self): pass app = QApplication(sys.argv) form = Form() form.show() app.exec_()
QLabel
import sys from math import * from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Form(QDialog): def __init__(self,parent=None): super().__init__(parent) #标签 self.aLabel = QLabel(self) self.aLabel.setText("hhhhhhh") #数字框 self.mySpinBox = QDoubleSpinBox(self) self.mySpinBox.setValue(100) self.mySpinBox.setRange(1,1000) #滑动条 self.s = QSlider() #可编辑文本 self.lineedit = QLineEdit("请输入我爱帅帅:") #不可编辑文本框 self.browser = QTextBrowser() self.browser.append("你改不了吧,嘿嘿") #选单 self.listWidget = QListWidget(self) self.listWidget.addItems(["巧克力","抹茶","冰淇淋"]) #下拉选单 self.comboBox = QComboBox(self) itemdata = ['学习python','学习c++','学习java'] self.comboBox.addItems(itemdata) #按钮 self.okButton = QPushButton(self) self.okButton.setText("我佛了...") layout = QVBoxLayout() layout.addWidget(self.aLabel) layout.addWidget(self.mySpinBox) layout.addWidget(self.s) layout.addWidget(self.lineedit) layout.addWidget(self.browser) layout.addWidget(self.listWidget) layout.addWidget(self.comboBox) layout.addWidget(self.okButton) self.setLayout(layout) def updateUi(self): pass app = QApplication(sys.argv) form = Form() form.show() app.exec_()
set_pen
import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class PenPropertiesDlg(QDialog): def __init__(self, parent=None): super(PenPropertiesDlg, self).__init__(parent) widthLabel = QLabel("&Width:") self.widthSpinBox = QSpinBox() widthLabel.setBuddy(self.widthSpinBox) self.widthSpinBox.setAlignment(Qt.AlignRight|Qt.AlignVCenter) self.widthSpinBox.setRange(0, 24) self.beveledCheckBox = QCheckBox("&Beveled edges") styleLabel = QLabel("&Style:") self.styleComboBox = QComboBox() styleLabel.setBuddy(self.styleComboBox) self.styleComboBox.addItems(["Solid", "Dashed", "Dotted", "DashDotted", "DashDotDotted"]) okButton = QPushButton("&OK") cancelButton = QPushButton("Cancel") buttonLayout = QHBoxLayout() buttonLayout.addStretch() buttonLayout.addWidget(okButton) buttonLayout.addWidget(cancelButton) layout = QGridLayout() layout.addWidget(widthLabel, 0, 0) layout.addWidget(self.widthSpinBox, 0, 1) layout.addWidget(self.beveledCheckBox, 0, 2) layout.addWidget(styleLabel, 1, 0) layout.addWidget(self.styleComboBox, 1, 1, 1, 2) layout.addLayout(buttonLayout, 2, 0, 1, 3) self.setLayout(layout) self.setWindowTitle("Pen Properties") okButton.clicked.connect(self.accept) cancelButton.clicked.connect(self.reject) class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) self.width = 1 self.beveled = False self.style = "Solid" penButton = QPushButton("Set Pen") self.label = QLabel("The Pen has not been set") self.label.setTextFormat(Qt.RichText) layout = QVBoxLayout() layout.addWidget(penButton) layout.addWidget(self.label) self.setLayout(layout) self.setWindowTitle("Pen") penButton.clicked.connect(self.setPenProperties) self.updateData() def updateData(self): bevel = "" if self.beveled: bevel = "<br>Beveled" self.label.setText("Width = {}<br>Style = {}{}".format(self.width, self.style, bevel)) def setPenProperties(self): dialog = PenPropertiesDlg(self) dialog.widthSpinBox.setValue(self.width) dialog.beveledCheckBox.setChecked(self.beveled) dialog.styleComboBox.setCurrentIndex( dialog.styleComboBox.findText(self.style)) if dialog.exec_(): self.width = dialog.widthSpinBox.value() self.beveled = dialog.beveledCheckBox.isChecked() self.style = dialog.styleComboBox.currentText() self.updateData() app = QApplication(sys.argv) form = Form() form.resize(400, 200) form.show() app.exec_()
问题:一球从某高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第n次落地时,共经过多少米?第n次反弹多高?
问题:alias设置与删除
问题:从键盘读取特定类型的数据(使用Scanner读取int类型)
求一个数组当中最大(最小)值的两种计算方法
Mysql5.7安装
maven下载及安装
Ubuntu下修改DNS重启也能用的方法
删除CNNIC证书
字符编码ASCII, Unicode和UTF-8概念扫盲