Search code examples
pythonpyforms

Pyforms AttributeError: ‘module’ object has no attribute ‘start_app’


After installing pyforms on my Raspberry Pi 3 i tried running the example i found on readthedocs, but the application is throwing an AttributeError (I tried both python2 and python3)


Python Code

import pyforms
from   pyforms          import BaseWidget
from   pyforms.Controls import ControlText
from   pyforms.Controls import ControlButton

class SimpleExample1(BaseWidget):

    def __init__(self):
        super(SimpleExample1,self).__init__('Simple example 1')

        #Definition of the forms fields
        self._firstname     = ControlText('First name', 'Default value')
        self._middlename    = ControlText('Middle name')
        self._lastname      = ControlText('Lastname name')
        self._fullname      = ControlText('Full name')
        self._button        = ControlButton('Press this button')


#Execute the application
if __name__ == "__main__":   pyforms.start_app( SimpleExample1 )

Error:

Traceback (most recent call last):
  File "PiControl.py", line 20, in <module>
    if __name__ == "__main__":   pyforms.start_app( SimpleExample1 )
AttributeError: ‘module’ object has no attribute ‘start_app’


Edit:

I tried to import start_app manually with

from pyforms.gui.standaloneManager import start_app

but then I get another ImportError:

Traceback (most recent call last):
  File "PiControl.py", line 4, in <module>
    from   pyforms.gui.standaloneManager import start_app
ImportError: cannot import name 'start_app'

Solution

  • This is very strange behavior and possibly means that your installation is broken. Try to install the latest versions from a repo:

    pip install -U git+https://github.com/UmSenhorQualquer/pyforms.git 
    pip install -U git+https://github.com/UmSenhorQualquer/pysettings.git
    pip install -U git+https://bitbucket.org/fchampalimaud/logging-bootstrap.git