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)、密碼显示( QL
PyQt5学习笔记08----标准输入框QInputDialog
最新推荐文章于 2025-04-09 16:04:41 发布