Commit f96b3b0b authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch '19-compatible-with-py3' into 'master'

Now import is compatble with python3

Closes #19

See merge request !9
parents 452a0d34 ad4abe56
......@@ -52,5 +52,6 @@ from .qMyDesignGui import QMyDesignGui
# Import IOs
import myIOs
#import myIOs
from .myIOs import *
......@@ -10,9 +10,13 @@ for function in os.listdir(os.path.dirname(os.path.abspath(__file__))):
if function[-3:] == '.py' and '_' not in os.path.basename(function):
functions.append(function[:-3])
print(functions)
# LOOP OVER FILES AND IMPORT THE FUNCTION
# THIS IS EQUIVALENT TO: FROM .FILE IMPORT FILE
for function in functions:
module = __import__('mydesigngui.myIOs', globals(), locals(), [function], -1)
#module = __import__('mydesigngui.myIOs', globals(), locals(), [function], -1)
module = __import__('mydesigngui.myIOs', globals(), locals(), [function], 0)
subMod = vars(module)[function]
vars()[function] = vars(subMod)[function]
from .. import MyData # CLASSES
from .readOrgFile import readOrgFile # FUNCTIONS
from .readOrgFile_ import readOrgFile # FUNCTIONS
_D_DTNAME = None
_D_FILENAME = 'serieParam.org'
......
......@@ -8,8 +8,10 @@ from . import QFormLayout
from . import QPushButton
from . import QSignal
from types import FunctionType
from . import sys
AVAIL_FUNCTIONS = []
PYVERSION = sys.version_info
for key in myIOs.__dict__.keys():
if key not in myIOs.__builtins__.keys() and not key.startswith('__'):
......@@ -31,10 +33,15 @@ class QFunctionFormular(QWidget):
self.wOptionalArgs = []
self.unexplicitArgs = False
self.unexplicitKwArgs = False
argCount = function.func_code.co_argcount # number of explicit arguments
argsName = function.func_code.co_varnames # list of the names of the local variables
defaultValues = function.func_defaults # default value of the optional arguments
if (PYVERSION < (3, 0)):
argCount = function.func_code.co_argcount # number of explicit arguments
argsName = function.func_code.co_varnames # list of the names of the local variables
defaultValues = function.func_defaults # default value of the optional arguments
else:
argCount = function.__code__.co_argcount # number of explicit arguments
argsName = function.__code__.co_varnames # list of the names of the local variables
defaultValues = function.__defaults__ # default value of the optional arguments
# extract the known arguments
self.explicitArgs = argsName[:argCount]
......@@ -125,7 +132,7 @@ class QOpenFileWidget(QWidget):
for function in AVAIL_FUNCTIONS:
self.functionsCombo.addItem(function.__name__)
index = AVAIL_FUNCTIONS.index(function)
print('> FUNCTION:' + str(type(AVAIL_FUNCTIONS[index])))
print('> FUNCTION:' + str(AVAIL_FUNCTIONS[index].__name__) + " " + str(type(AVAIL_FUNCTIONS[index])))
self.functionWidgets.append(QFunctionFormular(AVAIL_FUNCTIONS[index], self))
self.layout.addWidget(self.functionWidgets[-1])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment