问题
This is my python file:
import pyforms
import pyside
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')
#Define the button action
self._button.value = self.__buttonAction
def __buttonAction(self):
"""Button action event"""
self._fullname.value = self._firstname.value +" "+ self._middlename.value + \
" "+ self._lastname.value
#Execute the application
if __name__ == "__main__":
pyforms.startApp( SimpleExample1 )
And I got an error in the __init__.py
file:
Traceback (most recent call last):
File "C:\Python27\Ashish\pyforms\1.py", line 1, in <module>
import pyforms
File "C:\Python27\lib\site-packages\pyforms\__init__.py", line 4, in <module>
from pysettings import conf;
ImportError: No module named pysettings
Here is my __init__.py
:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import logging
from pysettings import conf;
conf += 'pyforms.gui.settings'
__author__ = "Ricardo Ribeiro"
__credits__ = ["Ricardo Ribeiro"]
__license__ = "MIT"
__version__ = '0.1.7.3'
__maintainer__ = "Ricardo Ribeiro"
__email__ = "ricardojvr@gmail.com"
__status__ = "Production"
logger = logging.getLogger(__name__)
if conf.PYFORMS_MODE in ['GUI', 'GUI-OPENCSP']:
from pyforms.gui import Controls
from pyforms.gui.BaseWidget import BaseWidget
if conf.PYFORMS_MODE in ['GUI-OPENCSP']:
from pyforms.gui.appmanager import startApp
else:
from pyforms.gui.standaloneManager import startApp
elif conf.PYFORMS_MODE in ['TERMINAL']:
from pyforms.terminal import Controls
from pyforms.terminal.BaseWidget import BaseWidget
from pyforms.terminal.appmanager import startApp
elif conf.PYFORMS_MODE in ['WEB']:
from pyforms_web.web import Controls
from pyforms_web.web.BaseWidget import BaseWidget
from pyforms_web.web.appmanager import startApp
回答1:
You will need to download and install pysettings from https://github.com/UmSenhorQualquer/pysettings/tree/92bde8c680bc0a00ae97cc09bd4dab1b697d6ed2
来源:https://stackoverflow.com/questions/41216740/pyforms-cannot-import-conf-from-pysettings