I am making a GUI calculator using tkinter and I am trying to position the text box and the buttons.
I want the buttons to be 3×3 with 0 at the bottom but I am having trouble.
Can someone assist me?
def text_box(): t_box = tk.Text(screen, width=25 ,height=5, font=("Ariel", 10)) # put cursor to left # make widget (wxh) stick # number should start at 0 # While GUI is running have starting number at 0 t_box.grid(row=0, column=0, padx=10, pady=20) def num_buttons(): btns = [] for i in range(0, 10): btn_storage = tk.Button(screen, text=f"{i}", font=("Ariel", 10)) row = i // 4 # Integer division to get row col = i % 4 # Modulo to get column btn_storage.grid(row=row + 1, column=col, sticky=tk.E, padx=2, pady=2) btns.append(btns)
Here is an example of what I want it to look like
_________ _text box_ 1 2 3 4 5 6 7 8 9 0
submitted by /u/TheEyebal
[link] [comments]
r/learnpython I am making a GUI calculator using tkinter and I am trying to position the text box and the buttons. I want the buttons to be 3×3 with 0 at the bottom but I am having trouble. Can someone assist me? def text_box(): t_box = tk.Text(screen, width=25 ,height=5, font=(“Ariel”, 10)) # put cursor to left # make widget (wxh) stick # number should start at 0 # While GUI is running have starting number at 0 t_box.grid(row=0, column=0, padx=10, pady=20) def num_buttons(): btns = [] for i in range(0, 10): btn_storage = tk.Button(screen, text=f”{i}”, font=(“Ariel”, 10)) row = i // 4 # Integer division to get row col = i % 4 # Modulo to get column btn_storage.grid(row=row + 1, column=col, sticky=tk.E, padx=2, pady=2) btns.append(btns) Here is an example of what I want it to look like _________ _text box_ 1 2 3 4 5 6 7 8 9 0 submitted by /u/TheEyebal [link] [comments]
I am making a GUI calculator using tkinter and I am trying to position the text box and the buttons.
I want the buttons to be 3×3 with 0 at the bottom but I am having trouble.
Can someone assist me?
def text_box(): t_box = tk.Text(screen, width=25 ,height=5, font=("Ariel", 10)) # put cursor to left # make widget (wxh) stick # number should start at 0 # While GUI is running have starting number at 0 t_box.grid(row=0, column=0, padx=10, pady=20) def num_buttons(): btns = [] for i in range(0, 10): btn_storage = tk.Button(screen, text=f"{i}", font=("Ariel", 10)) row = i // 4 # Integer division to get row col = i % 4 # Modulo to get column btn_storage.grid(row=row + 1, column=col, sticky=tk.E, padx=2, pady=2) btns.append(btns)
Here is an example of what I want it to look like
_________ _text box_ 1 2 3 4 5 6 7 8 9 0
submitted by /u/TheEyebal
[link] [comments]