0

So I'm having this little problem with my program, that is as follows: I have a frame in which I have several widgets and a button. I wish the function bound to that button to update the frame so that it adds a widget to the end of the column (I'm using grid manager). So the function takes an input from an entry field and adds it under all the other stuff in the frame as a label for example. Now I'm just struggling with how to code it to work. I'm quite new to Tkinter and don't know how to proceed. I know how to get the info out of the entry field, but I don't know how to make an algorithm that updates the UI as intended.

EDIT: I have a function that adds stuff from the entry field as a label to the grid. The problem I'm having is that when the button is pressed, the input should be put in the end of the column. If I hard code the function to add the label to a certain block in the grid like:

something.grid(column=0, row=3)

it will put all the labels after the first on top of each other, when I want them to be added in the next row of the last one added. I tried something like this:

for i in range(len(list_of_labels):
  something = label(self.__window, text="list_of_labels[i]")
  something.grid(column=0, row=i+2)

but it didn't work too well. I hope this is clearer..

3
  • (First Question Review): you might show some code to illustrate your problem.
    – eckes
    Jun 6, 2014 at 21:41
  • There's nothing special about this problem, just do whatever you do to put the first items in the grid: create the widget then call the grid method. What part of that are you struggling with? Jun 6, 2014 at 22:36
  • Use some variable to keep how may rows you have. And increase it after every grid()
    – furas
    Jun 7, 2014 at 19:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.