Pyforms AttributeError:“模块”对象没有属性“start\u app”

2024-05-18 23:44:29 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的Raspberry pi3上安装了pyforms之后,我尝试运行在readthedocs上找到的示例,但是应用程序抛出了一个AttributeError(我尝试了python2和python3)


Python代码

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 )

错误:

^{pr2}$

编辑:

我试图用手动导入start_app

from pyforms.gui.standaloneManager import start_app

但是我又得到了一个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'

Tags: thenamefromimportselfappinitbutton
2条回答

在阅读了pyforms的github站点之后,我了解到它是一个web框架。 所以我认为它会像其他web框架一样。错误提示“module”没有“start_app”方法,因此我认为您可能没有声明应用程序实例。“start_app”应该属于web应用程序实例。 可能是错了,因为我没看过文件。在

这是非常奇怪的行为,可能意味着您的安装已损坏。尝试从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

相关问题 更多 >

    热门问题