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.
Related
I have a PySide2 application, which doesn't run on Spyder due to some issues. However, PyQt5 runs fine. I would like to run the application in Spyder with PyQt5 but outside (console) with PySide2. I don't want to replace packages with search and replace at every deployment/development switch.
Checking with if 'dev' in sys.argv: works fine. However, problem is that I have files to be imported with inheritance classes inheriting classes from PySide2/PyQt5. e.g. Main.py inherits Dialog.py, which has a class Dialog(QDialog):. QDialog requires an import but I can't import PySide2 or PyQt5 in that file at that moment. I also can't pass any argument to the imported file afaik.
Is there any way to deal with such issues?
Basically I solved by checking arguments:
if 'dev' in sys.argv:
import PyQt5
else:
import PySide2
Then at every file, where I need to make a similar decision:
if 'PySide2' in sys.modules:
from PySide2 import QtCore, QtGui, QtWidgets
else:
from PyQt5 import QtCore, QtGui, QtWidgets
class Dialog(QtWidgets.QDialog):
...
When I run the main script with dev argument:
python main.py dev
then it runs with PyQt5, otherwise with PySide2
PS: This also works with cx_freeze excluding PyQt5 package, without any error.
I am new to PyQt and am currently working on a project which is was written in PyQt4. I need to update it to PyQt5 and have done most of it. However, when it comes to PyKDE, it generates the following error:
from PyKDE4.kdeui import KVBox, KHBox, KColorButton
RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class
The code line using PyKDE4 is:
from PyKDE4.kdeui import KVBox, KHBox, KColorButton
Basically most of the code is already in PyQt5, but I haven't found a translation for PyKDE4. Anyone can help?
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
I am very new to using PyQt4. So far, i have used QtDesigner to create the GUI windows i shall be using for my program.
However, when i run the first bit of python coding to get the user interface to appear, i get an error i cannot find a solution to.
Here's the code:
import sys, os
from PyQt4 import QtCore, QtGui, uic
form_class = uic.loadUiType("HomeScreen.ui") [0]
All i am trying to do with this is to load a GUI, which is called 'HomeScreen.ui'.
Upon running this code, the python shell returns an error saying:
from PyQt4 import QtCore, QtGui, uic
ImportError: No module named 'PyQt4'
I have Python 3.5 installed, as well as PyQt v4.11.4 and PyQt5.6.
'QtGui' and 'QtCore' are both saved in a folder called PyQt4 (and PyQt5), which are both stored in the path:
C:\Program Files (x86)\Python\Python35-32\Lib\site-packages
I believe this is where third party modules are supposed to be stored, but python can never find the module and i repeatedly get the same error message.
Any help would be appreciated.
I also work in windows and python 3,just run the execute file to install pyqt:
https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.6/
it works well in my environment
I researched and tried this for two days now and I cannot get gtk to work on Windows 7 with Python 3.4! Whenever I launch my .py file on Python 3.4 with import gtk, I get No module named gtk! I installed pygobject but it did not help. Even gtk3-demo command works in the windows cmd prompt.
I finally got gtk to import (I think) by copying the GTK directory right to C:\Python34\Lib. But now I have a problem with gtk.glade.
Where is this? Where do I copy it from and to where?
You are possibly using an outdated tutorial, see the current Python GTK 3 tutorial for a more up-to-date reference.
In particular, the way to import GTK has changed in GTK3 to:
from gi.repository import Gtk
And instead of libglade, you would use the newer Gtk.Builder class like so:
ui = Gtk.Builder()
ui.add_from_file("my_glade_file.glade")
(you still develop the UI using Glade, it is only how you access it from your program that has changed).