Problem background: When the interface needs to display more content, need to use scroll bar ScrollBar, Official document said ScrollBar can only with the following controls (canvas, entry, ListBox, text) combined. But if I want ScrollBar to be combined with frame.
The solution is to put the frame inside the canvas (such as filling the entire canvas), canvas with ScrollBar, so scrolling canvas is equivalent to rolling the frame.
Give me a chestnut.
Canvas=canvas (root,width=200,height=180,scrollregion= (0,0,520,520)) #创建canvas
canvas.place (x = +, y = 265) # Place canvas position
frame=frame (canvas) #把frame放在canvas里
frame.place (width=180, height=180) #frame的长宽, and canvas similar
Vbar=scrollbar (canvas,orient=vertical) #竖直滚动条
vbar.place (x = 180,width=20,height=180)
vbar.configure (Command=canvas.yview)
Hbar=scrollbar (canvas,orient=horizontal) #水平滚动条
hbar.place (x =0,y=165,width=180,height=20)
Hbar.configure (Command=canvas.xview)
canvas.config (xscrollcommand=hbar.set,yscrollcommand=vbar.set) #设置
Canvas.create_window ((90,240), window=frame) #create_window
Of course, if it is plain text scrolling, you can choose the Scrolltext component, its function and text, you can refer to this link https://www.jianshu.com/p/abea88607525