From 8b447c240cbb3a73d30e7d858ec062538bfccc84 Mon Sep 17 00:00:00 2001 From: Toast Date: Sun, 20 Oct 2024 01:09:41 +0200 Subject: [PATCH 1/2] Make my own main window --- src/leek/leek.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/leek/leek.py b/src/leek/leek.py index 0fc9342..5151951 100644 --- a/src/leek/leek.py +++ b/src/leek/leek.py @@ -1,13 +1,31 @@ -from PySide6.QtWidgets import QApplication, QWidget import sys +from PySide6.QtCore import QSize, Qt +from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton + + +# Subclass QMainWindow to customize your application's main window +class leekMainWindow(QMainWindow): + def __init__(self): + super().__init__() + + self.setWindowTitle("Leek!") + + button = QPushButton("Press Me!") + + self.setMaximumSize(QSize(800,600)) + self.setMinimumSize(QSize(400,300)) + + # Set the central widget of the Window. + self.setCentralWidget(button) + 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 = QWidget() + window = leekMainWindow() window.show() # IMPORTANT!!!!! Windows are hidden by default. # Start the event loop. From 0692a45f09b7f8109088f990195a7701f81353fd Mon Sep 17 00:00:00 2001 From: Toast Date: Sun, 20 Oct 2024 02:01:26 +0200 Subject: [PATCH 2/2] Make button checkable --- src/leek/leek.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/leek/leek.py b/src/leek/leek.py index 5151951..1c937ad 100644 --- a/src/leek/leek.py +++ b/src/leek/leek.py @@ -12,6 +12,9 @@ class leekMainWindow(QMainWindow): self.setWindowTitle("Leek!") button = QPushButton("Press Me!") + button.setCheckable(True) + button.clicked.connect(self.button_clicked) + button.clicked.connect(self.button_toggled) self.setMaximumSize(QSize(800,600)) self.setMinimumSize(QSize(400,300)) @@ -19,6 +22,12 @@ class leekMainWindow(QMainWindow): # Set the central widget of the Window. self.setCentralWidget(button) + def button_clicked(self): + print("Button was clicked") + + def button_toggled(self, checked): + print("Checked?", checked ) + def main(): # If you know you won't use command line arguments QApplication([]) works too.