Δημοσιεύτηκε: 20 Νοέμ 2011, 23:43
από clepto
το ξέρω για το κενά...το geany εφταιγε, δεν μου το εδειχνε σωστα το αρχειο...
το ανοιξα με gedit και ειδα οτι αρκετες γραμμες δεν ηταν σωστα..
ορίστε:
Κώδικας: Επιλογή όλων
#!/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_()

μου βγάζει όμως
Κώδικας: Επιλογή όλων
chris@chris-Aspire-5732Z:~/Επιφάνεια εργασίας$ ./physic.pyw
QWidget: Must construct a QApplication before a QPaintDevice
Ακυρώθηκε

έκανα αναζήτηση στο google και διάβασα αλλά δεν κατάλαβα που ακριβώς είναι το πρόβλημα