From aa44fcc7f64bd3bc212d4e51c9236b44899cfa4b Mon Sep 17 00:00:00 2001 From: Toast Date: Mon, 21 Oct 2024 10:42:28 +0200 Subject: [PATCH] Add connected input text box and label --- src/leek/leek.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/leek/leek.py b/src/leek/leek.py index 1c937ad..a95710e 100644 --- a/src/leek/leek.py +++ b/src/leek/leek.py @@ -1,7 +1,15 @@ import sys -from PySide6.QtCore import QSize, Qt -from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton +from PySide6.QtCore import QSize +from PySide6.QtWidgets import ( + QApplication, + QLabel, + QLineEdit, + QMainWindow, + QVBoxLayout, + QWidget, + QPushButton +) # Subclass QMainWindow to customize your application's main window @@ -11,16 +19,29 @@ class leekMainWindow(QMainWindow): self.setWindowTitle("Leek!") + self.label = QLabel() + + self.input = QLineEdit() + self.input.textChanged.connect(self.label.setText) + button = QPushButton("Press Me!") button.setCheckable(True) button.clicked.connect(self.button_clicked) 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.setMinimumSize(QSize(400,300)) + container = QWidget() + container.setLayout(layout) + # Set the central widget of the Window. - self.setCentralWidget(button) + self.setCentralWidget(container) def button_clicked(self): print("Button was clicked") @@ -33,6 +54,7 @@ def main(): # If you know you won't use command line arguments QApplication([]) works too. app = QApplication(sys.argv) + # Create a Qt widget, which will be our window. window = leekMainWindow() window.show() # IMPORTANT!!!!! Windows are hidden by default.