Add connected input text box and label
This commit is contained in:
parent
0692a45f09
commit
aa44fcc7f6
1 changed files with 25 additions and 3 deletions
|
|
@ -1,7 +1,15 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide6.QtCore import QSize, Qt
|
from PySide6.QtCore import QSize
|
||||||
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
|
from PySide6.QtWidgets import (
|
||||||
|
QApplication,
|
||||||
|
QLabel,
|
||||||
|
QLineEdit,
|
||||||
|
QMainWindow,
|
||||||
|
QVBoxLayout,
|
||||||
|
QWidget,
|
||||||
|
QPushButton
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Subclass QMainWindow to customize your application's main window
|
# Subclass QMainWindow to customize your application's main window
|
||||||
|
|
@ -11,16 +19,29 @@ class leekMainWindow(QMainWindow):
|
||||||
|
|
||||||
self.setWindowTitle("Leek!")
|
self.setWindowTitle("Leek!")
|
||||||
|
|
||||||
|
self.label = QLabel()
|
||||||
|
|
||||||
|
self.input = QLineEdit()
|
||||||
|
self.input.textChanged.connect(self.label.setText)
|
||||||
|
|
||||||
button = QPushButton("Press Me!")
|
button = QPushButton("Press Me!")
|
||||||
button.setCheckable(True)
|
button.setCheckable(True)
|
||||||
button.clicked.connect(self.button_clicked)
|
button.clicked.connect(self.button_clicked)
|
||||||
button.clicked.connect(self.button_toggled)
|
button.clicked.connect(self.button_toggled)
|
||||||
|
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
layout.addWidget(self.input)
|
||||||
|
layout.addWidget(self.label)
|
||||||
|
layout.addWidget(button)
|
||||||
|
|
||||||
self.setMaximumSize(QSize(800,600))
|
self.setMaximumSize(QSize(800,600))
|
||||||
self.setMinimumSize(QSize(400,300))
|
self.setMinimumSize(QSize(400,300))
|
||||||
|
|
||||||
|
container = QWidget()
|
||||||
|
container.setLayout(layout)
|
||||||
|
|
||||||
# Set the central widget of the Window.
|
# Set the central widget of the Window.
|
||||||
self.setCentralWidget(button)
|
self.setCentralWidget(container)
|
||||||
|
|
||||||
def button_clicked(self):
|
def button_clicked(self):
|
||||||
print("Button was clicked")
|
print("Button was clicked")
|
||||||
|
|
@ -33,6 +54,7 @@ def main():
|
||||||
# If you know you won't use command line arguments QApplication([]) works too.
|
# If you know you won't use command line arguments QApplication([]) works too.
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
# Create a Qt widget, which will be our window.
|
# Create a Qt widget, which will be our window.
|
||||||
window = leekMainWindow()
|
window = leekMainWindow()
|
||||||
window.show() # IMPORTANT!!!!! Windows are hidden by default.
|
window.show() # IMPORTANT!!!!! Windows are hidden by default.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue