zoukankan      html  css  js  c++  java
  • Python使用tkinter库创建图形界面HelloWorld

    备注

    tkinter是python自带的GUI库。若要追求功能强大的跨平台开发,建议使用QT与wxWidgets的wxPython版本


    一、源码:

    from tkinter import *
    
    class Application(Frame):
        def say_hi(self):
            print("hi there, everyone!")
    
        def createWidgets(self):
            self.QUIT = Button(self)
            self.QUIT["text"] = "QUIT"
            self.QUIT["fg"] = "red"
            self.QUIT["command"] = self.quit
    
            self.QUIT.pack({"side": "left"})
    
            self.hi_there = Button(self)
            self.hi_there["text"] = "Hello",
            self.hi_there["command"] = self.say_hi
    
            self.hi_there.pack({"side": "left"})
    
        def __init__(self, master=None):
            Frame.__init__(self, master)
            self.pack()
            self.createWidgets()
    
    root = Tk()
    app = Application(master=root)
    app.mainloop()
    root.destroy()
    



    二、结果预览:



  • 相关阅读:
    iOS -- @try
    javaScript学习
    iOS -- js与原生交互
    iOS -- WKWebView
    iOS -- UIWindow的使用
    iOS -- app生命周期中代理方法的应用场景
    iOS -- keyChain
    UISegmentedControl
    明天你好
    编程:是一门艺术(转)
  • 原文地址:https://www.cnblogs.com/beta2013/p/3377321.html
Copyright © 2011-2022 走看看