AnsweredAssumed Answered

Copying XY to clipboard using Python Add-In

Question asked by p2879k on Oct 22, 2014
Latest reply on Oct 24, 2014 by Hornbydd

Hi guys,


I am trying to create a simple tool to copy XY from where i click the mouse button. What i have done already is:


1. create add-in files using Python Add-In Wizard

2. create toolbar and tool inside it


in *.py file i got:


import arcpy import pythonaddins import win32clipboard as clipboard   class p_tool(object):     """Implementation for python-add-in-proj_addin.tool (Tool)"""     def __init__(self):         self.enabled = True         self.shape = "NONE"      def onMouseDownMap(self, x, y, button, shift):         button = 1         shift  = 2         clipboard.OpenClipboard()         clipboard.EmptyClipboard()         xy = str(x1)+' '+str(y1)         clipboard.SetClipboardData(xy, clipboard.CF_TEXT)         clipboard.closeClipboard()         message = xy         pythonaddins.MessageBox(message, "My Coordinates", 0) 



About win32clipboard - i tested in in python windon in ArcMap and I am able to import it and openclipboard() but emptyclipboard() does not work and gives me that error:


File "<string>", line 1, in <module>

error: (1418, 'EmptyClipboard', 'Thread does not have a clipboard open.')


thanks for your help!