Hide /Close Dialog

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Chri1
Posts: 86
Joined: Wed Oct 17, 2018 9:00 am

Hide /Close Dialog

Post by Chri1 »

Hi
I have a dialog-window for userinput of parameters for a cuboid.
There is a OK-Button and after clicking it, the Dialog should disappeare - That is my problem!
Then a new Dialog appeares "Click a Insertion Point"

Code: Select all

....
import DraftSnap
.....

class Ui_Dialog(QtGui.QDialog):
    def setupUi(self, Dialog):
        ....   Dialog to create a cuboid
        ....
        self.pB_Einf.clicked.connect(self.quader)   #Clicking the OK-Button calls function quader Part::Box
        ....
    def quader(self):   #Creates the cuboid
           global ding
           ding = App.ActiveDocument.addObject("Part::Box", "Box")
           l = self.doubleSpinBox_10.value() 
           ding.Length = str(l) + "m"
           ...
           snapit(ding)  # To insert the cuboid where the User clicked.
           
    def cb(point, self):  #Gets the Point from the snapper
         if point:
             print("Punkt:", point)
             Draft.move(ding,point,copy=False)           

def snapit(ding):
         print("Here should the Dialog disappeare!!!!") # <-------------------------------------------------------- ??????????????
         #MainWindow.close()
         #Mainwindow.done()
         point = FreeCADGui.Snapper.getPoint(callback = Ui_Dialog.cb)  #Calls function cb, wich moves the cuboid
....
How to close the Dialog?

It would be nice, if the cuboid would hang on the cursor, while the user moves to a Insertion Point - Is this possible?

Thanks Chr1
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Hide /Close Dialog

Post by microelly2 »

the simplest way is to hide the dialog inside your snapit

call snapit(ding,self)
and

def snapit(ding, dialog):
do something
dialog.hide()
Post Reply