confusion between global names and instantiated object variable names

2005-10-14 Thread wanwan
I'm trying to make a GUI, but for some of the instantiated object
variable names, the interpreter is looking at them as global names.
Here is an example of what I did:


class mygui:


def __init__(self, root):

self.menubar = Menu(root)

# Game Menu
self.menu1 = Menu(self.menubar, tearoff=0)
self.menu1.add_command(label="Open File", command=donothing)
self.menu1.add_separator()
self.menu1.add_command(label="Exit", command=root.quit)
self.menubar.add_cascade(label="File", menu=self.menu1)

# ignoring the rest of the program  ...


when I run my example, an error shows:
"NameError: global name'menubar' is not defined"

I wonder why it doesn't work.  Isn't that the way to define an object
variable?  

Any response would be appreciated.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: confusion between global names and instantiated object variable names

2005-10-14 Thread wanwan
oops, of course.

Very careless mistake.

thx

-- 
http://mail.python.org/mailman/listinfo/python-list


text widget example?

2005-11-06 Thread wanwan
I need my GUI to open and display a text file. I'm thinking of using a
text widget but it looks so complicated in the tkinter manual.

question I have is:

is there an example anyone can find on the internet?

-- 
http://mail.python.org/mailman/listinfo/python-list


Entry widget -- how to prevent change

2005-11-22 Thread wanwan
let's say I already have some content.  How do I set the widget so user
cannot change it/?

-- 
http://mail.python.org/mailman/listinfo/python-list