Creating GUI in macro

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Adam Jelínek
Posts: 13
Joined: Thu Jun 09, 2016 6:42 am

Creating GUI in macro

Postby Adam Jelínek » Fri Jul 01, 2016 10:12 am

Hello, as I am new to freeCAD, Python and I have never created any GUI application, I am confused about how to start.

I started by creating some simple windows using PySide. Then I researched that PySide is more or less dead and any development is inactive.
Then I found Qt. And the option to create GUI via Qt Creator.

But I do not know what version should I use. I found some topics about Qt5 being implementing into freeCAD. I even found something about PySide2.

But I am simply confused on all levels.

I would like to use python for creating some simple apps out of freeCAD as well. Therefore I would like to use Qt.
Can I install the current Qt 5.6.1 and the current Qt Creator 4.0.2? And develop some GUI for freeCAD and past it to macro??
I am a student, so licencing is not my problem I guess. All I want to do is for my personal use only.
User avatar
sgrogan
Posts: 5577
Joined: Wed Oct 22, 2014 5:02 pm

Re: Creating GUI in macro

Postby sgrogan » Fri Jul 01, 2016 12:20 pm

Adam Jelínek wrote:Can I install the current Qt 5.6.1 and the current Qt Creator 4.0.2? And develop some GUI for freeCAD and past it to macro??
You want to use the version of QT that matches the version your FreeCAD uses. It is listed in your "About FreeCAD" info as explained here: viewtopic.php?f=3&t=2264
The port to QT5/Pyside2 is not complete and FreeCAD doesn't support this yet. When the port is complete FreeCAD will support QT4 and QT5 for some period of time.
User avatar
DeepSOIC
Posts: 7291
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Creating GUI in macro

Postby DeepSOIC » Fri Jul 01, 2016 10:37 pm

Hi!
Qt is C++. PySide is python binding of it. You have to use PySide to make Gui for your macro, unless you want to mess with the trouble of compiling c++ code (which then probably can't be called "macro").

When creating Gui for AttachmentEditor, I used PartDesign Gear code as a starting point. But there is a plenty of macros with Gui in Macros recipes, use any of them as a starting point.

You need to create a .ui file for your Gui. Use Qt Creator for the purpose (any version will do - I use Qt Creator 3.4.1). You do not have to install Qt libraries for that.

There is also a Qt Designer program, totally dedicated to making ui files. It is included with FreeCAD libpack (on Windows).
mario52
Posts: 2804
Joined: Wed May 16, 2012 2:13 pm

Re: Creating GUI in macro

Postby mario52 » Sat Jul 02, 2016 9:41 am

hi welcome
Adam Jelínek wrote:I started by creating some simple windows using PySide. Then I researched that PySide is more or less dead and any development is inactive.
Then I found Qt. And the option to create GUI via Qt Creator.
see this example Qt_Example
here for begin PySide

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
josegegas
Posts: 42
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: Creating GUI in macro

Postby josegegas » Thu Jun 15, 2017 10:45 am

Hi. This document helped me a lot. There is an example on how to create a gui with QtDesigner and then put it into FreeCAD. Is one of the last chapters...

https://www.gitbook.com/book/yorikvanha ... al/details