Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are creating rows of widgets. Each row may have more or less widgets than other rows. At some point you need to get a list that represents the data in each row. You're asking, "how do I get this list?". Am I correct?</p> <p>You must have asked 20 questions about this one simple problem. The problem isn't in this or any other single function, it's in your general architecture. A very, very smart programmer once told me "if you want me to understand your code, don't show me your code, show me your data structures". The root problem here is, you have no data structures. If you don't organize your data, you can't hope to get at the data easily. </p> <p>There's nothing hard about this problem. Keep a list of the entry widgets for each row, and iterate over that list whenever you need the values. The following pseudocode shows how simple this can be:</p> <pre><code>class MyApp(object): def __init__(self): # this represents your data model. Each item in the # dict will represent one row, with the key being the # row number self.model = {} def add_row(self, parent, row_number): '''Create a new row''' e1 = Entry(parent, ...) e2 = Entry(parent, ...) e3 = Entry(parent, ...) ... # save the widgets to our model self.model[row_number] = [e1, e2, e3] def extend_row(self, parent, row_number, n): '''Add additional widgets to a row''' for i in range(n): e = Entry(parent, ...) self.model[row_number].append(e) def get_values(row_number): '''Return the values in the widgets for a row, in order''' result = [widget.get() for widget in self.model[row_number]] return result </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload