2

I'm writing a GUI program where I want to create several check buttons with text from a list. The problem is that I have many lists, and I therefore want the user to be able to go to the "next page" and see a different set of check buttons based on a different list. However, to do this I need some kind of textvariable in my check buttons so the text is updated every time a user goes to the next page. Though, as far as I know, there is no such option.

Is this possible to do, or do I need to create a separate check button and a separate label with the textvariable in it?

Help would be much appreciated. Thanks in advance!

3
  • could you include some of the code you have tried? personally, if there is only going to be two or three pages, I would consider using ttk.Notebook Commented Dec 4, 2012 at 15:36
  • Are you using ttk checkbuttons or standard tk checkbuttons? Commented Dec 4, 2012 at 15:40
  • Standard checkbuttons, I suppose. I'm really new too tkinter. And there are 365 lists, one list for every day in a year. Commented Dec 4, 2012 at 19:27

1 Answer 1

1

Only possible approach I can think of is doing config on a checkbutton. Assuming you are using standard tk checkbuton, you can call:

checkbutton.config(text=newtext)

where newtext is the new text, obviously.

Add the call to the callback bound to the next and previous page buttons. If you really need to use a variable, add a property to a class based on checkbutton and modify its setter to call the config function on asignment.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! But how would the frame with the check buttons be updated? If I call the config-method when the user clicks on "next" and "previous", wouldn't everything just look the same? I don't know how to give you some short code version of my program but it's supposed to be a digital calendar. Each date has a list of notes, so there are 365 lists, though some of them are empty. The check buttons are supposed to appear in front of every note, which allows the user to delete one or several notes at a time. Is the config-method the best way to do this or will it make things too complicated?
Reducing the problem to a short example is illuminating, Myone. I would like to help but it is somewhat hard to know exactly what you want to achieve without any kind of code.
If I understood you correctly, the number of checkbuttons is not constant. I'd personally rather create new checkbuttons and delete the old ones than configuring a constant number of them and keeping some hidden. Maybe the better approach would be to have a list widget with all the items, and have the user select the options in the list. You can set the selectmode argument to MULTIPLE when defining the list, so the user can select multiple elements inside it.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.