Sulabh Tiwari
Sulabh Tiwari

Reputation: 307

Issue with Scale widget using tickinterval

The widget shows tick using tickinterval when following code shown below,

from Tkinter import *
slider_1 = Scale(mGui,orient=HORIZONTAL,length = 100,from_=0,to=9, tickinterval =1).pack()

However it throws error with the following code

from Tkinter import *
from ttk import *
slider_1 = Scale(mGui,orient=HORIZONTAL,length = 100,from_=0,to=9, tickinterval =1).pack()

Error:

_tkinter.TclError: unknown option "-tickinterval"

Why is it so? Is it a bug or problem with the installation. For information i am using Python 2.7.10

Upvotes: 1

Views: 1318

Answers (1)

nbro
nbro

Reputation: 15857

This is because the ttk module contains also a Scale widget, and you are actually using the Scale widget from ttk and not from Tkinter. Widgets in the ttk module are customised and styled differently from Tkinter widgets.

Check the following documentation on ttk for more information regarding its widgets:

ttk — Tk themed widgets

To solve your problem, you could remove your second global import and simply do:

import ttk

Then, every time you want to use a widget from ttk, you can simply prefix it with ttk..

Upvotes: 2

Related Questions