alejandroautalan / pygubu

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

Trying to run functions from other classes on XML file #274

Closed lebao3105 closed 1 year ago

lebao3105 commented 1 year ago

I have some functions defined in other class than the main class where I placed the pygubu.Builder code. And I need to run one of them from a menu command:

<object class="tk.Menu" id="menu1">
   <child>
      <object class="tk.Menuitem.Command" id="new" named="True">
         <property name="command" type="command" cbtype="simple">fileops.new_tab</property>
         <property name="label" translatable="yes">New (Ctrl+N)</property>
       </object>
    </child>
</object>

And pygubu doesn't find out the specified command:

Missing callbacks for commands: ['fileops.new_tab']

I tried this too, and the program (and pygubu) returns nothing:

new = builder.get_object("new", master)
new.command = lambda: fileops.new_tab(self)
lebao3105 commented 1 year ago

I searched around the pygubu-designer wiki page and I've found this solution. Sorry to bother you this time