Newbie alert

Discussion in 'Python' started by Steve Holden, Feb 2, 2005.

  1. Steve Holden

    Steve Holden Guest

    Valone, Toren W. wrote:

    > Ok, new to Python and Tkinter.. Following along examples in book, got to
    > dialog windows example coded this
    >
    > # dialog1.py
    >
    > from Tkinter import *
    >
    > class Mydialog:

    ^^^^^^^^
    >

    [...]
    >
    > d = MyDialog(root)

    ^^^^^^^^
    >
    > root.wait_window(d.top)
    >
    > When I run it IDLE
    >
    > gives me this
    >
    > Traceback (most recent call last):
    > File "C:/Python24/dialog1.py", line 29, in -toplevel-
    > d = MyDialog(root)
    > NameError: name 'MyDialog' is not defined
    >
    > I have a feeling this is something very simple, but I cannot figure it out.
    > Help!


    Python is case-sensitive!

    regards
    Steve
    --
    Meet the Python developers and your c.l.py favorites March 23-25
    Come to PyCon DC 2005 http://www.pycon.org/
    Steve Holden http://www.holdenweb.com/
     
    Steve Holden, Feb 2, 2005
    #1
    1. Advertising

  2. Ok, new to Python and Tkinter.. Following along examples in book, got to
    dialog windows example coded this

    # dialog1.py

    from Tkinter import *

    class Mydialog:

    def _int_(self,parent):

    top = self.top = Toplevel(parent)

    Label(top, text="Value").pack()

    self.e = Entry(top)
    self.e.pack(padx=5)

    b = Button(top,text="OK", command=self.ok)

    b.pack(pady=5)

    def ok(self):

    print "value is", self.e.get()
    self.top.destroy()

    root = Tk()
    Button(root, text="Hello!").pack()
    root.update()

    d = MyDialog(root)

    root.wait_window(d.top)

    When I run it IDLE

    gives me this

    Traceback (most recent call last):
    File "C:/Python24/dialog1.py", line 29, in -toplevel-
    d = MyDialog(root)
    NameError: name 'MyDialog' is not defined

    I have a feeling this is something very simple, but I cannot figure it out.
    Help!
     
    Valone, Toren W., Feb 2, 2005
    #2
    1. Advertising

  3. Valone, Toren W. wrote:
    > Traceback (most recent call last):
    > File "C:/Python24/dialog1.py", line 29, in -toplevel-
    > d = MyDialog(root)
    > NameError: name 'MyDialog' is not defined


    Suggestion: Read the place in your code where MyDialog is defined and compare it
    with where it is used. Check case. You'll find the problem :)

    --
    Timo Virkkala
     
    Timo Virkkala, Feb 3, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John sorCrer
    Replies:
    1
    Views:
    745
    Alvin Bruney [MVP]
    Mar 4, 2004
  2. Bob
    Replies:
    3
    Views:
    471
    dorayme
    May 21, 2005
  3. iamaran
    Replies:
    1
    Views:
    430
    iamaran
    Dec 23, 2005
  4. Mersh
    Replies:
    0
    Views:
    512
    Mersh
    Mar 13, 2007
  5. Ganesh
    Replies:
    0
    Views:
    571
    Ganesh
    Jun 29, 2007
Loading...

Share This Page