Я хочу ограничить текстовое поле размером окна. Но здесь, в моем коде, текстовое поле превышает размер окна по вертикали, и поэтому полоса прокрутки не работает (насколько я заметил). Также полоса прокрутки прикреплена к рамке вместо текстового поля. Я хочу, чтобы он был прикреплен к текстовому полю.
from tkinter import *
class myGUI:
def __init__(self):
self.root = Tk()
self.root.title('Result')
self.root.geometry('400x400+580+120')
self.root.configure(bg = 'azure2')
self.root.focus()
frame_1 = Frame(self.root, bg = 'red')
frame_1.pack()
Label(frame_1,
text = f"On 08/09/12, following students were absent.",
font = ("",'10','bold'),
bg = 'azure2').pack(padx = 10, pady = 10)
textbox = Text(frame_1, width = 40, height = 20, state = DISABLED, cursor = 'arrow')
textbox.pack(side = LEFT, fill = BOTH)
for i in range(1, 50):
abs_std = Label(textbox, text = f'Student Name {i}', bg = 'white').pack(padx = 10, anchor = 'w')
textbox.window_create('end', window = abs_std)
textbox.insert('end', '\n')
vsb_1 = Scrollbar(frame_1, orient = VERTICAL, command = textbox.yview)
vsb_1.pack(side = RIGHT, fill = Y)
textbox.config(yscrollcommand = vsb_1.set)
close_Button = Button(self.root,
text = 'CLOSE',
font = 'TkDefaultFont 9 bold',
bg = 'dark turquoise',
command = self.root.destroy)
close_Button.pack(pady = 20, ipadx = 4)
b = myGUI()
mainloop()