Python - Tkinter Spinbox: Spinbox小部件是一个标准的Tkinter的Entry小窗口部件的变体,它可以用来选择从一个固定的值.
 
Spinbox小部件是一个标准的Tkinter的Entry小窗口部件的变体,它可以用来选择从一个固定的值.

语法:

这里是一个简单的语法来创建这个widget:

w = Spinbox( 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.
disabledbackground The background color to use when the widget is disabled.
disabledforeground The text color to use when the widget is disabled.
fg Text color.
font The font to use in this widget.
format Format string. No default value.
from_ The minimum value. Used together with to to limit the spinbox range.
justify Default is LEFT
relief Default is SUNKEN.
repeatdelay Together with repeatinterval, this option controls button auto-repeat. Both values are given in milliseconds.
repeatinterval See repeatdelay.
state One of NORMAL, DISABLED, or "readonly". Default is NORMAL.
textvariable No default value.
to See from.
validate Validation mode. Default is NONE.
validatecommand Validation callback. No default value.
values A tuple containing valid values for this widget. Overrides from/to/increment.
vcmd Same as validatecommand.
width Widget width, in character units. Default is 20.
wrap If true, the up and down buttons will wrap around.
xscrollcommand Used to connect a spinbox field to a horizontal scrollbar. This option should be set to the set method of the corresponding scrollbar.

方法:

spinbox对象有这些方法:

Methods & Description
delete(startindex [,endindex])
This method deletes a specific character or a range of text.
get(startindex [,endindex])
This method returns a specific character or a range of text.
identify(x, y)
Identifies the widget element at the given location.
index(index)
Returns the absolute value of an index based on the given index.
insert(index [,string]...)
This method inserts strings at the specified index location.
invoke(element)
Invokes a spinbox button.

例子:

自行尝试下面的例子:

from Tkinter import *

master = Tk()

w = Spinbox(master, from_=0, to=10)
w.pack() mainloop()

这将产生以下结果:

Tkinter Spinbox的更多相关文章

  1. tkinter中spinbox递增和递减控件(十)

    spinbox递增和递减控件 import tkinter wuya = tkinter.Tk() wuya.title("wuya") wuya.geometry("3 ...

  2. tkinter python(图形开发界面)

    Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包的接口.Tk和Tkinter可以在大多数的Unix平台下使用,同样可以应用在Windows和Macinto ...

  3. gui - tkinter 开发

    GUI 用户交互界面 tkinter 介绍 tkinter python自带的gui库,对图形图像处理库tk的封装 其他gui:pythonwin,wxpython,pyQT.. 概念介绍 组件:组成 ...

  4. tkinter python(图形开发界面) 转自:渔单渠

    Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包的接口.Tk和Tkinter可以在大多数的Unix平台下使用,同样可以应用在Windows和Macinto ...

  5. python中的Tkinter模块

    Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包的接口.Tk和Tkinter可以在大多数的Unix平台下使用,同样可以应用在Windows和Macinto ...

  6. python3.8 新特性

    https://docs.python.org/3.8/whatsnew/3.8.html python 3.8的新功能本文解释了与3.7相比,python 3.8中的新特性. 有关完整的详细信息,请 ...

  7. python-tkinter使用方法——转载(二)

    转载URL:https://www.cnblogs.com/yudanqu/p/9467803.html Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包 ...

  8. python_tkinter组件

    1.按钮 # 按钮 # bg设置背景色 btn = tkinter.Button(root,text = '按钮',bg = 'red') btn.pack() # fg设置前景色(文字颜色) btn ...

  9. Python笔记_第四篇_高阶编程_GUI编程之Tkinter_2.控件类

    1. Label控件: 说明:标签控件,可显示文本 图示1: 实例1: import tkinter # 创建主窗口__编程头部 win = tkinter.Tk() # 设置标题 win.title ...

随机推荐

  1. IOS开发 多线程GCD

    Grand Central Dispatch (GCD)是Apple开发的一个多核编程的解决方法. dispatch queue分成以下三种: 1)运行在主线程的Main queue,通过dispat ...

  2. OPEN(SAP) UI5 学习入门系列之二: 最佳实践练习(上)

    这篇博文难产了很久,原来是打算一周更新一篇的,上周原计划写MVC,但是写了一半,发现带入了太多的细节,不太符合这个入门系列的主题. 当我们学习一个新的技能的时候,如果一开始就面对大量的细节,很容易陷入 ...

  3. jquery.treetable.js

    html:   <table class="table table-hover table-responsive main-list" id="columntabl ...

  4. go语言】Goroutines 并发模式

    并发模式 让我们先来回顾一下boring函数的例子. func boring(msg string, c chan string) {    for i := 0; ; i++ {         c ...

  5. 实战:向GitHub提交代码时触发Jenkins自动构建

    当我们提交代码到GitHub后,可以在Jenkins上执行构建,但是每次都要动手去执行略显麻烦,今天我们就来实战Jenkins的自动构建功能,每次提交代码到GitHub后,Jenkins会进行自动构建 ...

  6. 套接字中的recv与send的注意事项

    recv() 特征* 如果连接的另一端断开连接,则recv立即返回空子串* recv是从接受缓冲区取出内容,当缓冲区为空则阻塞* recv如果一次接受不完缓冲区内容,下次会继续接收 send() 特征 ...

  7. HDU - 2973:YAPTCHA (威尔逊定理)

    The math department has been having problems lately. Due to immense amount of unsolicited automated ...

  8. BZOJ1563 NOI2009 诗人小G【决策单调性优化DP】

    LINK 因为是图片题就懒得挂了 简要题意:有n个串,拼接两个串需要加一个空格,给你l和p,问你拼接后每个串的总长减l的绝对值的p次方的最小值 首先打表发现一下这题是决策单调的对于所有数据都成立就当他 ...

  9. BZOJ3277 串 【广义后缀自动机】

    Description 字符串是oi界常考的问题.现在给定你n个字符串,询问每个字符串有多少子串(不包括空串)是所有n个字符串中 至少k个字符串的子串(注意包括本身). Input 第一行两个整数n, ...

  10. IIS项目发布完整流程

    第一步: 发布项目 使在IIS上发布是防止源码泄露 第二步: 打开IIS(如果没有就自己安装一个)打开IIS步骤 控制面板>系统安全>管理工具>IIS管理器 填写网站的名称和之前发布 ...