Accessing a List value from an Intvar - python

I am trying to create an example program for my high school class. The idea of the program is you can select a game (a basic version of Steam) from a selection of radiobuttons. The radiobuttons are linked to a IntVar stored in self.library_game. When you select a radiobutton I want to use the value that the radiobutton assigns the Intvar to take a name out of a list and display the name of the game in a label. I want to do this so I can use the IntVar to access other lists. The other lists will show things like the games installed status. if the game is not currently "installed" you will be able to click on a button to update the status to "install" the game so it can be "launched".
The problem i am encountering is: When I try and use the IntVar to access the libraryGames list I get the following error:"list indices must be integers or slices, not method". I have tried to store the value from the IntVar as a regular integer with "test=self.library_game.get" and used "test" to access the list, self.game_selection_label.configure(text = "You have chosen: " + str(libraryGames[test]),fg="#01fc07"), but it doesn't work.
I am not the strongest programmer and am really pushing my ceiling with this stuff, so any help would be amazing.
from tkinter import*
# Variables and Lists
#Classes
libraryGames=["The Witcher 3: Wild Hunt GOTE", "Jurassic World: Evolution", "Red Dead Redemption 2","Mass Effect Trilogy","Subnautica"]
libraryGamesInstall=[True,False, False, False, False]
class SteamGUI:
def __init__(self, parent):
#variables
global libraryGames
global libraryGamesInstall
WD=800
self.header =PhotoImage(file = "header.gif")
self.library_game = IntVar()
self.library_game.set = ()
Title=Label(parent, image = self.header, width=WD, anchor=N)
Title.grid(row=0, column=0,columnspan=2, sticky=N,padx=2, pady=2)
#User Library Menu
frame1=Frame(bg="#000000",)
frame1.grid(row=1, column=0, sticky = 'w')
library_label=Label(frame1, text="User Library",bg="#000000",fg="#01fc07",font=("Eras Demi ITC","40"), anchor=N)
library_label.grid(row=0, column=0,columnspan=2, sticky=N,padx=2, pady=2)
radio1 = Radiobutton(frame1, variable = self.library_game, value = 0,text =libraryGames[0],
bg="#000000",fg="#ffffff",font=("Calibri","20"), command = self.library_choice)
radio1.grid(row=1, column=0, columnspan=2, sticky = 'w')
radio2 = Radiobutton(frame1, variable = self.library_game, value =1,text =libraryGames[1],
bg="#000000",fg="#ffffff",font=("Calibri","20"), command = self.library_choice)
radio2.grid(row=2, column=0, columnspan=2, sticky = 'w')
radio3 = Radiobutton(frame1, variable = self.library_game, value =2,text =libraryGames[2],
bg="#000000",fg="#ffffff",font=("Calibri","20"),command = self.library_choice)
radio3.grid(row=3, column=0, columnspan=2, sticky = 'w')
radio4 = Radiobutton(frame1, variable = self.library_game, value =3,text =libraryGames[3],
bg="#000000",fg="#ffffff",font=("Calibri","20"),command = self.library_choice)
radio4.grid(row=4, column=0, columnspan=2, sticky = 'w')
radio5 = Radiobutton(frame1, variable = self.library_game, value =4,text =libraryGames[4],
bg="#000000",fg="#ffffff",font=("Calibri","20"),command = self.library_choice)
radio5.grid(row=5, column=0, columnspan=2, sticky = 'w')
self.game_selection_label=Label(frame1, text="No game selected", bg="#000000", fg="#ffffff", width="50",)
self.game_selection_label.grid(row=6, column=0, columnspan=2, sticky='w')
self.game_install_status_label=Label(frame1, text="Install Status", bg="#000000", fg="#ffffff", width="50",)
self.game_install_status_label.grid(row=7, column=0, sticky='w', pady=10)
self.playLabel =Label(frame1,text="Game Status", bg="#000000", fg="#ffffff", width="50", pady=10)
self.playLabel.grid(row=9, column=0, sticky='w')
installButton=Button(frame1, text="Install", width = 20, font=("Eras Demi ITC","10"), pady=10)
installButton.grid(row=8, column=0, sticky = 'sw',)
playButton=Button(frame1, text="Play", width = 20,font=("Eras Demi ITC","10"), pady=10)
playButton.grid(row=8, column=0, sticky = 'se',)
frame2=Frame(bg="#ffffff",)
frame2.grid(row=1, column=1)
def library_choice(self):
test=0
test=self.library_game.get
print("hi", self.library_game.get)
self.game_selection_label.configure(text = "You have chosen: " + str(libraryGames[test]),fg="#01fc07")
#self.game_selection_label.configure(text = "You have chosen: The witcher 3!!!!!",fg="#01fc07")
#Main Routine
root=Tk()
window = SteamGUI(root)
root.geometry("800x700+0+0")
root.title("Steam Basic")
root.mainloop()

