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)
Your code works, see the screenshots:
width=5:
width=55:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With