Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 759
Henry Zhu Avatar asked Dec 29 '14 23:12

Henry Zhu


Video Answer


1 Answers

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.

like image 185
Marcin Avatar answered Oct 01 '22 01:10

Marcin