#tkinter应用案例五:Label组件设图片为背景并点击按钮触发事件

from tkinter import *
from PIL.ImageTk import PhotoImage
from sqlalchemy.testing.exclusions import compound def callback():
var.set("正在进入学习空间……") root=Tk() #实例化TK
root.title("Jason niu工作室") frame1=Frame(root)
frame2=Frame(root) var=StringVar()
var.set("欢迎进入Jason niu工作室\n主要模块有:\n机器学习\n深度学习\n强化学习\n迁移学习\n区块链技术") photo=PhotoImage(file="G:\创业\背景图01.jpg")
imageLabel=Label(frame1)
imageLabel.pack(side=RIGHT) textLabel=Label(root,
textvariable=var,
justify=CENTER,
image=photo,
compound=CENTER,
font=("楷体",20,),fg="yellow")
textLabel.pack() theButton=Button(frame1,text="我想学习区块链技术的应用",font=("黑体",),fg="red",command=callback)
theButton.pack()
frame1.pack(padx=10,pady=10)
frame2.pack(padx=10,pady=10) mainloop()

#tkinter应用案例一:
import tkinter as tk
app=tk.Tk()
app.title("Jason niu工作室")
theLabel=tk.Label(app,text="进入GUI世界,请开始你的表演!")
theLabel.pack()
app.mainloop()

#tkinter应用案例二:
import tkinter as tk
from tkinter import *
from PIL.ImageTk import PhotoImage root=tk.Tk() textLabel=Label(root,
text="欢迎进入Jason niu工作室\n主要模块有:\n机器学习\n深度学习\n强化学习\n迁移学习\n区块链技术",
justify=CENTER,
padx=0)
textLabel.pack() photo=PhotoImage(file="G:\创业\云崖牛logo小.png")
imageLabel=Label(root,image=photo)
imageLabel.pack() mainloop()

#tkinter应用案例三:将GUI封装成类
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="欢迎进入Jason niu工作室",fg="yellow",bg="black",command=self.say_hi)
self.hi_there.pack() def say_hi(self):
print("你好,欢迎访问“一个处女座程序猿的博客”!")
root=tk.Tk()
app=APP(root)
root.mainloop()

#tkinter应用案例四:Label组件将图片设为背景
import tkinter as tk
from tkinter import *
from PIL.ImageTk import PhotoImage
from sqlalchemy.testing.exclusions import compound root=tk.Tk()
root.title("Jason niu工作室")
photo=PhotoImage(file="G:\创业\背景图01.jpg")
textLabel=Label(root,
text="欢迎进入Jason niu工作室\n主要模块有:\n机器学习\n深度学习\n强化学习\n迁移学习\n区块链技术",
justify=CENTER,
image=photo,
compound=CENTER,
font=("楷体",20,),
fg="yellow")
textLabel.pack() mainloop()

  

最新文章

  1. 精确率与召回率,RoC曲线与PR曲线
  2. 问题解决——CVSListBox的使用
  3. Linux 常用命令笔记 (持续更新)
  4. Leetcode Maximum Depth of Binary Tree
  5. Codeforces Round #332 (Div. 2) B. Spongebob and Joke 水题
  6. 前端自动生成/加载CSS
  7. app启动其他应用
  8. Java设置的读书笔记和集合框架Collection API
  9. hud 2099
  10. 反射应用--IOC和AOP
  11. cmd 与 bash 基础命令入门
  12. Spring+SpringMVC+MyBatis+easyUI整合进阶篇(十五)阶段总结
  13. TypeScript-封装
  14. [C++]PAT乙级1002.写出这个数(20/20)
  15. linux脚本实现scp命令自动输入密码和yes/no等确认信息
  16. c++下基于windows socket的多线程服务器(基于TCP协议)
  17. delphi 域名转ip并判断ip是否可以联通
  18. 用开源项目ExpandableTextView打造可以下拉扩展的TextView
  19. Spring AOP的注解方式实现
  20. Tomcat安全配置与性能优化

热门文章

  1. Koa与Node.js开发实战(2)——使用Koa中间件获取响应时间(视频演示)
  2. 将JSON转换成MAP的工具类
  3. python双端队列-collection模块
  4. Linux命令--tree
  5. tomcat用redis做session共享
  6. 如何做一个项目.ppt
  7. JavaScript—对象创建方式
  8. springmvc 开发流程图
  9. nyoj 633 幂
  10. LeetCode 14.Longest Common Prefix(C++)