Working on a notes program that saves notes, shows each note as tkinter window. Saves the notes in a pickled file, each pickled object is displayed as a label on a separate window.
global notes
load_color()
f = open('m.data', 'rb')
try:
while True:
try:
notes = pickle.load(f)
except EOFError:
break
root = Tk()
root.title('Note')
note_label = Label(root, text=notes, fg=color).pack(side=TOP)
root.mainloop()
except EOFError:
pass
This is the function that shows each of the objects on a separate window. When displaying the notes, each of the notes are displayed like this:
64832376note
The color is displayed correctly.
Not sure why this is happening. It should have showed what I typed in as a note in the window. In case this doesn't explain enough, here is the full code so far: https://pastebin.com/6rpeFfED Thanks in advance
It is because the statement note = str(input("Take a note: "))
inside note()
function will save the input note into local variable note
. Then you refer note
inside dump_notes()
function which actually refer to reference of note()
function.
To fix the issue, most simply way is to modify dump_notes()
function to accept argument, like dump_notes(note)
and then update dump_notes()
inside note()
function to dump_notes(note)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.