tkinter *
tkinter.filedialog * tkinter.colorchooser * tkinter.filedialog *
Application(Frame):
(master=):
().(master) .master = master
.textpad = .pack()
.createWidget()
():
menubar = Menu(root)
menuFile = Menu(menubar)
menuEdit = Menu(menubar)
menuHelp = Menu(menubar)
menubar.add_cascade(==menuFile)
menubar.add_cascade(==menuEdit)
menubar.add_cascade(==menuHelp)
menuFile.add_command(===.test)
menuFile.add_command(===.openfile)
menuFile.add_command(===.savefile)
menuFile.add_separator() menuFile.add_command(===.test)
root[] = menubar
.textpad = Text(root==)
.textpad.pack()
.contextMenu = Menu(root)
.contextMenu.add_command(==.openAskColor)
root.bind(.createContextMenu)
():
(askopenfilename(=)=) f: .textpad.insert(INSERTf.read())
.filename = f.name
():
(.filename) f:
c = .textpad.get(END)
f.write(c)
():
():
s1 = askcolor(==)
root.config(=s1[])
(event):
.contextMenu.post(event.x_rootevent.y_root)
__name__ == :
root = Tk()
root.geometry()
root.title()
app = Application(=root)
root.mainloop()
C:\Users\微软\AppData\Local\Programs\Python\Python37\python.exe C:/Users/微软/pycharm_execrise/pythonProject/GUI/note.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\微软\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/微软/pycharm_execrise/pythonProject/GUI/note.py", line 61, in openfile
self.textpad.insert(INSERT, f.read())
File "C:\Users\微软\AppData\Local\Programs\Python\Python37\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbd in position 0: invalid start byte
Process finished with exit code 0