[英]How do I set the width of a Tkinter.Text widget scrollbar?
I'm trying to create a Tkinter Text
widget with a Scrollbar
. 我正在尝试使用Scrollbar
创建一个Tkinter Text
小部件。 This is working all fine, except I want the Scrollbar
to have a width
of 12 pixels , instead of the default value of 16 pixels . 这一切都很好,除了我希望Scrollbar
的width
为12像素 ,而不是默认值16像素 。 On the documentation online, it states that width is indeed an option you can set. 在线文档中,它指出宽度确实是您可以设置的选项。 So what am I doing wrong? 那么我做错了什么? Below is the code I have tried using. 以下是我尝试过的代码。
from tkinter import *
root = Tk()
textBox = Text(root, bd=0, font=('Courier New', 8), width=100, height=25, wrap=NONE)
textVerticalScroll = Scrollbar(root, width=12)
textBox.configure(yscrollcommand=textVerticalScroll.set)
textBox.pack(side=LEFT, fill=BOTH, expand=True)
textVerticalScroll.pack(side=RIGHT, fill=Y)
Your code works, see the screenshots: 您的代码有效,请参见屏幕截图:
width=5: 宽度= 5:
width=55: 宽度= 55:
I guess this is os related. 我想这与os有关。 I'm using Ubuntu 14.04 x64 and python 3.4. 我正在使用Ubuntu 14.04 x64和python 3.4。 Maybe on windows or mac the width is fixed and controlled by os. 也许在Windows或Mac上宽度是固定的并由os控制。 Or tk implementation for these OSs does not change it or work properly. 或者这些操作系统的tk实现不会改变它或正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.