Python Forum
Closing Modal Window in QT
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closing Modal Window in QT

 I create a modal dialog in PyQT5 in this way:

from PyQt5 import QtCore, QtGui, QtWidgets

class FirmUi_Dialog(object):

   def setupUi(self, Dialog):
       Dialog.resize(311, 300)
       self.groupBox = QtWidgets.QGroupBox(Dialog)
       self.saveFirmPB = QtWidgets.QPushButton(Dialog)
       self.saveFirmPB.setGeometry(QtCore.QRect(140, 240, 75, 23))
       self.cancelPB = QtWidgets.QPushButton(Dialog)
       self.cancelPB.setGeometry(QtCore.QRect(220, 240, 75, 23))


   def saveFirmToDB(self):

   def closeFirmDialog(self):
      pass  #How I can close the Dialog (Modal Window)
            self.close() #doesn't work 
to open the dialog in the Mainwindow, I create the following function:

def showFirmaDialog(self):
   firmDialog = QtWidgets.QDialog()
   ui = FirmUi_Dialog()
This steps works fine. But I dont' find a way to trigger the close event for this dialog when I push the cancelPB 



Possibly Related Threads…
Thread Author Replies Views Last Post
Question closing a "nested" window with a button in PySimpleGUI and repeating this process Robby_PY 9 4,288 Jan-18-2021, 10:21 PM
Last Post: Serafim
  [PyQt] Received RunTimeError after script concludes, closing Dialog Window (clicking x-out) skipper0802 0 1,105 Oct-09-2020, 09:23 PM
Last Post: skipper0802
  Closing window on button click not working kenwatts275 4 1,242 May-03-2020, 01:59 PM
Last Post: deanhystad
  tkinter window and turtle window error 1885 3 3,517 Nov-02-2019, 12:18 PM
Last Post: 1885
  [split] Closing a window but not the whole program scriptdrache 1 1,079 Jun-25-2019, 03:43 PM
Last Post: joe_momma
  [Tkinter] Closing a window but not the whole program Wiggy1 2 2,694 Jan-11-2019, 12:51 AM
Last Post: Larz60+
  How to stop a tkinter function, without closing the window? keakins 5 9,582 Jun-29-2017, 11:53 AM
Last Post: keakins
  update a variable in parent window after closing its toplevel window gray 5 5,922 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020