Python GUI tkinter窗口视窗学习4
# test13
import tkinter as tk
window = tk.Tk()
window.title('my test')
window.geometry('700x400')
# 在windows窗口上创建一个frame
frame = tk.Frame(window)
frame.pack()
# 创建第二层框架frame,在主框架frame上
frame_l = tk.Frame(frame)
frame_r = tk.Frame(frame)
frame_l.pack(side = 'left')
frame_r.pack(side = 'right')
# 创建三组标签,为第二层frame上面的内容,分为左区域和右区域,用不同颜色标识
tk.Label(frame_l,text = 'on the frame_l1',bg = 'green').pack()
tk.Label(frame_l,text = 'on the frame_l1',bg = 'green').pack()
tk.Label(frame_l,text = 'on the frame_l1',bg = 'green').pack()
tk.Label(frame_r,text = 'on the frame_r1',bg = 'red').pack()
window.mainloop()
# test14
import tkinter as tk
# 使用messagebox需要先导入模块
import tkinter.messagebox
window = tk.Tk()
window.title('my test')
window.geometry('700x400')
def hit_me():
tkinter.messagebox.showinfo(title='Hi', message='你好!')
# tkinter.messagebox.showinfo(title='Hi', message='你好!') # 提示信息对话窗
# tkinter.messagebox.showwarning(title='Hi', message='有警告!') # 提出警告对话窗
# tkinter.messagebox.showerror(title='Hi', message='出错了!') # 提出错误对话窗
# print(tkinter.messagebox.askquestion(title='Hi', message='你好!')) # 询问选择对话窗return 'yes', 'no'
# print(tkinter.messagebox.askyesno(title='Hi', message='你好!')) # return 'True', 'False'
# print(tkinter.messagebox.askokcancel(title='Hi', message='你好!')) # return 'True', 'False'
tk.Button(window,text = 'hit me',bg = 'green',command = hit_me).pack()
window.mainloop()