WinPython und PYQT5

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
soulid
User
Beiträge: 8
Registriert: Freitag 13. Januar 2017, 11:15

Ich habe Winpython installiert (sollte doch PYQT5 und 4 bei sein, oder)?

Ich habe eine GUI mit PQT Designer zusammengelickt und versucht die anzeigen zu lassen...geht nich' :K
sowohl die .py als auch die .ui Deti liegen im Winpython Hautpverzeichnis. Ich verstehe nicht warum... :?

Fehlermeldung ist
runfile('C:/WinPython/guiprof.py', wdir='C:/WinPython')
Traceback (most recent call last):

File "<ipython-input-2-8dc8d2453a14>", line 1, in <module>
runfile('C:/WinPython/guiprof.py', wdir='C:/WinPython')

File "C:\WinPython\python-3.4.4.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)

File "C:\WinPython\python-3.4.4.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/WinPython/guiprof.py", line 9, in <module>
app = PyQt5.QApplication(sys.argv)

NameError: name 'PyQt5' is not defined
Hier ist der Code

Code: Alles auswählen

# -*- coding: utf-8 -*-
import sys

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.uic import *


app = PyQt5.QApplication(sys.argv)
w=loadUi("Guiprof.ui")
w.show()
sys.exit(app.exec_())

Code: Alles auswählen

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>800</width>
    <height>600</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>130</x>
      <y>350</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>PushButton</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_2">
    <property name="geometry">
     <rect>
      <x>130</x>
      <y>380</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>PushButton</string>
    </property>
   </widget>
   <widget class="QComboBox" name="comboBox">
    <property name="geometry">
     <rect>
      <x>230</x>
      <y>380</y>
      <width>69</width>
      <height>22</height>
     </rect>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>800</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>
Zuletzt geändert von soulid am Sonntag 22. Januar 2017, 18:44, insgesamt 1-mal geändert.
Sirius3
User
Beiträge: 17741
Registriert: Sonntag 21. Oktober 2012, 17:20

@soulid: Du importierst die Namen aus verschiedenen Modulen (was man aber nicht per *-Import machen sollte, weil man so nicht nachvollziehen kann, woher was kommt), aber PyQt5 importierst Du nicht. Korrekt wäre etwa soetwas

Code: Alles auswählen

from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
soulid
User
Beiträge: 8
Registriert: Freitag 13. Januar 2017, 11:15

Super- fluppt! :P

Danke!
Antworten