也在学习中,这些都是在莫烦python做志愿者写下的。~
本节就是对以上学习的总结,也是我们大家自己做一个小小项目的尝试~一共三篇。
这一次效果图是这样的:
都是前面熟悉的参数。为了防止大家忘记,特意加上代码注释。
界面创建
# welcome image
canvas = tk.Canvas(window, height=200, width=500)#创建画布
image_file = tk.PhotoImage(file='welcome.gif')#加载图片文件
image = canvas.create_image(0,0, anchor='nw', image=image_file)#将图片置于画布上
canvas.pack(side='top')#放置画布(为上端)
这里创建的就是我们效果图中的`welcome`。
# user information
tk.Label(window, text='User name: ').place(x=50, y= 150)#创建一个`label`名为`User name: `置于坐标(50,150)
tk.Label(window, text='Password: ').place(x=50, y= 190)
var_usr_name = tk.StringVar()#定义变量
var_usr_name.set('example@python.com')#变量赋值'e