zoukankan      html  css  js  c++  java
  • Tkinter 小应用

    import tkinter as tk
    
    class APP:
        def __init__(self,master):
            frame = tk.Frame(master)
            frame.pack(side = tk.LEFT,padx=50,pady=50)
    
            self.hi_there = tk.Button(frame,text ="打招呼",bg = "blue",fg = "white",command = self.say_hi)
            self.hi_there.pack()
    
        def say_hi(self):
            print("Hello World!")
    
    root = tk.Tk()
    app = APP(root)
    
    root.mainloop()
    from tkinter import*
    def callback():
        var.set("No!")
    root = Tk()
    
    frame1 = Frame(root)
    frame2 = Frame(root)
    var = StringVar()
    var.set("Sorry!
    There is someting Wrong!")
    
    textLabel = Label(frame1,
                      textvariable = var,
                      justify = LEFT)
    textLabel.pack(side=LEFT)
    
    photo = PhotoImage(file = "18.gif")
    imLabel = Label(frame1,image = photo)
    imLabel.pack(side = LEFT)
    
    theButton = Button(frame2,text = "I am OK !",command = callback)
    theButton.pack()
    
    '''
    photo = PhotoImage(file = "bg.gif")
    theLabel = Label(root,
                     text = "学 Python
    到 FichC",
                     justify = LEFT,
                     image = photo,
                     compound = CENTER,
                     fg = "white")
    theLabel.pack()
    '''
    frame1.pack(padx = 10,pady = 10)
    frame2.pack(padx = 10,pady = 10)
    mainloop()
  • 相关阅读:
    5.9编程练习
    linux下查看torch版本和cuda版本
    4.13编程练习
    C++ Primer Plus-3.7编程练习-第2题和第5题
    More on vim tips
    Method Calling in Perl
    换零钱 动态规划解法 C语言描述
    海伦平方根算法(LISP描述)
    expect 实现模拟交互
    tmux 入门
  • 原文地址:https://www.cnblogs.com/chenyang920/p/4906799.html
Copyright © 2011-2022 走看看