wir können eine Datei erstellen, falls benötigt und reinschreiben und anfügen
This commit is contained in:
parent
6d83bb99fa
commit
a604b4d201
21
journal.py
21
journal.py
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import tkinter as tk
|
||||
import os
|
||||
from tkinter import ttk
|
||||
from tkinter import ttk, StringVar
|
||||
from tkinter.messagebox import showinfo
|
||||
from datetime import datetime
|
||||
|
||||
|
|
@ -13,11 +13,10 @@ DAY = now.strftime("%d")
|
|||
journal_filename = "%s-%s-%s-Journal.txt" %(YEAR, MONTH, DAY)
|
||||
journal_filename_path = "./%s" % journal_filename
|
||||
|
||||
#if os.path.exists(journal_filename_path):
|
||||
# print('file already exists')
|
||||
#else:
|
||||
# # create a file
|
||||
# with open(journal_filename_path)
|
||||
if not os.path.exists(journal_filename_path):
|
||||
with open(journal_filename_path, "w"): pass
|
||||
else:
|
||||
with open(journal_filename_path, "a"): pass
|
||||
|
||||
# configure root window
|
||||
journal = tk.Tk()
|
||||
|
|
@ -48,11 +47,19 @@ message_label.pack(fill='x', expand=True)
|
|||
message_text = tk.Text(journal, height=50)
|
||||
message_text.pack()
|
||||
|
||||
def send_button_clicked(name, message):
|
||||
with open(journal_filename_path, "a") as journal_of_the_day:
|
||||
journal_of_the_day.write(name.get())
|
||||
journal_of_the_day.write(message.get())
|
||||
journal_of_the_day.write("-----------------")
|
||||
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: showinfo(title="Information", message="Deine Nachricht wurde gespeichert")
|
||||
command=send_button_clicked(name, message)
|
||||
)
|
||||
button_send.pack()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user