Δημοσιεύτηκε: 20 Νοέμ 2011, 23:26
από clepto
Κώδικας: Επιλογή όλων
#!/usr/bin/env python

import sys
from math import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Form(QDialog):

def __init__(self, parent=None):
super(Form, self).__init__(parent)

principalLabel = QLabel("speed")
self.speed = QLineEdit(" ")
self.speed.selectAll()
rateLabel = QLabel("position")
self.position = QLineEdit(" ")
self.position.selectAll()
timeLabel = QLabel("time: ")
self.time = QLineEdit(" ")
self.resultLabel = QLabel()
okButton = QPushButton("OK")

grid = QGridLayout()
grid.addWidget(principalLabel, 0, 0)
grid.addWidget(self.speed, 0, 1)
grid.addWidget(rateLabel, 1, 0)
grid.addWidget(self.position, 1, 1)
grid.addWidget(timeLabel, 2, 0)
grid.addWidget(self.time, 2, 1)
grid.addWidget(self.resultLabel, 3, 0)
grid.addWidget(okButton, 3, 1)
self.setLayout(grid)

self.connect(self.okButton,
SIGNAL("clicked()"), self.calculate)

self.setWindowTitle("Physic")

def calculate:
speed = self.speed.text()
position = self.position.text()
time = self.time.text()
if self.speed == " ":
result = position / time
elif self.position == " ":
result = speed * time
elif self.time == " ":
result = position / speed
self.resultLabel.setText(" " % result)

app = QApplication(sys.argv)
form = Form()
form.show()
app.exec_()


γιατί μου βγάζει
Κώδικας: Επιλογή όλων
File "physic.pyw", line 16
rateLabel = QLabel("position")
^
TabError: inconsistent use of tabs and spaces in indentation