0

I built a python addin for Arcmap and I need to print a folder path to a combo box, which should be a destination folder to copy my *.gdb file.

enter image description here

After a click on a "Backup" button this tool should copy my file to a folder on the right. But still I don't know how to figure that out. The only thing I can see is to read the last thing in Arcmap's python window and probably set it as input for a button.

enter image description here

But still have no idea even how to perform it.

EDIT:

I was changing only lines in python script, config.xml was made by default. Here is a piece of code:

import arcpy
import pythonaddins
class Backup(object):
 """Implementation for BackupServer_addin.Backup (Button)"""
 def __init__(self):
 self.enabled = True
 self.checked = False
 def onClick(self):
 if "" in BackupServer_addin.Folder.self.items:
 print self.items
class Folder(object):
 """Implementation for BackupServer_addin.Folder (ComboBox)"""
 def __init__(self):
 self.items = [""]
 self.editable = True
 self.enabled = True
 self.dropdownWidth = 'WWWWWW'
 self.width = 'WWWWWW'
 def onSelChange(self, selection):
 print "New Selection:",selection
 def onEditChange(self, text):
 print "Edit Change:",text
 def onFocus(self, focused):
 pass
 def onEnter(self):
 print "Current Value:",self.value
 def refresh(self):
 pass

This string is just a try to make a reference to the Folder combobox if "" in BackupServer_addin.Folder.self.items:

Here are the contents of config.xml:

<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Name>Python Addin</Name><AddInID>{413e6443-7e28-43e0-832a-33730a790ca4}</AddInID><Description>New Addin</Description><Version>0.1</Version><Image /><Author>Untitled</Author><Company>Untitled</Company><Date>02/03/2017</Date><Targets><Target name="Desktop" version="10.2" /></Targets><AddIn language="PYTHON" library="BackupServer_addin.py" namespace="BackupServer_addin"><ArcMap>
 <Commands>
 <Button caption="Backup" category="Python Addin" class="Backup" id="BackupServer_addin.Backup" image="Images\backup.png" message="Backup" tip="Backup"><Help heading="Backup">Backup</Help></Button>
 <ComboBox caption="Folder" category="Python Addin" class="Folder" id="BackupServer_addin.Folder" itemSizeString="WWWWWW" message="Folder" rows="4" sizeString="WWWWWW" tip="Folder"><Help heading="Folder">Folder</Help></ComboBox>
 </Commands>
 <Extensions>
 </Extensions>
 <Toolbars>
 <Toolbar caption="Toolbar" category="Python Addin" id="BackupServer_addin.toolbar" showInitially="true"><Items><Button refID="BackupServer_addin.Backup" /><ComboBox refID="BackupServer_addin.Folder" /></Items></Toolbar>
 </Toolbars>
 <Menus>
 </Menus>
 </ArcMap></AddIn></ESRI.Configuration>
asked Feb 3, 2017 at 8:01
4
  • What does your code to do what you describe look like? i.e. both the config.xml and your Python script. Commented Feb 3, 2017 at 9:30
  • @PolyGeo updated the question Commented Feb 3, 2017 at 9:40
  • Can you include the config.xml too, please? Commented Feb 3, 2017 at 9:42
  • @PolyGeo updated Commented Feb 3, 2017 at 9:52

1 Answer 1

1

Just found a solution: making of global parameter and putting it firstly into combo box parameters and then to button's:

Combobox:

class FolderPath(object):
 """Implementation for BackupPlus_addin.FolderPath (ComboBox)"""
 def __init__(self):
 self.items = [""]
 self.editable = True
 self.enabled = True
 self.dropdownWidth = 'WWWWWW'
 self.width = 'WWWWWW'
 def onSelChange(self, selection):
 print "New Selection:",selection
 def onEditChange(self, text):
 print "Edit Change:",text
 global fc
 fc = text
 def onFocus(self, focused):
 pass
 def onEnter(self):
 print "Current Value:",self.value
 def refresh(self):
 pass

Button:

class BackupToFolder(object):
 """Implementation for BackupPlus_addin.BackupToFolder (Button)"""
 def __init__(self):
 self.enabled = True
 self.checked = False
 def onClick(self):
 import arcpy
 import os
 import time
 from arcpy import env
 mxd = arcpy.mapping.MapDocument("CURRENT")
 df = mxd.activeDataFrame
 arcpy.env.overwriteOutput=True
 global fc 
 #some code
answered Feb 3, 2017 at 14:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.