473,372 Members | 898 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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.

quickRun.py
--------------------

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)
app.MainLoop()

interactions.py
----------------------

class Interactions:
def _init_(self):
pass
def appendShortcutList(self, storage, paths, commands):
f = open(storage, 'a')
s = "%s - %s\n" % (paths, commands)
f.write(s)
f.close()
def viewShortcutList(self, x):
f = open(x, 'r')
display = f.readlines()
print display
f.close()
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 12438
dpal
6
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

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

Similar topics

4
by: Dmitry | last post by:
Hello, Sometimes on js code execution Mozilla 1.5 prints in JS concole the following error: "Error: fn is not defined" where "fn" is the function name surely defined _before_ the line that...
2
by: PKuhne | last post by:
When pasting this code from the MS small Business Accounting Beta Concepts manual: DIM skdAssembly as = .LoadFrom(installpath.ToString()) the IDE shows : "Type 'Assembly' not defined" and...
0
by: Ganesh Muthuvelu | last post by:
Hello, What is wrong with this simple schema. When I try to load it to a dataset it gives me an error, "Data type not defined" Thanks. ****************************** <?xml version="1.0"...
0
by: wan | last post by:
Hi, Any idea of why a proper running Application in VS 2003 , could not run after converted to VS 2005 with the error "Could not load file or assembly , . Strong name validation failed".... The...
1
by: Larax | last post by:
Alright, so here's the problem. I define a global variable in my script and then add methods/properties to it. Everything works great, no error in Javascript Console. But when I refresh site,...
12
by: M G Henry | last post by:
I have a tabbed form that contains 12 different "pages" and when I try and run the form I get the error message too many fields defined --- which I believe is the 255 field limit in the record...
6
by: newholborn | last post by:
Hi everyone. I have some questions, which should be rather easy to reply, but as I am working on PHP, JavaScript, XML, CSS, Photoshop and other stuff at the same time, my head, which is about to...
0
benchpolo
by: benchpolo | last post by:
I am currently modifying an existing DTS process by adding a new field in the Transformation task. This process queries data from SQL tables and import it to MSExcel. Steps 1. Drop the table...
2
by: jmike | last post by:
I'm using some legacy code that has a user-defined exception in it. The top level program includes this line from TestRunError import * It also imports several other modules. These other...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.