From 38129948c609e12202b8876ab2b87cde941f82bb Mon Sep 17 00:00:00 2001 From: matin Date: Tue, 30 Sep 2025 16:02:57 +0200 Subject: new visual style --- calendar_gui.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 9 deletions(-) (limited to 'calendar_gui.py') diff --git a/calendar_gui.py b/calendar_gui.py index 5fadd73..f0edb52 100644 --- a/calendar_gui.py +++ b/calendar_gui.py @@ -3,7 +3,8 @@ from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QH QLabel, QLineEdit, QPushButton, QDateEdit, QTableWidget, QTableWidgetItem, QHeaderView, QDialog, QFormLayout, QComboBox, QMessageBox, QSpinBox, QAction, QFileDialog, QMenuBar, QTextEdit, - QAbstractItemView) + QAbstractItemView, QToolButton) +from PyQt5.QtWidgets import QStyle from PyQt5.QtCore import Qt, QDate, QLocale from PyQt5.QtGui import QFont, QFontDatabase from datetime import datetime, timedelta @@ -32,7 +33,19 @@ class EventDialog(QDialog): # Apply Arial font font = QFont("Arial", 12) - self.setFont(font) + self.setFont(font) + self.setStyleSheet( + "QDialog { background: #ffffff; }" + " QLabel { color: #333; }" + " QLineEdit, QDateEdit, QComboBox, QTextEdit, QSpinBox {" + " background: #fafbfe; color: #333; border: 1px solid #e1e4ee;" + " border-radius: 6px; padding: 6px; }" + " QDateEdit::drop-down, QComboBox::drop-down { border: none; }" + " QPushButton { background: #2f6feb; color: #fff; border: none;" + " border-radius: 6px; padding: 8px 12px; }" + " QPushButton:hover { background: #316de0; }" + " QPushButton:pressed { background: #2a5fcc; }" + ) # Start date selector self.start_date = QDateEdit() @@ -101,10 +114,12 @@ class EventDialog(QDialog): button_layout = QHBoxLayout() self.save_button = QPushButton("Speichern") self.save_button.setFont(font) + self.save_button.setIcon(self.style().standardIcon(QStyle.SP_DialogApplyButton)) self.save_button.clicked.connect(self.accept) self.cancel_button = QPushButton("Abbrechen") self.cancel_button.setFont(font) + self.cancel_button.setIcon(self.style().standardIcon(QStyle.SP_DialogCancelButton)) self.cancel_button.clicked.connect(self.reject) button_layout.addWidget(self.save_button) @@ -192,6 +207,12 @@ class CalendarManagerGUI(QMainWindow): # Create menu bar menubar = self.menuBar() menubar.setFont(self.app_font) + menubar.setStyleSheet( + "QMenuBar { background: #ffffff; color: #333; }" + " QMenuBar::item:selected { background: #f0f3fa; }" + " QMenu { background: #ffffff; color: #333; border: 1px solid #e1e4ee; }" + " QMenu::item:selected { background: #e6f0ff; }" + ) # File menu file_menu = menubar.addMenu('Start') @@ -199,12 +220,14 @@ class CalendarManagerGUI(QMainWindow): # Save action save_action = QAction('Speichern', self) save_action.setShortcut('Ctrl+S') + save_action.setIcon(self.style().standardIcon(QStyle.SP_DialogSaveButton)) save_action.triggered.connect(self.save_file) file_menu.addAction(save_action) # Load action load_action = QAction('Laden', self) load_action.setShortcut('Ctrl+L') + load_action.setIcon(self.style().standardIcon(QStyle.SP_DialogOpenButton)) load_action.triggered.connect(self.load_file) file_menu.addAction(load_action) @@ -213,20 +236,39 @@ class CalendarManagerGUI(QMainWindow): # Clear action clear_action = QAction('Einträge löschen', self) clear_action.setShortcut('Ctrl+N') + clear_action.setIcon(self.style().standardIcon(QStyle.SP_DialogResetButton)) clear_action.triggered.connect(self.clear_entries) file_menu.addAction(clear_action) # Exit action exit_action = QAction('Beenden', self) exit_action.setShortcut('Ctrl+Q') + exit_action.setIcon(self.style().standardIcon(QStyle.SP_DialogCloseButton)) exit_action.triggered.connect(self.close) file_menu.addAction(exit_action) def init_ui(self): central_widget = QWidget() main_layout = QVBoxLayout() + main_layout.setContentsMargins(16, 16, 16, 16) + main_layout.setSpacing(14) + # Global light style for consistency + self.setStyleSheet( + "QMainWindow { background: #ffffff; }" + " QLabel { color: #333; }" + " QLineEdit, QDateEdit, QComboBox, QTextEdit, QSpinBox {" + " background: #fafbfe; color: #333; border: 1px solid #e1e4ee;" + " border-radius: 6px; padding: 6px; }" + " QDateEdit::drop-down, QComboBox::drop-down { border: none; }" + " QPushButton { background: #2f6feb; color: #fff; border: none;" + " border-radius: 6px; padding: 8px 12px; }" + " QPushButton:hover { background: #316de0; }" + " QPushButton:pressed { background: #2a5fcc; }" + " QToolButton { border: none; }" + ) top_layout = QHBoxLayout() + top_layout.setSpacing(18) # Launch date input launch_date_layout = QVBoxLayout() @@ -264,6 +306,9 @@ class CalendarManagerGUI(QMainWindow): self.prediction_result.setReadOnly(True) self.prediction_result.setButtonSymbols(QDateEdit.ButtonSymbols.NoButtons) self.prediction_result.setDisplayFormat(self.dateformat) + self.prediction_result.setStyleSheet( + "QDateEdit { background: #f5faf5; border: 1px solid #cfe8cf; color: #1e4620; }" + ) prediction_result_layout.addWidget(prediction_result_label) prediction_result_layout.addWidget(self.prediction_result) @@ -277,9 +322,11 @@ class CalendarManagerGUI(QMainWindow): events_title.setFont(self.app_font) events_layout.addWidget(events_title) - # Add event button + # Add event button (modern with icon) add_event_button = QPushButton("Eintrag hinzufügen") add_event_button.setFont(self.app_font) + add_event_button.setIcon(self.style().standardIcon(QStyle.SP_FileDialogNewFolder)) + add_event_button.setStyleSheet("QPushButton { border-radius: 6px; padding: 6px 10px; }") add_event_button.clicked.connect(self.add_event) events_layout.addWidget(add_event_button) @@ -291,6 +338,18 @@ class CalendarManagerGUI(QMainWindow): self.events_table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.events_table.horizontalHeader().setFont(self.app_font) self.events_table.setColumnHidden(0, True) # Hide ID column + # Table visual tweaks for a modern look + self.events_table.setAlternatingRowColors(True) + self.events_table.setSelectionBehavior(QAbstractItemView.SelectRows) + self.events_table.setSelectionMode(QAbstractItemView.SingleSelection) + self.events_table.setStyleSheet( + "QHeaderView::section { background: #f5f7fb; color: #333; border: none;" + " border-bottom: 1px solid #e6e8ef; padding: 8px; }" + " QTableWidget { gridline-color: #e6e8ef; }" + " QTableView::item { padding: 6px; color: #333; }" + " QTableView::item:selected { background: #e6f0ff; color: #333; }" + " QTableView::item:hover { background: #f4f7ff; color: #333; }" + ) # Wrap long text and auto-resize rows so comments are readable self.events_table.setWordWrap(True) self.events_table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) @@ -423,12 +482,19 @@ class CalendarManagerGUI(QMainWindow): actions_widget = QWidget() actions_layout = QHBoxLayout() actions_layout.setContentsMargins(0, 0, 0, 0) - - modify_button = QPushButton("Editieren") - modify_button.setFont(self.app_font) - delete_button = QPushButton("Löschen") - delete_button.setFont(self.app_font) - + # Modern icon-only tool buttons + modify_button = QToolButton() + modify_button.setAutoRaise(True) + modify_button.setIcon(self.style().standardIcon(QStyle.SP_FileDialogDetailedView)) + modify_button.setToolTip("Eintrag bearbeiten") + modify_button.setFixedSize(28, 24) + + delete_button = QToolButton() + delete_button.setAutoRaise(True) + delete_button.setIcon(self.style().standardIcon(QStyle.SP_TrashIcon)) + delete_button.setToolTip("Eintrag löschen") + delete_button.setFixedSize(28, 24) + # Use lambda with default argument to capture the correct event_id modify_button.clicked.connect(lambda checked, eid=entry.id: self.modify_event(eid)) delete_button.clicked.connect(lambda checked, eid=entry.id: self.delete_event(eid)) -- cgit v1.1