5 Commits

Author SHA1 Message Date
Olli Graf
61e8c85bbe Styling des "Passwort vergessen" Button. 2025-02-17 06:49:49 +01:00
Olli Graf
dac83ccbf9 requirements.txt 2025-02-16 14:41:07 +01:00
Olli Graf
4d2b58b744 Dateien zu Teil 29 2025-02-16 14:39:34 +01:00
6db74b04f5 „date_diff.py“ hinzufügen
Übernahme
2024-11-11 07:00:14 +00:00
060c235e3f Typo korrigiert. 2024-11-09 16:58:16 +01:00
18 changed files with 304 additions and 0 deletions

52
date_diff.py Normal file
View File

@@ -0,0 +1,52 @@
#! python
import sys
from datetime import datetime
def date_diff_in_days(date1, date2):
try:
# Konvertiere die übergebenen Datumsangaben in datetime-Objekte
if date1 == '$today':
print('date1 ist heutiges Datum')
date1_obj = datetime.today()
date1_obj = date1_obj.replace(hour=0,minute=0,second=0,microsecond=0)
else:
print(f'konvertiere erstes Datum {date1}')
date1_obj = datetime.strptime(date1, "%d.%m.%Y")
if date2 == '$today':
print('date2 ist heutiges Datum')
date2_obj = datetime.today()
date2_obj = date2_obj.replace(hour=0,minute=0,second=0,microsecond=0)
else:
print(f'konvertiere zweites Datum {date2}')
date2_obj = datetime.strptime(date2, "%d.%m.%Y")
print(f'konvertiere zweites Datum {date2}')
# Berechne die Differenz zwischen den beiden Datumsangaben
print(f'erstes Datum: {date1_obj}, zweites Datum: {date2_obj}')
diff = abs(date1_obj - date2_obj).days
return diff
except ValueError as e:
print("Fehler beim Parsen der Datumsangaben:", e)
return None
if __name__ == "__main__":
# Überprüfe, ob genau zwei Datumsangaben als Parameter übergeben wurden
print(f'Params: {sys.argv}')
print(f'Anzahl Param: {len(sys.argv)}')
if len(sys.argv) != 3:
print("Bitte geben Sie zwei Datumsangaben im Format YYYY-MM-DD als Kommandozeilenparameter ein.")
else:
date1 = sys.argv[1]
date2 = sys.argv[2]
# Berechne die Differenz in Tagen zwischen den beiden Datumsangaben
difference = date_diff_in_days(date1, date2)
if difference is not None:
if sys.argv[1] == '$today':
date1= 'heutigen Tag'
if sys.argv[2] == '$today':
date2= 'heutigen Tag'
print(f"Zwischen dem {date1} und dem {date2} liegen {difference} Tage.")

4
teil29/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# created by virtualenv automatically
bin
lib

30
teil29/handleButton.py Executable file
View File

@@ -0,0 +1,30 @@
#! /usr/bin/python
#Datei: handleButton.py
import sys
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Button Signal")
button = QPushButton("Bitte klicken")
button.setCheckable(True)
button.clicked.connect(self.handle_button_click)
# Set the central widget of the Window.
self.setCentralWidget(button)
def handle_button_click(self):
print("Button geklickt")
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()

36
teil29/lineedit.py Executable file
View File

@@ -0,0 +1,36 @@
#! /usr/bin/python
#Datei: lineEdit.py
from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QVBoxLayout, QWidget
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Eingabe mit LineEdit")
self.label = QLabel()
self.input = QLineEdit()
self.input.textChanged.connect(self.label.setText)
layout = QVBoxLayout()
layout.addWidget(self.input)
layout.addWidget(self.label)
container = QWidget()
container.setLayout(layout)
# Set the central widget of the Window.
self.setCentralWidget(container)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()

78
teil29/login.py Executable file
View File

