2

I have a help pop up dialog that works fine in Linux and Windows where Python 3.5.x is installed but after a pyinstaller build the rest of the app works fine but that pop up is just an empty form void of all five of its widgets. I can’t see anything wrong with the code I’ve tried to remove widgets one at a time to see if any of them is a problem yet same result works before building and fails after

from tkinter import *
from tkinter import ttk

from tkinterhtml import TkinterHtml as tkhtml


class HelpSystem(Toplevel):
    def __init__(self, parent, dlgTitle='Help', helpfile='help.db',
                 Manuals=None, showtopic=None):
        Toplevel.__init__(self, parent)
        self.transient(parent)
        self.parent = parent
        self.title(dlgTitle)
        self.con = sqlite3.connect(helpfile)
        self.cur = self.con.cursor()
        self.helpfile = helpfile
        self.Manuals = Manuals
        self.showtopic = showtopic
        self.searchresults = []
        self.searchindex = -1
        self.search_width = 67
        self.tree_height = 19
        body = Frame(self)
        self.initial_focus = self.Dialog_Builder(body)
        body.pack()
        self.grab_set()
        if not self.initial_focus:
            self.initial_focus = self
        self.protocol("WM_DELETE_WINDOW", self.exitme)
        self.initial_focus.focus_set()
        self.wait_window(self)

    def Dialog_Builder(self, mybody):
        self.sbox = Entry(mybody, width=self.search_width,
                          font=('Helvetica', 15))
        self.sbuts = Button(mybody, text='Search',
                            command=lambda: self.btnClick('s'))
        self.sbutn = Button(mybody, text='Next',
                            command=lambda: self.btnClick('n'))
        ff = self._font_details('Helvetica', 15)
        self.toc = ttk.Treeview(mybody, show='tree', height=self.tree_height,
                                selectmode=BROWSE)
        self.toc.bind('<ButtonRelease-1>', self._clicktopic)
        self.style = ttk.Style()
        self.style.configure('Treeview', font=("Helvetica", 15))
        self.style.configure('Treeview', rowheight=ff[1])
        self.toc.column('#0', width=(ff[0] * 20))
        self.vwr = tkhtml(mybody, height=ff[1] * self.tree_height)
        self.sbox.grid(column=0, row=0, columnspan=8, rowspan=1, padx=5,
                       pady=5, sticky=W)
        self.sbuts.grid(column=8, row=0, columnspan=1, rowspan=1, padx=5,
                        pady=5, sticky=W)
        self.sbutn.grid(column=9, row=0, columnspan=1, rowspan=1, padx=5,
                        pady=5, sticky=W)
        self.toc.grid(column=0, row=1, columnspan=3, rowspan=1, padx=5, pady=5,
                      sticky=NW)
        self.vwr.grid(column=3, row=1, columnspan=7, rowspan=1, padx=5, pady=5,
                      sticky=NW)
Noctis Skytower
  • 21,433
  • 16
  • 79
  • 117
Kevin
  • 157
  • 1
  • 1
  • 7
  • do you get error message when you run in console/terminal/cmd.exe ? – furas Jan 17 '18 at 23:32
  • 1
    To make code more readable see [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/) – furas Jan 17 '18 at 23:33
  • Don’t know why I didn’t think of trying running from terminal yes there is an error: File "tkinterhtml/__init__.py", line 34, in __init__ File "tkinterhtml/__init__.py", line 22, in load_tkhtml tkinter.TclError: can't find package Tkhtml – Kevin Jan 18 '18 at 01:02
  • I have tried it without tkinterhtml sending the output to a temp file and using webbrowser.open() instead of tkinterhtml but I got no widgets showing then as well. I can try that again tomorrow and run it from terminal to see what error it gives but I'd prefer to display the results in my app over sending it to a web browser – Kevin Jan 18 '18 at 01:07
  • Unlike last time where the form still was empty: this time removing all references to tkinterhtml displayed the other four widgets before and after pyinstaller build. Last time I redirected the data to a webbrowser this time I just ignored the data making the pop up dialog useless. Apparently webbrowser doesn't work in the build as well. Does anyone know how I can get Tkhtml working in a pyinstaller build? – Kevin Jan 18 '18 at 14:07
  • pyinstaller (and similar programs) is not ideal and sometimes it can't find all modules which it has to add to project but you can create config file and manually add needed modules - you have to read documentation. Especially about [spec file](https://pyinstaller.readthedocs.io/en/stable/spec-files.html) – furas Jan 18 '18 at 14:16
  • BTW: error message always put in question, not in comment. It will be more readable. You error shows that pyinstaller didn't add tkhtml module to project. – furas Jan 18 '18 at 14:19
  • I have tried to use --add-binary 'tkhtml.so' it did not help – Kevin Jan 18 '18 at 15:10
  • why do you think it has to be `tkhtml.so` and not `libtkhtml.so` nor `libtkhtml.3.0.so` nor anything else ? – furas Jan 18 '18 at 19:57
  • using Google I found source code and this https://bitbucket.org/aivarannamaa/tkinterhtml/src/aaa7ccff86cce9def2d311d76b81a14e4b3a5916/tkinterhtml/tkhtml/Linux/64-bit/Tkhtml/?at=master You could do the same. BTW: You could also use full path in pyinstaller. – furas Jan 18 '18 at 20:05
  • I had tried libtkhtml.3.0.so as well – Kevin Jan 18 '18 at 22:06
  • You don't understand - I put `libtkhtml.3.0.so` only as example - you have to find correct name. Don't guess it. You can search on your disk, or in source code in repo (see link in previous comment) – furas Jan 18 '18 at 22:09
  • I didn't guess it I found the file in my Python 3.5x library folder and copied it to my folder with my source code. – Kevin Jan 18 '18 at 22:45

0 Answers0