When i click on ADD button, i want to add a new element , thanks to inserter to get title and corpus of the wanted new element.
I get this traceback:
Traceback (most recent call last):
File "main.py", line 181, in <module>
menu.play()
File "/home/billy/Bureau/codage/noel/thorpy/menus/basicmenu.py", line 150, in play
self.react_to_all_events()
File "/home/billy/Bureau/codage/noel/thorpy/menus/tickedmenu.py", line 21, in react_to_all_events
self.treatement(event)
File "/home/billy/Bureau/codage/noel/thorpy/menus/basicmenu.py", line 131, in treatement
self.react(event)
File "/home/billy/Bureau/codage/noel/thorpy/menus/basicmenu.py", line 116, in react
element.react(event)
File "/home/billy/Bureau/codage/noel/thorpy/elements/ghost.py", line 299, in react
reaction._try_activation(event)
File "/home/billy/Bureau/codage/noel/thorpy/miscgui/reaction.py", line 45, in _try_activation
self.reac_func(event, **self.params)
File "/home/billy/Bureau/codage/noel/thorpy/elements/clickable.py", line 53, in _reaction_unpress
self.run_user_func()
File "/home/billy/Bureau/codage/noel/thorpy/elements/ghost.py", line 116, in run_user_func
self.user_func(**self.user_params)
File "main.py", line 66, in create_mission
central_injector(tit,cor)
File "main.py", line 51, in central_injector
central_box.add_elements(new_elem)
File "/home/billy/Bureau/codage/noel/thorpy/elements/ghost.py", line 167, in add_elements
for el in elements:
TypeError: 'Element' object is not iterable
---------------------------------------------
Code: Select all
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import pygame
import thorpy
"""
from mss import mss
screen = mss().monitors[1]
print(screen)
WIDTH = screen['width']
HEIGHT = screen['height']
"""
WIDTH = 800
HEIGHT = 600
douz_W = int(WIDTH/12)
douz_H = int(HEIGHT/12)
application = thorpy.Application((WIDTH, HEIGHT), " TEST")
title_element = thorpy.make_text("Bla bla bla", 25, (0,255,50))
class Mission():
def __init__(self, title = None,corpus = None):
self.title = title
self.corpus = corpus
def print_self(self):
print(self.__dict__)
def text_input(title, value=""):
ins = thorpy.Inserter.make(title,value=value)
box = thorpy.make_ok_box([ins])
thorpy.auto_ok(box)
box.center()
thorpy.launch_blocking(box)
return ins.get_value()
def pass_func():
pass
def central_injector(tit,cor):
new_elem = thorpy.Element.make(tit)
thorpy.makeup.add_basic_help(new_elem,cor)
central_box.add_elements(new_elem)
thorpy.functions.refresh_current_menu()
central_box.store()
central_box.unblit_and_reblit()
def create_mission():
## tit = input("\n Title : ")
## cor = input("\n corpus : ")
print("uh")
tit = text_input("Title: ")
cor = text_input("Corpus: ")
#x = Mission(tit,cor,them,creationdate = arrow.utcnow())
x = Mission(tit,cor)
print("\n create_mission")
x.print_self()
central_injector(tit,cor)
background.unblit_and_reblit()
def pass_func():
pass
ADD = thorpy.make_button("ADD", func = create_mission)
MODIFY = thorpy.make_button("MODIFY", func = pass_func )
RESET = thorpy.make_button("RESET", func = pass_func )
barbuttonlist = [ADD,MODIFY,RESET]
barbuttonlist[0].set_main_color((0,0,255))
barbuttonlist[1].set_main_color((255,145,0))
barbuttonlist[2].set_main_color((125,125,125))
clicksgroup = thorpy.make_group(barbuttonlist, "h")
def move_to_box(element, from_box, to_box):
if element in central_box.get_elements():
print("\n.......................................................")
for e in element.get_elements():
#print(e)
#print("---------")
#print(e.get_family_rect())
#print(e.get_ancesters()[1])
#print("---------")
#print(e.get_oldest_ancester())
print("\n")
e.force_unjailed()
#remove from central box
from_box.remove_elements([element])
from_box.store()
from_box.unblit_and_reblit()
#add to success box
to_box.add_elements([element])
thorpy.functions.refresh_current_menu()
to_box.store()
to_box.unblit_and_reblit()
else:
print("element not source box box")
def easy_move(element, to_box):
for e in element.get_elements():
print(e.get_ancesters()[1])
e.force_unjailed()
current_box = e.get_ancesters()[1]
current_box.remove_elements([element])
current_box.store()
current_box.unblit_and_reblit()
to_box.add_elements([element])
thorpy.functions.refresh_current_menu()
to_box.store()
to_box.unblit_and_reblit()
go_up = thorpy.make_button("^", easy_move)
indicator2 = thorpy.Element.make(" MISSION B ")
thorpy.makeup.add_basic_help(indicator2,"Build nuclear power plant")
validator2 = thorpy.make_button("ok", move_to_box)
thorpy.makeup.add_basic_help(validator2,"click here to accept")
validator2.set_main_color((0,255,0,170))
xannihilator2 = thorpy.make_button("X", move_to_box)
thorpy.makeup.add_basic_help(xannihilator2,"click here to reject")
xannihilator2.set_main_color((255,0,0,150))
thorpy.makeup.add_basic_help(go_up,"click here to teleport")
go_up.set_main_color((50,50,50, 200))
activline_2 = [indicator2,validator2,xannihilator2, go_up]
activgroup_2 = thorpy.make_group(activline_2, "h")
elements = [clicksgroup,activgroup_2]
central_box = thorpy.Box.make(elements=elements,
size=(9*douz_W,5*douz_H))
failed_box = thorpy.Box.make(elements=None,
size=(9*douz_W,2*douz_H))
succes_box = thorpy.Box.make(elements=None,
size=(9*douz_W,2*douz_H))
central_box.center()
central_box.add_lift()
central_box.set_main_color((220,220,220,70))
failed_box.add_lift()
failed_box.set_main_color((255,0,0,90))
succes_box.add_lift()
succes_box.set_main_color((0,255,0,70))
validator2.user_params = {"element":activgroup_2, "from_box":central_box, "to_box":succes_box}
xannihilator2.user_params = {"element":activgroup_2, "from_box":central_box, "to_box":failed_box}
go_up.user_params = {"element":activgroup_2,"to_box":central_box}
background = thorpy.Background.make(image=thorpy.style.EXAMPLE_IMG,
elements=[title_element, central_box,failed_box,succes_box])
thorpy.store(background)
menu = thorpy.Menu(background)
menu.play()
application.quit()
---------------------------------------------
a) Your Python version : Python 3.5.2
b) The version of ThorPy you use : 1.5.9
c) Your OS : Linux
d) Your keyboard layout : AZERTY,