如何使用Tkinter在框架中创建滚动条?

时间:2019-05-12 01:03:13

标签: python tkinter scrollbar frame

在此框架中,我将在处理某些结果后显示一些结果,但是当我有多个输入时,我将获得相同数量的输出,并且只有一些结果可见,而其他结果则隐藏在另一个框架后面。我希望可以创建一个滚动条,以便可以看到尽可能多的输入输出。谢谢。

 #### GUI STARTS HERE ####

root = tk.Tk()
root.title('Stemmer & POS-TAGGER - By  Majidi. v0.1')
canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
canvas.pack()

 background_image = tk.PhotoImage(file='landscape.png')
 background_label = tk.Label(root, image=background_image)
 background_label.place(relwidth=1, relheight=1)

 frame = tk.Frame(root, bg='#2196f3', bd=1)
 frame.place(relx=0.5, rely=0.1, relwidth=0.75, relheight=0.1, 
 anchor='n')

 entry = tk.Entry(frame, font=40)
 entry.place(relwidth=0.65, relheight=1)

button = tk.Button(frame, bg='#eee', text="Process", font=40, 
command=lambda: process(entry.get()))
button.place(relx=0.7, relheight=1, relwidth=0.3)

lower_frame = tk.Frame(root, bg='#ffffff', bd=0)
lower_frame.place(relx=0.5, rely=0.25, relwidth=0.75, relheight=0.6, anchor='n')

label = tk.Label(lower_frame, bg='#fff')
label.place(relwidth=1, relheight=1)

root.mainloop()

#### GUI ENDS HERE ####

screenshot of the output. Here everything is visible, once more than 3 outputs, things get hidden behind the frame.

0 个答案:

没有答案