PyQt6 - give it a try

Hello,

i got a script that works well. But i can`t replicate it on my desktop.

try:
	from PyQt6.QtWidgets import (QApplication, QMainWindow, QVBoxLayout,
								 QWidget, QLabel, QPushButton,
								 QHBoxLayout, QGridLayout, QFrame,
								 QTableWidget, QTableWidgetItem, QHeaderView,
								 QAbstractItemView, QCheckBox)
	from PyQt6.QtGui import QFont, QPixmap, QIcon, QCursor
	from PyQt6.QtCore import Qt
except:
	import traceback
	print(traceback.format_exc())
	sys.exit()


i use Python 3.11. and newest PyQt6.

KR

Andreas

When you do your pip install, you install packages for your python 3.11 installation.
While in pyRevit, you are running on the iron python engine 2.7
No pyqt6 installed for this engine and I doubt you could make it work easily… It has to run outside of the Revit process

You could use the subprocess module for that.
But still, it would be difficult to deploy this solution without having every user to install python 3.11 + the packages you need.

Other route include making an exe out of you python code

1 Like

The pyRevit C python engine versions are only 3.7.8 and 3.8.5, try to use that versions to create your environment.

Also, make sure your PYTHONPATH points to the python 3.7/3.8 python executable.

Finally, I already offered you alternatives in the other discussion you linked here, why insist in using pyQT?

1 Like

@sanzoghenzo ,

issue is we will rollout in the office. It already runs with Cpython and dynamo. My College already can create widgets with PyQt.

For mi it is only a testing, that i can even run it on my Desktop.

I will also test your paths. Maybe we move our “tank” in a other direction. :wink:

KR

Andreas

Oh, now I see, without the context you just gave me, it seemed that you’ve ignored the advice altogether.

To sum up, what you should try:

  • install python 3.8.5 in your machine
  • ensure the PYTHONPATH environment variable points to that python version
  • add the #! /usr/bin/env python3 at the first line of your script, if you haven’t already
1 Like

@sanzoghenzo ,

but i need there unicode, can i compine this snippet?

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

… i think you are right. There are much more stable WPF as PyQt. If it starts this way! Thank you.

With python 3 unicode is the default, you shouldn’t need to add the coding info

if this is the case @sanzoghenzo , why i get this error ?

when i skipt # -*- coding: utf-8 -*- from the first line, and replace it by #! /usr/bin/env python3

It shouldn’t behave like this, but you can leave the coding line, it doesn’t hurt anyway :wink:
I suppose the coding info must be the first line, but try to switch them if it doesn’t work

1 Like