I followed this link to convert .ui to .py using python in windows but its not working.I tried installing pyuic4 but its not working. Is there any tools or libraries in python for doing it? Please suggest .
why not just import it?
import sys
from PyQt4 import QtGui, uic
app = QtGui.QApplication(sys.argv)
widget = uic.loadUi('demo.ui')
widget.show()
sys.exit(app.exec_())
ps: sorry i cant answer in comment section. my reputation too low
have an application created to convert the .ui (Pyqt5 Created by qt designer) file to py ( you can use for windows it will work perfectly)
you can convert your file easily using this application,
Direct Download Link: https://download1653.mediafire.com/utmxc4pza7ug/1f0gkwk6577g7fi/Ui+to+Py.zip
Mediafire link to download: https://www.mediafire.com/file/1f0gkwk6577g7fi/Ui_to_Py.zip/file
you check the source code of the application on my GitHub: https://github.com/Harvindar994/
tags: python, pyqt5, qt designer
Related
I am using macOS Big Sur beta currently. I have been able to download the libraries via Pycharm 2020.1.2 however, when running my program, no window appears to show what I've been working on.
Example:
Here is a simple line of code I've gotten as an example.
import sys
from PyQt5.QtWidgets import QApplication, QLabel
app = QApplication([])
label = QLabel('Welcome to PYQT5 Tester')
label.show()
app.exec_()
When I run the app, there are no errors and the sole description is my file directory. I am really confused to if I haven't installed anything but any help would be appreciated.
Went down to PyQt5==5.13 and it's working for me now.
I would like to make a custom widget plugin for Qt Designer using python (3.7 with pyqt5). Everything should work, but it doesn't show up in Qt Designer.
Here is what I have done so far after much trial and error and a little help from others with similar issues (Qt Designer: could not find custom PyQt widget plugins and Custom QWidgets. How do I build/get the pyqt5 plugin for Qt Designer on Mac?)
I installed Qt Designer (Creator) 5.13 from the Qt website.
I installed SIP (4.9.18) and PyQt5 (5.13.0) from source rather than pip because it was necessary to get the libpyqt5.dylib file that is necessary (no pyqt5-tools for mac). I put this file in the /Users/[user]/Qt/5.13.0/clang_64/plugins/designer directory
I just want to get the setup correct before making my own plugin. So, I downloaded analogclock.py and analogclockplugin.py from https://github.com/baoboa/pyqt5/tree/master/examples/designer/plugins and modified the plugins.py file like this:
from PyQt5.QtCore import QLibraryInfo, QProcess, QProcessEnvironment
# Tell Qt Designer where it can find the directory containing the plugins and
# Python where it can find the widgets.
env = QProcessEnvironment.systemEnvironment()
env.insert('PYQTDESIGNERPATH', '[path to the plugin.py files]/designer_plugins')
env.insert('PYTHONPATH', '[path to the widgets]/designer_widgets')
# Start Designer.
designer = QProcess()
designer.setProcessEnvironment(env)
designer_bin = QLibraryInfo.location(QLibraryInfo.BinariesPath)
designer_bin = '/Users/[user]/Qt/5.13.0/clang_64/bin/Designer.app/Contents/MacOS/Designer'
designer.start(designer_bin)
designer.waitForFinished(-1)
I ran plugins.py. Qt Designer opens correctly, and when I checked the Designer-->About Plugins I see libpyqt5.dylib inside Loaded Plugins. However, the PyAnalogClock widget was not inside of it and the plugin widget was not in the left-side widget box.
I tried to debug by setting environmental variables from the terminal like this:
[user]$ export QT_DEBUG_PLUGINS=1
[user]$ export PYQTDESIGNERPATH='[path to the widgets]/designer_widgets'
[user]$ export PYTHONPATH='[path to the widgets]/designer_widgets'
[user]$ /Users/[user]/Qt/5.13.0/clang_64/bin/Designer.app/Contents/MacOS/Designer
The relevant portion of the output was this:
Found metadata in lib /Users/[user]/Qt/5.13.0/clang_64/plugins/designer/libpyqt5.dylib, metadata=
{
"IID": "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface",
"archreq": 0,
"className": "PyCustomWidgets",
"debug": false,
"version": 331008
}
loaded library "/Users/[user]/Qt/5.13.0/clang_64/plugins/designer/libpyqt5.dylib"
and toward the end
loaded library "Python.framework/Versions/3.7/Python"
ModuleNotFoundError: No module named 'PyQt5'
ModuleNotFoundError: No module named 'PyQt5'
When I did not export PYQTDESIGNERPATH and PYTHONPATH from the command line, this error disappeared. But of course, then Qt doesn't know where the files are.
In any case, that is my current state. I do not understand why the PyQt5 module cannot be found by Qt Designer or what else I can try to get this to work.
here is an 🤦♂️ momemt
So, I found this on the PyQt reference guide which I had somehow overlooked
For a simple but complete and fully documented example of a custom widget that defines new Qt signals, slots and properties, and its plugin, look in the examples/designer/plugins directory of the PyQt5 source package
ok. did that. ran the demo. it works fine. Copied the whole plugins directory somewhere else. still fine. So I must have done something funky naming the folders or something. anyway, now I will just work on making my own plugin. days of frustration because of being dumb. but happy it works.
I have python 2.7 under windows x64, I have been trying to make a simple GUI using PyQt4, like this:
from PyQt4 import *
from ui_mainwindow import Ui_MainWindow
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
when I run the program I have this error: " No module named ui_mainWindow"
-I have pyqt4 installed
- I have tried to replace um_mainwindow with ui_simple and clientGUI but the same error resulted.
What am I doing wrong and how to fix this?
thank you
As far as I know, ui_mainWindow is a python file generated by some Qt Tool, that transforms .ui file from QtDesigner to Python class.
I have no real experience with PyQT, but I know both C++/Qt and python. In C++/Qt QtCreator does the job of transforming .ui file to C++ class, but probably in python You need to do this Yourself.
I cannot convert my .ui file from Qt Designer to a .py file with the PySide scritp : pyside-uic.exe
I get this error :
Someone can help me ?
OK, I have the answer now, I was using both PyQT4 and Pyside as librairies for my interface. The problem is that some librairies are not compatible with both librairies (like PyQwt). So, it's really important to choose weather you use PyQt or Pyside for your interface.
I've been trying to get PyQt4 to work on my OSx machine (10.8.5) for some time - I've loaded it on my windows machine with no problem by using an installer.
I have sip 4.8.5, Python 2.7 Qt 4.8.5 loaded on my machine using homebrew.
When I try to debug the following file in WING, I get the following error:
Code from Zetcode as a test
import sys
import QtGui
def main():
app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Exception:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/PyQt4/_qt.so, 2):
Library not loaded: QtDesigner.framework/Versions/4/QtDesigner
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/PyQt4/_qt.so
Reason: image not found
Why is the Qt library not loading? What do I need to do to get the library to load?
Thanks,
-j
I don't personally use homebrew, but I'm pretty sure it installs stuff in /usr/local. From the error message it looks like it is accessing /Library/Frameworks/Python.framework. I also don't use WingIDE, but it looks like it is using a different python install than you want it to. I'm sure there is a way to specify which python it uses.
You probably need to set the Python Executable in Project Properties (from the Project menu) to /usr/local/bin/python -- or whatever the value of sys.executable is in the Python that has PyQt4 installed into it.
Note that in Wing 101 this is done in the Configure Python dialog instead, which is accessed from the Edit menu.