Tkinter Scrollbar(垂直滚动部件)
语法:
这里是一个简单的语法来创建这个widget:
w = Scrollbar ( master, option, ... )
参数:
master: 这代表了父窗口.
options: 下面是这个小工具最常用的选项列表。这些选项可以作为键 - 值对以逗号分隔.
| Option | Description |
|---|---|
| activebackground | The color of the slider and arrowheads when the mouse is over them. |
| bg | The color of the slider and arrowheads when the mouse is not over them. |
| bd | The width of the 3-d borders around the entire perimeter of the trough, and also the width of the 3-d effects on the arrowheads and slider. Default is no border around the trough, and a 2-pixel border around the arrowheads and slider. |
| command | A procedure to be called whenever the scrollbar is moved. |
| cursor | The cursor that appears when the mouse is over the scrollbar. |
| elementborderwidth | The width of the borders around the arrowheads and slider. The default is elementborderwidth=-1, which means to use the value of the borderwidth option. |
| highlightbackground | The color of the focus highlight when the scrollbar does not have focus. |
| highlightcolor | The color of the focus highlight when the scrollbar has the focus. |
| highlightthickness | The thickness of the focus highlight. Default is 1. Set to 0 to suppress display of the focus highlight. |
| jump | This option controls what happens when a user drags the slider. Normally (jump=0), every small drag of the slider causes the command callback to be called. If you set this option to 1, the callback isn't called until the user releases the mouse button. |
| orient | Set orient=HORIZONTAL for a horizontal scrollbar, orient=VERTICAL for a vertical one. |
| repeatdelay | This option controls how long button 1 has to be held down in the trough before the slider starts moving in that direction repeatedly. Default is repeatdelay=300, and the units are milliseconds. |
| repeatinterval | repeatinterval |
| takefocus | Normally, you can tab the focus through a scrollbar widget. Set takefocus=0 if you don't want this behavior. |
| troughcolor | The color of the trough. |
| width | Width of the scrollbar (its y dimension if horizontal, and its x dimension if vertical). Default is 16. |
Methods:
Scrollbar objects have these methods:
| Methods | Description |
|---|---|
| get() | Returns two numbers (a, b) describing the current position of the slider. The a value gives the position of the left or top edge of the slider, for horizontal and vertical scrollbars respectively; the b value gives the position of the right or bottom edge. |
| set ( first, last ) | To connect a scrollbar to another widget w, set w's xscrollcommand or yscrollcommand to the scrollbar's set() method. The arguments have the same meaning as the values returned by the get() method. |
例子:
自行尝试下面的例子:
from Tkinter import * root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y ) mylist = Listbox(root, yscrollcommand = scrollbar.set )
for line in range(100):
mylist.insert(END, "This is line number " + str(line)) mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview ) mainloop()
这将产生以下结果:

Tkinter Scrollbar(垂直滚动部件)的更多相关文章
- Tkinter类之窗口部件类
Tkinter类之窗口部件类 Tkinter支持15个核心的窗口部件,这个15个核心窗口部件类列表如下:窗口部件及说明:Button:一个简单的按钮,用来执行一个命令或别的操作.Canvas:组织图形 ...
- Android TextView多行垂直滚动
在Android应用中,有时候需要TextView可以垂直滚动,今天我就介绍一下怎么实现的.在布局里: <TextView android:id="@+id/tvCWJ" a ...
- js实现的新闻列表垂直滚动实现详解
js实现的新闻列表垂直滚动实现详解:新闻列表垂直滚动效果在大量的网站都有应用,有点自然是不言而喻的,首先由于网页的空间有限,使用滚动代码可以使用最小的空间提供更多的信息量,还有让网页有了动态的效果,更 ...
- 自己写一个jQuery垂直滚动栏插件(panel)
html中原生的滚动栏比較难看,所以有些站点,会自己实现滚动栏,导航站点hao123在一个側栏中,就自己定义了垂直滚动栏,效果比較好看,截图例如以下: watermark/2/text/aHR0cDo ...
- [转]jquery.vTicker(垂直滚动)
转至:http://www.w3ci.com/plugin/660.html 简介 vTicker 是一款非常小巧的 jQuery 垂直滚动插件,压缩后只有 2KB.vTicker 支持自定义滚动时间 ...
- Android自定义垂直滚动自动选择日期控件
------------------本博客如未明正声明转载,皆为原创,转载请注明出处!------------------ 项目中需要一个日期选择控件,该日期选择控件是垂直滚动,停止滚动时需要校正日期 ...
- 自定义ViewGroup实现垂直滚动
转载请表明出处:http://write.blog.csdn.net/postedit/23692439 一般进入APP都有欢迎界面,基本都是水平滚动的,今天和大家分享一个垂直滚动的例子. 先来看看效 ...
- javascript焦点图之垂直滚动
html代码布局,需要用到定位,不细说了 <!DOCTYPE html> <html lang="en"> <head> <meta ch ...
- TextSwitcher实现文本自动垂直滚动
实现功能:用TextSwitcher实现文本自动垂直滚动,类似淘宝首页广告条. 实现效果: 注意:由于网上横向滚动的例子比较多,所以这里通过垂直的例子演示. 实现步骤:1.extends TextSw ...
随机推荐
- Makefile总结
1.Makefile由目标(Target).依赖关系(Dependency).命令(Command)组成. (1)目标:可定义多个目标,默认指定第一个,make时可指定其中一个. (2)依赖关系:在同 ...
- PXE_kickstart安装Ubuntu
1.准备 1.1.apt-get remove iptables卸载IP过滤表1.2.下载镜像 2.DHCP安装2.1.apt-get install dhcp3-server(在ubuntu12中, ...
- Mysql查询架构信息
今天想给整个数据库做初始化,也就是清空所有表,然后让索引归零,使用truncate table 就可以,但好多张表,怎么批量搞定呢? 有人说重建表吧,dump一下,然后再重建,但我还是想用trunca ...
- HDU - 5942 :Just a Math Problem (莫比乌斯)
题意:略. 思路:问题转化为1到N,他们的满足mu[d]!=0的因子d个数. 即1到N的因子的莫比乌斯系数平方和. (经验:累加符号是累加的个数,我们把常数提到前面,然后用杜教筛累加个数即可. ht ...
- Codeforces 28C Bath Queue 【计数类DP】*
Codeforces 28C Bath Queue LINK 简要题意:有 n 个人等概率随机进入 m 个房间,一个房间可以有多个人,第 i 个房间有 ai 个水龙头,在一个房间的人要去排队装水,他们 ...
- python学习-序列排序
python的排序中,可以使用内置的sort()来对序列进行排序,也可以使用内置的sorted()函数对序列进行排序,区别是,当使用sort()时,是对原序列进行排序,而sorted()则是生成一个新 ...
- POJ1220 Number Base Conversion
题意 Write a program to convert numbers in one base to numbers in a second base. There are 62 differen ...
- js核心知识
枚举属性: var o = {x:1} console.log("x" in o);//true console.log("toString" in o);// ...
- #231-D: declaration is not visible outside of function
通常出现在.h中的函数声明,函数声明中的变量用到了.h当中没有的变量形式,比如特殊定义的结构体
- SSH远程登录CentOS服务器
1.把ssh默认远程连接端口修改为2200编辑防火墙配置:vi /etc/sysconfig/iptables防火墙增加新端口2222 -A INPUT -m state --state NEW -m ...