2

I wrote a GUI that is working fine, it's supposed to get some information from a file and to show me on entries, and base on how many lines of info are present, it will generate same many entries.

The problem on this code is: I want to let me to change some values and to save them back on file and I do not know how to take that entry.get() from all entries on the frame. If I try to get a reference on it I will get back just the last entry changes printed.

def DataShow(self):
    # Import dictionary after the settings file was read
    from res.lib.Settings import app_settings

    # Make local frame
    frame = ScrolledFrameVertical(self, width=353)
    frame.pack(expand=True, fill="y", side="top")

    Button(frame, text="Save", command=lambda:save()).pack(fill="x", side="top")

    # Create entrys base on dictionary data and info
    for data, info in app_settings.items():
        d = Settings.Entry(frame, data, 20, info, 31)

    def save():
        print(d.get())

And is look like that: And is look like that

Community
  • 1
  • 1
ASI
  • 334
  • 3
  • 15
  • 1
    U can try to add the `textvariable` when youc reate the entry widget for save the entry value and get it back when u want see [here](https://effbot.org/tkinterbook/entry.htm) for more infos – Mat.C Jan 14 '20 at 15:05
  • Your problem is to get all the childrens of a widget? (Frame in that case) – JimShapedCoding Jan 14 '20 at 15:19
  • From `Settings.Entry(frame, data, 20, info, 31)` I return just the entry. They are generated and I do not know how to get them values... I still try with that `textvariable` – ASI Jan 14 '20 at 15:24
  • Can you use either `data` or `info` as key to save the reference of the `Entry` in a dictionary? – acw1668 Jan 14 '20 at 15:30

1 Answers1

2

You can get all children of a widget with .winfo_children().

def save():
    for child in frame.winfo_children():
        print(child.get())
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Was not so easy to understand this, but I played with it and that `.winfo_children()` was my solution. Thanks a lot. – ASI Jan 14 '20 at 15:51