Related

Python Tkinter how to list down, but the newest element is on top

I am working on a little finance project. When I add to my balance, the entry gets listed among themselves. But I want to "change direction", so the newest entry is always on row 3 and the others lists among themselves. The problem is I don't know how to access to the other Elements to add to their row.
It should be something like that:
I entry a amount to add to the main balance- for example 40$
It gets shown on column 0, row 3
If I add another amount it should show on row 3- for example 20$, and the 40$ should move to row 4.
It should get listed like that:
row 3: 20$ ,
row 4: 40$
and so on..
Sorry for beginner mistakes, Im new to python :)
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
class App():
def __init__(self):
self.window = tk.Tk()
self.window.title("Expenses")
self.window.geometry("700x600")
self.window.resizable(0,0)
self.username_list = ["a"]
self.password_list = ["a"]
self.balace = 90
self.row_first_column = 2
self.start_frame()
self.window.mainloop()
def start_frame(self):
self.window.columnconfigure(0, weight=1)
self.window.columnconfigure(1, weight=1)
self.window.columnconfigure(2, weight=1)
self.heading_label = ttk.Label(self.window, text="Log-In", font=("", 25))
self.heading_label.grid(column=1, row=0, sticky=tk.NS, pady=40)
self.username = ttk.Label(self.window, text="Username:")
self.username.grid(column=1, row=1, sticky=tk.W, pady=30)
self.password = ttk.Label(self.window, text="Password:")
self.password.grid(column=1, row=2, sticky=tk.W)
self.entry1 = ttk.Entry(self.window)
self.entry1.grid(column=1, row=1)
self.entry2 = ttk.Entry(self.window)
self.entry2.grid(column=1, row=2)
self.warning = ttk.Label(self.window, text="")
self.warning.grid(column=1, row=3, sticky= tk.NS, pady=10)
self.button1 = ttk.Button(self.window, text="Submit", command= self.check_data)
self.button1.grid(column=1, row=4, sticky=tk.NS)
def check_data(self):
username_check = self.entry1.get()
password_check = self.entry2.get()
if username_check in self.username_list and password_check in self.password_list:
self.main_frame()
else:
self.warning.configure(text="Incorrect data! Try again")
self.entry2.delete(0, tk.END)
def main_frame(self):
self.username.destroy()
self.password.destroy()
self.entry1.destroy()
self.entry2.destroy()
self.warning.destroy()
self.button1.destroy()
self.heading_label.configure(text="Finance", font=("", 25))
#First Column
self.sub_heading1 = ttk.Label(self.window, text="Overview", font=("", 15))
self.sub_heading1.grid(column=0, sticky=tk.NS, row=1, pady=20)
self.balance_label = ttk.Label(self.window, text=f"{self.balace}$")
self.balance_label.grid(column=0, row=2, pady=20, sticky=tk.NS)
#Second Column
self.sub_heading2 = ttk.Label(self.window, text="Add", font=("", 15))
self.sub_heading2.grid(column=1, sticky=tk.NS, row=1, pady=20)
self.add_balance = ttk.Entry(self.window, width=5)
self.add_balance.grid(column=1, row=2, pady=20, sticky=tk.NS)
self.add_button = ttk.Button(self.window, text="Add",width=3, command= self.entry_add_balance)
self.add_button.grid(column=1, row=3, pady=10, sticky=tk.NS)
#Third Column
self.sub_heading3 = ttk.Label(self.window, text="Minus", font=("", 15))
self.sub_heading3.grid(column=2, sticky=tk.NS, row=1, pady=20)
def entry_add_balance(self):
addjust_balance_user = int(self.add_balance.get())
self.add_balance.delete(0, tk.END)
self.balace += addjust_balance_user
self.balance_label.configure(text=f"{self.balace}$")
#First Column
self.row_first_column += 1
new_add_label = ttk.Label(self.window, text=f"+{addjust_balance_user}$")
new_add_label.grid(column=0, row=self.row_first_column, pady=5,padx=15, sticky=tk.E)
app = App()

