• 技术文章 >常见问题 >Python常见问题

    怎么用python写窗口程序

    silencementsilencement2020-03-19 13:52:14原创8200

    Python也可以创建界面,需要导入tkinter
    具体看代码:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    from tkinter import *

     

    def btnClick():

        textLabel['text']='我点击了按钮'

     

    root = Tk(className="我的第一个窗口程序");

     

    textLabel = Label(root,text = '提示显示',justify=LEFT,padx=10)

    textLabel.pack(side = TOP)

     

    btn = Button(root)

    btn['text']='点击测试'

    btn['command'] = btnClick

    btn.pack(side = BOTTOM)

     

    mainloop()

    更多技术请关注python视频教程

    专题推荐:python
    上一篇:python怎么使用迭代器 下一篇:有哪些运用python的公司

    相关文章推荐

    • 如何在python下写脚本• python中怎样输入两行• 如何给python安装包• python如何查看对象的属性

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网