• tkinter学习笔记_06


    12、弹窗 messagebox

    import tkinter as tk
    from tkinter import messagebox
    root = tk.Tk()
    root.title("xxx")
    root.geometry('200x100')
    
    def hit_me():
        # tk.messagebox.showinfo(title='Hi', message='hahaha') # message 给窗口的信息,图标是python火箭
        # tk.messagebox.showwarning(title='Hi', message='程序有错, 是否修改下执行')  # 提示信息框 ,图标是感叹号
        # tk.messagebox.showerror(title='Hi', message='程序错了不能再运行了')
        # tk.messagebox.askquestion(title='Hi', message='yes or no')   # 问用户信息,有返回值,返回值是yes和no
        # if return == 'yes':
        #     print('xxxx')
        # tk.messagebox.askyesno(title='Hi', message='yes or no')  # 返回的是 False 和 True
        print(tk.messagebox.askretrycancel(title='Hi', message='yes or no'))  # 返回的是 重试True 和取消False
        print(tk.messagebox.askokcancel(title='Hi', message='yes or no'))   # 第一次返回的是 重试True 和取消False
        # 第二次返回的是 确定True 和取消False
    tk.Button(root, text='hit me', command=hit_me).pack()
    
    root.mainloop()

    13、放置位置   pack grid place

    import tkinter as tk
    root = tk.Tk()
    root.title("xxx")
    root.geometry('200x100')
    # pack方法
    # tk.Label(root, text=1).pack(side='top') # 上
    # tk.Label(root, text=1).pack(side='bottom') # 下
    # tk.Label(root, text=1).pack(side='left') # 左
    # tk.Label(root, text=1).pack(side='right') # 右
    
    # grid方法12格子方法, 4行, 3列
    # for i in range(4):
    #     for j in range(3):
    #         # row 行    column 列    padx 长    pady 高
    #         tk.Label(root, text=1).grid(row=i, column=j, padx=10, pady=10)
    
    # palce 精准放置
    tk.Label(root, text=1).place(x=10, y=100, anchor='nw')  # anchor 放在哪个角部
    
    root.mainloop()

  • 相关阅读:
    CMS网站 中最好用的!
    成为优秀设计师的十大条件
    网站变色(黑白)!
    设计师必知的18种服装风格
    HDFS核心类FileSystem的使用
    Hadoop的伪分布式安装和部署的流程
    初学MapReduce离线计算(eclipse实现)
    hdfs的客户端读写流程以及namenode,secondarynamenode,checkpoint原理
    hadoop常用的操作指令
    TableLayoutPanel&SplitContainer 布局
  • 原文地址:https://www.cnblogs.com/lixy-88428977/p/9367103.html
Copyright © 2020-2023  润新知