alejandroautalan / pygubu-designer

A simple GUI designer for the python tkinter module
GNU General Public License v3.0
800 stars 98 forks source link

Bind options and use #230

Closed wyzarddoc72 closed 5 months ago

wyzarddoc72 commented 7 months ago

*I have looked for information on how to use the bind options in the designer and have had no luck. Any help would be appreciated. Request --> A button or fill in the blank for text boxes so string text input could be done with less frustration thanks for all your hard work other than a few glitches the program works great.

alejandroautalan commented 7 months ago

Hello @wyzarddoc72 thanks for trying pygubu, and sorry for the late response.

The bindings panel

The purpose of this panel is to speed up the definition of bindings in the designer. To do this, the user must define three parameters:

Sequence descriptor: sequence or event to be associated with

Event handler: is the name of the function or method that will be called when the event is fired.

Add: Specifies that the handler will be added to the handler list associated with the same sequence or event.

Example

The ttk.Treeview widget raises a virtual event "\<\<TreeviewSelect>>" when the user selects a row from the treeview. To define in the designer a function that reacts when this event is executed, proceed as follows:

Captura desde 2024-02-11 03-27-28

If we generate the code with the "Application" template it will look similar to the following:

class BindingsApp:
    def __init__(self, master=None):
        self.builder = builder = pygubu.Builder()
        builder.add_resource_path(PROJECT_PATH)
        builder.add_from_file(PROJECT_UI)
        # Main widget
        self.mainwindow: tk.Toplevel = builder.get_object("toplevel1", master)
        builder.connect_callbacks(self)

    def run(self):
        self.mainwindow.mainloop()

    def on_row_selected(self, event=None):
        pass

The call to "builder.connect_callbacks(self)" connects the bindings to the generated methods.

In the generated "on_row_selected" method we write the code necessary to react to that event.

For more info about bingings see this page I hope this information helps you.

Regards Alejandro A.

wyzarddoc72 commented 7 months ago

Thanks so much for the reply. I decided I did not need the binding functionality after all.In future releases I would suggest a similar type of entry box for the button command so that options could be added/passed to the command thanks again

On Sunday, February 11, 2024 at 12:08:02 AM MST, Alejandro Autalán ***@***.***> wrote:  

Hello @wyzarddoc72 thanks for trying pygubu, and sorry for the late response.

The bindings panel

The purpose of this panel is to speed up the definition of bindings in the designer. To do this, the user must define three parameters:

Sequence descriptor: sequence or event to be associated with

Event handler: is the name of the function or method that will be called when the event is fired.

Add: Specifies that the handler will be added to the handler list associated with the same sequence or event.

Example

The ttk.Treeview widget raises a virtual event "<>" when the user selects a row from the treeview. To define in the designer a function that reacts when this event is executed, proceed as follows:

Captura.desde.2024-02-11.03-27-28.png (view on web)

If we generate the code with the "Application" template it will look similar to the following: class BindingsApp: def init(self, master=None): self.builder = builder = pygubu.Builder() builder.add_resource_path(PROJECT_PATH) builder.add_from_file(PROJECT_UI)

Main widget

    self.mainwindow: tk.Toplevel = builder.get_object("toplevel1", master)
    builder.connect_callbacks(self)

def run(self):
    self.mainwindow.mainloop()

def on_row_selected(self, event=None):
    pass

The call to "builder.connect_callbacks(self)" connects the bindings to the generated methods.

In the generated "on_row_selected" method we write the code necessary to react to that event.

For more info about bingings see this page I hope this information helps you.

Regards Alejandro A.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

wyzarddoc72 commented 6 months ago

Another use question --> I see colors in the generated file but not on my x windows?? How do I activate background colors?thanksDoc On Sunday, February 11, 2024 at 12:08:02 AM MST, Alejandro Autalán @.***> wrote:

Hello @wyzarddoc72 thanks for trying pygubu, and sorry for the late response.

The bindings panel

The purpose of this panel is to speed up the definition of bindings in the designer. To do this, the user must define three parameters:

Sequence descriptor: sequence or event to be associated with

Event handler: is the name of the function or method that will be called when the event is fired.

Add: Specifies that the handler will be added to the handler list associated with the same sequence or event.

Example

The ttk.Treeview widget raises a virtual event "<>" when the user selects a row from the treeview. To define in the designer a function that reacts when this event is executed, proceed as follows:

Captura.desde.2024-02-11.03-27-28.png (view on web)

If we generate the code with the "Application" template it will look similar to the following: class BindingsApp: def init(self, master=None): self.builder = builder = pygubu.Builder() builder.add_resource_path(PROJECT_PATH) builder.add_from_file(PROJECT_UI)

Main widget

    self.mainwindow: tk.Toplevel = builder.get_object("toplevel1", master)
    builder.connect_callbacks(self)

def run(self):
    self.mainwindow.mainloop()

def on_row_selected(self, event=None):
    pass

The call to "builder.connect_callbacks(self)" connects the bindings to the generated methods.

In the generated "on_row_selected" method we write the code necessary to react to that event.

For more info about bingings see this page I hope this information helps you.

Regards Alejandro A.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

wyzarddoc72 commented 6 months ago

Another use question --> I see colors in the generated file but not on my x windows?? How do I activate background / foreground colors? thanks Doc

wyzarddoc72 commented 5 months ago

Thanks for all your good information!!