Creating a planner GUI application using PyQt6 involves setting up a basic window with widgets corresponding to the various categories you want to track. Below, I'll outline a simple application that encapsulates the described functionality. This example will demonstrate the setup of a main window with widgets for input and display.
First, ensure PyQt6 is installed:
pip install PyQt6
Now, here's a simple example implementation:
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QTextEdit, QVBoxLayout, QPushButton, QMessageBox
from PyQt6.QtGui import QColor
from PyQt6.QtCore import Qt
class PlannerApp(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Daily Planner")
# Set-up layout
layout = QVBoxLayout()
# Define colors
self.setStyleSheet("background-color: #FFEEAD;")
# Task Input
self.task_label = QLabel("Daily Tasks:", self)
layout.addWidget(self.task_label)
self.task_input = QTextEdit(self)
layout.addWidget(self.task_input)
# Thanksgiving Input
self.thanksgiving_label = QLabel("Thanksgiving Note:", self)
layout.addWidget(self.thanksgiving_label)
self.thanksgiving_input = QTextEdit(self)
layout.addWidget(self.thanksgiving_input)
# Study Hours Input
self.study_label = QLabel("Study Hours:", self)
layout.addWidget(self.study_label)
self.study_input = QLineEdit(self)
layout.addWidget(self.study_input)
# Today's Song Input
self.song_label = QLabel("Today's Song:", self)
layout.addWidget(self.song_label)
self.song_input = QLineEdit(self)
layout.addWidget(self.song_input)
# Wake Up Time Input
self.wakeup_label = QLabel("Wake Up Time:", self)
layout.addWidget(self.wakeup_label)
self.wakeup_input = QLineEdit(self)
layout.addWidget(self.wakeup_input)
# Motivation Input
self.motivation_label = QLabel("Today's Motivation:", self)
layout.addWidget(self.motivation_label)
self.motivation_input = QTextEdit(self)
layout.addWidget(self.motivation_input)
# Save Button
self.save_button = QPushButton("Save Today's Plan", self)
self.save_button.setStyleSheet("background-color: #FFAD60;")
self.save_button.clicked.connect(self.save_plan)
layout.addWidget(self.save_button)
self.setLayout(layout)
def save_plan(self):
tasks = self.task_input.toPlainText()
thanksgiving = self.thanksgiving_input.toPlainText()
study_hours = self.study_input.text()
song = self.song_input.text()
wakeup_time = self.wakeup_input.text()
motivation = self.motivation_input.toPlainText()
# Here you can add functionality to save the data to a file or database
# Show a message box
QMessageBox.information(self, "Saved", "Your daily plan has been saved successfully!", QMessageBox.StandardButton.Ok)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = PlannerApp()
window.setStyleSheet("color: #A02334;") # Text color
window.setGeometry(100, 100, 400, 600)
window.show()
sys.exit(app.exec())
Explanation:
-
Labels and Inputs: Uses QLabel for headings and QLineEdit or QTextEdit for inputs where necessary.
-
Layout Management: Uses QVBoxLayout to stack widgets vertically, making the GUI structured and straightforward.
-
Styling: Sets a background color using QWidget's stylesheet functionality to create a uniform appearance with specified colors. For example, the window's background is set to #FFEEAD and the text color to #A02334.
-
Button and Functionality: Includes a "Save" button that will eventually save the entered information. Currently, it shows a confirmation message in a QMessageBox.
-
Executable: This script when run will open a window application appropriate for Mac, Windows, or Linux that reacts to user inputs accordingly.
This example aims to give a starting point to roll out new features or persist data to files/databases as needed. You can add persistence by writing the input fields’ contents to a file or a database when the user clicks the save button.