<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python Toolbox vs Addin - How to reference an image/icon for the tkinter app? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-vs-addin-how-to-reference-an-image/m-p/1319986#M72232</link>
    <description>&lt;P&gt;We created a tkinter app using a python toolbox. In this tkinter app we are able to change the photo in the header of the app using this code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;app = Tk("SAMPLE")
file_name = r'Images\\icon.png'
current_dir = pathlib.Path(__file__).parent.resolve() 
img_path = os.path.join(current_dir, file_name)
photo = PhotoImage(file = img_path)
app.iconphoto(False, photo)
app.mainloop()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;However, we would like to use this as an Addin. We followed these instructions:&amp;nbsp;&lt;A title="Part 1" href="https://www.youtube.com/watch?v=70niqCcVAZM" target="_self"&gt;https://www.youtube.com/watch?v=70niqCcVAZM&lt;/A&gt;&amp;nbsp;This worked fine until we inserted the lines 2-6 in above code. With these lines, the Addin won't start at all. We referenced the python-toolbox like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string installPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string toolboxPath = Path.Combine(installPath, "Sample.pyt\\Tool");
Geoprocessing.ExecuteToolAsync(toolboxPath, null, null, null, null, GPExecuteToolFlags.GPThread);&lt;/LI-CODE&gt;&lt;P&gt;Within the Config.daml file of the Addin, we use the exact same icon using this reference:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;controls&amp;gt;
        &amp;lt;button id="Button1" caption="Caption" className="Button1" loadOnClick="true" smallImage="pack://application:,,,/Caption;component/Images/icon.png" largeImage="pack://application:,,,/Caption;component/Images/icon2.png"&amp;gt;
          &amp;lt;tooltip heading="Tooltip Heading"&amp;gt;Caption&amp;lt;disabledText /&amp;gt;&amp;lt;/tooltip&amp;gt;
        &amp;lt;/button&amp;gt;
&amp;lt;/controls&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;I already tried to use the reference of the second code snippet in the first one. But unsurprisingly, it failed. Can anyone explain how I need to reference a .png-file used in tkinter in a python-toolbox which is referenced in an addin?&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2023 07:28:57 GMT</pubDate>
    <dc:creator>nadja</dc:creator>
    <dc:date>2023-08-18T07:28:57Z</dc:date>
    <item>
      <title>Python Toolbox vs Addin - How to reference an image/icon for the tkinter app?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-vs-addin-how-to-reference-an-image/m-p/1319986#M72232</link>
      <description>&lt;P&gt;We created a tkinter app using a python toolbox. In this tkinter app we are able to change the photo in the header of the app using this code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;app = Tk("SAMPLE")
file_name = r'Images\\icon.png'
current_dir = pathlib.Path(__file__).parent.resolve() 
img_path = os.path.join(current_dir, file_name)
photo = PhotoImage(file = img_path)
app.iconphoto(False, photo)
app.mainloop()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;However, we would like to use this as an Addin. We followed these instructions:&amp;nbsp;&lt;A title="Part 1" href="https://www.youtube.com/watch?v=70niqCcVAZM" target="_self"&gt;https://www.youtube.com/watch?v=70niqCcVAZM&lt;/A&gt;&amp;nbsp;This worked fine until we inserted the lines 2-6 in above code. With these lines, the Addin won't start at all. We referenced the python-toolbox like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string installPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string toolboxPath = Path.Combine(installPath, "Sample.pyt\\Tool");
Geoprocessing.ExecuteToolAsync(toolboxPath, null, null, null, null, GPExecuteToolFlags.GPThread);&lt;/LI-CODE&gt;&lt;P&gt;Within the Config.daml file of the Addin, we use the exact same icon using this reference:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;controls&amp;gt;
        &amp;lt;button id="Button1" caption="Caption" className="Button1" loadOnClick="true" smallImage="pack://application:,,,/Caption;component/Images/icon.png" largeImage="pack://application:,,,/Caption;component/Images/icon2.png"&amp;gt;
          &amp;lt;tooltip heading="Tooltip Heading"&amp;gt;Caption&amp;lt;disabledText /&amp;gt;&amp;lt;/tooltip&amp;gt;
        &amp;lt;/button&amp;gt;
&amp;lt;/controls&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;I already tried to use the reference of the second code snippet in the first one. But unsurprisingly, it failed. Can anyone explain how I need to reference a .png-file used in tkinter in a python-toolbox which is referenced in an addin?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 07:28:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-toolbox-vs-addin-how-to-reference-an-image/m-p/1319986#M72232</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2023-08-18T07:28:57Z</dc:date>
    </item>
  </channel>
</rss>

