stuff inside frame in .grid() method doesn't seem to wanna work

Question:

trying to use the .grid method to make a school assignment and stuff i try to have under a frame seems to ignore the frame’s position, is there a way to have it stay inside the frame? or in summary can stuff be put inside frames and be placed alongside the frame?

used code:

from tkinter import *
import random as rn

hlavni=Tk()
hlavni.geometry('500x400')
hrac_f=Frame(hlavni,width=100,height=100,bg="red")
hrac_f.grid(row=0,column=1,padx=20,pady=20)
test1=Label(hrac_f,text="why").grid(row=0,column=0,padx=20,pady=20)
hlavni.mainloop()

picture of what i am getting
current wrong result

i tried looking through forums and tried using tutorial vids but none had the information i was looking for.

what i am trying to achieve rn:
current next goal

final goal of the assignment(if there exists a better solution the one i am trying to use):
the assignment

Asked By: Naj Litarvan

||

Answers:

This what is my bot had said :)) lol

from tkinter import *
import random as rn
#This is fucking BUG
hlavni=Tk()
hlavni.geometry('500x400')
hrac_f=Frame(hlavni,width=100,height=100,bg="red")
hrac_f.grid(row=0,column=1,padx=20,pady=20)
test1=Label(hrac_f,text="why").grid(row=0,column=0,padx=20,pady=20)
hlavni.mainloop()
Answered By: Muhammad Riad
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.