Is it possible to overwrite an entry field with label in tkinter?

I have a simple label and entry field that would:
1) Create a static label and clear the entry field after confirmation button click
2) Clear static label after reset button click
Is there any way to overwrite the entry field with a static label of the user input on the confirmation click instead of creating a new static label? And overwriting the static label with an empty entry field on the reset click?
Thank you for the help in advance.
from tkinter import *
root = Tk()
frame1 = Frame(root)
frame1.pack()
def reset():
set_cname.destroy()
cbtn['state'] = NORMAL
def confirm():
global set_cname
text1="Customer Name: " + entry1.get()
set_cname = Label(frame1, text=text1)
set_cname.grid(row=3, column=0, columnspan=1)
entry1.delete(0, 'end')
cbtn['state'] = DISABLED
cname = Label(frame1, text="Customer Name: ").grid(padx=5, pady=5, columnspan=2, sticky=W)
entry1 = Entry(frame1)
entry1.grid(row=0, column=2, padx=5)
cbtn = Button(frame1, text="Confirm", command=confirm, width=20)
cbtn.grid(row=1, column=4, padx=5, pady=5)
rbtn = Button(frame1, text="Reset Names", command=reset, width=20)
rbtn.grid(row=2, column=4, padx=5, pady=5)
root.mainloop()
You can replace the Entry with a Label by first creating both and then using pack() to switch between them. The trick is to not let their different sizes affect the application layout, which can be accomplished by disabling size propagation.
In my example I create a new frame (entry_frame) with a fixed size and then disable size propagation (.pack_propagate(False)). Then I use this new frame to contain the Entry/Label. Im giving the entry_frame the bg color khaki to let you see exactly where it is.
I fiddled a bit with the column numbers also.
from tkinter import *
root = Tk()
frame1 = Frame(root)
frame1.pack()
def reset():
text_label.pack_forget()
entry1.pack()
cbtn['state'] = NORMAL
def confirm():
global set_cname
entry1.pack_forget()
text_label.config(text=entry1.get())
text_label.pack(side='left')
entry1.delete(0, 'end')
cbtn['state'] = DISABLED
cname = Label(frame1, text="Customer Name: ")
cname.grid(row=0, column=0, padx=5, pady=5, sticky=W)
entry_frame = Frame(frame1, width=130, height=20, bg='khaki')
entry_frame.grid(row=0, column=1, padx=5, pady=5, sticky='nsew')
entry_frame.pack_propagate(False) # Disable size propagation
entry1 = Entry(entry_frame) # Customer name entry
entry1.pack()
text_label = Label(entry_frame) # Label to hold customer name
cbtn = Button(frame1, text="Confirm", command=confirm, width=20)
cbtn.grid(row=1, column=2, padx=5, pady=5)
rbtn = Button(frame1, text="Reset Names", command=reset, width=20)
rbtn.grid(row=2, column=2, padx=5, pady=5)
root.mainloop()
Be aware that this solution will be sensitive to font size changes.

Tkinter how to display image and not move any content around?

