码迷,mamicode.com
首页 > 编程语言 > 详细

python之tkinter使用-滚动条

时间:2017-11-01 13:29:54      阅读:601      评论:0      收藏:0      [点我收藏+]

标签:label   jpg   hit   ica   size   col   image   实例化   es2017   

 

 1 # GUI:tkinter使用
 2 # 通过调节滚动条改变标签中字体大小
 3 import tkinter as tk
 4 
 5 
 6 def resize(ev=None):
 7     ‘‘‘改变label字体大小‘‘‘
 8     label.config(font=‘Helvetica -%d bold‘ % scale.get())
 9 
10 
11 top = tk.Tk()  # 实例化tkinter对象
12 top.geometry(‘250x150‘)  # 设置窗口大小
13 top.title(‘滑动设置‘)  # 设置窗口标题
14 
15 # Label控件
16 label = tk.Label(top, text=‘Hello World‘, font=‘Helvetica -12 bold‘)
17 label.pack(fill=tk.Y, expand=1)
18 
19 # scale滚动条,数值从10到40,水平滑动,回调resize函数
20 scale = tk.Scale(top, from_=10, to=40, orient=tk.HORIZONTAL, command=resize)
21 scale.set(25)  # 设置初始值
22 scale.pack(fill=tk.X, expand=1)
23 
24 # Button控件
25 quit_btn = tk.Button(top, text=‘QUIT‘, command=top.quit,
26                      activeforeground=‘white‘, activebackground=‘red‘)
27 quit_btn.pack()
28 
29 tk.mainloop()

 

截图:

技术分享

 

python之tkinter使用-滚动条

标签:label   jpg   hit   ica   size   col   image   实例化   es2017   

原文地址:http://www.cnblogs.com/gongxr/p/7765857.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!