博客:第一天,做个笔记吧

# -*- coding: utf-8 -*-
from tkinter import *
import time
# 导入tkinter模块的所有内容

def callback(): # 定义一个 改变文本的函数 .
var.set("程序一-------------------")
print("11111111111111-------------------------")
time.sleep(10)
print("11111111111111-------------------------")

def callback2(): # 定义一个 改变文本的函数 .
var.set("程序一-------------------")
print("22222222-------------------------")
time.sleep(10)
print("22222222-------------------------")

root = Tk() # 初始旷的声明 .

root.title('WiFi兼容稳定性!')
#设置窗口的大小宽x高+偏移量
root.geometry('500x300+500+200')
#设置窗口标题
#root.title('爬虫程序')
# root.overrideredirect(1)
#设置窗口图标
#root.iconbitmap('spider_128px_1169260_easyicon.net.ico')

frame1 = Frame(root) # 在初始旷里面 声明两个模块 .
frame2 = Frame(root)

# 创建一个文本Label对象
var = StringVar() #声明可变 变量 .
var.set("请选择要运行的程序, 单击即可!") # 设置变量 .
textLabel = Label(frame1, # 绑定到模块1
textvariable=var, # textvariable 是文本变量的意思 .
justify=LEFT) # 字体 位置
textLabel.pack(side=LEFT) # 整体位置

# 创建一个图像Label对象
# 用PhotoImage实例化一个图片对象(支持gif格式的图片)
photo = PhotoImage(file="C:/Users/Administrator/Desktop/1.gif")
imgLabel = Label(frame1, image=photo)
imgLabel.pack(side=RIGHT)

# 加一个按钮
theButton1 = Button(frame2, text="程序一", command=callback) # 按下按钮 执行 callback函数
theButton1.pack()

theButton2 = Button(frame2, text="程序2", command=callback2) # 按下按钮 执行 callback函数
theButton2.pack()
frame1.pack(padx=10, pady=10)
frame2.pack(padx=10, pady=10)

mainloop()
原文地址:https://www.cnblogs.com/buergege520/p/8531517.html