1
class Window(QtGui.QMainWindow):
    def __init__(self):
        super(Window, self).__init__()
        self.tabs()

    def home(self):
        df = QtGui.QPushButton('hello', self)
        df.move(300, 300)
        self.show()

    def tabs(self):
        btn_1 = QtGui.QPushButton('Home', self)
        btn_1.clicked.connect(self.home)
        self.show()

Trying to access the module 'home()' and print button 'hello' when button btn_1 in module tabs is clicked. Not happening..

2
  • Hey Rajesh! What is happening instead? Is there an error message? What do you think is going wrong? Providing more information makes it easier to help. :) Commented May 22, 2017 at 20:07
  • 1
    sorry i was not clear. The btn_1 button is showing but when i click it the df button from home() module is not displayed the window. Commented May 22, 2017 at 20:11

1 Answer 1

1

When you create the new object it appears hidden, so that it is visible uses the show() function.

def home(self):
    df = QtGui.QPushButton('hello', self)
    df.move(300, 300)
    df.show()
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Worked right away. I was using self.show() insted of df.show()..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.