müssen noch schauen, wie wir den message text in die Datei bekommen
This commit is contained in:
parent
4266bc27ab
commit
d39dd9d484
22
journal.py
22
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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user