Python PyInstaller Tkinter Button Tied to Messagebox Does Nothing
<p>I have a tiny button with a question mark in my app. When clicked, it displays the doc string from a function in my app which helps to explain what the app does.</p>

<p>The problem is, I build a single .exe using pyinstaller and this question mark button does nothing when clicked.</p>

<p><strong>Recreation Steps</strong></p>

<ol>
<li>save the file below as run.py</li>
<li>open command-prompt</li>
<li>paste <code>pyinstaller.exe --onefile --windowed run.py</code></li>
<li>go to <code>dist</code> folder and run single exe</li>
<li>click <code>?</code> button and notice it does nothing</li>
</ol>

<p>run.py below</p>

<pre><code>import tkinter as tk
from tkinter import ttk

''' pyinstaller.exe --onefile --windowed run.py '''

def someotherfunction():
  '''
  This is some message that I
  want to appear but it currently doesn\'t
  seem to work

  when I put try to launch a messagebox
  showinfo window...
  '''
  pass

def showhelpwindow():
  return tk.messagebox.showinfo(title='How to use this tool',
                         message=someotherfunction.__doc__)

root = tk.Tk()
helpbutton = ttk.Button(root, text='?', command=showhelpwindow, width=2)
helpbutton.grid(row=0, column=3, sticky='e')
root.mainloop()
</code></pre>

<p>My setup:</p>

<ul>
<li>PyInstaller 3.2</li>
<li>Windows 7</li>
<li>Python 3.4.2</li>
</ul>

<p>I tried adding <a href="http://stackoverflow.com/questions/28349359/pyinstaller-single-file-executable-doesnt-run"><code>--noupx</code></a> option but that didn't fix it.</p>

<p>EDIT:</p>

<p>I removed <code>--windowed</code> option this time and the console is now showing me an error when I click this button.</p>

<pre><code>Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter\__init__.py", line 1533, in __call__
  File "run.py", line 156, in showhelpwindow
AttributeError: 'module' object has no attribute 'messagebox'
</code></pre>

<p>Line 3 below is the solution. I needed to import the <code>tkinter.messagebox</code> module explicitly.</p>

<pre><code>import tkinter as tk
from tkinter import ttk
import tkinter.messagebox

''' pyinstaller.exe --onefile --windowed run.py '''

def someotherfunction():
  '''
  This is some message that I
  want to appear but it currently doesn\'t
  seem to work

  when I put try to launch a messagebox
  showinfo window...
  '''
  pass

def showhelpwindow():
  return tk.messagebox.showinfo(title='How to use this tool',
                         message=someotherfunction.__doc__)

root = tk.Tk()
helpbutton = ttk.Button(root, text='?', command=showhelpwindow, width=2)
helpbutton.grid(row=0, column=3, sticky='e')
root.mainloop()
</code></pre>

python tkinter messagebox pyinstaller