Skip to content

QPushButton


The push button, or command button, is perhaps the most commonly used widget in any graphical user interface. Push (click) a button to command the computer to perform some action, or to answer a question. Typical buttons are OK, Apply, Cancel, Close, Yes, No and Help.

Parameters:

Name Type Description Default
text str

The text to display on the button.

None

Signals

  • clicked: Emitted when the button is clicked.

Methods


Examples


button = QtWidgets.QPushButton("Click me!")
print(button.text())
'Click me!'
button.setText("Don't click me!")
print(button.text())
'Don't click me!'


text()

Returns the text displayed in the button.

Returns:

Type Description
str

The text displayed in the button.


setText(text)

Sets the text to be displayed in the button.

Parameters:

Name Type Description Default
text str

The text to display in the button.

required