Commit 1d4c2efa by BellCodeEditor

auto save

parent 39bdb55e
Showing with 51 additions and 0 deletions
import tkinter
from tkinter import *
alist=["星期六去打球","星期一去帮妈妈买东西","4号要回学校","周末写作业"]
class Note:
def __init__(self):
#设置窗口
self.root=tkinter.Tk()
self.root.title("我的便签——待办事项")
self.root.geometry("300x340+500+300")
self.root.resizable(width=False,height=False)
#加载图片
self.bg=tkinter.PhotoImage(file='bg.png')
#页面布局
def show(self):
#创建画布
self.canv=tkinter.Canvas(self.root,width=300,height=340,bg='lightblue')
self.canv.place(x=0,y=0)
#画布设置背景
self.canv.create_image(0,0,image=self.bg,anchor=NW)
#画布添加文字
self.y=20
for info in alist:
self.canv.create_text(40,self.y,text=info,fill='#ff9900',
anchor=W,font=('宋体',11))
self.y+=30
self.e1=tkinter.Entry(self.root,show=None,width=25,
font=('宋体',13),bg='snow')
self.e1.place(x=10,y=310)
self.btn=tkinter.Button(self.root,text="添加",font=('宋体',12),
width=5,bg='lightblue',command=self.get_input)
self.btn.place(x=240,y=305)
#命令函数
def get_input(self):
content=self.e1.get()
if content!='':
alist.append(content)
print(alist)
self.canv.create_text(40,self.y,text=content,fill="#FF9900",
font=('宋体',11),anchor=W)
self.e1.delete("0",END)
note=Note()
note.show()
note.root.mainloop()
print(alist)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment