alejandroautalan / pygubu

A simple GUI builder for the python tkinter module
MIT License
2.04k stars 214 forks source link

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

Closed cddrgn closed 2 years ago

cddrgn commented 2 years ago

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.

cddrgn commented 2 years ago

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 ""

alejandroautalan commented 2 years ago

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

Regards Alejandro A.

cddrgn commented 2 years ago

Hey Alejandro, no problem on timing. I thought perhaps we needed a new compile to make it work.

Thx again! Really a lot of potential in this product. I’m getting up to speed on tkinter, but if I can help in any way, let me know.

Will Richmond @.*** 971.235.4848

On Sep 3, 2022, at 23:05, Alejandro Autalán @.***> wrote:

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

Regards Alejandro A.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.