From d39dd9d484a23b04ebd2bc470c3b920b6b08991d Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 20 Jan 2024 00:30:16 +0100 Subject: [PATCH] =?UTF-8?q?m=C3=BCssen=20noch=20schauen,=20wie=20wir=20den?= =?UTF-8?q?=20message=20text=20in=20die=20Datei=20bekommen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- journal.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/journal.py b/journal.py index dde9a86..b273baa 100755 --- a/journal.py +++ b/journal.py @@ -10,13 +10,15 @@ now = datetime.now() YEAR = now.strftime("%Y") MONTH = now.strftime("%m") 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 if not os.path.exists(journal_filename_path): - with open(journal_filename_path, "w"): pass + with open(journal_filename_path, "w"): + pass else: - with open(journal_filename_path, "a"): pass + with open(journal_filename_path, "a"): + pass # configure root window journal = tk.Tk() @@ -44,22 +46,26 @@ name_entry.focus() # textbox message_label = tk.Label(journal, text="Deine Nachricht:") 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() -def send_button_clicked(name, message): + +def send_button_clicked(): with open(journal_filename_path, "a") as journal_of_the_day: 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") showinfo(title="Information", message="Deine Nachricht wurde gespeichert") + # Send Button button_send = ttk.Button( journal, text="Abschicken", - #command=lambda: showinfo(title="Information", message="Deine Nachricht wurde gespeichert") - command=lambda: send_button_clicked(name, message) + # command=lambda: showinfo(title="Information", message="Deine Nachricht wurde gespeichert") + command=lambda: send_button_clicked() ) button_send.pack() @@ -71,4 +77,4 @@ button_quit = ttk.Button( ) button_quit.pack() -journal.mainloop() \ No newline at end of file +journal.mainloop()