4141import math
4242import PySide .QtCore as QtCore
4343import PySide .QtGui as QtGui
44+ import PySide .QtWidgets as QtWidgets
4445
4546import FreeCAD
4647import FreeCADGui
@@ -83,7 +84,7 @@ def _get_incmd_shortcut(itm):
8384# Customized widgets
8485#---------------------------------------------------------------------------
8586
86- class DraftBaseWidget (QtGui .QWidget ):
87+ class DraftBaseWidget (QtWidgets .QWidget ):
8788 def __init__ (self ,parent = None ):
8889 super ().__init__ (parent )
8990 def eventFilter (self , widget , event ):
@@ -106,7 +107,7 @@ def changeEvent(self, event):
106107 else :
107108 super ().changeEvent (event )
108109
109- class DraftLineEdit (QtGui .QLineEdit ):
110+ class DraftLineEdit (QtWidgets .QLineEdit ):
110111 """custom QLineEdit widget that has the power to catch Escape keypress"""
111112 def __init__ (self , parent = None ):
112113 super ().__init__ (parent )
@@ -130,7 +131,7 @@ def __init__(self,widget,extra=None):
130131 else :
131132 self .form = widget
132133 def getStandardButtons (self ):
133- return int (QtGui .QDialogButtonBox .Close )
134+ return int (QtWidgets .QDialogButtonBox .Close )
134135 def accept (self ):
135136 if hasattr (FreeCADGui ,"draftToolBar" ):
136137 return FreeCADGui .draftToolBar .validatePoint ()
@@ -203,7 +204,7 @@ def __init__(self):
203204
204205 # add only a dummy widget, since widgets are created on demand
205206 self .baseWidget = DraftBaseWidget ()
206- self .tray = QtGui .QToolBar (None )
207+ self .tray = QtWidgets .QToolBar (None )
207208 self .tray .setObjectName ("Draft tray" )
208209 self .tray .setWindowTitle ("Draft tray" )
209210 self .toptray = self .tray
@@ -221,7 +222,7 @@ def __init__(self):
221222
222223 def _pushbutton (self ,name , layout , hide = True , icon = None ,
223224 width = None , checkable = False , square = False ):
224- button = QtGui .QPushButton (self .baseWidget )
225+ button = QtWidgets .QPushButton (self .baseWidget )
225226 button .setObjectName (name )
226227 if square :
227228 button .setMaximumSize (QtCore .QSize (button .height (), button .height ()))
@@ -241,7 +242,7 @@ def _pushbutton(self,name, layout, hide=True, icon=None,
241242 return button
242243
243244 def _label (self ,name , layout , hide = True , wrap = False ):
244- label = QtGui .QLabel (self .baseWidget )
245+ label = QtWidgets .QLabel (self .baseWidget )
245246 label .setObjectName (name )
246247 if wrap :
247248 label .setWordWrap (True )
@@ -264,8 +265,8 @@ def _inputfield (self,name, layout, hide=True, width=None):
264265 inputfield .setObjectName (name )
265266 if hide : inputfield .hide ()
266267 if not width :
267- sizePolicy = QtGui .QSizePolicy (
268- QtGui .QSizePolicy .Expanding , QtGui .QSizePolicy .Preferred )
268+ sizePolicy = QtWidgets .QSizePolicy (
269+ QtWidgets .QSizePolicy .Expanding , QtWidgets .QSizePolicy .Preferred )
269270 inputfield .setSizePolicy (sizePolicy )
270271 inputfield .setMinimumWidth (110 )
271272 else :
@@ -276,10 +277,10 @@ def _inputfield (self,name, layout, hide=True, width=None):
276277 def _spinbox (self ,name , layout , val = None , vmax = None ,
277278 hide = True , double = False , size = None ):
278279 if double :
279- sbox = QtGui .QDoubleSpinBox (self .baseWidget )
280+ sbox = QtWidgets .QDoubleSpinBox (self .baseWidget )
280281 sbox .setDecimals (params .get_param ("Decimals" , path = "Units" ))
281282 else :
282- sbox = QtGui .QSpinBox (self .baseWidget )
283+ sbox = QtWidgets .QSpinBox (self .baseWidget )
283284 sbox .setObjectName (name )
284285 if vmax : sbox .setMaximum (vmax )
285286 if val : sbox .setValue (val )
@@ -289,15 +290,15 @@ def _spinbox (self,name, layout, val=None, vmax=None,
289290 return sbox
290291
291292 def _checkbox (self ,name , layout , checked = True , hide = True ):
292- chk = QtGui .QCheckBox (self .baseWidget )
293+ chk = QtWidgets .QCheckBox (self .baseWidget )
293294 chk .setChecked (checked )
294295 chk .setObjectName (name )
295296 if hide : chk .hide ()
296297 layout .addWidget (chk )
297298 return chk
298299
299300 def _combo (self ,name ,layout ,hide = True ):
300- cb = QtGui .QComboBox (self .baseWidget )
301+ cb = QtWidgets .QComboBox (self .baseWidget )
301302 cb .setObjectName (name )
302303 if hide : cb .hide ()
303304 layout .addWidget (cb )
@@ -316,10 +317,10 @@ def setupToolBar(self,task=False):
316317
317318 # point
318319
319- xl = QtGui .QHBoxLayout ()
320- yl = QtGui .QHBoxLayout ()
321- zl = QtGui .QHBoxLayout ()
322- bl = QtGui .QHBoxLayout ()
320+ xl = QtWidgets .QHBoxLayout ()
321+ yl = QtWidgets .QHBoxLayout ()
322+ zl = QtWidgets .QHBoxLayout ()
323+ bl = QtWidgets .QHBoxLayout ()
323324 self .layout .addLayout (xl )
324325 self .layout .addLayout (yl )
325326 self .layout .addLayout (zl )
@@ -340,19 +341,19 @@ def setupToolBar(self,task=False):
340341
341342 # text
342343
343- self .textValue = QtGui .QTextEdit (self .baseWidget )
344+ self .textValue = QtWidgets .QTextEdit (self .baseWidget )
344345 self .textValue .setObjectName ("textValue" )
345346 self .textValue .setTabChangesFocus (True )
346347 self .layout .addWidget (self .textValue )
347348 self .textValue .hide ()
348- tl = QtGui .QHBoxLayout ()
349+ tl = QtWidgets .QHBoxLayout ()
349350 self .layout .addLayout (tl )
350351 self .textOkButton = self ._pushbutton ("textButton" , tl , icon = "button_valid" )
351352
352353 # additional line controls
353354
354- ll = QtGui .QHBoxLayout ()
355- al = QtGui .QHBoxLayout ()
355+ ll = QtWidgets .QHBoxLayout ()
356+ al = QtWidgets .QHBoxLayout ()
356357 self .layout .addLayout (ll )
357358 self .layout .addLayout (al )
358359 self .labellength = self ._label ("labellength" , ll )
@@ -366,33 +367,33 @@ def setupToolBar(self,task=False):
366367
367368 # options
368369
369- fl = QtGui .QHBoxLayout ()
370+ fl = QtWidgets .QHBoxLayout ()
370371 self .layout .addLayout (fl )
371372 self .numFacesLabel = self ._label ("numfaceslabel" , fl )
372373 self .numFaces = self ._spinbox ("numFaces" , fl , 3 )
373- ol = QtGui .QHBoxLayout ()
374+ ol = QtWidgets .QHBoxLayout ()
374375 self .layout .addLayout (ol )
375- rl = QtGui .QHBoxLayout ()
376+ rl = QtWidgets .QHBoxLayout ()
376377 self .layout .addLayout (rl )
377378 self .labelRadius = self ._label ("labelRadius" , rl )
378379 self .radiusValue = self ._inputfield ("radiusValue" , rl )
379380 self .radiusValue .setText (FreeCAD .Units .Quantity (0 ,FreeCAD .Units .Length ).UserString )
380- bl = QtGui .QHBoxLayout ()
381+ bl = QtWidgets .QHBoxLayout ()
381382 self .layout .addLayout (bl )
382383 self .undoButton = self ._pushbutton ("undoButton" , bl , icon = 'Draft_Rotate' )
383- bl = QtGui .QHBoxLayout ()
384+ bl = QtWidgets .QHBoxLayout ()
384385 self .layout .addLayout (bl )
385386 self .finishButton = self ._pushbutton ("finishButton" , bl , icon = 'Draft_Finish' )
386- bl = QtGui .QHBoxLayout ()
387+ bl = QtWidgets .QHBoxLayout ()
387388 self .layout .addLayout (bl )
388389 self .closeButton = self ._pushbutton ("closeButton" , bl , icon = 'Draft_Lock' )
389- bl = QtGui .QHBoxLayout ()
390+ bl = QtWidgets .QHBoxLayout ()
390391 self .layout .addLayout (bl )
391392 self .wipeButton = self ._pushbutton ("wipeButton" , bl , icon = 'Draft_Wipe' )
392- bl = QtGui .QHBoxLayout ()
393+ bl = QtWidgets .QHBoxLayout ()
393394 self .layout .addLayout (bl )
394395 self .orientWPButton = self ._pushbutton ("orientWPButton" , bl , icon = 'Draft_SelectPlane' )
395- bl = QtGui .QHBoxLayout ()
396+ bl = QtWidgets .QHBoxLayout ()
396397 self .layout .addLayout (bl )
397398 self .selectButton = self ._pushbutton ("selectButton" , bl , icon = 'view-select' )
398399
@@ -424,8 +425,8 @@ def setupToolBar(self,task=False):
424425 checked = params .get_param ("SubelementMode" ))
425426
426427 # spacer
427- spacerItem = QtGui .QSpacerItem (20 , 40 , QtGui .QSizePolicy .Minimum ,
428- QtGui .QSizePolicy .Expanding )
428+ spacerItem = QtWidgets .QSpacerItem (20 , 40 , QtWidgets .QSizePolicy .Minimum ,
429+ QtWidgets .QSizePolicy .Expanding )
429430 self .layout .addItem (spacerItem )
430431
431432 QtCore .QObject .connect (self .xValue ,QtCore .SIGNAL ("valueChanged(double)" ),self .changeXValue )
@@ -620,7 +621,7 @@ def taskUi(self,title="Draft",extra=None,icon="Draft_Draft"):
620621 self .isTaskOn = True
621622 todo .delay (FreeCADGui .Control .closeDialog ,None )
622623 self .baseWidget = DraftBaseWidget ()
623- self .layout = QtGui .QVBoxLayout (self .baseWidget )
624+ self .layout = QtWidgets .QVBoxLayout (self .baseWidget )
624625 self .setupToolBar (task = True )
625626 self .retranslateUi (self .baseWidget )
626627 self .panel = DraftTaskPanel (self .baseWidget ,extra )
@@ -753,10 +754,10 @@ def pointUi(self, title=translate("draft","Point"), cancel=None, extra=None,
753754 self .xValue .selectAll ()
754755
755756 def labelUi (self ,title = translate ("draft" ,"Label" ),callback = None ):
756- w = QtGui .QWidget ()
757+ w = QtWidgets .QWidget ()
757758 w .setWindowTitle (translate ("draft" ,"Label type" ))
758- l = QtGui .QVBoxLayout (w )
759- combo = QtGui .QComboBox ()
759+ l = QtWidgets .QVBoxLayout (w )
760+ combo = QtWidgets .QComboBox ()
760761 from draftobjects .label import get_label_types
761762 types = get_label_types ()
762763 for s in types :
@@ -788,7 +789,7 @@ def offUi(self):
788789 self .pointcallback = None
789790 self .mask = None
790791 self .isTaskOn = False
791- self .baseWidget = QtGui .QWidget ()
792+ self .baseWidget = QtWidgets .QWidget ()
792793
793794 def trimUi (self ,title = translate ("draft" ,"Trimex" )):
794795 self .taskUi (title , icon = "Draft_Trimex" )
@@ -906,9 +907,9 @@ def isThere(widget):
906907 def relocate (self ):
907908 """relocates the right-aligned buttons depending on the toolbar size"""
908909 if self .baseWidget .geometry ().width () < 400 :
909- self .layout .setDirection (QtGui .QBoxLayout .TopToBottom )
910+ self .layout .setDirection (QtWidgets .QBoxLayout .TopToBottom )
910911 else :
911- self .layout .setDirection (QtGui .QBoxLayout .LeftToRight )
912+ self .layout .setDirection (QtWidgets .QBoxLayout .LeftToRight )
912913
913914 def makeDumbTask (self , extra = None , on_close_call = None ):
914915 """create a dumb taskdialog to prevent deleting the temp object"""
@@ -918,7 +919,7 @@ def __init__(self, extra=None, callback=None):
918919 self .form = [extra ]
919920 self .callback = callback
920921 def getStandardButtons (self ):
921- return int (QtGui .QDialogButtonBox .Close )
922+ return int (QtWidgets .QDialogButtonBox .Close )
922923 def reject (self ):
923924 if self .callback :
924925 self .callback ()
@@ -1355,11 +1356,11 @@ def toggleContinue(self):
13551356 if hasattr (self .panel ,"form" ):
13561357 if isinstance (self .panel .form ,list ):
13571358 for w in self .panel .form :
1358- c = w .findChild (QtGui .QCheckBox ,"ContinueCmd" )
1359+ c = w .findChild (QtWidgets .QCheckBox ,"ContinueCmd" )
13591360 if c :
13601361 c .toggle ()
13611362 else :
1362- c = self .panel .form .findChild (QtGui .QCheckBox ,"ContinueCmd" )
1363+ c = self .panel .form .findChild (QtWidgets .QCheckBox ,"ContinueCmd" )
13631364 if c :
13641365 c .toggle ()
13651366 except Exception :
@@ -1405,7 +1406,7 @@ def setStyleButton(self):
14051406
14061407 def popupMenu (self ,llist ,ilist = None ,pos = None ):
14071408 """pops up a menu filled with the given list"""
1408- self .groupmenu = QtGui .QMenu ()
1409+ self .groupmenu = QtWidgets .QMenu ()
14091410 for i ,l in enumerate (llist ):
14101411 if ilist :
14111412 self .groupmenu .addAction (ilist [i ],l )
@@ -1632,26 +1633,26 @@ class FacebinderTaskPanel:
16321633 def __init__ (self ):
16331634
16341635 self .obj = None
1635- self .form = QtGui .QWidget ()
1636+ self .form = QtWidgets .QWidget ()
16361637 self .form .setObjectName ("FacebinderTaskPanel" )
1637- self .grid = QtGui .QGridLayout (self .form )
1638+ self .grid = QtWidgets .QGridLayout (self .form )
16381639 self .grid .setObjectName ("grid" )
1639- self .title = QtGui .QLabel (self .form )
1640+ self .title = QtWidgets .QLabel (self .form )
16401641 self .grid .addWidget (self .title , 0 , 0 , 1 , 2 )
16411642
16421643 # tree
1643- self .tree = QtGui .QTreeWidget (self .form )
1644+ self .tree = QtWidgets .QTreeWidget (self .form )
16441645 self .grid .addWidget (self .tree , 1 , 0 , 1 , 2 )
16451646 self .tree .setColumnCount (2 )
16461647 self .tree .setHeaderLabels (["Name" ,"Subelement" ])
16471648
16481649 # buttons
1649- self .addButton = QtGui .QPushButton (self .form )
1650+ self .addButton = QtWidgets .QPushButton (self .form )
16501651 self .addButton .setObjectName ("addButton" )
16511652 self .addButton .setIcon (QtGui .QIcon (":/icons/Arch_Add.svg" ))
16521653 self .grid .addWidget (self .addButton , 3 , 0 , 1 , 1 )
16531654
1654- self .delButton = QtGui .QPushButton (self .form )
1655+ self .delButton = QtWidgets .QPushButton (self .form )
16551656 self .delButton .setObjectName ("delButton" )
16561657 self .delButton .setIcon (QtGui .QIcon (":/icons/Arch_Remove.svg" ))
16571658 self .grid .addWidget (self .delButton , 3 , 1 , 1 , 1 )
@@ -1667,7 +1668,7 @@ def isAllowedAlterView(self):
16671668 return True
16681669
16691670 def getStandardButtons (self ):
1670- return int (QtGui .QDialogButtonBox .Ok )
1671+ return int (QtWidgets .QDialogButtonBox .Ok )
16711672
16721673 def update (self ):
16731674 """fills the treewidget"""
@@ -1676,12 +1677,12 @@ def update(self):
16761677 for f in self .obj .Faces :
16771678 if isinstance (f [1 ],tuple ):
16781679 for subf in f [1 ]:
1679- item = QtGui .QTreeWidgetItem (self .tree )
1680+ item = QtWidgets .QTreeWidgetItem (self .tree )
16801681 item .setText (0 ,f [0 ].Name )
16811682 item .setIcon (0 , QtGui .QIcon (":/icons/Part_3D_object.svg" ))
16821683 item .setText (1 ,subf )
16831684 else :
1684- item = QtGui .QTreeWidgetItem (self .tree )
1685+ item = QtWidgets .QTreeWidgetItem (self .tree )
16851686 item .setText (0 ,f [0 ].Name )
16861687 item .setIcon (0 , QtGui .QIcon (":/icons/Part_3D_object.svg" ))
16871688 item .setText (1 ,f [1 ])
@@ -1739,10 +1740,10 @@ def accept(self):
17391740 return True
17401741
17411742 def retranslateUi (self , TaskPanel ):
1742- TaskPanel .setWindowTitle (QtGui .QApplication .translate ("draft" , "Faces" , None ))
1743- self .delButton .setText (QtGui .QApplication .translate ("draft" , "Remove" , None ))
1744- self .addButton .setText (QtGui .QApplication .translate ("draft" , "Add" , None ))
1745- self .title .setText (QtGui .QApplication .translate ("draft" , "Facebinder elements" , None ))
1743+ TaskPanel .setWindowTitle (QtWidgets .QApplication .translate ("draft" , "Faces" , None ))
1744+ self .delButton .setText (QtWidgets .QApplication .translate ("draft" , "Remove" , None ))
1745+ self .addButton .setText (QtWidgets .QApplication .translate ("draft" , "Add" , None ))
1746+ self .title .setText (QtWidgets .QApplication .translate ("draft" , "Facebinder elements" , None ))
17461747
17471748#def translateWidget(w, context=None, disAmb=None):
17481749# '''translator for items where retranslateUi() is unavailable.
@@ -1757,7 +1758,7 @@ def retranslateUi(self, TaskPanel):
17571758# w.setWindowTitle(newText)
17581759
17591760# #handle children
1760- # wKids = w.findChildren(QtGui .QWidget)
1761+ # wKids = w.findChildren(QtWidgets .QWidget)
17611762# for i in wKids:
17621763# className = i.metaObject().className()
17631764# if hasattr(i,"text") and hasattr(i,"setText"):
0 commit comments