I have a list of data of of 25 names to be entered in for a 10 classes.
The requires adding scroll bars to the tkinter window
To make the codes look simple, I have made the tkinter window with Class-1 and 3 names.
### Import Libraries
from tkinter import *
import tkinter as tk
from tkinter import ttk
### Create Tkinter window
window = tk.Tk()
window.state("zoomed")
### Create function to strore names for Class-1
def Update_Class1():
student_Class1_Name1 = entry_Class1_Name1.get()
student_Class1_Name1_to_display = "\n" + str(student_Class1_Name1) + "\n"
student_Class1_Name1_to_display_label = Label(window)
student_Class1_Name1_to_display_label["text"] = student_Class1_Name1_to_display
student_Class1_Name1_to_display_label.grid(column=1, row=4)
student_Class1_Name2 = entry_Class1_Name2.get()
student_Class1_Name2_to_display = "\n" + str(student_Class1_Name2) + "\n"
student_Class1_Name2_to_display_label = Label(window)
student_Class1_Name2_to_display_label["text"] = student_Class1_Name2_to_display
student_Class1_Name2_to_display_label.grid(column=2, row=4)
student_Class1_Name3 = entry_Class1_Name3.get()
student_Class1_Name3_to_display = "\n" + str(student_Class1_Name3) + "\n"
student_Class1_Name3_to_display_label = Label(window)
student_Class1_Name3_to_display_label["text"] = student_Class1_Name3_to_display
student_Class1_Name3_to_display_label.grid(column=3, row=4)
### Put Labels in the window
tk.Label(window, text="\n\n\n\n\n\n\n\n Class Information \n\n\n\n\n\n").grid(column=0, row=1)
tk.Label(window, text="\n\n\n\n\n\n\n\n Class Number \n\n\n\n\n\n").grid(column=0, row=2)
tk.Label(window, text="\n\n\n\n\n\n\n\n Class-1 \n\n\n\n\n\n").grid(column=0, row=3)
### Put Entry boxes in window
tk.Label(window, text="\t\t\t\t\t\t Name-1 \t\t\t\t\t\t").grid(column=1, row=2)
entry_Class1_Name1 = tk.Entry(window , width=16)
entry_Class1_Name1.grid(column=1, row=3)
tk.Label(window, text="\t\t\t\t\t\t Name-2 \t\t\t\t\t\t").grid(column=2, row=2)
entry_Class1_Name2 = tk.Entry(window , width=16)
entry_Class1_Name2.grid(column=2, row=3)
tk.Label(window, text="\t\t\t\t\t\t Name-3 \t\t\t\t\t\t").grid(column=3, row=2)
entry_Class1_Name3 = tk.Entry(window , width=16)
entry_Class1_Name3.grid(column=3, row=3)
### Create button for Class-1
Button_Class1 = tk.Button(window, text="Update Class-1", command=Update_Class1)
Button_Class1.grid(column=1, row=6)
### Insert scroll bars
##vbar = ttk.Scrollbar(window, orient=VERTICAL) ## vertical scrollbar
##vbar.grid(row=0, column=1, sticky=NS)
##
##hbar = ttk.Scrollbar(window, orient=HORIZONTAL) ## horizontal scrollbar
##hbar.grid(row=1, column=0, sticky=EW)
### END
window.mainloop()
(In order to see what actual codes do, simply disable all the \n and \t characters.)
Can somebody please let me know, how do I add the scroll bars to the existing codes so that I can have access to Update button and Name-3 entry box?