Qt.Gui in FreeCAD 0.19 python module

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Qt.Gui in FreeCAD 0.19 python module

Post by vocx »

wmayer wrote: Tue Dec 03, 2019 12:06 pm Our solution is considered to be a simple wrapper for PySide2 and its purpose is exactly to avoid to explicitly handle the differences between PySide and PySide2 in client code.
IMO, it reduces readability of code when you everywhere have to add try-except-else constructs.
I don't think it's too bad, because such try-except blocks would be used sparingly. PySide and PySide2 aren't very different.
Now that Qt5 and Py3 are the default versions for FreeCAD the wrapper should be the other way around, i.e. make the wrapper for PySide to behave it like PySide2. The advantage of this wrapper will be that when we completely drop Qt4 support we only have to remove the wrapper but don't have to touch a single line in client code.
Well, let us know if you plan to make this official soon so we can start preparing on the Python workbenches. Qt4 has been obsolete for many years but many programs seemingly still support it.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Qt.Gui in FreeCAD 0.19 python module

Post by wmayer »

Well, let us know if you plan to make this official soon so we can start preparing on the Python workbenches.
I was just thinking about it but I don't have concrete plans at the moment. The question then is if this should happen before or after the release and if it's worth all the work.
Qt4 has been obsolete for many years but many programs seemingly still support it.
In the recent days when I was forced to use my very old computer with Qt4 and Py2 I could still compile and run FreeCAD.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Qt.Gui in FreeCAD 0.19 python module

Post by vocx »

wmayer wrote: Wed Dec 04, 2019 8:37 am I was just thinking about it but I don't have concrete plans at the moment. The question then is if this should happen before or after the release and if it's worth all the work.
Probably after the release so that we can dedicate the proper attention, and we don't try to tackle too many things at the same time. Also, since Python 2 is now officially unsupported, we should try to push Python 3 and Qt5 more than ever.
In the recent days when I was forced to use my very old computer with Qt4 and Py2 I could still compile and run FreeCAD.
No ofense to you, but you should really have a spare computer that is up to date. People are willing to gift you a computer for free, just ask!
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Qt.Gui in FreeCAD 0.19 python module

Post by wmayer »

No offense to you, but you should really have a spare computer that is up to date. People are willing to gift you a computer for free, just ask!
As I wrote somewhere else in the forum I already have a new computer.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Qt.Gui in FreeCAD 0.19 python module

Post by vocx »

wmayer wrote: Thu Dec 05, 2019 3:36 am As I wrote somewhere else in the forum I already have a new computer.
Well, yes, but another one! What happens if the new computer breaks? Get a spare one, as many as you need!
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Qt.Gui in FreeCAD 0.19 python module

Post by yorik »

Now I imagine Werner surrounded by piles and piles of computers...
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Qt.Gui in FreeCAD 0.19 python module

Post by keithsloan52 »

I have some Qt code that works with 0.19 but not 0.18.

Is there a way to easily make it work with both

Code: Select all


from PySide import QtGui, QtCore

import FreeCAD
import FreeCADGui

class GDMLColourMapList(QtGui.QScrollArea) :

   def __init__(self,matList) :
      super().__init__()
      # Scroll Area which contains the widgets, set as the centralWidget
      # Widget that contains the collection of Vertical Box
      self.widget = QtGui.QWidget()
      self.matList = matList
      # The Vertical Box that contains the Horizontal Boxes of  labels and buttons
      self.vbox = QtGui.QVBoxLayout()
      self.widget.setLayout(self.vbox)

      #Scroll Area Properties
      self.setVerticalScrollBarPolicy(QtGui.Qt.ScrollBarAlwaysOn)
      self.setHorizontalScrollBarPolicy(QtGui.Qt.ScrollBarAlwaysOff)
      self.setWidgetResizable(True)
      self.setWidget(self.widget)

   def addEntry(self, colour) :
      print('Add Entry')
      mat = GDMLMaterial(self.matList)
      self.vbox.addWidget(GDMLColourMapEntry(colour,mat))
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Qt.Gui in FreeCAD 0.19 python module

Post by openBrain »

What's the error ?
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Qt.Gui in FreeCAD 0.19 python module

Post by keithsloan52 »

openBrain wrote: Wed Jul 29, 2020 1:29 pm What's the error ?
On 0.19 it works on 0.18 I get

Code: Select all

[/File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/GDMLColourMap.py", line 111, in __init__
    self.setVerticalScrollBarPolicy(QtGui.Qt.ScrollBarAlwaysOn)

module 'PySide.QtGui' has no attribute 'Qt'

Code: Select all

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16146 (Git)
Build type: Release
Branch: (HEAD detached at 0.18.4)
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 3.6.7
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Interesting that it is Qt version 5.6.2. having read various forum posts I thought 0.18 was Qt4
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Qt.Gui in FreeCAD 0.19 python module

Post by openBrain »

I wonder what's the magic so it works in 0.18. :)
'Qt' namespace is in QtCore. So you have to import 'QtCore' and use QtCore.Qt.ScrollBarAlwaysOn
Post Reply