Henry Zhu
Henry Zhu

Reputation: 2628

How do I set the width of a Tkinter.Text widget scrollbar?

I'm trying to create a Tkinter Text widget with a Scrollbar. 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. 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)

Upvotes: 7

Views: 2897

Answers (1)

Marcin
Marcin

Reputation: 238967

Your code works, see the screenshots:

width=5:

enter image description here

width=55:

enter image description here

I guess this is os related. I'm using Ubuntu 14.04 x64 and python 3.4. Maybe on windows or mac the width is fixed and controlled by os. Or tk implementation for these OSs does not change it or work properly.

Upvotes: 5

Related Questions