[Tutor] Code Regress
robertvstepp at gmail.com
Tue Feb 2 00:48:17 EST 2016
On Mon, Feb 1, 2016 at 8:22 AM, Evan Sommer <evanlespaul at gmail.com> wrote:
> I tried the code suggestion that you proposed in december, and while
> it did count down time, it actually set me back in a way because the
> display is not how I desired it to be.
I think you need to review all of Alan's previous suggestions. If you
do not understand what he said, then you should ask a specific
question so that we can help you understand.
> The way the display looks in this program below is how I have been
> asked to run it, and all that I need to change is the fact that the
> program adds 2 separate windows when it changes color. I just need one
Each time you call tk.Lbl, you are creating another label. Alan
suggested that you update the background property directly. You can
do this using the config() method. Look it up in the docs! A start
in this direction might be:
your_label = tk.Label(root, ...)
And when you want to change the background color, use:
This will change that particular property because the Label object
supports the config() method. This method is used *after* applying
pack to create your label.
The code you supplied did not have any vertical spacing and was rather
hard to read. You should separate logical blocks of code with a blank
line (or possibly two). It makes it much easier to read!
As far as I can tell you never call your function, count_down, and
essentially duplicate what it does in your main code.
Why don't you try putting everything in a single for loop and test
when it is time to change colors with an if-elif construct? A
skeleton might be:
for t in range(240, -1, -1):
if t == 120:
elif t == 60:
More information about the Tutor