May-20-2023, 05:22 PM
This May be really simple, but I'm not finding enough details to help as I'm just learning TKinter.
I have a simple grid sourced by a Python list, and I'm trying to center it regardless of window size, and add single push button at bottom of the window.
What I have tested caused the full window to grey out.
my code:
![[Image: gridOnly.png]](https://www.buy-fla.com/gridOnly.png)
Any assistance greatly appreciated.
I have a simple grid sourced by a Python list, and I'm trying to center it regardless of window size, and add single push button at bottom of the window.
What I have tested caused the full window to grey out.
my code:
import tkinter as tk from tkinter import * import tkinter.font as font window = tk.Tk() window.title("Feed Bins") window.geometry("800x400") aList = ["Bin 1", "Bin 2", "Bin 3", "Bin 4", "Bin 5","Bin 6", "Bin 7", "Bin 8", "Bin 9", "Bin 10", "Bin 11", "Bin 12", "Bin 13", "Bin 14", "Bin 15"] onList = ["Bin 3", "Bin 12", "Bin 14"] # For testing, usually empty myFont2 = font.Font(size=10) label= [0] * 15 for x in range(5): # Number of Rows for y in range(3): #Number of Colums frame = tk.Frame(master=window,relief=tk.RAISED,borderwidth=4) frame.grid(row=x, column=y, padx=5, pady=5) # line 13 label[x+(y*5)] = tk.Label(master=frame, text=aList[x+(y*5)],font=myFont2, height=3, width=20) label[x+(y*5)].pack(fill="x") def check_alerts(): global aList,onList for x in range(0,len(aList)): if aList[x] in onList: label[x].config(bg = "red") else: label[x].config(bg = "lightgrey") window.after(1000,check_alerts) check_alerts() window.mainloop()
![[Image: gridOnly.png]](https://www.buy-fla.com/gridOnly.png)
Any assistance greatly appreciated.