I'm trying to create a GUI in Python 2.7 with Tkinter. I need that the increment value from my Spinbox changes accordingly to a value selected from a selection of Radiobutton. I've tried different approaches but not success so far. I'm attaching part of the code that isn't working. I really appreciate if someone could come up with a solution. Thanks!
class Frequency_Window(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
global var_increment
self.var_x = IntVar()
self.self_value = IntVar()
self.freq_Hz = IntVar()
self.parent.title("Test")
self.pack(fill=BOTH, expand=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(1, pad=7)
self.rowconfigure(5, weight=1)
self.rowconfigure(5, pad=7)
self.var_x.set("1")
label_RadioButton = ttk.Label(self,
justify=LEFT,
text="Increments")
label_RadioButton.grid(sticky=N+W+S+E,
pady=4,
padx=5,
row=0,
column=1)
R1 = ttk.Radiobutton(self,
text="1",
variable=self.var_x,
command=self.set_increment,
value=1)
R1.grid(sticky=NW,
row=1,
column=1,
pady=5)
R10 = ttk.Radiobutton(self,
text="10",
variable=self.var_x,
command=self.set_increment,
value=10)
R10.grid(sticky=NW,
row=2,
column=1,
pady=5)
R100 = ttk.Radiobutton(self,
text="100",
variable=self.var_x,
command=self.set_increment,
value=100)
R100.grid(sticky=NW,
row=3,
column=1,
pady=5)
var_freq_Hz = Spinbox(self,
textvariable=self.freq_Hz,
font=("Calibri",30),
justify="right",
bd=0,
bg='black',
fg='white',
from_=0,
to=999,
increment=self.var_x.get(),
width=4,
relief=FLAT,
buttonbackground='black')
var_freq_Hz.grid(sticky=N+W+S+E,
row=1,
column=0,
columnspan=1,
rowspan=1,
padx=5)
def set_increment(self):
selection = "You selected the option " + str(self.var_x.get())
print selection
return
Hi I just found the way to do it. I had to change my object available in the class adding it to self. From this:
var_freq_Hz = Spinbox(self,
textvariable=self.freq_Hz,
font=("Calibri",30),
justify="right",
bd=0,
bg='black',
fg='white',
from_=0,
to=999,
increment=self.var_x.get(),
width=4,
relief=FLAT,
buttonbackground='black')
var_freq_Hz.grid(sticky=N+W+S+E,
row=1,
column=0,
columnspan=1,
rowspan=1,
padx=5)
To this:
self.var_freq_Hz = Spinbox(self,
textvariable=self.freq_Hz,
font=("Calibri",30),
justify="right",
bd=0,
bg='black',
fg='white',
from_=0,
to=999,
width=4,
relief=FLAT,
buttonbackground='black')
self.var_freq_Hz.grid(sticky=N+W+S+E,
row=1,
column=0,
columnspan=1,
rowspan=1,
padx=5)
And then in the call function, I used the configure option to change the value of increment, as this:
def set_increment(self):
selection = "You selected the option " + str(self.var_x.get())
self.var_freq_Hz.config(increment = self.var_x.get())
print selection
return
Now it's working properly. However, if someone comes up with a more Pythonic solution is highly appreciate! Cheers!
Related
Every time I click on the buttons I get a error. Could anyone help me by providing a fix or telling me what the issue was because I cant see the issue.
Whenever the button is clicked it is supposed to open a new page and the side bar on the left with the buttons in should stay where they are at.
import tkinter
import tkinter.messagebox
import customtkinter
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("dark-blue")
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
# configure window
self.title("Opium")
self.geometry(f"{1100}x{580}")
# configure grid layout (4x4)
self.grid_columnconfigure(1, weight=1)
self.grid_columnconfigure((2, 3), weight=0)
self.grid_rowconfigure((0, 1, 2), weight=1)
# create sidebar frame with widgets
self.content_label = customtkinter.CTkLabel(self, text="", font=customtkinter.CTkFont(size=30, weight="bold"))
self.content_label.grid(row=0, column=1, rowspan=4, sticky="nsew", padx=(10, 0), pady=(20, 10))
self.sidebar_frame = customtkinter.CTkFrame(self, width=140, corner_radius=0)
self.sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsew")
self.sidebar_frame.grid_rowconfigure(4, weight=1)
self.logo_label = customtkinter.CTkLabel(self.sidebar_frame, text="Opium", font=customtkinter.CTkFont(size=30, weight="bold"))
self.logo_label.grid(row=0, column=0, padx=20, pady=(20, 10))
self.sidebar_button_1 = customtkinter.CTkButton(self.sidebar_frame, text="Button 1", command=self.sidebar_button_event)
self.sidebar_button_1.grid(row=1, column=0, padx=20, pady=10)
self.sidebar_button_2 = customtkinter.CTkButton(self.sidebar_frame, text="Button 2", command=self.sidebar_button_event)
self.sidebar_button_2.grid(row=2, column=0, padx=20, pady=10)
self.sidebar_button_3 = customtkinter.CTkButton(self.sidebar_frame, text="Button 3", command=self.sidebar_button_event)
self.sidebar_button_3.grid(row=3, column=0, padx=20, pady=10)
self.appearance_mode_label = customtkinter.CTkLabel(self.sidebar_frame, text="Appearance Mode:", anchor="w")
self.appearance_mode_label.grid(row=5, column=0, padx=20, pady=(10, 0))
self.appearance_mode_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["Light", "Dark", "System"],
command=self.change_appearance_mode_event)
self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10))
def open_input_dialog_event(self):
dialog = customtkinter.CTkInputDialog(text="Type in a number:", title="CTkInputDialog")
print("CTkInputDialog:", dialog.get_input())
def change_appearance_mode_event(self, new_appearance_mode: str):
customtkinter.set_appearance_mode(new_appearance_mode)
def change_scaling_event(self, new_scaling: str):
new_scaling_float = int(new_scaling.replace("%", "")) / 100
customtkinter.set_widget_scaling(new_scaling_float)
def sidebar_button_event(self):
try:
self.right_frame.destroy()
except AttributeError:
pass
self.right_frame = customtkinter.CTkFrame(self, bg="white", width=900, height=580)
self.right_frame.grid(row=0, column=1, rowspan=3, columnspan=2, sticky="nsew")
self.home_label = customtkinter.CTkLabel(self.right_frame, text="Home", font=customtkinter.CTkFont(size=30, weight="bold"), bg="white")
self.home_label.pack(side="top", fill="both", padx=20, pady=20)
if __name__ == "__main__":
app = App()
app.mainloop()
I have tested the code and the error you are getting when clicking the buttons is
ValueError: ['bg'] are not supported arguments. Look at the documentation for supported arguments.
As the error already says, bg is not a supported argument by customtkinter.
https://github.com/TomSchimansky/CustomTkinter/wiki/CTkLabel#arguments
In your specific case you have to change the two instances of bg="white" to bg_color="white".
import tkinter
import tkinter.messagebox
import customtkinter
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("dark-blue")
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
# configure window
self.title("Opium")
self.geometry(f"{1100}x{580}")
# configure grid layout (4x4)
self.grid_columnconfigure(1, weight=1)
self.grid_columnconfigure((2, 3), weight=0)
self.grid_rowconfigure((0, 1, 2), weight=1)
# create sidebar frame with widgets
self.content_label = customtkinter.CTkLabel(
self, text="", font=customtkinter.CTkFont(size=30, weight="bold"))
self.content_label.grid(
row=0, column=1, rowspan=4, sticky="nsew", padx=(10, 0), pady=(20, 10))
self.sidebar_frame = customtkinter.CTkFrame(
self, width=140, corner_radius=0)
self.sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsew")
self.sidebar_frame.grid_rowconfigure(4, weight=1)
self.logo_label = customtkinter.CTkLabel(
self.sidebar_frame, text="Opium", font=customtkinter.CTkFont(size=30, weight="bold"))
self.logo_label.grid(row=0, column=0, padx=20, pady=(20, 10))
self.sidebar_button_1 = customtkinter.CTkButton(
self.sidebar_frame, text="Button 1", command=self.sidebar_button_event)
self.sidebar_button_1.grid(row=1, column=0, padx=20, pady=10)
self.sidebar_button_2 = customtkinter.CTkButton(
self.sidebar_frame, text="Button 2", command=self.sidebar_button_event)
self.sidebar_button_2.grid(row=2, column=0, padx=20, pady=10)
self.sidebar_button_3 = customtkinter.CTkButton(
self.sidebar_frame, text="Button 3", command=self.sidebar_button_event)
self.sidebar_button_3.grid(row=3, column=0, padx=20, pady=10)
self.appearance_mode_label = customtkinter.CTkLabel(
self.sidebar_frame, text="Appearance Mode:", anchor="w")
self.appearance_mode_label.grid(row=5, column=0, padx=20, pady=(10, 0))
self.appearance_mode_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["Light", "Dark", "System"],
command=self.change_appearance_mode_event)
self.appearance_mode_optionemenu.grid(
row=6, column=0, padx=20, pady=(10, 10))
def open_input_dialog_event(self):
dialog = customtkinter.CTkInputDialog(
text="Type in a number:", title="CTkInputDialog")
print("CTkInputDialog:", dialog.get_input())
def change_appearance_mode_event(self, new_appearance_mode: str):
customtkinter.set_appearance_mode(new_appearance_mode)
def change_scaling_event(self, new_scaling: str):
new_scaling_float = int(new_scaling.replace("%", "")) / 100
customtkinter.set_widget_scaling(new_scaling_float)
def sidebar_button_event(self):
try:
self.right_frame.destroy()
except AttributeError:
pass
self.right_frame = customtkinter.CTkFrame(
self, bg_color="white", width=900, height=580)
self.right_frame.grid(row=0, column=1, rowspan=3,
columnspan=2, sticky="nsew")
self.home_label = customtkinter.CTkLabel(
self.right_frame, text="Home", font=customtkinter.CTkFont(size=30, weight="bold"), bg_color="white")
self.home_label.pack(side="top", fill="both", padx=20, pady=20)
if __name__ == "__main__":
app = App()
app.mainloop()
For the next time please be so kind and include the error message you are getting with your question
I'm making a game based off of the periodic table with tkinter. I made the particle frame just fine, so I decided to copy the code and reuse it for the element frame, changing only the variable names. But for some reason, even though the particle frame works just fine, nothing shows up for the element frame. Here is my full code:
# Boilerplate
import random
import periodictable as pt
from tkinter import *
root = Tk()
root.title('Periodic Table Game')
root.geometry('350x250')
LightBlue = "#b3c7d6"
Menu = Frame(root)
elementFrame = Frame(root)
particleFrame = Frame(root)
settingsFrame = Frame(root)
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
for AllFrames in (Menu, elementFrame, particleFrame, settingsFrame):
AllFrames.grid(row=0, column=0, sticky='nsew')
AllFrames.configure(bg=LightBlue)
def show_frame(frame):
frame.tkraise()
show_frame(Menu)
# Menu Frame
Menu.grid_columnconfigure(0, weight=1)
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
MenuTitle = Label(Menu, text="Periodic Table Game", font=("Arial", 15), bg=LightBlue)
MenuTitle.grid(row=0, column=0, pady=25)
MenuTitle.grid_rowconfigure(1, weight=1)
MenuTitle.grid_columnconfigure(1, weight=1)
MenuButton1 = Button(Menu, width=25, text="Guess The Particles", command=lambda: show_frame(particleFrame))
MenuButton1.grid(row=1, column=0)
MenuButton2 = Button(Menu, width=25, text="Guess The Element Name", command=lambda: show_frame(elementFrame))
MenuButton2.grid(row=2, column=0, pady=5)
SettingsButton = Button(Menu, width=25, text="Settings", command=lambda: show_frame(settingsFrame))
SettingsButton.grid(row=3, column=0)
# Particle Frame
particleFrame.grid_columnconfigure(0, weight=1)
BackButtonF2 = Button(particleFrame, text='Back', command=lambda: show_frame(Menu))
BackButtonF2.grid(row=0, column=0, sticky=W)
ParticleLabel = Label(particleFrame, text='testing', bg=LightBlue)
ParticleLabel.grid(row=1, column=0, pady=15)
ParticleEntry = Entry(particleFrame)
ParticleEntry.grid(row=2, column=0, pady=10)
ParticleEnter = Button(particleFrame, text='Enter', width=10)
ParticleEnter.grid(row=3, column=0, pady=10)
# Element Frame
elementFrame.grid_columnconfigure(0, weight=1)
BackButtonF3 = Button(particleFrame, text='Back', command=lambda: show_frame(Menu))
BackButtonF3.grid(row=0, column=0, sticky=W)
ElementLabel = Label(particleFrame, text='testing', bg=LightBlue)
ElementLabel.grid(row=1, column=0, pady=15)
ElementEntry = Entry(particleFrame)
ElementEntry.grid(row=2, column=0, pady=10)
ElementEnter = Button(particleFrame, text='Enter', width=10)
ElementEnter.grid(row=3, column=0, pady=10)
root.mainloop()
Why does identical code work only with one frame?
Precisely, because you copied the code you don't spot where the issue is.
When you are defining the element frame widgets you are placing them all into particleFrame.
Example:
BackButtonF3 = Button(particleFrame, text='Back', command=lambda: show_frame(Menu))
should be
BackButtonF3 = Button(elementFrame, text='Back', command=lambda: show_frame(Menu))
Your problem will be solved.
Change this particleFrame, to elementFrame
snippet code:
BackButtonF3 = Button(elementFrame, text='Back', command=lambda: show_frame(Menu))
BackButtonF3.grid(row=0, column=0, sticky=W)
ElementLabel = Label(elementFrame, text='testing', bg=LightBlue)
ElementLabel.grid(row=1, column=0, pady=15)
ElementEntry = Entry(elementFrame)
ElementEntry.grid(row=2, column=0, pady=10)
ElementEnter = Button(elementFrame, text='Enter', width=10)
ElementEnter.grid(row=3, column=0, pady=10)
Screenshot before:
Screenshot after same as elementFrame and particleFrame:
in my GUI I used two panedwindow widgets with two inside frames for each of them. All works as I axpected, except the resizing.. when I resize the frames, all widgets start to flick, and I really don't like to see it.
To understand better the issue, I took a piece of code from my real program and I simplified it as much as possible:
from tkinter import *
from tkinter import ttk
class MainWindow:
def __init__(self):
# main window:
self.parent=Tk()
self.parent.geometry("760x620+370+100")
self.parent.title("Main Window")
self.parent.configure(background="#f0f0f0")
self.parent.minsize(760, 600)
self.Frame1=PanedWindow(self.parent, orient=HORIZONTAL)
self.Frame1.grid(row=0, column=0, padx=(5,4), pady=(6,0), sticky="nswe")
self.parent.grid_columnconfigure(0, weight=1)
self.parent.grid_rowconfigure(0, weight=1)
self.Frame1_1=Frame(self.Frame1)
self.Frame1_1.pack(side=LEFT)
self.Frame1_2=Frame(self.Frame1)
self.Frame1_2.pack(side=RIGHT)
self.Frame1_1.grid_columnconfigure(0, weight=1)
self.Frame1_1.grid_rowconfigure(0, weight=1)
# Frame1_1:
self.Frame1_1_1=PanedWindow(self.Frame1_1, orient=VERTICAL)
self.Frame1_1_1.grid(row=0, column=0, sticky="nswe")
self.MainNotebook=ttk.Notebook(self.Frame1_1_1)
self.MainNotebook.pack(fill=BOTH, expand=True)
self.MainNotebookFrame=Frame(self.MainNotebook, background="white")
self.MainNotebookFrame.pack()
self.MainNotebook.add(self.MainNotebookFrame, text="Tab1")
self.Search1SV=StringVar()
self.Search1Entry=ttk.Entry(self.MainNotebookFrame, textvariable=self.Search1SV)
self.Search1Entry.pack(fill=BOTH, padx=5, pady=5)
self.TVDFrame=Frame(self.MainNotebookFrame, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
self.TVDFrame.pack(fill=BOTH, expand=True, padx=5, pady=(0,4))
self.TVDFrame.grid_columnconfigure(1, weight=1)
self.TVDFrame.grid_rowconfigure(1, weight=1)
self.TreeView1=ttk.Treeview(self.TVDFrame, height=10, selectmode="browse")
self.TreeView1.grid(row=0, column=0, columnspan=3, rowspan=3, sticky="nsew")
self.HeaderFrame=Frame(self.TVDFrame, height=25, background="#d9ebf9")
self.HeaderFrame.grid(row=0, column=0, columnspan=3, sticky="nsew")
ttk.Label(self.HeaderFrame, text="Languages:", background="#d9ebf9").grid(row=0, column=0, pady=3)
self.TreeView1SBY=ttk.Scrollbar(self.TVDFrame, orient="vertical", command=self.TreeView1.yview)
self.TreeView1SBY.grid(row=0, column=2, rowspan=2, sticky="nse")
self.TreeView1.configure(yscroll=self.TreeView1SBY.set)
self.TreeView1.insert("", "end", text="Ciao")
self.TreeView1.insert("", "end", text="Hola")
self.TreeView1.insert("", "end", text="привет")
Frame(self.TVDFrame, height=1, width=4, background="white", highlightthickness=0, highlightbackground="white").grid(row=0, column=0, columnspan=3, sticky="new")
Frame(self.TVDFrame, height=1, width=4, background="white", highlightthickness=0, highlightbackground="white").grid(row=2, column=0, columnspan=3, sticky="ew")
Frame(self.TVDFrame, width=1, height=4, background="white", highlightthickness=0, highlightbackground="white").grid(row=0, column=0, rowspan=3, sticky="ns")
self.SecondNotebookFrame=Frame(self.Frame1_1_1)
self.SecondNotebookFrame.pack(fill=BOTH)
self.SecondNotebook=ttk.Notebook(self.SecondNotebookFrame)
self.SecondNotebook.pack(fill=BOTH, expand=True, pady=(2,1))
self.OptionalFrame1=Frame(self.SecondNotebook, background="white")
self.OptionalFrame1.pack()
self.SecondNotebook.add(self.OptionalFrame1, text="Tab1")
self.OptionalFrame2=Frame(self.OptionalFrame1, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
self.OptionalFrame2.pack(fill=BOTH, expand=True, padx=5, pady=(5,4))
self.PBFrame1=Frame(self.Frame1_1, background="white", highlightbackground="#d9d9d9", highlightthickness=1)
self.PBFrame1.grid(row=1, column=0, padx=(1,3), pady=(3,1), sticky="nswe")
self.PBFrame2=Frame(self.PBFrame1, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
self.PBFrame2.pack(fill=BOTH, padx=5, pady=5)
self.Progressbar=ttk.Progressbar(self.PBFrame2, mode="determinate", maximum=100, value=0)
self.Progressbar.pack(fill=BOTH, padx=10, pady=10)
# frame Frame1_2:
self.WorkNotebook=ttk.Notebook(self.Frame1_2)
self.WorkNotebook.pack(fill=BOTH, expand=True, pady=(1,0))
self.WorkNotebookFrame=Frame(self.WorkNotebook, background="white")
self.WorkNotebookFrame.pack()
self.WorkNotebook.add(self.WorkNotebookFrame, text="Tab1")
self.WorkNotebookFrame=Frame(self.WorkNotebookFrame, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
self.WorkNotebookFrame.pack(fill=BOTH, expand=True, padx=5, pady=(5,4))
self.PBFrame1=Frame(self.Frame1_1, background="white", highlightbackground="#d9d9d9", highlightthickness=1)
self.PBFrame1.grid(row=1, column=0, padx=(1,3), pady=(3,1), sticky="nswe")
self.PBFrame2=Frame(self.PBFrame1, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
self.PBFrame2.pack(fill=BOTH, padx=5, pady=5)
self.Progressbar=ttk.Progressbar(self.PBFrame2, mode="determinate", maximum=100, value=0)
self.Progressbar.pack(fill=BOTH, padx=10, pady=10)
self.Frame1.add(self.Frame1_1, minsize=230)
self.Frame1.add(self.Frame1_2, minsize=250)
self.Frame1_1_1.add(self.MainNotebook, minsize=56)
self.Frame1_1_1.add(self.SecondNotebookFrame, minsize=104)
# end:
self.parent.mainloop()
if __name__=="__main__":
app=MainWindow()
in addition I attached also a GIF and this image shows exactly when the issue happen:
how can I solve the resizing issue?
I have packaged a group a widgets into a single widget as follows:
class RunOptions(tk.Frame):
def __init__(self, master=None):
super().__init__(master, bg='green')
self.label = tk.Label(self, text='Options:')
self.folder_button_label = tk.Label(self, text='Select a Folder', bg='white')
self.folder_button = tk.Button(self, text='Select Image Folder')
self.template_button = tk.Button(self, text='Select Template')
self.template_frame = ImageCanvas(self, height=64, width=64)
self.label.grid(row=0, sticky='W')
self.folder_button.grid(row=1, column=1, sticky='W')
self.folder_button_label.grid(row=1, column=0, sticky='W')
self.template_button.grid(row=2, column=1, sticky='W')
self.template_frame.grid(row=2, column=0, sticky='W')
and
class DetectionCanvas(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.xml_var = tk.IntVar()
self.detectframe = ImageCanvas(self, label='Detection:', height=175, width=175)
self.x_out = tk.Label(self, bg='white', text='X:', anchor='w')
self.y_out = tk.Label(self, bg='white', text='Y:', anchor='w')
self.w_out = tk.Label(self, bg='white', text='W:', anchor='w')
self.h_out = tk.Label(self, bg='white', text='H:', anchor='w')
self.xml_check = tk.Checkbutton(self, text=' Save XML File',variable=self.xml_var)
self.detectframe.grid(row=0, column=0, rowspan=4)
self.x_out.grid(row=0, column=1)
self.y_out.grid(row=1, column=1)
self.w_out.grid(row=2, column=1)
self.h_out.grid(row=3, column=1)
self.xml_check.grid(row=4, column=0, sticky='w')
def display_out(self, *args):
pass
both of these widgets are all arranged in a large empty canvas (purple) using grid, but that doesn't matter here because the issue is in the individual widgets themselves:
I want the buttons in the options to anchor to the left, filling in the gap between the label. For the detection widget I want the labels to anchor left towards the canvas. I've tried anchoring and using sticky but nothing in the second column seems to move.
I have a Toplevel Window with one grid row containing a Label, Entry and a "+" Button (window on startup)
When I hit the Add-Button a new row with the same content is generated. But the problem is, that the window doesn't resize and fit to its new contents. Should look like this resized window.
The code is below:
def process_map():
numbers = {0:'\u2080', 1:'\u2081', 2:'\u2082', 3:'\u2083', 4:'\u2084', 5:'\u2085', 6:'\u2086', 7:'\u2087', 8:'\u2088', 9:'\u2089'}
button_pos = tk.IntVar(0)
ENTRIES = {}
def add_button():
if button_pos.get() >= 10:
index = numbers[button_pos.get()//10] + numbers[button_pos.get()%10]
else:
index = numbers[button_pos.get()]
lb = tk.Label(top_root, text='\u03C6'+index)
lb.grid(row=button_pos.get(), column=0, sticky='NWES')
entry = tk.Entry(top_root, width=4, relief='sunken', bd=2)
entry.grid(row=button_pos.get(), column=1, sticky='WE', padx=5, pady=5)
ENTRIES.update({button_pos.get():entry})
bt.grid(row=button_pos.get(), column=2, sticky='WE', padx=5, pady=5)
bt_close.grid(row=button_pos.get()+1, column=1, padx=5, pady=5)
bt_start.grid(row=button_pos.get()+1, column=0, padx=5, pady=5)
button_pos.set(button_pos.get()+1)
center(top_root)
top_root = tk.Toplevel(root)
top_root.title('Select \u03C6')
lb = tk.Label(top_root, text='\u03C6\u2081', height=1)
lb.grid(row=0, column=0, sticky='NWES')
entry = tk.Entry(top_root, width=4, relief='sunken', bd=2)
entry.grid(row=0, column=1, sticky='WE', padx=5, pady=5)
button_pos.set(button_pos.get()+2)
ENTRIES.update({button_pos.get():entry})
bt = tk.Button(top_root, text='+', command=add_button,)
bt.grid(row=0, column=2, sticky='WE', padx=5, pady=5)
bt_close = tk.Button(top_root, text='Cancel', width=15, command=top_root.destroy)
bt_close.grid(row=button_pos.get()+1, column=1, padx=5, pady=5)
bt_start = tk.Button(top_root, text='Start', width=15)
bt_start.grid(row=button_pos.get()+1, column=0, padx=5, pady=5)
center(top_root)
top_root.mainloop()