tilføj beskrivelser og datoer
This commit is contained in:
parent
1988c6249f
commit
1dc57a051c
88
klandr.py
88
klandr.py
|
@ -5,12 +5,36 @@ import json
|
||||||
d = Dialog(dialog="dialog")
|
d = Dialog(dialog="dialog")
|
||||||
d.set_background_title("Klandr")
|
d.set_background_title("Klandr")
|
||||||
|
|
||||||
#klandringer = [{"klandrer":"Person 1","klandret":"Person 2","title":"Title to be","description":"Description to be"}]
|
|
||||||
with open("klandringer.json", "r") as jsonfile:
|
|
||||||
klandringer = json.loads(jsonfile.read())
|
|
||||||
|
|
||||||
|
klandringer = None
|
||||||
|
with open("klandringer.json", "r") as jsonfile:
|
||||||
|
contents = jsonfile.read()
|
||||||
|
if contents == "":
|
||||||
|
complete_klandringer = {}
|
||||||
|
else:
|
||||||
|
complete_klandringer = json.loads(contents)
|
||||||
|
|
||||||
|
|
||||||
# Begin definitions
|
# Begin definitions
|
||||||
|
|
||||||
|
def menu_select_date():
|
||||||
|
global klandringer
|
||||||
|
if complete_klandringer == {}:
|
||||||
|
date_entries = [()]
|
||||||
|
else:
|
||||||
|
date_entries = [(k,"") for k in complete_klandringer]
|
||||||
|
date_entries.append(("Ny","Opret en ny dato"))
|
||||||
|
code, tag = d.menu("Vælg den dato du vil ændre",
|
||||||
|
title="Vælg dato",
|
||||||
|
choices=date_entries)
|
||||||
|
if code == d.OK:
|
||||||
|
date = tag
|
||||||
|
if tag == "Ny":
|
||||||
|
date = new_date()
|
||||||
|
|
||||||
|
klandringer = complete_klandringer[date]
|
||||||
|
menu_main()
|
||||||
|
|
||||||
def menu_main():
|
def menu_main():
|
||||||
code, tag = d.menu("Vælg punkt på dagsordenen",
|
code, tag = d.menu("Vælg punkt på dagsordenen",
|
||||||
title="Hovedmenu",
|
title="Hovedmenu",
|
||||||
|
@ -34,6 +58,7 @@ def menu_klandringer():
|
||||||
title="Klandringer",
|
title="Klandringer",
|
||||||
choices=[("Ny", "Oprette en ny klandring"),
|
choices=[("Ny", "Oprette en ny klandring"),
|
||||||
("Ændr", "Ændre en eksisterende klandring"),
|
("Ændr", "Ændre 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")])
|
||||||
|
|
||||||
|
@ -47,6 +72,8 @@ def menu_klandringer():
|
||||||
if klandring != None:
|
if klandring != None:
|
||||||
if tag == "Ændr":
|
if tag == "Ændr":
|
||||||
edit_klandring(klandring)
|
edit_klandring(klandring)
|
||||||
|
elif tag == "Beskriv":
|
||||||
|
describe_klandring(klandring)
|
||||||
elif tag == "Slet":
|
elif tag == "Slet":
|
||||||
delete_klandring(klandring)
|
delete_klandring(klandring)
|
||||||
else:
|
else:
|
||||||
|
@ -61,26 +88,43 @@ def menu_select_klandring():
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
def create_klandring():
|
def create_klandring():
|
||||||
klandringer.append({"klandrer":"","klandret":"","title":""})
|
klandringer.append({"klandrer":"","klandret":"","title":"","description":"","taber":""})
|
||||||
edit_klandring(-1)
|
edit_klandring(-1)
|
||||||
|
|
||||||
|
|
||||||
def edit_klandring(strid):
|
def edit_klandring(strid):
|
||||||
id = int(strid)
|
id = int(strid)
|
||||||
|
k = klandringer[id]
|
||||||
code, elements = d.form("Ændr detaljer om klandring",
|
code, elements = d.form("Ændr detaljer om klandring",
|
||||||
title="Ændr klandring",
|
title="Ændr klandring",
|
||||||
elements=[("Titel:",1,1,klandringer[id]["title"],1,11,40,40),
|
elements=[("Titel:",1,1,k["title"],1,11,40,40),
|
||||||
("Klandrer:",2,1,klandringer[id]["klandrer"],2,11,20,20),
|
("Klandrer:",2,1,k["klandrer"],2,11,20,20),
|
||||||
("Klandret:",3,1,klandringer[id]["klandret"],3,11,20,20)])
|
("Klandret:",3,1,k["klandret"],3,11,20,20),
|
||||||
|
("Taber:",4,1,k["taber"],4,11,20,20)])
|
||||||
|
|
||||||
if code == d.OK:
|
if code == d.OK:
|
||||||
klandringer[id]["title"] = elements[0]
|
k["title"] = elements[0]
|
||||||
klandringer[id]["klandrer"] = elements[1]
|
k["klandrer"] = elements[1]
|
||||||
klandringer[id]["klandret"] = elements[2]
|
k["klandret"] = elements[2]
|
||||||
save_klandringer()
|
k["taber"] = elements[3]
|
||||||
|
save()
|
||||||
|
|
||||||
menu_klandringer()
|
menu_klandringer()
|
||||||
|
|
||||||
|
def describe_klandring(strid):
|
||||||
|
id = int(strid)
|
||||||
|
k = klandringer[id]
|
||||||
|
code, text = d.editbox_str(k["description"],
|
||||||
|
height=0,
|
||||||
|
width=0,
|
||||||
|
title=k["klandrer"] + " v. " + k["klandret"] + " - " + k["title"])
|
||||||
|
|
||||||
|
if code == d.OK:
|
||||||
|
k["description"] = text
|
||||||
|
save()
|
||||||
|
|
||||||
|
menu_klandringer()
|
||||||
|
|
||||||
|
|
||||||
def delete_klandring(strid):
|
def delete_klandring(strid):
|
||||||
id = int(strid)
|
id = int(strid)
|
||||||
|
@ -91,15 +135,29 @@ def delete_klandring(strid):
|
||||||
if code == d.OK:
|
if code == d.OK:
|
||||||
del klandringer[id]
|
del klandringer[id]
|
||||||
d.msgbox("Klandringen er slettet!")
|
d.msgbox("Klandringen er slettet!")
|
||||||
save_klandringer()
|
save()
|
||||||
|
|
||||||
menu_klandringer()
|
menu_klandringer()
|
||||||
|
|
||||||
def save_klandringer():
|
def save():
|
||||||
with open("klandringer.json","w") as jsonfile:
|
with open("klandringer.json","w") as jsonfile:
|
||||||
jsonfile.write(json.dumps(klandringer))
|
jsonfile.write(json.dumps(complete_klandringer))
|
||||||
|
|
||||||
# End klandringer
|
# End klandringer
|
||||||
|
|
||||||
|
def new_date():
|
||||||
|
code, pickdate = d.calendar("Vælg en dato")
|
||||||
|
|
||||||
|
if code == d.OK:
|
||||||
|
date = str(pickdate[2]).zfill(4) + "-" + str(pickdate[1]).zfill(2) + "-" + str(pickdate[0]).zfill(2)
|
||||||
|
complete_klandringer[date] = []
|
||||||
|
save()
|
||||||
|
return date
|
||||||
|
else:
|
||||||
|
menu_select_date()
|
||||||
|
|
||||||
# End definitions
|
# End definitions
|
||||||
|
|
||||||
menu_main()
|
menu_select_date()
|
||||||
|
|
||||||
|
#menu_main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user