harshvinay752 / RangeSlider

Python tkinter widget for range selection in slider widget structure with two handles
MIT License
11 stars 4 forks source link

Rendering Bug "padX too small" #6

Closed Bonifatius94 closed 1 year ago

Bonifatius94 commented 1 year ago

Hi @harshvinay752, thank you for providing this much needed Tkinter widget!

I'm encountering a rendering issue, though. When using pack() or grid(), I get this error message.

.local/lib/python3.10/site-packages/RangeSlider/RangeSlider.py", line 44, in __init__
raise Exception("padX too small, value won't be visible completely, expected padX to be atleast "+ str(critical1+1)+"px.")
Exception: padX too small, value won't be visible completely, expected padX to be atleast 11px.

I use your range slider like this:

lower = tk.DoubleVar(frame, 0.0)
upper = tk.DoubleVar(frame, 1.0)
slider = RangeSliderH(frame, [lower, upper])

frame.pack(fill="x")
slider.grid(row=0, column=3)

Thanks for your help in advance. I'll let you know in case I figure it out myself.

Best wishes, Marco

PetervanLunteren commented 1 year ago

@Bonifatius94 I had the same issue. You can solve it by specifying the proposed padX.

lower = tk.DoubleVar(frame, 0.0)
upper = tk.DoubleVar(frame, 1.0)
slider = RangeSliderH(frame, [lower, upper], padX=11)

frame.pack(fill="x")
slider.grid(row=0, column=3)
harshvinay752 commented 1 year ago

Hey @Bonifatius94 I hope your problem was resolved, as nicely answered by @PetervanLunteren . The widget requires a minimum padding based on font size and handle size in order to properly show the current position/value of handle. The aforementioned padding is quantified using an optional variable padX and padY for RangeSliderH and RangeSliderV respectively. Thank you @PetervanLunteren for your answer.

Bonifatius94 commented 1 year ago

Thanks for your reply. I ended up using another approach to structure my UI. But yeah, good to know how to make the slider work. Maybe I'll use it next time :smile:

harshvinay752 commented 1 year ago

Thanks for your reply @Bonifatius94 and your comments about the widget. Since, nothing remains to be discussed in this issue, closing it.