müssen noch schauen, wie wir den message text in die Datei bekommen
This commit is contained in:
parent
4266bc27ab
commit
d39dd9d484
24
journal.py
24
journal.py
|
|
@ -10,13 +10,15 @@ now = datetime.now()
|
||||||
YEAR = now.strftime("%Y")
|
YEAR = now.strftime("%Y")
|
||||||
MONTH = now.strftime("%m")
|
MONTH = now.strftime("%m")
|
||||||
DAY = now.strftime("%d")
|
DAY = now.strftime("%d")
|
||||||
journal_filename = "%s-%s-%s-Journal.txt" %(YEAR, MONTH, DAY)
|
journal_filename = "%s-%s-%s-Journal.txt" % (YEAR, MONTH, DAY)
|
||||||
journal_filename_path = "./%s" % journal_filename
|
journal_filename_path = "./%s" % journal_filename
|
||||||
|
|
||||||
if not os.path.exists(journal_filename_path):
|
if not os.path.exists(journal_filename_path):
|
||||||
with open(journal_filename_path, "w"): pass
|
with open(journal_filename_path, "w"):
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
with open(journal_filename_path, "a"): pass
|
with open(journal_filename_path, "a"):
|
||||||
|
pass
|
||||||
|
|
||||||
# configure root window
|
# configure root window
|
||||||
journal = tk.Tk()
|
journal = tk.Tk()
|
||||||
|
|
@ -44,22 +46,26 @@ name_entry.focus()
|
||||||
# textbox
|
# textbox
|
||||||
message_label = tk.Label(journal, text="Deine Nachricht:")
|
message_label = tk.Label(journal, text="Deine Nachricht:")
|
||||||
message_label.pack(fill='x', expand=True)
|
message_label.pack(fill='x', expand=True)
|
||||||
message_text = tk.Text(journal, height=50)
|
#message_text = ttk.Text(journal, height=50)
|
||||||
|
message_text = tk.Text(journal)
|
||||||
message_text.pack()
|
message_text.pack()
|
||||||
|
|
||||||
def send_button_clicked(name, message):
|
|
||||||
|
def send_button_clicked():
|
||||||
with open(journal_filename_path, "a") as journal_of_the_day:
|
with open(journal_filename_path, "a") as journal_of_the_day:
|
||||||
journal_of_the_day.write(name.get() + "\n")
|
journal_of_the_day.write(name.get() + "\n")
|
||||||
journal_of_the_day.write(message.get() + "\n")
|
message_text_str=message_text.get()
|
||||||
|
journal_of_the_day.write(message_text_str + "\n")
|
||||||
journal_of_the_day.write("-----------------\n")
|
journal_of_the_day.write("-----------------\n")
|
||||||
showinfo(title="Information", message="Deine Nachricht wurde gespeichert")
|
showinfo(title="Information", message="Deine Nachricht wurde gespeichert")
|
||||||
|
|
||||||
|
|
||||||
# Send Button
|
# Send Button
|
||||||
button_send = ttk.Button(
|
button_send = ttk.Button(
|
||||||
journal,
|
journal,
|
||||||
text="Abschicken",
|
text="Abschicken",
|
||||||
#command=lambda: showinfo(title="Information", message="Deine Nachricht wurde gespeichert")
|
# command=lambda: showinfo(title="Information", message="Deine Nachricht wurde gespeichert")
|
||||||
command=lambda: send_button_clicked(name, message)
|
command=lambda: send_button_clicked()
|
||||||
)
|
)
|
||||||
button_send.pack()
|
button_send.pack()
|
||||||
|
|
||||||
|
|
@ -71,4 +77,4 @@ button_quit = ttk.Button(
|
||||||
)
|
)
|
||||||
button_quit.pack()
|
button_quit.pack()
|
||||||
|
|
||||||
journal.mainloop()
|
journal.mainloop()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user