This is my code:
from tkinter import *
from tkinter import messagebox as smxg
root = Tk()
root.geometry("675x456")
root.title("To Do List")
# Create a Frame to contain your widgets
# Function to link the scrollbar to the frame's yview
var_ = {}
scroll = Scrollbar(root,)
#canva.config(yscrollcommand=scroll.set)
scroll.pack(fill=Y,side=RIGHT)
canva = Canvas(root,yscrollcommand=scroll.set)
canva.pack(fill="both")
scroll.config(command=canva.yview)
def done():
for u in range(1, 6):
if var_[u].get() == 1:
with open("task_data.txt", mode="a") as f:
f.write(f"Today you have done {l[u]}\n")
if scale_var.get() >= 6:
smxg.askquestion("Fine day", "What happened? Why are you sad?")
smxg.askyesnocancel("Confirmation", "Are you sure you want to submit?")
l = ["", "coding", "exercise", "study", "game", "walking"]
Label( text="To-Do List", font="bold,15,bold").pack()
frame = Frame(root)
frame.pack(side = "right",anchor="center")
# Frame for scale and "How's your day" label
scale_frame = Frame(frame)
scale_frame.pack(padx=20)
scale_var = Scale(scale_frame, from_=1, to=10)
scale_var.pack()
Label(scale_frame, text="How's your day", justify="right").pack()
for i in range(1, 6):
var_[i] = IntVar()
Label( text=f"\n\n{i}. {l[i].title()}", font="Times,10,bold").pack(anchor="nw")
Checkbutton( variable=var_[i]).pack()
Button(frame, text="Submit", command=done).pack(side="bottom")
root.mainloop()
I was expecting a scroll bar in right side using canvas and pack