tilføj batch mode
This commit is contained in:
parent
1dc57a051c
commit
7c809ac711
43
klandr.py
43
klandr.py
|
@ -49,7 +49,8 @@ def menu_main():
|
||||||
menu_klandringer()
|
menu_klandringer()
|
||||||
elif tag == "Afsluttende":
|
elif tag == "Afsluttende":
|
||||||
menu_afsluttende()
|
menu_afsluttende()
|
||||||
|
else:
|
||||||
|
quit()
|
||||||
|
|
||||||
# Begin klandringer
|
# Begin klandringer
|
||||||
|
|
||||||
|
@ -60,13 +61,16 @@ def menu_klandringer():
|
||||||
("Ændr", "Ændre en eksisterende klandring"),
|
("Ændr", "Ændre en eksisterende klandring"),
|
||||||
("Beskriv", "Beskriv en eksisterende klandring"),
|
("Beskriv", "Beskriv en eksisterende klandring"),
|
||||||
#("Omarrangér", "Omarrangere de eksisterende klandringer"),
|
#("Omarrangér", "Omarrangere de eksisterende klandringer"),
|
||||||
("Slet", "Slette en eksisterende klandring")])
|
("Slet", "Slette en eksisterende klandring"),
|
||||||
|
("Batch", "Gå i batch-mode")])
|
||||||
|
|
||||||
if code == d.CANCEL:
|
if code == d.CANCEL:
|
||||||
menu_main()
|
menu_main()
|
||||||
elif code == d.OK:
|
elif code == d.OK:
|
||||||
if tag == "Ny":
|
if tag == "Ny":
|
||||||
create_klandring()
|
create_klandring()
|
||||||
|
elif tag == "Batch":
|
||||||
|
batch_mode()
|
||||||
else:
|
else:
|
||||||
klandring = menu_select_klandring()
|
klandring = menu_select_klandring()
|
||||||
if klandring != None:
|
if klandring != None:
|
||||||
|
@ -76,8 +80,8 @@ def menu_klandringer():
|
||||||
describe_klandring(klandring)
|
describe_klandring(klandring)
|
||||||
elif tag == "Slet":
|
elif tag == "Slet":
|
||||||
delete_klandring(klandring)
|
delete_klandring(klandring)
|
||||||
else:
|
|
||||||
menu_klandringer()
|
menu_klandringer()
|
||||||
|
|
||||||
def menu_select_klandring():
|
def menu_select_klandring():
|
||||||
klandringer_entries = [(str(i),k["klandrer"] + " v. " + k["klandret"] + " - " + k["title"]) for i,k in enumerate(klandringer)]
|
klandringer_entries = [(str(i),k["klandrer"] + " v. " + k["klandret"] + " - " + k["title"]) for i,k in enumerate(klandringer)]
|
||||||
|
@ -89,7 +93,7 @@ def menu_select_klandring():
|
||||||
|
|
||||||
def create_klandring():
|
def create_klandring():
|
||||||
klandringer.append({"klandrer":"","klandret":"","title":"","description":"","taber":""})
|
klandringer.append({"klandrer":"","klandret":"","title":"","description":"","taber":""})
|
||||||
edit_klandring(-1)
|
return edit_klandring(-1)
|
||||||
|
|
||||||
|
|
||||||
def edit_klandring(strid):
|
def edit_klandring(strid):
|
||||||
|
@ -108,8 +112,9 @@ def edit_klandring(strid):
|
||||||
k["klandret"] = elements[2]
|
k["klandret"] = elements[2]
|
||||||
k["taber"] = elements[3]
|
k["taber"] = elements[3]
|
||||||
save()
|
save()
|
||||||
|
|
||||||
menu_klandringer()
|
return code
|
||||||
|
|
||||||
|
|
||||||
def describe_klandring(strid):
|
def describe_klandring(strid):
|
||||||
id = int(strid)
|
id = int(strid)
|
||||||
|
@ -122,9 +127,8 @@ def describe_klandring(strid):
|
||||||
if code == d.OK:
|
if code == d.OK:
|
||||||
k["description"] = text
|
k["description"] = text
|
||||||
save()
|
save()
|
||||||
|
|
||||||
menu_klandringer()
|
return code
|
||||||
|
|
||||||
|
|
||||||
def delete_klandring(strid):
|
def delete_klandring(strid):
|
||||||
id = int(strid)
|
id = int(strid)
|
||||||
|
@ -136,13 +140,23 @@ def delete_klandring(strid):
|
||||||
del klandringer[id]
|
del klandringer[id]
|
||||||
d.msgbox("Klandringen er slettet!")
|
d.msgbox("Klandringen er slettet!")
|
||||||
save()
|
save()
|
||||||
|
|
||||||
menu_klandringer()
|
|
||||||
|
|
||||||
|
return code
|
||||||
|
|
||||||
|
def batch_mode():
|
||||||
|
#code = create_klandring()
|
||||||
|
for i,k in enumerate(klandringer):
|
||||||
|
code = describe_klandring(i)
|
||||||
|
if code != d.OK:
|
||||||
|
break
|
||||||
|
code = edit_klandring(i)
|
||||||
|
if code != d.OK:
|
||||||
|
break
|
||||||
|
|
||||||
def save():
|
def save():
|
||||||
with open("klandringer.json","w") as jsonfile:
|
with open("klandringer.json","w") as jsonfile:
|
||||||
jsonfile.write(json.dumps(complete_klandringer))
|
jsonfile.write(json.dumps(complete_klandringer))
|
||||||
|
|
||||||
# End klandringer
|
# End klandringer
|
||||||
|
|
||||||
def new_date():
|
def new_date():
|
||||||
|
@ -155,7 +169,8 @@ def new_date():
|
||||||
return date
|
return date
|
||||||
else:
|
else:
|
||||||
menu_select_date()
|
menu_select_date()
|
||||||
|
|
||||||
|
|
||||||
# End definitions
|
# End definitions
|
||||||
|
|
||||||
menu_select_date()
|
menu_select_date()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user