[Tutor] Dynamic TKinter widgets?
Chris Fuller
cfuller084 at thinkingplanet.net
Sun Nov 25 04:33:26 CET 2012
On Saturday 24 November 2012, Nathan wrote:
> I'm working on a simple Tarot reading program in Python 2.7, and I'm having
> a bit of trouble with some GUI abstract. (Sorry, no code in here.)
>
> As of right now, all of the logic is working, and I can generate Tarot
> spreads that tell me, in text, the role of each card "position", and what
> card is in that position. For example, if I were to use a simple three-card
> past/present/future spread, the output would be something like:
>
> Past: Prince of Swords
> Present: The Hermit
> Future: Ten of Disks
>
> What I'm trying to do now is add support for the card images. the problem
> is, the program supports multiple types of spreads (two, so far, are
> selectable), and they use different numbers of cards. It looks like I need
> a variable number of widgets to display something like this. I'm not
> entirely sure how I would handle something like that.
>
> Right now, though, I do have two ideas that I would like to run by you
> guys.
>
> The first is to use one text widget-- as opposed to the one label widget
> I'm currently using-- and embed the images where the card names would be. I
> would have to try out some demos first, though, to see if I can otherwise
> use text widgets just as label widgets.
>
> The other idea, which seems much more cumbersome, is to create a dummy
> frame widget, then a frame widget designed specifically for each type of
> spread. The user selects the spread they want to use (Celtic Cross), and
> the associated frame gets placed on the GUI.
>
> What do you guys think? Is there a better way to deal (ha!) with this?
I think the usual procedure with something like this is a single Canvas
widget.
You could also use a Notebook with tabs disabled from Pmw or the like to
implement multiple alternate Frames. As you say, more cumbersome.
Cheers
More information about the Tutor
mailing list