bootstrap like grid organisation for item placement

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

bootstrap like grid organisation for item placement

Postby buffalo » Mon Jun 12, 2017 8:18 pm

how to place butons or items this way :
Image

ThorPy
Site Admin
Posts: 21
Joined: Wed May 13, 2015 9:44 pm

Re: bootstrap like grid organisation for item placement

Postby ThorPy » Wed Jun 14, 2017 6:28 pm

Here is a possible solution:

Code: Select all

import thorpy, pygame

application = thorpy.Application((500,500), "Bootstrap")

#first we just create the elements
jumbotron = thorpy.make_button("Jumbotron")
jumbotron.set_size((400,100))

text_area1 = thorpy.make_button("Text area 1")
text_area1.set_size((300,50))

text_area2 = thorpy.make_button("Text area 2")
text_area2.set_size((300,50))

text_area3 = thorpy.make_button("Text area 3")
text_area3.set_size((140,50))

text_area4 = thorpy.make_button("Text area 4")
text_area4.set_size((140,50))

image1 = thorpy.make_button("Image 1") #actually, use thorpy.Image
image1.set_size((80,80))

image2 = thorpy.make_button("Image 2") #actually, use thorpy.Image
image2.set_size((80,80))

#second we group them
texts_3_4 = thorpy.make_group([text_area3, text_area4], "h") #h means horizontal
all_texts = thorpy.make_group([text_area1,text_area2,texts_3_4], "v") #vertical
images_box = thorpy.Box.make([image1,image2]) #we put images in the box as in the scheme
texts_and_box = thorpy.make_group([all_texts, images_box], "h")

background = thorpy.Background.make(image=thorpy.style.EXAMPLE_IMG,
                                    elements=[jumbotron, texts_and_box])
thorpy.store(background) #default storing is vertical, so its okay

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