The Scale Widget 
Author Message
 The Scale Widget

Quote:

> Is there a way to modify the scale widget so that the slider
> only can move in one direction?

Here's a programatic solution:

from Tkinter import *
import string

global scale, position

position = 100

def setHeight(canvas, heightStr):
    global position
    height = string.atoi(heightStr)

    if height < position:
        height = position
        if height > 250: height = 250
        position = height
        scale.set(position)

    height = height + 1
    position = height
    y2 = height - 30
    if y2 < 1:
        y2 = 1
    canvas.coords('poly',
                 15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20)
    canvas.coords('line',
                 15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20)

root = Tk()
root.title('Scale')

canvas = Canvas(root, width=50, height=50, bd=0, highlightthickness=0)
canvas.create_polygon(0,0,1,1,2,2, fill='cadetblue', tags='poly')
canvas.create_line(0,0,1,1,2,2,0,0, fill='black', tags='line')
scale = Scale(root, orient=VERTICAL, length=284, from_=0, to=250,
              tickinterval=50, command=lambda h,
              c=canvas:setHeight(c,h))
scale.grid(row=0, column=0, sticky='NE')
canvas.grid(row=0, column=1, sticky='NWSE')
scale.set(position)
root.mainloop()



Mon, 15 Sep 2003 03:52:15 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem with scale Tk's scale widget

2. The Scale widget

3. Tk scale widget 'resolution' problem

4. Tkinter Scale widget problems

5. tile scale widget

6. Scale widget and highlight border.

7. scale widget question

8. height of a scale widget

9. Tk8.4.4 scale widget bug?

10. Bug in scale widget?

11. Problem with scale widget

12. scale widget question

 

 
Powered by phpBB® Forum Software