import sys
from PyQt4 import QtGui,QtCore
class MainWindow(QtGui.QWidget):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.setWindowTitle('酒店管理')
self.setWindowIcon(QtGui.QIcon('fire.jpg'))
houseNum = QtGui.QLabel('房价号')
price = QtGui.QLabel('房款')
yajin = QtGui.QLabel('押金')
ruzhu = QtGui.QLabel('入住')
qiandan = QtGui.QLabel('签单')
date = QtGui.QLabel('日期')
self.houseNumEdit = QtGui.QLineEdit()
self.priceEdit = QtGui.QLineEdit()
self.yajinEdit = QtGui.QLineEdit()
self.ruzhuEdit = QtGui.QLineEdit()
self.qiandanEdit = QtGui.QLineEdit()
self.dateEdit = QtGui.QLineEdit()
grid =QtGui.QGridLayout()
grid.addWidget(houseNum,1,0)
grid.addWidget(self.houseNumEdit,1,1)
grid.addWidget(price,2,0)
grid.addWidget(self.priceEdit,2,1)
grid.addWidget(yajin,3,0)
grid.addWidget(self.yajinEdit,3,1)
grid.addWidget(ruzhu,4,0)
grid.addWidget(self.ruzhuEdit,4,1)
grid.addWidget(qiandan,5,0)
grid.addWidget(self.qiandanEdit,5,1)
grid.addWidget(date,6,0)
grid.addWidget(self.dateEdit,6,1)
ok = QtGui.QPushButton('确定')
grid.addWidget(ok,7,0)
self.setLayout(grid)
self.resize(550,400)
self.connect(ok,QtCore.SIGNAL('clicked()'), self.addNum) #OK按钮 的clicked()时间 信号 绑定到addNum这个函数 也叫槽
def addNum(self):
houseNum = self.houseNumEdit.text() #获取文本框内容
yajin = self.yajinEdit.text()
price = self.priceEdit.text()
ruzhu = self.ruzhuEdit.text()
qiandan = self.qiandanEdit.text()
date = self.dateEdit.text()
print('房间号: %s 押金: %s 房款: %s 入住: %s 签单: %s 日期: %s' % (houseNum,
yajin,price,ruzhu,
qiandan,date))
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
from PyQt4 import QtGui,QtCore
class MainWindow(QtGui.QWidget):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.setWindowTitle('酒店管理')
self.setWindowIcon(QtGui.QIcon('fire.jpg'))
houseNum = QtGui.QLabel('房价号')
price = QtGui.QLabel('房款')
yajin = QtGui.QLabel('押金')
ruzhu = QtGui.QLabel('入住')
qiandan = QtGui.QLabel('签单')
date = QtGui.QLabel('日期')
self.houseNumEdit = QtGui.QLineEdit()
self.priceEdit = QtGui.QLineEdit()
self.yajinEdit = QtGui.QLineEdit()
self.ruzhuEdit = QtGui.QLineEdit()
self.qiandanEdit = QtGui.QLineEdit()
self.dateEdit = QtGui.QLineEdit()
grid =QtGui.QGridLayout()
grid.addWidget(houseNum,1,0)
grid.addWidget(self.houseNumEdit,1,1)
grid.addWidget(price,2,0)
grid.addWidget(self.priceEdit,2,1)
grid.addWidget(yajin,3,0)
grid.addWidget(self.yajinEdit,3,1)
grid.addWidget(ruzhu,4,0)
grid.addWidget(self.ruzhuEdit,4,1)
grid.addWidget(qiandan,5,0)
grid.addWidget(self.qiandanEdit,5,1)
grid.addWidget(date,6,0)
grid.addWidget(self.dateEdit,6,1)
ok = QtGui.QPushButton('确定')
grid.addWidget(ok,7,0)
self.setLayout(grid)
self.resize(550,400)
self.connect(ok,QtCore.SIGNAL('clicked()'), self.addNum) #OK按钮 的clicked()时间 信号 绑定到addNum这个函数 也叫槽
def addNum(self):
houseNum = self.houseNumEdit.text() #获取文本框内容
yajin = self.yajinEdit.text()
price = self.priceEdit.text()
ruzhu = self.ruzhuEdit.text()
qiandan = self.qiandanEdit.text()
date = self.dateEdit.text()
print('房间号: %s 押金: %s 房款: %s 入住: %s 签单: %s 日期: %s' % (houseNum,
yajin,price,ruzhu,
qiandan,date))
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())