How to hide a window in the constructor immediately after creation

0 votes
I want to hide a window immediately after it is created. It works only if I do this with the help of a button or something.

class Example(QWidget):
    def __init__(self, parent=None):
        super(Example, self).__init__(parent)
        self.hide() # doesn't work
        self.btn = QPushButton('Hide', self)
        self.btn.clicked.connect(self.click) # works
        self.btn.show()

    def click(self): # works
        self.hide()
Apr 17, 2018 in Python by aryya
• 7,460 points
924 views

1 answer to this question.

0 votes
You can use QtCore.QTimer

class Example(QWidget):
    def __init__(self, app):
        QWidget.__init__(self)
        QTimer.singleShot(0, self.hide)
answered Apr 17, 2018 by anonymous

Related Questions In Python

0 votes
1 answer

Hide a window in the constructor immediately after it is created?

Apparently it seems that the code should ...READ MORE

answered Sep 28, 2018 in Python by Priyaj
• 58,020 points
1,307 views
0 votes
1 answer

How to get the size of a string in Python?

If you are talking about the length ...READ MORE

answered Jun 4, 2018 in Python by aryya
• 7,460 points
1,392 views
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29, 2019 in Python by rajesh
• 1,270 points
2,146 views
0 votes
1 answer

I have a dictonary in python how to access the value field?

dic={"car":["limo","sedan"]} print (dic.keys())    <-----------------------Fetch the key "car" print (dic['car'][0])   <------------------------Fetch ...READ MORE

answered Dec 20, 2018 in Python by Shuvodip
816 views
0 votes
1 answer

How to remove the duplicate values in a list?

a = [10,20,30,40,10,20,30,40,30,40,50,60] s = set(a) c = list(s) print(c) this ...READ MORE

answered Mar 20, 2019 in Python by Mohammad
• 3,230 points
902 views
+1 vote
1 answer

How to find the index of a particular value in a dataframe?

First, use the dataframe to match the ...READ MORE

answered Apr 8, 2019 in Python by Esha
281,752 views
0 votes
1 answer

How to find the value of a row in a csv file in python?

If you want to find the value ...READ MORE

answered May 20, 2019 in Python by Sanam
19,245 views
0 votes
1 answer

How to count the number of elements in a list?

To count the number of elements of ...READ MORE

answered May 27, 2019 in Python by Nisa
• 1,090 points
5,253 views
0 votes
1 answer

How can I write nested dictionaries to a csv file?

You can use the pandas library to ...READ MORE

answered Apr 17, 2018 in Python by anonymous
1,206 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
3,475 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP