Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9117481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:54:20+00:00 2026-06-17T04:54:20+00:00

I am working with python and pyqt. I have a dialog that I want

  • 0

I am working with python and pyqt. I have a dialog that I want to temporarily hide. After calling

dlg.hide()

I try calling

dlg.show()

but nothing happens. It is never re-displayed.

I am new to pyqt so any help is greatly appreciated.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:54:21+00:00Added an answer on June 17, 2026 at 4:54 am

    You are looking for the exec_ method that makes the dialog modal, see how this works:

    #!/usr/bin/env python
    #-*- coding:utf-8 -*-
    
    from PyQt4 import QtCore, QtGui
    
    class myDialog(QtGui.QDialog):
        def __init__(self, parent=None):
            super(myDialog, self).__init__(parent)
    
            self.dialog = None
    
            self.buttonShow = QtGui.QPushButton(self)
            self.buttonShow.setText("Show Dialog")
            self.buttonShow.clicked.connect(self.on_buttonShow_clicked)
    
            self.buttonHide = QtGui.QPushButton(self)
            self.buttonHide.setText("Close")
            self.buttonHide.clicked.connect(self.on_buttonHide_clicked)
    
            self.layout = QtGui.QVBoxLayout(self)
            self.layout.addWidget(self.buttonShow)
            self.layout.addWidget(self.buttonHide)
    
        @QtCore.pyqtSlot()
        def on_buttonHide_clicked(self):
            self.accept()
    
        @QtCore.pyqtSlot()
        def on_buttonShow_clicked(self):
            self.dialog = myDialog(self)
            self.dialog.exec_()
    
    class myWindow(QtGui.QWidget):  
        def __init__(self, parent=None):
            super(myWindow, self).__init__(parent)
    
            self.buttonShow = QtGui.QPushButton(self)
            self.buttonShow.setText("Show Dialog")
            self.buttonShow.clicked.connect(self.on_buttonShow_clicked)
    
            self.layout = QtGui.QVBoxLayout(self)
            self.layout.addWidget(self.buttonShow)
    
            self.dialog = myDialog(self)
    
        @QtCore.pyqtSlot()
        def on_buttonHide_clicked(self):
            self.dialog.accept()
    
        @QtCore.pyqtSlot()
        def on_buttonShow_clicked(self):
            self.dialog.exec_()
    
    if __name__ == "__main__":
        import sys
    
        app = QtGui.QApplication(sys.argv)
        app.setApplicationName('myWindow')
    
        main = myWindow()
        main.show()
    
        sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working Python based program that I want to run as a
Working with Python in Emacs if I want to add a try/except to a
I am currently working with Python and have been confused over the fact that
I have a working Python script that executes an external command and calls Popen.communicate()
Working in python 2.7. I have an argument that takes a list, adds the
I have a working python wrapper for C++ code (as suggested here Calling C/C++
Working in Python. I have a function that reads from a queue and creates
I have a working python 2.7 program that calls a DLL. I am trying
I have a working Python 2.6 install and just installed the PyQt4 built for
After compiling a in unix-working python file using import py_compile py_compile.compile('server.py') I get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.