Beispiel #1
0
def run():
    import thorpy
    application = thorpy.Application((600, 600), "ThorPy test")

    ##thorpy.theme.set_theme("human")

    #### SIMPLE ELEMENTS ####

    ghost = thorpy.Ghost()
    ghost.finish()

    element = thorpy.Element("Element")
    element.finish()
    thorpy.makeup.add_basic_help(
        element, "Element instance:\nMost simple graphical element.")

    clickable = thorpy.Clickable("Clickable")
    clickable.finish()
    clickable.add_basic_help(
        "Clickable instance:\nCan be hovered and pressed.")

    draggable = thorpy.Draggable("Draggable")
    draggable.finish()
    thorpy.makeup.add_basic_help(draggable,
                                 "Draggable instance:\nYou can drag it.")

    #### SIMPLE Setters ####

    checker_check = thorpy.Checker("Checker")
    checker_check.finish()
    thorpy.makeup.add_basic_help(
        checker_check, "Checker instance:\nHere it is of type 'checkbox'.")

    checker_radio = thorpy.Checker("Radio", typ="radio")
    checker_radio.finish()
    thorpy.makeup.add_basic_help(
        checker_radio, "Checker instance:\nHere it is of type 'radio'.")

    browser = thorpy.Browser("../../", text="Browser")
    browser.finish()
    browser.set_prison()

    browserlauncher = thorpy.BrowserLauncher(browser,
                                             name_txt="Browser",
                                             file_txt="Nothing selected",
                                             launcher_txt="...")
    browserlauncher.finish()
    browserlauncher.scale_to_title()
    thorpy.makeup.add_basic_help(
        browserlauncher,
        "Browser instance:\nA way for user to find a file or" +
        "\na folder on the computer.")

    dropdownlist = thorpy.DropDownListLauncher(
        name_txt="DropDownListLauncher",
        file_txt="Nothing selected",
        titles=[str(i) for i in range(1, 9)])
    dropdownlist.finish()
    dropdownlist.scale_to_title()
    thorpy.makeup.add_basic_help(dropdownlist,
                                 "DropDownList:\nDisplay a list of choices.")

    slider = thorpy.SliderX(120, (5, 12),
                            "Slider: ",
                            typ=float,
                            initial_value=8.4)
    slider.finish()
    thorpy.makeup.add_basic_help(
        slider, "SliderX:\nA way for user to select a value." +
        "\nCan select any type of number (int, float, ..).")
    slider.set_center

    inserter = thorpy.Inserter(name="Inserter: ", value="Write here.")
    inserter.finish()
    thorpy.makeup.add_basic_help(
        inserter, "Inserter:\nA way for user to insert a value.")

    text_title = thorpy.make_text("Test Example", 25, (0, 0, 255))

    central_box = thorpy.Box("", [
        ghost, element, clickable, draggable, checker_check, checker_radio,
        dropdownlist, browserlauncher, slider, inserter
    ])
    central_box.finish()
    central_box.center()
    central_box.add_lift()
    central_box.set_main_color((200, 200, 255, 120))

    background = thorpy.Background(color=(200, 200, 200),
                                   elements=[text_title, central_box])
    background.finish()

    thorpy.store(background)

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

    application.quit()
    except KeyError as e:
        print(f'{node} not in the node dict dictionary. The node number should be of type string and between 1-200')
        raise e

background, thief, d1, d2, d3, d4, d5 = LoadInput()
agent_icons = [thief, d1, d2, d3, d4, d5]
curr_num = ''
running = True
x,y = 500,500
player_turn = 0
blink = 1
# for testing only. ideally initialize using the node to pixel function and the positions obtained from the game code
agents_pos = {0:(2,2), 1: (10,10), 2: (20,20), 3: (30,30), 4: (40,40), 5: (50,50)}

#declaration of some ThorPy elements ...
dropdownlist = thorpy.DropDownListLauncher(const_text='actions', titles=["proposition1", "prop2", "prop3"])#thorpy.SliderX(100, (12, 35), "My Slider")
dropdownlist.scale_to_title()
dropdownlist.max_chars = 12
button = thorpy.make_button("Quit", func=thorpy.functions.quit_func)
box = thorpy.Box(elements=[dropdownlist,button])
#we regroup all elements on a menu, even if we do not launch the menu
menu = thorpy.Menu(box)
#important : set the screen as surface for all elements
for element in menu.get_population():
    element.surface = screen
#use the elements normally...
box.set_topleft((100,100))
box.blit()
box.update()

while running:
Beispiel #3
0
def run():
    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.make(browser,
                                                  const_text="Choose file:",
                                                  var_text="")
    browserlauncher.max_chars = 20  #limit size of browser launcher

    dropdownlist = thorpy.DropDownListLauncher(
        const_text="Choose number:",
        var_text="",
        titles=[str(i) * i for i in range(1, 9)])
    dropdownlist.scale_to_title()
    dropdownlist.max_chars = 20  #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.")

    quit = thorpy.make_button("Quit", func=thorpy.functions.quit_menu_func)

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

    elements = [
        element, clickable, draggable, checker_check, checker_radio,
        dropdownlist, browserlauncher, slider, inserter, quit
    ]
    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.make(image=thorpy.style.EXAMPLE_IMG,
                                        elements=[title_element, central_box])
    thorpy.store(background)

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

    application.quit()
Beispiel #4
0
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 = [
    text, line, element, clickable, draggable, checker_check, checker_radio,