Skip to content Skip to sidebar Skip to footer

Scrollregions Height Won't Go More Than 4000

My scrollregion height won't go any more than 4000. It doesn't change the height when I set it to 10000. I've tried to change the Canvas height by adding 100+ to it from tkinter im

Solution 1:

Your code is correct in the sense of the Python (and the Tkinter) syntax. I modified it slightly to proof it's correctness. (Of course, all of new lines are not obligatory.)
1. Let's open the window to a full screen:

FrameU = Tk()   # The existing string
windowHeight = FrameU.winfo_screenheight()
windowWidth = FrameU.winfo_screenwidth()
FrameU.geometry('{}x{}'.format(windowWidth, windowHeight))
FrameU.state('zoomed')

2. I changed the vertical position of the second frame for full view of the vertical scrollbar (on my current 1280 x 768 screen):

FrameNU.place(x=0,y=0,relx=.2,rely=.05)  # the old rely was 0.2

3. New variable for the big canvas:

w1, h1 = 0, 4000    # size of scrollable area  # the exisiting string
h2 = 10000          # the new variable
  1. And we use this new variable instead h1:
canvas_Main = Canvas(FrameNU, ... ,scrollregion = (0,0,w1,h2), ... )  # Here h2 - the only change  
  1. Reference lines for the scrollbar correct behavior proof, as Bryan Oakley adviced.
canvas_Main.create_line(10, h1-5, 100, h1-5, fill = 'green')  
canvas_Main.create_line(10, h2-5, 100, h2-5, fill = 'blue')   # before VscrollBarMove function definition

That's all.


Solution 2:

When I changed the height from 4000 to 10000 it didnt change anything but made the scrollbar look smaller as if it had more area going down but it doesn't.

That's precisely what changing the scrollregion does. It changes the part of the canvas that can be scrolled into view, which in turn affects how the thumb of the scrollbar is drawn. It doesn't matter whether you've drawn in that region or not.

You can see that it works by setting the height to 10000, and then drawing something at y coordinate 9000. When you scroll, that item will come into view.


Post a Comment for "Scrollregions Height Won't Go More Than 4000"