0

the button is calling the clickMethod Function,as it is dispalying "You clicked PushButton" in the console but it is not displaying the label

import sys

import self as self
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton
from PyQt5.uic.properties import QtWidgets

if __name__ == "__main__":
    app = QApplication([])
    w = QWidget()
    VideoUrl = QLabel(w)
    VideoUrl.setText('videoURL')
    VideoUrl.move(100, 40)
    InputText = QLineEdit(w)
    InputText.move(100, 60)
    Button = QPushButton(w)
    Button.setText('Download')
    Button.move(100, 100)


def clickMethod():
    print("You clicked PushButton")
    output = QLabel(w)
    output.setText("clicked")
    output.move(100, 70)


Button.clicked.connect(clickMethod)

w.resize(700, 500)

w.show()
sys.exit(app.exec_())
  • Be a bit more careful with your code logic. Testing against __name__ doesn't make much sense if you then refer to objects that could have only been created there: if `__name__` is different (for example, if you try to import the file), `app`, `w` and `Button` will not exist, and your program will crash. – musicamante Mar 29 '20 at 12:40
  • thanks for the input,can you provide alternative solutions,like documentation – Sameer mohd Mar 29 '20 at 17:38

1 Answers1

1

Try adding ouput.show() at the end of clickMethod.

Seon
  • 3,332
  • 8
  • 27