This is my current Python code:
from tkinter import *
import glob
import os
from PIL import Image, ImageTk
import tkinter as tk
root = tk.Tk()
root.title("SIGN OFF")
root.minsize(840, 800)
# Add a grid
mainframe = tk.Frame(root)
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
mainframe.pack(pady=100, padx=100)
# Create a Tkinter variable
tkvar = tk.StringVar(root)
directory = "C:/Users/eduards/Desktop/work/data/to-do"
choices = glob.glob(os.path.join(directory, "*.jpg"))
tkvar.set('...To Sign Off...') # set the default option
popupMenu = tk.OptionMenu(mainframe, tkvar, *choices)
tk.Label(mainframe, text="Choose your sign off here:").grid(row=1, column=1)
popupMenu.grid(row=2, column=1)
label2 = tk.Label(mainframe, image=None)
label2.grid(row=4, column=0)
# On change dropdown callback.
def change_dropdown(*args):
""" Updates label2 image. """
imgpath = tkvar.get()
img = Image.open(imgpath)
img = img.resize((240,250))
photo = ImageTk.PhotoImage(img)
label2.image = photo
label2.configure(image=photo)
tk.Button(mainframe, text="Open", command=change_dropdown).grid(row=3, column=1)
var1 = IntVar()
Checkbutton(mainframe, text="Ingredients present in full (any allergens in bold with allergen warning if necessary)", variable=var1).grid(column = 2, row=1, sticky=W)
var2 = IntVar()
Checkbutton(mainframe, text="May Contain Statement.", variable=var2).grid(column = 2, row=2, sticky=W)
var3 = IntVar()
Checkbutton(mainframe, text="Cocoa Content (%).", variable=var3).grid(column = 2, row=3, sticky=W)
var4 = IntVar()
Checkbutton(mainframe, text="Vegetable fat in addition to Cocoa butter", variable=var4).grid(column = 2, row=4, sticky=W)
var5 = IntVar()
Checkbutton(mainframe, text="Instructions for Use.", variable=var5).grid(column = 2, row=5, sticky=W)
var6 = IntVar()
Checkbutton(mainframe, text="Additional warning statements (pitt/stone, hyperactivity etc)", variable=var6).grid(column = 2, row=6, sticky=W)
var7 = IntVar()
Checkbutton(mainframe, text="Nutritional Information Visible", variable=var7).grid(column = 2, row=7, sticky=W)
var8 = IntVar()
Checkbutton(mainframe, text="Storage Conditions", variable=var8).grid(column = 2, row=8, sticky=W)
var9 = IntVar()
Checkbutton(mainframe, text="Best Before & Batch Information", variable=var9).grid(column = 2, row=9, sticky=W)
var10 = IntVar()
Checkbutton(mainframe, text="Net Weight & Correct Font Size.", variable=var10).grid(column = 2, row=10, sticky=W)
var11 = IntVar()
Checkbutton(mainframe, text="Barcode - Inner", variable=var11).grid(column = 2, row=11, sticky=W)
var12 = IntVar()
Checkbutton(mainframe, text="Address & contact details correct", variable=var12).grid(column = 2, row=12, sticky=W)
root.mainloop()
gives me the output of this:
The problem I am having is, when I choose a directory, open the image it stretches out all other content, I am wondering, how can I place the image next to the check-boxes and not move the check-boxes content?
Here is the output:
this is the output I am intending to get (used paint to edit):
You need to add rowspan option to your label2 variable, as follows:
label2.grid(row = 4, column = 0, rowspan = 10)
Edit the rowspan value to get the desired result
Looks like your window is supposed to consist of two independent columns. You can do this by nesting Frame objects. Starting with your main frame, put two frames side by side, like so:
mainframe = tk.Frame(root)
# configure your main frame here
leftframe = tk.Frame(mainframe)
leftframe.grid(row=0, column=0)
rightframe = tk.Frame(mainframe)
rightframe.grid(row=0, column=1)
And now you can proceed to place your widgets around. For instance:
# menu and label are supposed to be in the left column
tk.Label(leftframe, text="Choose your sign off here:").grid(row=0, column=0)
popupMenu = tk.OptionMenu(leftframe, tkvar, *choices)
# ...
# but you want the checkboxes on the right
var1 = IntVar()
Checkbutton(rightframe, text="Ingredients present in full (any allergens in bold with allergen warning if necessary)", variable=var1).grid(row=0, column=0, sticky=W)
# ...
Please note the changes I made to row and column arguments. And of course, read the docs for the Grid Geometry Manual, as Eduard mentioned.

track which frame user is in on button press?

