dear all .. i'm newbee on python and pyqt, i try to make small program with pyqt, the program is running, when i press the return key its will show input dialog and if i input 1 on label1 will show "one" and if i press enter egain input dialog will show again and if i input 2 the problem is the label still show "one" not show "two", any body can help me ..? pls
this is my code:
import sys
from PyQt4 import QtGui, QtCore
class class InputDialog(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(300, 300, 350, 80)
self.resize(1024,768)
self.setWindowTitle('InputDialog')
self.label = QtGui.QLabel(self)
self.label.setGeometry (10,10,80,20)
self.label.setText("Operator :")
self.label1 = QtGui.QLabel(self)
self.label1.setGeometry(90,10,80,20)
def keyPressEvent(self, event):
if event.key() == (QtCore.Qt.Key_Return):
self.label1.clear()
text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter Your name:')
if ok and ok==1:
self.label1.setText("one")
elif ok and ok==2:
self.label.setText("two")
else:
self.label1.setText("ok")
app = QtGui.QApplication(sys.argv)
ya = InputDialog()
ya.show()
app.exec_()
sorry for my bad english