Python Forum
[PyQt] Help converting python qt4 script to qt5 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [PyQt] Help converting python qt4 script to qt5 (/thread-34071.html)



Help converting python qt4 script to qt5 - Bladeforce - Jun-23-2021

Hi,

Could someone help with converting this pyqt4 script to pyqt5 please?
When i run it i get this error:

Error:
Traceback (most recent call last): File "/usr/local/bin/wlcreator.py", line 31, in <module> from PyQt4.QtGui import * ImportError: No module named PyQt4.QtGui
I've uploaded the script as an attachment

Thanks very much


RE: Help converting python qt4 script to qt5 - deanhystad - Jun-23-2021

Replace "from PyQt4..." to from PyQt5..."?


RE: Help converting python qt4 script to qt5 - Bladeforce - Jun-23-2021

Hi,

I tried changing what you said and now i'm getting this error:

Error:
File "./wlcreator.py", line 54 print "COMMAND:",command ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("COMMAND:",command)?
I've tried changing this line with the one it thinks it should be and now i get this error

Error:
File "./wlcreator.py", line 66 if len(output) > 0: print "OUTPUT:\n",output ^ SyntaxError: invalid syntax



RE: Help converting python qt4 script to qt5 - deanhystad - Jun-23-2021

Looks like your scripts are written in Python 2 and you are now using Python 3. print is a function in Python 3. Here is a porting guide.

https://docs.python.org/3/howto/pyporting.html


RE: Help converting python qt4 script to qt5 - Axel_Erfurt - Jun-23-2021

change your imports

import sys
import glob
import os
import tempfile
import subprocess
import shlex
import shutil
from configparser import ConfigParser
import urllib

from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
and put all print in brackets


RE: Help converting python qt4 script to qt5 - Bladeforce - Jun-23-2021

Thanks for all the help so far!

I have done as requested an now get this error

Error:
Traceback (most recent call last): File "./wlcreator.py", line 719, in <module> main = MainWindow() File "./wlcreator.py", line 266, in __init__ self.executable = BrowseControl("Exe path", "Select exe file", "Path to an Windows executable file", "", File "./wlcreator.py", line 102, in __init__ self.connect(self.edit, SIGNAL("textChanged(QString)"), self.edited) AttributeError: 'BrowseControl' object has no attribute 'connect'



RE: Help converting python qt4 script to qt5 - Axel_Erfurt - Jun-24-2021

self.edit.textChanged.connect(self.edited)