Simple Class Question - need clarity please

Stevie_mac no.email at please.com
Fri Apr 9 19:53:46 EDT 2004


> Its a good idea to post the entire error traceback so we see the
> actual line of code the error refers to. This error usually means
> you accessed a name from a module without prefixing it with the
> module name. But so far as I can see you haven't done that here.

# mywindow.py #
import win32con, win32ui
from pywin.mfc import dialog #, window
class Window:
    def MakeDlgTemplate(self):
        style = win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION |
win32con.WS_SYSMENU | win32con.DS_SETFONT
        dlg = [ ["My Dialog", (0, 0, 100, 100), style, None, (8, "MS Sans Serif")], ]
        s = win32con.BS_PUSHBUTTON | win32con.WS_CHILD | win32con.WS_VISIBLE
        dlg.append([128, "Cancel", win32con.IDCANCEL, (55, 80, 40, 16), s])
        return dlg
    def DoModal(self):
        mw = win32ui.CreateDialogIndirect( self.MakeDlgTemplate() )
        mw.DoModal()

import mywindow
class MyClass(mywindow.Window):
    def Show(self):
        self.DoModal()

t = MyClass()
t.Show()

#ERROR OUTPUT
File "C:\My Python Stuff\window\test.py", line 7, in ?
    t.Show()
  File "C:\My Python Stuff\window\test.py", line 4, in Show
    self.DoModal()
  File "C:\My Python Stuff\window\mywindow.py", line 12, in DoModal
    mw = win32ui.CreateDialogIndirect( self.MakeDlgTemplate() )
NameError: global name 'MakeDlgTemplate' is not defined






More information about the Python-list mailing list