alejandroautalan/pygubu

code script generation with boolean checkbox results on string output, which throws error in tKinter

cddrgn opened this issue · 3 comments

Keep up the awesome work on Pygubu! its a great and much needed tool. Found one minor bug:

When i choose boolean for my checkbutton type, and run the resultant code, Python throws and error, about the boolean being null or ""

File "C:\Program Files\Python310\lib\tkinter_init_.py", line 614, in set

return self._tk.globalsetvar(self._name, self._tk.getboolean(value))

_tkinter.TclError: expected boolean value but got ""

When I create the button object, im using either Tk or Ttk button and they both generate this in code, as an example button:

    self.chkRunProd = ttk.Checkbutton(self.frmRunMethods)

    self.bRunProd = tk.BooleanVar(value="")

    self.chkRunProd.configure(

        state="normal",

        takefocus=True,

        text="<= Run in Production (Dev=Off)",

        variable=self.bRunProd,

    )

    self.chkRunProd.grid(column=0, padx=6, pady=2, row=0, sticky="nw")

notice PyGubu makes tk.BooleanVar(value="") in code, which is throwing the error. if i manually change this to True/False, or remove it altogehter, code runs fine. Should probably default to False or just remove the (value="") default var value. It seems more of a designer bug, rather than pygubu. but should be an easy fix.

hi alejandro, i just tried to rebuild UI tkinter code after updating the builderobject.py file. that failed to produce any code on the code script window. i then uninstalled and reinstalled pygubu and pygubu-designer via pip to get the new files - hopefully. I now have this installed, in addition to other packages:

C:\WINDOWS\system32>pip list
Package Version


pygubu 0.24.2
pygubu-designer 0.29.1

when i build the code, create a .pyw app file from this code and run it, it still fails in the exact way:

Traceback (most recent call last):
File "C:\Program Files\Python310\lib\tkinter_init_.py", line 614, in set
return self._tk.globalsetvar(self._name, self._tk.getboolean(value))
_tkinter.TclError: expected boolean value but got ""

Hello. Sorry for the inconvenience. The issue is fixed in the master branch only.
I will make a new release ASAP.

Regards
Alejandro A.