471,319 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Help a newb with a "global name 'interactions' is not defined" problem

Ok so I just started to program with Python about a week ago and I am trying to make a program that will take the path of a file and a shortcut command and save it to a text file. Eventually I want to have a little command line box that sits on the desktop that I can execute those commands from but that is for another day. At the moment I am just trying to figure out how to put the code together but I keep getting into trouble when I try to use one method within another, especially when I import one from another class. I am using PythonCard ontop of wxPython if that matters at all.

When I use on_browseBtn_mouseClick(self, event): I get the error. It says in interactions.appendShortcutList(shortcutList, r, v) Name Error: "global name 'interactions' is not defined. Any help with anything would be great.


from PythonCard import dialog, model
import os
import interactions

class QuickRun(model.Background):
def on_initialize(self, event):
shortcutList = 'storage.txt'
def on_browseBtn_mouseClick(self, event):
self.components.status.text = "Please remember to save."
result = dialog.directoryDialog(self, 'Choose a directory', 'a')
self.components.filePath.text = result.path
def on_saveBtn_mouseClick(self, event):
r = self.components.filePath.text
v = self.components.shortcutInput.text
interactions.appendShortcutList(shortcutList, r, v)
self.components.status.text = "Saved!"
if __name__ == '__main__':
app = model.Application(QuickRun)


class Interactions:
def _init_(self):
def appendShortcutList(self, storage, paths, commands):
f = open(storage, 'a')
s = "%s - %s\n" % (paths, commands)
def viewShortcutList(self, x):
f = open(x, 'r')
display = f.readlines()
print display
I have alot more questions but I will refrain from asking them for now. I am just starting to program so any general tips or points where I am making mistakes would help. Thanks
Aug 20 '06 #1
1 12261
You have named your class Interactions. In your main script, you are calling for the class interactions. Compare.. Interactions ! = interactions.
Also, is this a project you are doing for kicks? If you you need such a utility, slickrun does what you have described, almost to the letter. Of course, Slickrun is a windows only app. ;)
Aug 23 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.