i've run into a problem with tkinter, where i'm unsure of how to tell what frame the user is in, and save that to a variable. i need (i think) this information to be able to switch between multiple frames.
def check(value): # checks to see if the button that was click was the correct answer
if value:
print("you picked the right answer!")
answers.increase()
frame1.grid_remove()
frame2.grid(row=5)
else:
print("sorry thats not right")
frame1.grid_remove()
frame2.grid(row=5)
this function is called by a button like:
q1choice1 = Button(frame1, height=2, width=50, text=question1[1].text, command=lambda: check(question1[1].value))
q1choice2 = Button(frame1, height=2, width=50, text=question1[2].text, command=lambda: check(question1[2].value))
q1choice3 = Button(frame1, height=2, width=50, text=question1[3].text, command=lambda: check(question1[3].value))
q1choice4 = Button(frame1, height=2, width=50, text=question1[4].text, command=lambda: check(question1[4].value))
instead of frame1.grid_remove and frame2.grid i would like to be able to have a variable such as x.grid_remove() y.grid(row=) so that this on function can switch between all frames. i can post the rest of the code if it's needed but i tried to just keep it to what is relevant.
thanks,
full code:
from tkinter import *
# class for the correct answers in choices
class Correct(object):
value = True
def __init__(self, text):
self.text = text
# class for incorrect answers
class Incorrect(object):
value = False
def __init__(self, text):
self.text = text
# this class allows me to increment a var for num of correct answers
class CountRight(object):
def __init__(self):
self.right = 0
def increase(self):
self.right +=1
answers = CountRight()
framecount = CountRight()
framecount.increase()
def check(value): # checks to see if the button that was click was the correct answer
framecount.increase()
framestring = ["frame" , framecount.right]
framestring = str(framestring)
framestring = "".join(framestring)
framestring = framestring.replace("'", "")
framestring = framestring.replace(",", "")
framestring = framestring.replace(" ", "")
print(framestring)
if value:
print("you picked the right answer!")
answers.increase()
framestring.grid_remove()
framestring.grid(row=5)
else:
print("sorry thats not right")
frame1.grid_remove()
frame2.grid_remove()
def center(win):
win.update_idletasks()
width = win.winfo_width()
frm_width = win.winfo_rootx() - win.winfo_x()
win_width = width + 2 * frm_width
height = win.winfo_height()
titlebar_height = win.winfo_rooty() - win.winfo_y()
win_height = height + titlebar_height + frm_width
x = win.winfo_screenwidth() // 2 - win_width // 2
y = win.winfo_screenheight() // 2 - win_height // 2
win.geometry('{}x{}+{}+{}'.format(width, height, x, y))
win.deiconify()
question1 = ["question", Correct("A:"), Incorrect("B:"),
Incorrect("C:"), Incorrect("D:")]
master = Tk()
toplabel = Label(master,font="big", text="quiz!")
toplabel.grid(row=0)
master.geometry("350x350")
center(master)
# ******************** FRAME ONE *********************
frame1 = Frame(master)
qlabel1 = Label(frame1, text=question1[0])
q1choice1 = Button(frame1, height=2, width=50, text=question1[1].text, command=lambda: check(question1[1].value))
q1choice2 = Button(frame1, height=2, width=50, text=question1[2].text, command=lambda: check(question1[2].value))
q1choice3 = Button(frame1, height=2, width=50, text=question1[3].text, command=lambda: check(question1[3].value))
q1choice4 = Button(frame1, height=2, width=50, text=question1[4].text, command=lambda: check(question1[4].value))
frame1.grid(row=5, sticky="nsew")
qlabel1.grid(row=0, column=0, rowspan=5, columnspan=5, sticky="nsew")
q1choice1.grid(row=6, column=0, rowspan=5, columnspan=5, sticky="nsew")
q1choice2.grid(row=11, column=0, rowspan=5, columnspan=5, sticky="nsew")
q1choice3.grid(row=16, column=0, rowspan=5, columnspan=5, sticky="nsew")
q1choice4.grid(row=21, column=0, rowspan=5, columnspan=5, sticky="nsew")
# ******************** FRAME TWO *********************
frame2 = Frame(master)
question2 = ["question", Incorrect("A:"), Incorrect("B:"),
Correct("C:"), Incorrect("D:")]
qlabel2 = Label(frame2, text=question2[0])
q2choice1 = Button(frame2, height=2, width=50, text=question2[1].text, command=lambda: check(question2[1].value))
q2choice2 = Button(frame2, height=2, width=50, text=question2[2].text, command=lambda: check(question2[2].value))
q2choice3 = Button(frame2, height=2, width=50, text=question2[3].text, command=lambda: check(question2[3].value))
q2choice4 = Button(frame2, height=2, width=50, text=question2[4].text, command=lambda: check(question2[4].value))
qlabel2.grid(row=0, column=0, rowspan=5, columnspan=5, sticky="n")
q2choice1.grid(row=6, column=0, rowspan=5, columnspan=5, sticky="n")
q2choice2.grid(row=11, column=0, rowspan=5, columnspan=5, sticky="n")
q2choice3.grid(row=16, column=0, rowspan=5, columnspan=5, sticky="n")
q2choice4.grid(row=21, column=0, rowspan=5, columnspan=5, sticky="n")
mainloop()
Why don't you try to set the variable every time the frame changes, so in the code that changes the frame add another parameter, in the function which will take the name of the frame and then in the function it will set a (Global??) variable to that name which can be read at any time?
so for example
def change(..., newFrame):
global curFrame
curFrame = newFrame
change() being the function in which you use to change the frame to another
This will be added to the function you use to change the frame, and this will make use of a global variable which can be read any where, which you set to hold the value of the frame you change to when you change it

