This is my code and the scale bar does not display. Any suggestion?
from tkinter import *
self.mAsk = Scale(root, orient="horizontal", from_=1, to=16, label = "Mines", resolution = 1, sliderlength=25)
root=Tk()
root.mainloop()
This is my code and the scale bar does not display. Any suggestion?
from tkinter import *
self.mAsk = Scale(root, orient="horizontal", from_=1, to=16, label = "Mines", resolution = 1, sliderlength=25)
root=Tk()
root.mainloop()
You have at least three problems here:
root
before defining it, so your program is just going to raise a NameError
.self.mAsk
when you don't have anything named self
, so that's also going to raise a NameError
. (Do you not understand what classes are, and why self
appears in methods of classes in many tkinter examples?)pack
, grid
, or place
to actually place mAsk
on the parent window. See the chapters on the three different Geometry Managers in the Tkinter book if you have no idea what this means.If you fix all three, then it works:
from tkinter import *
root=Tk()
mAsk = Scale(root, orient="horizontal", from_=1, to=16, label = "Mines", resolution = 1, sliderlength=25)
mAsk.pack()
root.mainloop()