Here is some simple code はじめまして。 python3.6を使用して、GUIを作成しています。 Canvasに配置されるobjectsの範囲内で、scrollbarを操作させたいと考えていますが、方法が分かりません。 以下のコードは、scrollbarにバインドした、canvas_x、canvas_yにおいて、何等か記述すれば細かく制御できるかと思うのです。info関数は、 From tkinter import * from tkinter i.
shadowofanerd on Reels
How are the 'units' (what) from the tkinter canvas scrolling methods xview (scroll, step, what) and yview (scroll, step, what) defined
Is it defined in pixels
Is it possible to change it (for a slo. Instead of capturing an event, have the scrollbar call a command of your choosing There's nothing that requires a scrollbar directly call the xview or yview commands of a scrollable widget First, create a function that can be called by the scrollbar
It must accept the same arguments that the normal xview or yview commands accept Then, it simply needs to pass those arguments on to xview or. Thanks a lot reblochon masque for your answer The code you added actually led me to an even easier solution, that is the use of the attribute xview_moveto
Indeed, if i use the following code
Myentry.xview_moveto(1) the end of the entry is visualized together with the file name as i needed. Scrollbars don't do anything magic To make a scrollbar work, they are simply configured to call the xview or yview method of the canvas There's nothing preventing you from directly calling those methods yourself
The xview_moveto and yview_moveto take a fraction as an argument, and scrolls the canvas so that that fraction is above or to the left of the visible portion of the canvas Your scrollbars need to have the frame as a parent, not the canvas From tkinter import * root=tk() frame=frame(root,width=300,height=300) frame.pack(expand=true, fill=both) #.grid(row=0,column=0) canvas=canvas(frame,bg='#ffffff',width=300,height=300,scrollregion=(0,0,500,500)) hbar=scrollbar(frame,orient=horizontal) hbar.pack(side=bottom,fill=x) hbar.config(command=canvas.xview) vbar. Not sure what you call a zoom, but to zoom (enlarge) you should change view_wview and view_hview (width and height), not x/y position, as it's only moves around room
H/v border is how many pixels from edge when move starts to follow object (so all in center is dead zone then)
Hborder/vborder should be at max half of wview/hview. Is there a way to add a scrollbar to my entire window without putting everything into a frame I've set everything up with.grid, and i don't like the idea of wrapping a frame around everything