από clepto » 20 Νοέμ 2011, 23:43
το ξέρω για το κενά...το 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 και διάβασα αλλά δεν κατάλαβα που ακριβώς είναι το πρόβλημα
1 Γνώσεις Linux: Ικανοποιητικό ┃ Προγραμματισμού: Ικανοποιητικό ┃ Αγγλικών: Ικανοποιητικό
2 Ubuntu 13.04 raring 3.8.0-30-generic 64bit (en_US.UTF-8, Unity ubuntu), Ubuntu 3.8.0-19-generic, Windows 7
3 Intel Core i7-3537U CPU @ 2.00GHz ‖ RAM 3840 MiB ‖ ASUS K56CB
4 Intel 3rd Gen Core processor Graphics Controller [8086:0166] {i915}
5 wlan0: Atheros Inc. AR9485 Wireless Network Adapter [168c:0032] (rev 01) ⋮ eth0: Realtek RTL8111/8168 PCI Express Gigabit Ethernet controller [10ec:8168] (rev 0a)