Seite 1 von 1

WinPython und PYQT5

Verfasst: Sonntag 22. Januar 2017, 18:18
von soulid
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>

Re: WinPython doesn't start PYQT5

Verfasst: Sonntag 22. Januar 2017, 18:39
von Sirius3
@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)

Re: WinPython und PYQT5

Verfasst: Sonntag 22. Januar 2017, 18:48
von soulid
Super- fluppt! :P

Danke!