pyside2uic, qtdesigner output, and FreeCAD

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
drmacro
Veteran
Posts: 8872
Joined: Sun Mar 02, 2014 4:35 pm

pyside2uic, qtdesigner output, and FreeCAD

Post by drmacro »

I would like to create some dialogs for use with my FC python code.

There is plenty of "stuff" around about doing so...but. The last time I followed one of the FreeCAD tutorials about doing so, it recommended using pip to install pyside2-tools to get pyside2uic to convert the QTDesigner out put to pyside python. Which proceeded to wreak havoc on my PC and I could no longer build or run FreeCAD.

So, what is the correct way to get pyside2uic?

It doesn't appear to be included in the FC dependencies.

:?:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by onekk »

No need to use Qtcreator for simple dialogs

see the bottom of this page

https://wiki.freecadweb.org/Dialog_creation

I have done some test this morning for a project and it work fine, at least in Linux with Appimages.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by openBrain »

onekk wrote: Fri May 07, 2021 5:49 pm No need to use Qtcreator for simple dialogs
QtCreator isn't QtDesigner.
drmacro
Veteran
Posts: 8872
Joined: Sun Mar 02, 2014 4:35 pm

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by drmacro »

onekk wrote: Fri May 07, 2021 5:49 pm No need to use Qtcreator for simple dialogs

see the bottom of this page

...
As noted QTDesigner, not QTCreator. ;)

And, I didn't say I didn't know how to make simple dialogs. 8-)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by onekk »

Sorry, it wasn't my intention to offend you.

Now I don't know what OS you are using, but generally, pip and Linux distribution don't cope very well, at least on debian based distributions.

On Windows I don't know, in the past when I've used windows generally I've installed python using the official packages, so maybe on windows pip is almost safe.

But I don't know if in the FreeCAD bundle there is already pip installed, as many people advice to install on Windows the "portable build" to keep FreeCAD "environment" separate from the OS installed programs.

Better to ask on the Installation section, for one reason many people that know this "delicate interactions" between OS and FreeCAD are frequenting that section of this forum.

But as usual, when asking something that could be OS related put the "FreeCAD info" on the post (in the installation forum almost everytime you are asked to do so).

Hope it helps

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
drmacro
Veteran
Posts: 8872
Joined: Sun Mar 02, 2014 4:35 pm

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by drmacro »

No offense taken... I have pretty thick skin. :lol:

I ran into @kkremitski on gitter last night.

Apparently pyside2uic has been replaced and the replacement (uic) should be available with the dependencies for building FreeCAD. I'm going to try it later.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by wmayer »

drmacro wrote: Fri May 07, 2021 5:42 pm The last time I followed one of the FreeCAD tutorials about doing so, it recommended using pip to install pyside2-tools
If so then it's a bad advice because it may pull in another Qt version than the default version for your system (in case it's a Linux) and may cause quite some instabilities. The recommended way is to install official packages of your repository.
It doesn't appear to be included in the FC dependencies
It's currently not possible to generate Python code out of a ui file that has some FreeCAD specific widgets. To make this working we had to write some wrapper classes using the PySide2 type system.

For more details see: https://forum.freecadweb.org/viewtopic.php?f=10&t=5374
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by onekk »

wmayer wrote: Sun May 09, 2021 6:08 am It's currently not possible to generate Python code out of a ui file that has some FreeCAD specific widgets. To make this working we had to write some wrapper classes using the PySide2 type system.
...
@wmayer it is not clear to me a couple of things:

1) is it possible to use qtcreator/qtdesigner (or whatever is named now) to create UI for FreeCAD
2) what are the "FreeCAD specific widgets"
3) I'm interest in knowing more on Gui programming to make some Macro, there is some documentation on "how to " manage the TreeView interaction, or to better explain, how much the wiki pages are updated to be "in sync" with the actual FreeCAD version.

To be more clear, sometimes we users and "newbie developers" (pass me the term) are struggling with incomplete or outdated informations, there will be a manner to mark the wiki pages as "not in sync" and maybe talk with some people that could change something.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by wmayer »

onekk wrote: Sun May 09, 2021 1:52 pm 1) is it possible to use qtcreator/qtdesigner (or whatever is named now) to create UI for FreeCAD
Sure.
2) what are the "FreeCAD specific widgets"
E.g. the class QuantitySpinBox is derived from QAbstractSpinBox and is part of the FreeCAD code. We also provide a plugin that can be used with the Qt Designer in order to simplify its usage.
However, when you use pyside's uic tool to create Python code from the UI format it won't support QuantitySpinBox.
drmacro
Veteran
Posts: 8872
Joined: Sun Mar 02, 2014 4:35 pm

Re: pyside2uic, qtdesigner output, and FreeCAD

Post by drmacro »

wmayer wrote: Sun May 09, 2021 6:08 am ...
If so then it's a bad advice because it may pull in another Qt version than the default version for your system (in case it's a Linux) and may cause quite some instabilities. The recommended way is to install official packages of your repository.
In fact I was referring to a FreeCAD wiki: https://wiki.freecadweb.org/Dialog_creation

Unfortunately, it's only mention of what to do on Linux is labeled To Do, I was left to guessing...and guessed wrong. :roll:
It's currently not possible to generate Python code out of a ui file that has some FreeCAD specific widgets. To make this working we had to write some wrapper classes using the PySide2 type system.

For more details see: https://forum.freecadweb.org/viewtopic.php?f=10&t=5374
This may be helpful when I get to using FreeCAD widgets...though, I don't know what's available. I have just been attempting to use non-FreeCAD widgets like textedit and checkbox.

The thread starts in 2014 and rests in 2017, then rekindled in March of this year...so this has been bouncing around for some time. 8-)

The wiki page I referenced above is a sort of jumping off point to several dialog example pages. I found no mention of FreeCADGui.PySideUic in any of the 6 pages linked for more examples.

I also noted that many of the examples are using PyQT4 and python 2.7.

It appears the FreeCAD scripting/dialog wiki pages could use some love... :mrgreen:

It also appears that Ubuntu 20.04 and the FreeCAD dependencies are in some sort of transition, with the package by @kkremitski rejected, etc.

It seems I have a knack for getting into "perfect storm" situations with software... :oops:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply