Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Error w/ Add-In

$
0
0
I am writing an Add-In of a Toolbox with Buttons that open certain folders or files. These file aid in data entry. I can get my buttons to show up but they are not working. Is it I cannot use the os library in my burron classes? Do I haveto import it some special way or add it to the XML file someway? I used the Add-In Wizard. I get this error in the Python Window in my MXD:

Code:

>>>
Traceback (most recent call last):
  File "C:\Documents and Settings\me\Local Settings\Application Data\ESRI\Desktop10.1\AssemblyCache\{blahblah}\ZoningMapLookup_addin.py", line 10, in onClick
    class button1959(object):
NameError: global name 'os' is not defined

This is my code for the addin:
Code:

import arcpy
import pythonaddins
from os import *

def openLink(link):
    """Opens a link up in Windows' default program for extension"""
    startfile(link)
    return 0

class button1959(object):
    """Implementation for b1959.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        openLink(r"\\fullfilepathhere\\")

class button1972(object):
    """Implementation for b1972.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        openLink(r"\\fullfilepathhere\\")


Viewing all articles
Browse latest Browse all 2485

Trending Articles