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. Jmter安装和配置

    一.安装JDK 安装JDK 选择安装目录 安装过程中会出现两次安装提示 .第一次是安装 jdk ,第二次是安装 jre .建议两个都安装在同一个java文件夹中的不同文件夹中.(不能都安装在java文 ...

  2. fedora 修改home下的中文目录为英文目录

    <h4>修改home下的中文目录为英文目录</h4>习 惯问题,喜欢使用fedora为您在home目录下自创建的“桌面”.“文档”,“图片 .公共的” .“下载”. “音乐”. ...

  3. 一个关于PCA的疑问

    我们知道PCA干的事情是把n维的样本投影到k维,同时丢失的信息能够达到最少. 为什么说principal component是covariance matrix的特征值中最大的前k个对应的特征向量上的 ...

  4. Android Hook神器:XPosed入门与登陆劫持演示

    前段时间写了一篇关于Cydia Substrate广告注入的文章,大家都直呼过瘾.但是,真正了解这一方面的同学应该知道,其实还有一个比Cydia Substrate更出名的工具:XPosed. 不是因 ...

  5. Java并发--synchronized

    以下是本文的目录大纲: 一.什么时候会出现线程安全问题? 二.如何解决线程安全问题? 三.synchronized同步方法或者同步块 转载原文链接:http://www.cnblogs.com/dol ...

  6. BZOJ1229 USACO2008 Nov toy 玩具 【三分+贪心】*

    BZOJ1229 USACO2008 Nov toy 玩具 Description 玩具 [Chen Hu, 2006] Bessie的生日快到了, 她希望用D (1 <= D <= 10 ...

  7. 阿里云简单的HTTPS配置

    1, 在CA证书服务中购买证书,填写信息,之后[域名授权配置]. 域名授权配置有两种,一种是文件配置,一种是DNS配置,这里我选择DNS配置. 记录类型:TXT 主机记录:按照上图填写 记录值:按照上 ...

  8. 《DSP using MATLAB》示例Example7.8

    窗函数的设计思想就是选择一个理想的频率选择滤波器(通常其脉冲响应函数是 非因果.无限长的),然后截断(取窗)这个无限长脉冲响应,得到一个线性相位.因果的 FIR滤波器.频率域示意图如下: 我们的目的: ...

  9. gradle build scan 插件使用

    1. 添加插件 build.gradle plugins { id 'com.gradle.build-scan' version '1.10.2' } buildScan { // Uncommen ...

  10. openresty 使用 log_by_lua 发送日志到 syslog-ng

    1. 安装   opm get p0pr0ck5/lua-resty-logger-socket   2. 使用    location   lua_by_lua_block    log_by_lu ...