how to have radio_pool inside central_box ?

This is the place for queries about ThorPy issues : installation, coding, ...
buffalo
Posts: 44
Joined: Thu Feb 25, 2016 10:34 am

how to have radio_pool inside central_box ?

Postby buffalo » Sat Jun 17, 2017 5:14 pm

i would like to get this http://www.thorpy.org/examples/pools.html working in central_box here : http://www.thorpy.org/examples/overview.html

i get errors like AttributeError: 'list' object has no attribute 'father' or AttributeError: 'RadioPool' object has no attribute 'get_storer_rect'

Code: Select all

import thorpy
application = thorpy.Application((1000, 800), "ThorPy Overview")
browser = thorpy.Browser.make("../../", text="Browser")
browserlauncher = thorpy.BrowserLauncher.make(browser, const_text="Choose file:",
                                                var_text="")
browserlauncher.max_chars = 60 #limit size of browser launcher
inserter = thorpy.Inserter.make(name="Inserter: ", value="Write here.")

checker_radio_0 = thorpy.Checker.make("only_target_file", type_="radio")
checker_radio_1 = thorpy.Checker.make("All_python_files", type_="radio")

radios = [checker_radio_0,checker_radio_1]
radio_pool = thorpy.RadioPool(radios, first_value=radios[1], always_value=True)
#checker_radio = thorpy.Checker.make(["only_target_file","All_python_files"], type_="radio")

title_element = thorpy.make_text("Overview example", 22, (255,255,0))

elements = [browserlauncher, inserter, radio_pool]
#elements = [radios]

central_box = thorpy.Box.make(elements=elements)
central_box.fit_children(margins=(100,100)) #we want big margins
central_box.center() #center on screen
central_box.add_lift() #add a lift (useless since box fits children)
central_box.set_main_color((0,220,0,70)) #set box color and opacity

background = thorpy.Background.make(image=thorpy.style.EXAMPLE_IMG,
                                    elements=[title_element, central_box])
thorpy.store(background)
menu = thorpy.Menu(background)
menu.play()
application.quit()

buffalo
Posts: 44
Joined: Thu Feb 25, 2016 10:34 am

Re: how to have radio_pool inside central_box ?

Postby buffalo » Sun Jun 18, 2017 8:39 am

Answer : Like this :

Code: Select all

import thorpy

application = thorpy.Application((800, 600), "ThorPy Overview")

title_element = thorpy.make_text("Overview example", 35, (255,255,0))

clickable = thorpy.Clickable.make("Clickable")
thorpy.makeup.add_basic_help(clickable,"Clickable:\nCan be hovered and pressed.")

topitems = [title_element, clickable]

#-------------------------------------------

checker_radio_0 = thorpy.Checker.make("only_target_file", type_="radio")
checker_radio_1 = thorpy.Checker.make("All_python_files", type_="radio")

radiolist = [checker_radio_0,checker_radio_1]
radio_pool = thorpy.RadioPool(radiolist, first_value=radiolist[1], always_value=True)


buttons = [thorpy.Togglable.make("togglable"+str(i)) for i in range(4)]
togglable_pool = thorpy.TogglablePool(buttons, first_value=buttons[1],
                                                        always_value=False)


radio_and_toggable = radiolist + buttons
#-------------------------------------------

elements = topitems + radio_and_toggable

#-------------------------------------------

central_box = thorpy.Box.make(elements=elements)
central_box.fit_children(margins=(30,30)) #we want big margins
central_box.center() #center on screen
central_box.add_lift() #add a lift (useless since box fits children)
central_box.set_main_color((220,220,220,180)) #set box color and opacity

background = thorpy.Background.make(image=thorpy.style.EXAMPLE_IMG,
                                    elements=[title_element, central_box])
thorpy.store(background)

menu = thorpy.Menu(background)
menu.play()

application.quit()


Return to “General ThorPy help”

Who is online

Users browsing this forum: No registered users and 0 guests