Select to view content in your preferred language

python addin enable/disable button

3540
2
Jump to solution
07-24-2017 08:29 AM
ChrisHolmes
Frequent Contributor

Hello,

I have a python addin which has a combobox and a series of buttons. I added some code so that depending upon what's selected from the combobox, the buttons are either enabled or disabled. It's working fine except for one button (cleanupdatabtn). In all cases this button does not enable or disable. I've checked many times and the spelling is correct. I'm at a bit of a loss for what I'm missing, maybe someone can see something here that I don't.

Thanks!

class ApplicationType(object):
    """Implementation for PlanningTools_addin.applicationtypecmb (ComboBox)"""
    def __init__(self):
        self.items = ['Community Boundary Change','Development Permit','Disposal of Reserve',
                      'Land Use Amendment','New Community Proposal','Outline Plan','Road Closure',
                      'SDAB','Street Name Change','Subdivision','Export Map Window as JPEG']
        #self.text = 'Select Application Type'
        self.editable = True
        self.enabled = True
        self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWW'
        self.width = 'WWWWWWWWWWWWWWWWWWWW'
    def onSelChange(self, selection):
        #pythonaddins.MessageBox(selection,'text in combobox',0)
        if selection in ('Community Boundary Change','Development Permit','Disposal of Reserve',
                         'New Community Proposal','Outline Plan','Road Closure',
                         'SDAB','Street Name Change','Subdivision'):
            setupprojectbtn.enabled = True
            setupparcelbtn.enabled = False
            reviewmapbtn.enabled = False
            createimagebtn.enabled = False
            cleanupdatabtn.enabled = True
        elif selection == 'Land Use Amendment':
            setupprojectbtn.enabled = True
            setupparcelbtn.enabled = True
            reviewmapbtn.enabled = True
            createimagebtn.enabled = True
            cleanupdatabtn.enabled = False
        elif selection == 'Export Map Window as JPEG':
            setupprojectbtn.enabled = False
            setupparcelbtn.enabled = False
            reviewmapbtn.enabled = False
            createimagebtn.enabled = True
            cleanupdatabtn.enabled = False
        else:
            pythonaddins.MessageBox('something is wrong','e',0)
0 Kudos
1 Solution

Accepted Solutions
ChrisHolmes
Frequent Contributor

Figured it out. The button createimagesbtn, I was referencing it as createimagebtn. So the code was puking out before it ever got to cleanupdatabtn. Only noticed it by accident when I happened to have the python window open in arcmap and the error showed there.

View solution in original post

0 Kudos
2 Replies
ChrisHolmes
Frequent Contributor

Here is the code for the buttons. I cannot figure out why the one button will not enable/disable.

class CleanUpData(object):
    """Implementation for PlanningTools_addin.cleanupdatabtn (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        #pass
        #pythonaddins.MessageBox('Clean up data button clicked','title',0)
        processButton('CleanUpData')
class CreateImages(object):
    """Implementation for PlanningTools_addin.createimagesbtn (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        #pass
        #pythonaddins.MessageBox('Create images button clicked','title',0)
        processButton('CreateImages')
class ReviewMap(object):
    """Implementation for PlanningTools_addin.reviewmapbtn (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        #pass
        #pythonaddins.MessageBox('Review map button clicked','title',0)
        processButton('ReviewMap')
class SetupParcel(object):
    """Implementation for PlanningTools_addin.setupparcelbtn (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        #pass
        #pythonaddins.MessageBox('Setup parcel button clicked','title',0)
        processButton('SetupParcel')
class SetupProject(object):
    """Implementation for PlanningTools_addin.setupprojectbtn (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        #pass
        #pythonaddins.MessageBox('Setup project button clicked','title',0)
        processButton('SetupProject')
0 Kudos
ChrisHolmes
Frequent Contributor

Figured it out. The button createimagesbtn, I was referencing it as createimagebtn. So the code was puking out before it ever got to cleanupdatabtn. Only noticed it by accident when I happened to have the python window open in arcmap and the error showed there.

0 Kudos