def generateForm(classe, instance=None): box = GridLayout(cols=2) box.reponses = list() # D'abord, on voit s'il y a une image dans le modèle try: images = getmember(classe, 'image') if not images: images = [] except Exception as e: images = [] for image in images: if image in classe.requis: elem = getmember(classe, image) box.add_widget(Label(text=elem.verbose_name)) if instance: values = getmember(instance, image) else: values = None reponse = widgetDict['E_ImageField'](image, elem, values) reponse.champ = image box.add_widget(reponse) box.reponses.append(reponse) others = [champ for champ in classe.requis if champ not in images] fdict = dict([(name, obj) for name, obj in inspect.getmembers( classe, lambda x: dbHelper.isType(type(x))) if name in others]) for nom_champ in others: box.add_widget(Label(text=fdict[nom_champ].verbose_name)) ty = dbHelper.whatType(type(fdict[nom_champ])) if instance: values = getmember(instance, nom_champ) if is_related(classe, nom_champ): values = list(values) else: values = None reponse = widgetDict[ty](nom_champ, fdict[nom_champ], values) reponse.champ = nom_champ box.add_widget(reponse) box.reponses.append(reponse) box.add_widget(Widget()) return box