@@ -0,0 +1,78 @@
#! /usr/bin/python
#Datei: lineEdit.py
from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QPushButton, QGridLayout, QWidget
from PyQt6.QtGui import QPixmap
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Login")
layout = QGridLayout()
layout.setContentsMargins(20, 20, 20, 20)
layout.setSpacing(10)
self.user_logo_pixmap =QPixmap('./user.jpg')
self.user_logo_label = QLabel()
self.user_logo_label.setPixmap(self.user_logo_pixmap)
layout.addWidget(self.user_logo_label,1,1)
self.user_label = QLabel('Username:')
self.password_label = QLabel('Passwort:')
self.username_input = QLineEdit()
self.password_input = QLineEdit()
self.password_input.setEchoMode(QLineEdit.EchoMode.Password)
layout.addWidget(self.user_label,2,0)
layout.addWidget(self.username_input,2,1,1,2)
layout.addWidget(self.password_label,3,0)
layout.addWidget(self.password_input,3,1,1,2)
#Buttons
self.register_button = QPushButton("Register")
layout.addWidget(self.register_button, 4, 1)
self.login_button = QPushButton("Login")
self.login_button.clicked.connect(self.handle_login_button)
self.register_button.clicked.connect(self.handle_register_button)
layout.addWidget(self.login_button, 4, 2)
# Password vergessen
self.forgot_pw_button = QPushButton('Passwort vergessen')
self.forgot_pw_button.setStyleSheet('QPushButton {background-color: #A3C1DA; color: blue;}')
layout.addWidget(self.forgot_pw_button,5,2)
container = QWidget()
container.setLayout(layout)
# Set the central widget of the Window.
self.setCentralWidget(container)
def handle_register_button(self):
print('Register Button')
def handle_login_button(self):
print(f'Login mit {self.username_input.text()} and {self.password_input.text()}')
def handle_forgot_pw_button(self):
print('Forgot PW')
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()

26
teil29/mainwindow.py Executable file
View File

@@ -0,0 +1,26 @@
#! /usr/bin/python
#Datei: mainwindows.py
import sys
from PyQt6.QtCore import QSize, Qt
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton
# Subclass QMainWindow to customize your application's main window
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("My App")
button = QPushButton("Bitte klicken")
# Set the central widget of the Window.
self.setCentralWidget(button)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()

12
teil29/pushbutton.py Executable file
View File

@@ -0,0 +1,12 @@
#! /usr/bin/python
#Datei: pushbutton.py
import sys
from PyQt6.QtWidgets import QApplication, QPushButton
app = QApplication(sys.argv)
window = QPushButton("Bitte klicken")
window.show()
app.exec()

8
teil29/pyvenv.cfg Normal file
View File

@@ -0,0 +1,8 @@
home = /usr/bin
implementation = CPython
version_info = 3.11.2.final.0
virtualenv = 20.17.1+ds
include-system-site-packages = false
base-prefix = /usr
base-exec-prefix = /usr
base-executable = /usr/bin/python3

5
teil29/requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
numpy==2.2.3
opencv-python==4.11.0.86
PyQt6==6.8.1
PyQt6-Qt6==6.8.2
PyQt6_sip==13.10.0

30
teil29/sizewindow.py Executable file
View File

@@ -0,0 +1,30 @@
#! /usr/bin/python
# Datei: sizewindow.py
import sys
from PyQt6.QtCore import QSize, Qt
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton
# abgeleitet von QMainWindow können wir unser GUI besser einstellen und
# z.B. die Dimensionen des Fensters ändern.
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Fenstergröße")
button = QPushButton("Bitte klicken")
self.setFixedSize(QSize(400, 300))
# der Button sitzt als zentrales Widget im Fenster.
self.setCentralWidget(button)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()

BIN
teil29/user.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

23
teil29/window.py Executable file
View File

@@ -0,0 +1,23 @@
#! /usr/bin/python
#Datei: window.py
# Die benötigten Qt Widgets
from PyQt6.QtWidgets import QApplication, QWidget
# Für die Kommandozeilenparameter
import sys
# QTApplication instanziieren. Die Kommandozeilenparameter geben wir
# mit.
app = QApplication(sys.argv)
# Window Widget erzeugen
window = QWidget()
window.show() # Das Fenster muss immer manuell angzeigt werden.
# Wvent-Loop starten.
app.exec()
# So lang die Event-Loop läuft kommen wir hier nicht hin,
# sie kann durch den "Schließen" Button des Fensters unterbrochen werden.