2

I'm trying to figure out a way to display an image in a dialog box that will be used for a help menu for my toolbar addins.

The best scenario i've found is using the pythonaddins module and the messagebox popup, but can't figure out how to any formatting, except pure text string.

Is there another way to display information that i can call via a button click.

  • 2
    Python Add-Ins are pretty limited on this type of functionality. Since you are wanting to create help content, perhaps it would be easier to create an HTML page and open that when the user clicks on a button? You wouldn't even need to host it from a web server, you could just package it up in the install folder. – crmackey Nov 2 '15 at 16:18
  • Ah cheers, will go that route, I thought about using html earlier but couldn't find any information on opening up a html from a button onclick? Cheers for the quick response – cmca Nov 2 '15 at 16:32
  • 2
    That part is easy. For your onClick() method, you can use the builtin webbrowser module to call the HTML file: webbrowser.open(r'path\to\your\help_page.html'). If you package this up in the install folder where the script resides, it is very easy to make it find it from the relative path. – crmackey Nov 2 '15 at 16:45
  • 1
    @crmackey Your comments look worth writing up as a short answer. – PolyGeo Nov 8 '15 at 23:22
  • @PolyGeo, thanks. I have summarized my comments into a short answer. – crmackey Nov 9 '15 at 14:06
3

As per my comments, I think making a simple HTML page to serve as help documentation would be the easiest solution. Python Add Ins are fairly limited with pop up options. The HTML page wouldn't need to be hosted on a web server and can just be included in the install directory of the Add In and use relative paths to open this when the onClick() method is invoked.

The HTML doc can easily be opened using the builtin webbrowser module. So if you have a structure like this:

Your_AddIn_Name
    \install
        Your_AddIn_Name.py
        help.html

You can open your help.html file in a web browser by adding this to your onClick() method:

# Your_AddIn_Name.py
import webbrowser
# code...
class SomeToolClass(object):
    # code...
    def onClick(self):
        webbrowser.open('help.html')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.