ThorPy

A GUI library for pygame

Examples - Elements overview

Full code

ThorPy provides a fast way to let user decide between a list of choices. As for alerts, you may either need blocking or non-blocking choices.


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
import thorpy application = thorpy.Application((800, 600), "ThorPy Overview") element = thorpy.Element("Element") thorpy.makeup.add_basic_help(element,"Element:\nMost simple graphical element.") clickable = thorpy.Clickable("Clickable") thorpy.makeup.add_basic_help(clickable,"Clickable:\nCan be hovered and pressed.") draggable = thorpy.Draggable("Draggable") thorpy.makeup.add_basic_help(draggable,"Draggable:\nYou can drag it.") checker_check = thorpy.Checker("Checker") checker_radio = thorpy.Checker("Radio", type_="radio") browser = thorpy.Browser("../../", text="Browser") browserlauncher = thorpy.BrowserLauncher(browser, const_text="Choose file:", var_text="") browserlauncher.max_chars = 15 #limit size of browser launcher dropdownlist = thorpy.DropDownListLauncher(const_text="Choose:", var_text="", titles=[str(i)*i for i in range(1, 9)]) dropdownlist.scale_to_title() dropdownlist.max_chars = 12 #limit size of drop down list slider = thorpy.SliderX(80, (5, 12), "Slider: ", type_=float, initial_value=8.4) inserter = thorpy.Inserter(name="Inserter: ", value="Write here.") title_element = thorpy.make_text("Overview example", 22, (255,0,0)) elements = [element, clickable, draggable, checker_check, checker_radio, dropdownlist, browserlauncher, slider, inserter] central_box = thorpy.Box(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(image=thorpy.style.EXAMPLE_IMG, elements=[title_element, central_box]) thorpy.store(background) menu = thorpy.Menu(background) menu.play() application.quit()