alejandroautalan/pygubu

Problem when trying to run the .ui application

nbro opened this issue · 3 comments

nbro commented

I have used the code you are suggestion to run my "hello.ui" file, but it's not working, and raises the exception "raise Exception('Widget not defined.')" at line 322 of your init.py file under /builder.

This is my hello.ui:

<?xml version='1.0' encoding='utf-8'?>
<interface>
  <object class="ttk.Frame" id="Frame_1">
    <property name="height">200</property>
    <property name="width">200</property>
    <layout>
      <property name="column">0</property>
      <property name="propagate">True</property>
      <property name="row">0</property>
    </layout>
    <child>
      <object class="ttk.Button" id="Button_1">
        <property name="text" translatable="yes">Button_1</property>
        <layout>
          <property name="column">0</property>
          <property name="propagate">True</property>
          <property name="row">0</property>
        </layout>
      </object>
    </child>
  </object>
</interface>

This is the code I am using to run the "hello.ui"

#test.py
import tkinter as tk
import pygubu

class Application:
    def __init__(self, master):

        #1: Create a builder
        self.builder = builder = pygubu.Builder()

        #2: Load an ui file
        builder.add_from_file('hello.ui')

        #3: Create the widget using a master as parent
        self.mainwindow = builder.get_object('mainwindow', master)


if __name__ == '__main__':
    root = tk.Tk()
    app = Application(root)
    root.mainloop()

I am running the application from the main folder of the project. I had also some problems in running the builder/designer, until I did not find the script under /bin in this github repository. I think you should clarify better how to run the builder/designer in your README file.

My OS is Darwin.

Apart from this, would be possible to contribute with my help to this project?

I was thinking also in developing something similar, but my knowledge of tkinter is still not so good, but I would like starting helping you in this project, of course if you don't mind.

If it's ok, it would be great if you could tell me more in details how can I understand better your application, how can study it further, how did you structure the project, so that I am also able to navigate through it without any problems.

Hi dossan, thanks for trying pygubu.

I have used the code you are suggestion to run my "hello.ui" file, but it's not working, and raises the exception "raise Exception('Widget not defined.')" at line 322 of your init.py file under /builder.

The problem here is that your main widget is a ttk.Frame with id = Frame_1, so in your code you must use

self.mainwindow = builder.get_object('Frame_1', master)

Either change the id in the designer or in your code.

I will try to improve the documentation but, in the mean time, there are some useful tips in the wiki about the usage of pygubu and the designer. https://github.com/alejandroautalan/pygubu/wiki

Apart from this, would be possible to contribute with my help to this project?
I was thinking also in developing something similar, but my knowledge of tkinter is still not so good, but I would like starting helping you in this project, of course if you don't mind.

If it's ok, it would be great if you could tell me more in details how can I understand better your application, how can study it further, how did you structure the project, so that I am also able to navigate through it without any problems.

Any contribution is welcome, if you want to change code, feel free to fork the project make your modifications and make pull requests (the github way of work)

I will try to make some docs about the structure of the project for developers but, until then, you can ask me for help.

Regards
Alejandro A.

docs for developers are needed, i alse want to improve it, but, my English is to bad, and unstand all the codes needs time.

Dbof commented

Same problem with your example 'hellowindow.ui'. Frame there has id 'mainframe', your code says 'mainwindow'.