Ich möchte Daten in eine Liste schreiben,
hat auch immer geklappt, aber jetzt versuche ich noch Text - Farbe hinzuzufügen.
Leider kam dann das raus:
Code: Alles auswählen
8
#e2d523#dc1010Code: Alles auswählen
8
10
#000000Aber hier nicht ich finde keinen fehler:
ohne Farbe stand blos 8 und 10 da untereinander
hat alles geklappt.
das Problem ist hier nur das es die Farbe nicht überschreibt wenn ich Farbe angebe,
sondern nur neben einander schreibt.
Code: Alles auswählen
from tkinter import*
import tkinter
import os
import string
import tkinter.colorchooser
root = tkinter.Tk()
root.title("Neue Notiz eintragen")
root.geometry('560x400')
root.maxsize(900,500)
root.minsize(770,450)
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(),
root.winfo_screenheight()))
def save():
save = open("desknotiz.txt", 'w')
save.write(etext.get(0.0, 'end'))
save.close()
def ask_quit():
root.destroy()
root.mainloop()
def setTxTColor():
(triple, hexstr) = tkinter.colorchooser.askcolor(color="#000000")
if hexstr:
datenread = open('daten.cfd', 'r')
aktuallisirungstime = datenread.read()
schriftgr = datenread.read()
farbauswahl.config(bg = hexstr)
farbe = open('daten.cfd', 'w')
farbe.write(aktuallisirungstime)
farbe.write(schriftgr)
farbe.write(hexstr) #Hier schreib es die Farbe rein
farbe.close()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y )
def textgrousse(event):
etext.config(font = ("Arial", regler1.get()))
def cofigfile(event):
zeit = regler.get()
temp = open('daten.cfd', 'r')
temp.readline()
schriftgr = temp.readline()
txtcolor = temp.readline()
aktualisirung = open('daten.cfd', 'w')
aktualisirung.write(str(zeit) + "\n")
aktualisirung.write(schriftgr + "\n")
aktualisirung.write(txtcolor + "\n")
aktualisirung.close()
save()
def cofigfilegr():
gr = "10"
gr = varZahl.get()
temp = open('daten.cfd', 'r')
aktuallisirungstime = temp.readline()
temp.readline()
txtcolor = temp.readline()
gruosse = open('daten.cfd', 'w')
gruosse.write(aktuallisirungstime + "\n")
gruosse.write(str(gr) + "\n")
gruosse.write(txtcolor + "\n")
gruosse.close()
def openfile():
externesProgramm = "notizdesk.pyw"
os.system(externesProgramm)
########################################################
schrift = tkinter.Label(root, text = "Schriftgr\xf6\xdfe:")
schrift.place(relx=0.01, rely=0.005)
regler1 = Scale(root,from_=8, to=40, orient=HORIZONTAL, command = textgrousse)
regler1.set(10)
regler1.place(relx=0.09, rely=0.00, relwidth=0.15)
#Sonderzeichen = Button(root,text = "Sonderzeichen",command = sonderzeichen)
#Sonderzeichen.place(relx = 0.25, rely = 0.015)
##########################################################
etext = Text(root,yscrollcommand=scrollbar.set)
scrollbar.config(command=etext.yview)
etext.config(font =("Arial", 11))
etext.config(fg="black")
file = open(r'desknotiz.txt', 'r')
text = file.read()
etext.insert(INSERT, r"" + text)
file.close()
scrollbar.place(relx=0.9602, rely=0.08, relheight=0.55)
etext.place(relx=0.01, rely=0.08, relwidth=0.95, relheight=0.55)
############################################################
optionen = LabelFrame(root, text="Optionen f\xfcr die Anzeige auf den Desktop")
optionen.place(relx=0.01, rely = 0.64, relwidth = 0.9, relheight = 0.26)
time = tkinter.Label(optionen, text = "Aktualisierungszeit in Sekunden")
time.place(relx=0.04, rely=0.07)
regler = Scale(optionen,from_=1, to=120, orient=HORIZONTAL, command = cofigfile)
regler.set(10)
regler.place(relx=0.04, rely=0.22, relwidth=0.25)
Schriftgr = tkinter.Label(optionen, text = "Schriftgr\xf6\xdfe")
Schriftgr.place(relx=0.04, rely=0.6)
gruosse = ["4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "13", "14", "15", "16", "17", "18", "19", "20"]
varZahl = tkinter.StringVar()
op = tkinter.OptionMenu(optionen, varZahl, *gruosse, command = cofigfilegr)
varZahl.set("10")
op.place(relx=0.04, rely=0.78, relwidth=0.08, relheight = 0.2)
farbauswahl = Button(optionen,text = "",command = setTxTColor)
farbauswahl.config(bg = "black")
farbauswahl.place(relx=0.15, rely=0.8008, relwidth=0.06, relheight = 0.16)
##############################################################
ok = Button(root,text = "OK",command = save)
ok.place(relx=0.04, rely=0.92, relwidth=0.15, relheight=0.06)
openprog = Button(root,text = "Anzeigen",command = open)
openprog.place(relx=0.3, rely=0.92, relwidth=0.15, relheight=0.06)
close = Button(root,text = "Schlie\xdfen",command = ask_quit)
close.place(relx=0.7, rely=0.92, relwidth=0.15, relheight=0.06)
root.mainloop()
