Python Forum
data from multiple Entry widgets
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
data from multiple Entry widgets
#11
I thought that was most of what you had done in your first post. You created (and stored) the widgets in an array (I assume you're using pandas or such).

xxx[a,b,c] = Entry(root, bg="white",fg="black", width=7,relief=SUNKEN).grid(row=p_row,column=p_col+1)
Then in your loops it looks like you try to retrieve the data, but you don't do anything with it. It's like a line that says 2+4. It turns into 6, but then is thrown away.

for a in range(8):
          for b in range(4):
            for c in range(5):
               xxx[a,b,c].get()
    print(xxx)
Perhaps instead you could change the "get" line above to something like:
data = xxx[a,b,c].get()
print(f"Widget {a},{b},{c} has data {data}")
Then when the loop is run, you can see all the data (or make use of it in some way).
Reply
#12
(Aug-15-2020, 10:47 PM)bowlofred Wrote: I thought that was most of what you had done in your first post. You created (and stored) the widgets in an array (I assume you're using pandas or such).

xxx[a,b,c] = Entry(root, bg="white",fg="black", width=7,relief=SUNKEN).grid(row=p_row,column=p_col+1)
Then in your loops it looks like you try to retrieve the data, but you don't do anything with it. It's like a line that says 2+4. It turns into 6, but then is thrown away.

for a in range(8):
          for b in range(4):
            for c in range(5):
               xxx[a,b,c].get()
    print(xxx)
Perhaps instead you could change the "get" line above to something like:
data = xxx[a,b,c].get()
print(f"Widget {a},{b},{c} has data {data}")
Then when the loop is run, you can see all the data (or make use of it in some way).

This doesn't work.
data = xxx[a,b,c].get()
I get the error: AttributeError: 'numpy.float64' object has no attribute 'get'

I tried
data[a,b,c]=xxx[a,b,c].get()
data=xxx[a,b,c].get()
where data is an array[8,4,5]
I tried where data is a single variable. All of them gave the same error.
Reply
#13
Ah, true. (I don't use numpy arrays much and will tend to miss things). It's possible to create arrays that hold objects, but it's harder. A dictionary could work, but you don't get the nice indexing. Just as an attempt though, maybe something like:

# store the widget in a dict, with a tuple key for indexing
xxx = {}
# whatever loop you had over a, b, and c...
    xxx[(a,b,c)] = Entry(root, bg="white",fg="black", width=7,relief=SUNKEN).grid(row=p_row,column=p_col+1)


# retrieve the widgets:
for a in range(8):
          for b in range(4):
            for c in range(5):
               data = xxx[(a,b,c)].get()
               print(f"Widget {a},{b},{c} has data {data}")
Otherwise if you want the array to hold a python object, try initializing it with dtype=object.
Reply
#14
Neat idea with using a tuple as key.

As you mentioned you can initialize a Numpy array to hold objects.
import numpy
from tkinter import *

root = Tk()
xxx = numpy.empty((2, 2, 2), dtype=object)
xxx[0, 0, 0] = Entry(root)
xxx[0, 0, 0].place
print(xxx)
mainloop
Output:
[[<tkinter.Entry object .!entry> None] [None None]]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Load multiple Jason data in one Data Frame vijays3 6 1,545 Aug-12-2022, 05:17 PM
Last Post: vijays3
  Python, how to manage multiple data in list or dictionary with calculations and FIFO Mikeardy 8 2,600 Dec-31-2021, 07:47 AM
Last Post: Mikeardy
  How to map two data frames based on multiple condition SriRajesh 0 1,477 Oct-27-2021, 02:43 PM
Last Post: SriRajesh
  Load the data from multiple source files to one table amy83 2 2,586 Apr-27-2021, 12:33 AM
Last Post: Pedroski55
  API Gateway to manage multiple API's get put data robsuttonjr 2 2,535 Mar-09-2021, 04:09 PM
Last Post: robsuttonjr
  Pandas: how to split one row of data to multiple rows and columns in Python GerardMoussendo 4 6,824 Feb-22-2021, 06:51 PM
Last Post: eddywinch82
  How to filter out Column data From Multiple rows data? firaki12345 10 5,101 Feb-06-2021, 04:54 AM
Last Post: buran
  Fetching data from multiple tables in a single request. swaroop 0 1,893 Jan-09-2021, 04:23 PM
Last Post: swaroop
  How to fill parameter with data from multiple columns CSV file greenpine 1 1,662 Dec-21-2020, 06:50 PM
Last Post: Larz60+
  Load data from One oracle Table to Multiple tables amy83 1 1,778 Dec-02-2020, 01:57 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020