How do I make entry boxes in a second window?

I have been trying to make an entry box for people to enter their names, as part of a "registration" for a mini-program that I am doing, but the result is that an entry box doesn't appear at all.
Here is the section of the code that is troubling me:
def win2(self):
# this is the child window
board = Toplevel()
board.title("Sign up")
board.focus_set()
board.grab_set()
userVar = StringVar()
userVar.set('Username')
square1Label = Label(board,textvariable=userVar)
square1Label.grid(row=0, column=7)
userEnt=Entry(self)
userEnt.grid(row=1, column=7)
s2Var = StringVar()
s2Var.set('First Name')
square2Label = Label(board,textvariable=s2Var)
square2Label.grid(row=1, column=7)
leaveButton = Button(board, text="Quit", command=board.destroy)
leaveButton.grid(row=1, column=1, sticky='nw')
board.wait_window(board)
And here is the coding in full, minus the importing of Tkinter and the mainloop:
class Application(Frame):
"""GUI Application for making Baakibook"""
def __init__(self, parent):
"""Initialize the frame"""
Frame.__init__(self, parent, bg="light blue")
self.win1()
# different windows
def win1(self):
# this is the main/root window
signupButton = Button(root, text="Sign up", command=self.win2)
signupButton.grid(row=9, column=7)
loginButton = Button(root, text="Log in", command=self.win3)
loginButton.grid(row=10, column=7)
leaveButton = Button(root, text="Quit", command=root.destroy)
leaveButton.grid(row=1, column=1, sticky='nw')
b1Var = StringVar()
b2Var = StringVar()
b1Var.set('b1')
b2Var.set('b2')
box1Label = Label(root,textvariable=b1Var,width=12)
box1Label.grid(row=3, column=2)
box2Label = Label(root,textvariable=b2Var,width=12)
box2Label.grid(row=3, column=3)
root.mainloop()
def win2(self):
# this is the child window
board = Toplevel()
board.title("Sign up")
board.focus_set()
board.grab_set()
userVar = StringVar()
userVar.set('Username')
square1Label = Label(board,textvariable=userVar)
square1Label.grid(row=0, column=7)
userEnt=Entry(self)
userEnt.grid(row=1, column=7)
s2Var = StringVar()
s2Var.set('First Name')
square2Label = Label(board,textvariable=s2Var)
square2Label.grid(row=1, column=7)
leaveButton = Button(board, text="Quit", command=board.destroy)
leaveButton.grid(row=1, column=1, sticky='nw')
board.wait_window(board)
def win3(self):
# this is the child window
board = Toplevel()
board.title("Login User")
board.focus_set()
board.grab_set()
s1Var = StringVar()
s2Var = StringVar()
s1Var.set("s1")
s2Var.set("s2")
square1Label = Label(board,textvariable=s1Var)
square1Label.grid(row=0, column=7)
square2Label = Label(board,textvariable=s2Var)
square2Label.grid(row=0, column=6)
leaveButton = Button(board, text="Quit", command=board.destroy)
leaveButton.grid(row=1, column=1, sticky='nw')
board.wait_window(board)
The first argument you use to create the widget is what parent you want it assigned to. So, this line:
userEnt=Entry(self)
userEnt.grid(row=1, column=7)
makes the Entry widget in the Frame that you created in __init__. If you want it to appear in the Toplevel, create it like the other widgets you made in that method, ie:
userEnt=Entry(board)
userEnt.grid(row=1, column=7)
Also, your grid in the Toplevel doesn't make sense right now and a couple of your widgets will appear stacked until you change it.

Categories