zoukankan      html  css  js  c++  java
  • python_图形界面编程示例

    "常用Tkinter组件的使用"
    #一、弹出消息框
    #1 弹出提示消息框
    from tkinter.messagebox import *
    showinfo(title='提示',message='欢迎光临')
    #2 弹出警告消息框
    from tkinter.messagebox import *
    showwarning(title='提示',message='请输入密码')
    #3 弹出错误消息框
    from tkinter.messagebox import *
    showerror(title='提示',message='密码错误')
    #4 弹出疑问消息框方法1 如果用户单击‘是’按钮,则askquestion()函数返回YES,否则返回NO
    from tkinter.messagebox import *
    ret=askquestion(title='请确认',message='是否删除此用户')
    if ret==YES:
        showinfo(title='提示',message='已删除')
    #4 弹出疑问消息框方法2 如果用户单击‘是’按钮,则askyesno()函数返回True,否则返回False
    from tkinter.messagebox import *
    ret=askyesno(title='请确认',message='是否删除此用户')#askyesnocancel()
    if ret==True:
        showinfo(title='提示',message='已删除')
    #5 弹出带‘确定’和‘取消’按钮的疑问消息框 如果用户单击‘确定’按钮,则askokcancel()函数返回True,否则返回False
    from tkinter.messagebox import *
    ret=askokcancel(title='请确认',message='是否确定继续?')
    if ret==True:
        showinfo(title='提示',message='继续')
    #6 弹出带‘重试’和‘取消’按钮的疑问消息框
    from tkinter.messagebox import *
    ret=askretrycancel(title='提示',message='操作失败您可以选择')
    if ret==True:
        showinfo(title='提示',message='继续')
        
    #二、创建Windows窗口
    from tkinter import *
    win=Tk()#创建窗口对象
    win.title('我的窗口')#设置窗口标题
    win.geometry('800x600')#设置窗口大小,这里x不是乘号,而是字母x
    win.minsize(400,300)#设置窗口的最小  窗口对象.minsize(最小宽度,最下高度)
    win.maxsize(140,900)#设置窗口的最大
    win.mainloop()#进入窗口主循环,也就是显示窗口
    

      

  • 相关阅读:
    [React] Cleaning up Functional Components with Custom Hooks
    [React] useCallback + useMemo to avoid re-render
    [React] Replacing Instance Variables with the useRef Hook
    [Cloud Architect] 4. Introduction to Design for Cost, Performance, & Scalability
    [Cloud Architect] 3. Monitor, React, and Recover
    [Cloud Architect] 3. Business Objectives
    1314:【例3.6】过河卒(Noip2002)
    1313:【例3.5】位数问题
    rk3568 linux sdk Buildroot 开发
    AcWing 873. 欧拉函数
  • 原文地址:https://www.cnblogs.com/tianqizhi/p/8340738.html
Copyright © 2011-2022 走看看