Python Forum
[PyQt] Help converting python qt4 script to qt5
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Help converting python qt4 script to qt5
#1
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
Yoriz write Jun-23-2021, 04:34 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Attached Files

.py   wlcreator.py (Size: 33.36 KB / Downloads: 355)
Reply
#2
Replace "from PyQt4..." to from PyQt5..."?
Reply
#3
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
Yoriz write Jun-23-2021, 05:22 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#4
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
Reply
#5
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
Reply
#6
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'
Yoriz write Jun-24-2021, 05:16 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#7
self.edit.textChanged.connect(self.edited)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020