tkinter 窗体框架使用
界面布局
pack()
默认居中,从上而下
def init_window(title,w,h,icon_path):
window = tk.Tk()
window.title(title)
window.iconphoto(False, tk.PhotoImage(file=icon_path))
screen_width, screen_height = window.maxsize()
top_x = screen_width/2 - w/2
top_y = screen_height/2 - h/2
window.geometry("%dx%d+%d+%d" %(w,h,top_x,top_y))
btn=Button(window,text='选择图片')
btn.pack()
window.mainloop()
主窗口大小和位置
geometry("wxh±x±y")
创建图片对象
photo = PhotoImage(file="xxxpath")