Validierung und Kommentare verbessert
This commit is contained in:
parent
485f8a850f
commit
c2775d2c25
@ -1,9 +1,14 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
|
||||
status = 1
|
||||
status = 1 # 1 - neue Eingabe, 2 - Eingabe verarbeitet
|
||||
|
||||
def switch_status(newS: int = None):
|
||||
""" Verändert den globalen Status
|
||||
|
||||
:param newS: neuer Statuswert
|
||||
:return: None
|
||||
"""
|
||||
global status
|
||||
if not newS:
|
||||
if status == 1:
|
||||
@ -15,6 +20,10 @@ def switch_status(newS: int = None):
|
||||
update_statusbar()
|
||||
|
||||
def update_statusbar():
|
||||
""" Passt die Farbe der Statuszeile an den Status an.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
global status
|
||||
if status == 1:
|
||||
frame_statusbar['style'] = 'aFrame.TFrame'
|
||||
@ -24,6 +33,11 @@ def update_statusbar():
|
||||
frame_statusbar['style'] = 'bFrame.TFrame'
|
||||
|
||||
def calculate(*args):
|
||||
""" Berechnet aus der eingegebenen Länge in feet die Länge in Metern.
|
||||
|
||||
:param args:
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
stringvalue = feet.get()
|
||||
stringvalue = stringvalue.replace(",",".")
|
||||
@ -36,7 +50,12 @@ def calculate(*args):
|
||||
pass
|
||||
return True
|
||||
|
||||
def check_entry(what):
|
||||
def check_entry(what : str = ""):
|
||||
""" Validiert, ob Eingabe leer oder eine Fließkommazahl ist.
|
||||
|
||||
:param what: str eingegebene Zeichenkette
|
||||
:return: boolean
|
||||
"""
|
||||
switch_status(1)
|
||||
if what == "":
|
||||
# Nichts eingegeben
|
||||
@ -45,6 +64,7 @@ def check_entry(what):
|
||||
try:
|
||||
# DEBUG
|
||||
print(what)
|
||||
what = what.replace(',', '.')
|
||||
float(what)
|
||||
return True
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user