3

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'
Error404
  • 719
  • 9
  • 30
  • do you have any other file named pyforms in the same directory? – Abhishek P Aug 22 '17 at 08:55
  • @AbhishekP no, PiControl.py is the only file in the directory – Error404 Aug 22 '17 at 08:59
  • @Error404, if you import start_app manually, can you start an app? `from pyforms.gui.standaloneManager import start_app`. Check your `PYFORMS_MODE` environment variable: right before `start_app` do: `import os; print(os.environ.get('PYFORMS_MODE'))` – 9dogs Aug 22 '17 at 09:34
  • @9dogs the `PYFORMS_MODE` environment variable was unset, so i tried setting it to `GUI`, which produces the same result – Error404 Aug 22 '17 at 09:48
  • @9dogs importing `start_app` from `pyforms.gui.standaloneManager` produced an `ImportError` (see updated question) – Error404 Aug 22 '17 at 09:51
  • @Error404 This is strange... Do you have `git` available? Try installing latest versions from repo: `pip install git+https://github.com/UmSenhorQualquer/pyforms.git --upgrade` `pip install git+https://github.com/UmSenhorQualquer/pysettings.git --upgrade`, `pip install git+https://bitbucket.org/fchampalimaud/logging-bootstrap.git` – 9dogs Aug 22 '17 at 10:54
  • @9dogs That fixed the problem. Thanks! If you add this as an answer I will accept it. – Error404 Aug 22 '17 at 13:37

1 Answers1

3

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
Toshinou Kyouko
  • 334
  • 9
  • 21
9dogs
  • 1,446
  • 10
  • 18