I am relatively new to python (I have used it on and off for a few small
projects over the last few years) so I imagine that what I am trying to do
has already been done, but practical experience, even if it is reinventing
the wheel, is still useful, so...
I am trying to write a module to handle drop down menus using curses (on
linux). Curses seems to have a wrapper for the panels library, but not
forms, or menus. I am not even sure that the menus library would give me
what I want (as I also do not have much curses experience in other
languages), so I am writing my own module.
The code works fine if I include it with my application code in a singe
file. If I seperate out the menu class and related functions into a
seperate module, however, then when I try to have it call a funtion in the
man (calling) file I get an error saying:
Traceback (most recent call last):
File "./hp", line 62, in ?
curses.wrapper(main)
File "/usr/lib/python2.3/curses/wrapper.py", line 44, in wrapper
res = func(stdscr, *rest)
File "./hp", line 58, in main
mb.mainloop(items)
File "/home/mns/menu.py", line 258, in mainloop
exec cmd + "('" + name + "')"
File "<string>", line 1, in ?
NameError: name 'NOP' is not defined
'NOP' is the name of the function that I am trying to call. It does not
exist in the menu module, but is in the calling (hp) module. I can't
qualify the name (i.e. __main__.NOP() ) since __main__ can not be used for
qualification, only called module names can be used that way.
How do I get the module to call functions in a parent module. Tkinter
would set up a callback function and bind it to an event. Can something
similar be done for a console program using curses?
--
Marc Shapiro
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----