Good afternoon everyone!
I need to develop a calculator in pyqt 4, but I do not know how to connect the number / operations buttons to the virtual lcd display. I already researched, but found nothing that solved my problem. Can someone help me? What I've done so far is here (excuse me for the code rolled up, I'm an inciter!
import sys
from PyQt4 import QtGui
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
grid = QtGui.QGridLayout()
self.setLayout(grid)
lcd = QtGui.QLCDNumber(self)
grid.addWidget(lcd, 0,1)
um = QtGui.QPushButton('1', self)
grid.addWidget(um, 1,1)
dois = QtGui.QPushButton('2', self)
grid.addWidget(dois, 1,2)
tres = QtGui.QPushButton('3', self)
grid.addWidget(tres, 1,3)
quatro = QtGui.QPushButton('4', self)
grid.addWidget(quatro, 2,1)
cinco = QtGui.QPushButton('5', self)
grid.addWidget(cinco, 2,2)
seis = QtGui.QPushButton('6', self)
grid.addWidget(seis, 2,3)
sete = QtGui.QPushButton('7', self)
grid.addWidget(sete, 3,1)
oito = QtGui.QPushButton('8', self)
grid.addWidget(oito, 3,2)
nove = QtGui.QPushButton('9', self)
grid.addWidget(nove, 3,3)
zero= QtGui.QPushButton('0', self)
grid.addWidget(zero, 4,1)
mais= QtGui.QPushButton('+', self)
grid.addWidget(mais, 4,2)
menos= QtGui.QPushButton('-', self)
grid.addWidget(menos, 4,3)
vezes= QtGui.QPushButton('*', self)
grid.addWidget(vezes, 5,1)
dividir= QtGui.QPushButton('/', self)
grid.addWidget(dividir, 5,2)
igual= QtGui.QPushButton('=', self)
grid.addWidget(igual, 5,3)
self.move(300, 150)
self.setWindowTitle('Calculadora')
self.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()