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