In [ ]:
from IPython.display import HTML, display

display(HTML('''<script>
code_show=true; 
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
} 
$( document ).ready(code_toggle);
</script>
<a href="javascript:code_toggle()">^</a>'''))
print('')

PANORAMAS OF CINEMA online

// PANORAMA CREATOR

v0.03

In [ ]:
# GLOBAL
tag_http = 'http://poctag-env.eba-vjpstfpz.eu-central-1.elasticbeanstalk.com/tags'
button_color = 'black' # #7d1b27
print('')

PANORAMA OF IMAGES

tags index

In [ ]:
import requests
import ipywidgets as widgets

this_request = tag_http+'?action=GET_ALL_TAGS'
r = requests.get(this_request).json()['body']
for e in sorted(r):
    print(e, end='  .  ')
    
def get_tags(event):
    clear_output()

    this_request = tag_http+'?action=GET_ALL_TAGS'
    r = requests.get(this_request).json()['body']
    for e in sorted(r):
        print(e, end='  .  ')
    
    display(refresh_tags_button)
    
refresh_tags_button = widgets.Button(description="refresh tags", button_style='info')
refresh_tags_button.style.button_color = button_color
display(refresh_tags_button)
refresh_tags_button.on_click(get_tags)
In [ ]:
print ('\n')

users index

In [ ]:
this_request = tag_http+'?action=GET_ALL_USERS'
r = requests.get(this_request).json()['body']
for e in sorted(r):
    print(e, end='  .  ')

def get_users(event):
    clear_output()

    this_request = tag_http+'?action=GET_ALL_USERS'
    r = requests.get(this_request).json()['body']
    for e in sorted(r):
        print(e, end='  .  ')
    
    display(refresh_users_button)

        
refresh_users_button = widgets.Button(description="refresh users", button_style='info')
refresh_users_button.style.button_color = button_color
display(refresh_users_button)
refresh_users_button.on_click(get_users)
In [ ]:
print ('\n')

> type a tag and/or user

In [ ]:
from IPython.display import clear_output
from ipywidgets import interactive

def getUser(user):
    return

def getTag(tag):
    return

def refresh(event):
    clear_output()
    display(w_tag)
    display(w_user)
    display(add_refresh_button)
    
    global this_user, this_tag
    this_user = w_user.kwargs['user']
    this_tag = w_tag.kwargs['tag']
    
    if len(this_user) > 0 and len(this_tag) > 0:
        this_request = tag_http+'?action=GET_FRAMES_USER_TAG&tag=%s&user=%s'%(this_tag,this_user)
        my_frames_tag = requests.get(this_request).json()
        this_length = len(my_frames_tag['body'])
        print (this_length, 'images to render')
    elif len(this_user) > 0 and len(this_tag) == 0:
        this_request = tag_http+'?action=GET_FRAMES_USER&user=%s'%(this_user)
        my_frames_tag = requests.get(this_request).json()
        this_length = len(my_frames_tag['body'])
        print (this_length, 'images to render')
        this_tags = set([ f['tag'] for f in my_frames_tag['body'] ])
        print (this_user, 'is talking about  .  ', end='')
        for e in sorted(this_tags): print(e, end='  .  ')
    elif len(this_user) == 0 and len(this_tag) > 0:
        this_request = tag_http+'?action=GET_FRAMES_TAG&tag=%s'%(this_tag)
        my_frames_tag = requests.get(this_request).json()
        this_length = len(my_frames_tag['body'])
        print (this_length, 'images to render')
        this_users = set([ f['user'] for f in my_frames_tag['body'] ])
        print (this_tag, 'is talked about by  .  ', end='')
        for e in sorted(this_users): print(e, end='  .  ')
    else:
        print ('type a user name and/or a tag')

w_user = interactive(getUser, user='')
w_tag = interactive(getTag, tag='')

add_refresh_button = widgets.Button(description="refresh", button_style='info')
add_refresh_button.style.button_color = button_color
add_refresh_button.on_click(refresh)

display(w_tag)
display(w_user)
display(add_refresh_button)
In [ ]:
print ('\n')

> select your options

In [ ]:
#
def getType(panorama, orientation, square, resolution):
    return

def getSize(size):
    return 

# BUTTON EVENT
def make_request(event):
    clear_output()
    display(ui2)
    display(ui1)
    display(request_panorama_button)

    this_size = size.kwargs['size']
    this_type = panorama.value
    this_square = square.value
    this_contour = 'no'
    this_resolution = resolution.value
    
    my_orientation = orientation.value
    if my_orientation == '[ ]': this_orientation = 'square'
    else: this_orientation = my_orientation

    this_query = 'http://poccreatepanorama-env-1.eba-upy2qcn6.eu-central-1.elasticbeanstalk.com/panorama?'
    if this_type: this_query = this_query+'type=%s'%this_type
    if this_user: this_query = this_query+'&user=%s'%this_user
    if this_tag: this_query = this_query+'&tag=%s'%this_tag
    if this_orientation: this_query = this_query+'&orientation=%s'%this_orientation
    if this_contour: this_query = this_query+'&images_contour=%s'%this_contour
    if this_square: this_query = this_query+'&images_square=%s'%this_square
    if this_size: this_query = this_query+'&grid=%s'%this_size
    if this_resolution: this_query = this_query+'&resolution=%s'%this_resolution
    
    # make request
    html_doc = requests.get(this_query)
    #print (this_query)
    
    from bs4 import BeautifulSoup
    soup = BeautifulSoup(html_doc.text, 'html.parser')
    my_panorama = soup.p.text
    if 'https://' in my_panorama: pass
    else: print (my_panorama)

    from IPython.display import Image
    display( Image(url=my_panorama) )

panorama = widgets.RadioButtons( options=['atlas','dreams'], value='atlas', description='type' )
orientation = widgets.RadioButtons( options=['horizontal','vertical','[ ]'], value='horizontal', description='orientation', disabled=False )
square = widgets.RadioButtons( options=['no', 'yes'], value='no', description='square imgs' )
# grid / resolution box
resolution = widgets.RadioButtons( options=['low', 'high'], value='low', description='resolution' )
size = interactive(getSize, size='3,2')
#size_box = widgets.VBox([resolution, size])
# arrange in boxes
ui1 = widgets.HBox([panorama, orientation, square, resolution])
ui2 = widgets.HBox([size])
out = widgets.interactive_output(getType, {'panorama': panorama, 'orientation':orientation, 'square':square,
                                          'resolution': resolution})

display(ui2)
display(ui1)

request_panorama_button = widgets.Button(description="create panorama", button_style='info')
request_panorama_button.style.button_color = button_color
request_panorama_button.on_click(make_request)
display(request_panorama_button)
In [ ]:
print('\n', '\n', '\n', '\n', '\n')

ETH Zurich       Department of Architecture       Chair for Digital Architectonics       2021

In [ ]: