Array tkinter Entry to Label

2024/10/11 18:20:08

Hey Guys I am beginner and working on Project Linear and Binary search GUI application using Tkinter, I want to add multiple Entry boxes values to label and in an array here, I tried but its not working fine:

enter image description here

import tkinter as tkroot=tk.Tk()
root.title("Looping of entry box")
root.geometry("1200x600")def ApplytoLabel():xx=size.get()for i in range(xx):ArrayLabel=tk.Label(root,text="Array Element")ArrayLabel.pack()def Boxes():xx=size.get()for i in range(xx):        box=tk.Entry(root)box.pack()ApplytoLabel1=tk.Button(root,text="Submit To Array",command=ApplytoLabel)ApplytoLabel1.pack()Array = tk.Frame(root)
Array.pack()text1=tk.Label(Array,text="Enter the Size of Array:",font="Arial 10 bold",fg="blue")
text1.grid(row=0,column=0,sticky="w")size=tk.IntVar()ArraySize=tk.Entry(Array,textvariable=size)
ArraySize.grid(row=0,column=1,sticky="w")SizeofArray=tk.Button(Array,text="Submit",command=Boxes)
SizeofArray.grid(row=0,column=2,sticky="w")root.mainloop()
Answer

Well; it's not working fine is not much of a problem description but I'm going to guess you want to keep the array elements in some way. The usual way to do this is to create a list and then add the Entrys to the list as you create them.

When you create the Labels you simply read the values from the list of Entrys as they have the same index as the Labels. Part of the code:

def ApplytoLabel():xx=size.get()for i in range(xx):element = box_list[i].get() # Get value from corresponding EntryArrayLabel=tk.Label(root,text="Array Element: " + element)ArrayLabel.pack()box_list = []   # Create list of Entrys
def Boxes():xx=size.get()for i in range(xx):        box=tk.Entry(root)box.pack()box_list.append(box)    # Append current Entry to listApplytoLabel1=tk.Button(root,text="Submit To Array",command=ApplytoLabel)ApplytoLabel1.pack()
https://en.xdnf.cn/q/118289.html

Related Q&A

Grid search and cross validation SVM

i am implementing svm using best parameter of grid search on 10fold cross validation and i need to understand prediction results why are different i got two accuracy results testing on training set not…

Accessing dynamically created tkinter widgets

I am trying to make a GUI where the quantity of tkinter entries is decided by the user.My Code:from tkinter import*root = Tk()def createEntries(quantity):for num in range(quantity):usrInput = Entry(roo…

Graphene-Django Filenaming Conventions

Im rebuilding a former Django REST API project as a GraphQL one. I now have queries & mutations working properly.Most of my learning came from looking at existing Graphene-Django & Graphene-Py…

Summing up CSV power plant data by technology and plant name

Ive got a question regarding the Form 860 data about US power plants.It is organized block-wise and not plant-wise. To become useful, the capacity numbers must be summed up.How may I get the total capa…

Send and receive signals from another class pyqt

I am needing a way to receive signals sent by a Class to another class. I have 2 classes: In my first class I have a function that emits a signal called asignal In my second class I call the first cla…

I can not add many values in one function

I have a gui applicationI put text into text box1, text box2,………… text box70 ,and then click on the pushButton, The function return_text () in the module_b.py be called. Now I can call one instance…

Close browser popup in Selenium Python

I am scraping a page using Selenium, Python. On opening the page one Popup appears. I want to close this popup anyway. I tried as below:url = https://shopping.rochebros.com/shop/categories/37browser = …

How can I replace certain string in a string in Python?

I am trying to write two procedures to replace matched strings in a string in python. And I have to write two procedures. def matched_case(old new): .........note: inputs are two strings, it returns a…

Python: `paste multiple (unknown) csvs together

What I am essentially looking for is the `paste command in bash, but in Python2. Suppose I have a csv file:a1,b1,c1,d1 a2,b2,c2,d2 a3,b3,c3,d3And another such:e1,f1 e2,f2 e3,f3I want to pull them toget…

Django Redirect after Login Error

Im new to Django and I know that to redirect after login I have to set the parameter page. But this only works when the login is successful. How can i do the same thing when some error occurs?? Ps: I…