Hallo miteinander,
ich komme von C# und bin auf der Suche nach einer Sprache die keine gewaltige Runtime voraussetzt (wie Java oder C#) bei Python gelandet.
Habe nun Python 3.3.0 sowie das entsprechende PySide-Paket installiert. Im Qt-Designer eine simple Form erstellt und wollte diese nach Python
kompilieren. Bekomme dabei folgende Fehlermeldungen :
pyside-uic: Traceback (most recent call last):
pyside-uic: File "C:\Development\Python33\Scripts\pyside-uic-script.py", line 5, in <module>
pyside-uic: from pkg_resources import load_entry_point
pyside-uic: ImportError: No module named 'pkg_resources'
In http://qt-project.org/wiki/PySideSimpli ... loseButton ist dieser Fehler beschrieben.
Abhilfe schafft die Installation 'setuptools' . Diese liegen allerdings nur bis zur Phython-Version 2.7 vor.
Wie kann ich diesen Fehler bei 3.3 beseitigen ? Vielen Dank für Eure Hilfe !
Karsten
Fehler beim kompilieren einer Qt-Form mit PySide
-
- User
- Beiträge: 86
- Registriert: Sonntag 23. Dezember 2012, 07:54
Diese Antwort hatte ich ein wenig befürchtet ! Trotzdem vielen Dank
- Hyperion
- Moderator
- Beiträge: 7478
- Registriert: Freitag 4. August 2006, 14:56
- Wohnort: Hamburg
- Kontaktdaten:
Was genau ist denn eine "gewaltige" Runtime?
encoding_kapiert = all(verstehen(lesen(info)) for info in (Leonidas Folien, Blog, Folien & Text inkl. Python3, utf-8 everywhere))
assert encoding_kapiert
assert encoding_kapiert
Hoffentlich ist Dein Englisch besser als mein Deutsch.
Du kannst die XML Code vom Designer direct verwenden. Hier ist ein Beispiel ...
Neugierig wie die Designer XML Code aussieht? Fast lesbar ...
Du kannst die XML Code vom Designer direct verwenden. Hier ist ein Beispiel ...
Code: Alles auswählen
''' run_form_button_label1.py
A simple loader for .ui XML files generated with PySide Designer
the Designer's XML file was saved as "form_button_label1.ui"
it contains a QWidget form with a QPushButton and a QLabel
The QPushButton and QLabel are not connected using the Designer
the connection is done by this programming code
Download PySide (LGPL-licensed version of PyQT) from:
http://qt-project.org/wiki/PySide
tested with Python33
'''
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtUiTools import QUiLoader
def on_click():
'''the button has been clicked, change the label text'''
label.setText("hello")
# create the application
app = QApplication([])
# create the ui loader
loader = QUiLoader()
# and load the form's ui file created by Designer
# should be in the working folder or use full path
widget = loader.load("form_button_label1.ui")
widget.show()
# create the pushbutton and label objects
# (for correct names check the .ui file)
button = widget.findChild(QPushButton, 'pushButton')
label = widget.findChild(QLabel, 'label')
# if the button is clicked, change the label text
# uses newer connect style (4.7)
button.clicked.connect(on_click)
# execute the application
app.exec_()
Code: Alles auswählen
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>84</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>46</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Zuletzt geändert von Anonymous am Dienstag 29. Januar 2013, 01:29, insgesamt 1-mal geändert.
Grund: Quelltexte in passende Code-Tags gesetzt.
Grund: Quelltexte in passende Code-Tags gesetzt.