-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuntitled.py
30 lines (26 loc) · 1.45 KB
/
untitled.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QLineEdit,QInputDialog
class MyWindow(QtWidgets.QWidget):
def __init__(self):
super(MyWindow,self).__init__()
self.myButton = QtWidgets.QPushButton(self)
self.myButton.setObjectName("myButton")
self.myButton.setText("Test")
self.myButton.clicked.connect(self.msg)
def msg(self):
#后面四个数字的作用依次是 初始值 最小值 最大值 小数点后位数
doubleNum,ok1 = QInputDialog.getDouble(self, "标题","计数:", 37.56, -10000, 10000, 2)
#后面四个数字的作用依次是 初始值 最小值 最大值 步幅
intNum,ok2 = QInputDialog.getInt(self, "标题","计数:", 37, -10000, 10000, 2)
#第三个参数可选 有一般显示 (QLineEdit.Normal)、密碼显示( QLineEdit. Password)与不回应文字输入( QLineEdit. NoEcho)
stringNum,ok3 = QInputDialog.getText(self, "标题","姓名:",QLineEdit.Normal, "王尼玛")
#1为默认选中选项目,True/False 列表框是否可编辑。
items = ["Spring", "Summer", "Fall", "Winter"]
item, ok4 = QInputDialog.getItem(self, "标题","Season:", items, 1, True)
text, ok5 = QInputDialog.getMultiLineText(self, "标题", "Address:", "John Doe\nFreedom Street")
if __name__=="__main__":
import sys
app=QtWidgets.QApplication(sys.argv)
myshow=MyWindow()
myshow.show()
sys.exit(app.exec_())