Home > other >  Why don't the scrollbar tkinter activation?
Why don't the scrollbar tkinter activation?

Time:11-17

I want to make a frame with a scrollbar, on the Internet to find a few programs changed once, why use the called function button to activate the scroll bar, but the default load calls the function is unable to load, I confirm the default load was transferred to the function, but the scroll bar is not show, have card for two days, a great god gives directions

 

The from tkinter import *

The class ScrollbarFrame () :
Def __init__ (self, master) :

Myframe=Frame (master, relief=GROOVE, bd=1, bg='# 99 FFFF)
Myframe. The grid (row=0, the column=0)

Self. Canvas=canvas (myframe, bg='# 88 ff1f')
# self. Canvas. Pack (side="left")

Self. Myscrollbar=Scrollbar (myframe, received a="vertical", the command=self. Canvas. Yview)
Self. Myscrollbar. Pack (side="right", the fill="y")


Self. Frame=frame (self. Canvas, bg='# 6 f060f)
Self. Canvas. Create_window (window=(0, 0), the self. The frame and anchor='nw')

# self. Canvas. Config (width=300, height=300)
Self. Canvas. Config (yscrollcommand=self. Myscrollbar. Set)
Self. Canvas. Pack (side="left", expand=True, the fill=BOTH)

The self. The data ()

Self. Bt=Button (myframe, text="activate scroll", the command=self. Myfunction)
Self. Bt. Pack ()

Self. Canvas. Bind (" & lt; Configure>" , the self. Myfunction ())

Def data (self) :
For I in range (50) :
Label (self) frame, the text=I). The grid (row=I, the column=0)
Label (self) frame, the text="my text" + STR (I)). The grid (row=I, the column=1)
The Label (self) frame, the text="... "). The grid (row=I, the column=2)
Def myfunction (self) :
Self. Canvas. The configure (scrollregion=self. Canvas. Bbox (" all "),)
Print (6666)
Self. Canvas. The configure (width=500, height=500)
Self. Canvas. Config (yscrollcommand=self. Myscrollbar. Set)


Root=Tk ()
App=ScrollbarFrame (root)

Root. Mainloop ()


  • Related