[Tutor] blocking user access

Diana Hawksworth dianahawks at optusnet.com.au
Thu Mar 24 10:27:40 CET 2005

Liam, I am using IDLE - and Tkinter, John and Liam. I have been working
through the book "Python Programming" by Michael Dawson.  One of his
programs calls for the entry of a password, then reveals a message.  What I
would like to do is make the Text widget that reveals the message, unusable
by a user!

I tried the state = DISABLED in the 2nd line of code below, where the widget
to display the text is created - and it did disable the Text widget - to the
extent that it wouldn't reveal the message!  I have tried multiple other
places to put the DISABLED - at the end of this code for instance, but it
doesn't seem to work there! Where can I place it so that it will prevent a
user access to that Text widget?

Also - assuming I can get it to work - what is the term I need to use to
enable to Text widget again so that it will continue to work the next time
around. I tried ENABLED - but was told that global name is not defined!

Any ideas? Thanks in advance for suggestions.


Here is the code:

# create text widget to display message
        self.secret_txt = Text(self, width = 35, height = 5, wrap = WORD)
        self.secret_txt.grid(row = 3, column = 0, columnspan = 2, sticky =

    def reveal(self):
        """ Display message based on password. """
        contents = self.pw_ent.get()
        if contents == "secret":
            message = "Here's the secret to living to 100: live to 99 " \
                      "and then be VERY careful."

            message = "That's not the correct password, so I can't share " \
                      "the secret with you."

        self.secret_txt.delete(0.0, END)
        self.secret_txt.insert(0.0, message)

> Hi Diana,
> Welcome.
> Are you using IDLE? Could you provide a copy of your code?
> Regards,
> Liam Clarke
> Still a newbie, but not as much. :)
> On Wed, 23 Mar 2005 20:59:02 +1100, Diana Hawksworth
> <dianahawks at optusnet.com.au> wrote:
> >
> > Hi!  I need help on blocking user access to a message box - for example,
> > program could provide an answer to an input.  At the moment, the user
> > access to - and can type into - that "answer" space. How do I prevent
> > from happening please?
> >
> > Diana - a very newbie!
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
> >
> -- 
> 'There is only one basic human right, and that is to do as you damn well
> And with it comes the only basic human duty, to take the consequences.

More information about the Tutor mailing list