zoukankan      html  css  js  c++  java
  • 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()

  • 相关阅读:
    SQLServer.Produce的研究
    petshop以异步方式插入订单的疑惑(后面理解了)
    SQLHelper.GetCachedParameters方法之缓存
    DALFactory抽象工厂理解
    petshop异时消息处理队列抽象工厂
    AJAX学习2(经典)
    对SQLServerDAL.order的研究(不错,有心得)
    Invertory类对商品库存的更新困惑解决了
    AJAX学习1
    用DataSet读取xml文件
  • 原文地址:https://www.cnblogs.com/lixy-88428977/p/9367103.html
Copyright © 2011-2022 走看看