Hide /Close Dialog

Need help, or want to share a macro? Post here!
Posts: 61
Joined: Wed Oct 17, 2018 9:00 am

Hide /Close Dialog

Postby Chri1 » Fri May 17, 2019 10:01 am

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)

def snapit(ding):
         print("Here should the Dialog disappeare!!!!") # <-------------------------------------------------------- ??????????????
         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
Posts: 4560
Joined: Tue Nov 12, 2013 4:06 pm

Re: Hide /Close Dialog

Postby microelly2 » Fri May 17, 2019 10:30 am

the simplest way is to hide the dialog inside your snapit

call snapit(ding,self)

def snapit(ding, dialog):
do something