-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create app for triangular array of boxes
- Loading branch information
1 parent
54ce8ab
commit 1fa0bab
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import streamlit as st | ||
from stmol import showmol,add_box | ||
import py3Dmol | ||
#In this example, we will explore how to work with the add_box function to create boxes. | ||
#For this a colection of boxes is created in a double for loop. Because why not? | ||
|
||
scene=py3Dmol.view(width=800,height=800) # Create a scene by defining a blank view | ||
# In the following for loops, we create many boxes of different colors | ||
for i in range(20): | ||
ii=i*10 | ||
for j in range(10): | ||
jj=j*10 | ||
if jj>ii: # This is to build boxes only for diagonal and above | ||
add_box(scene,bxc=[ii,jj,0],bxd=[10,10,10],boxColor=ii*693870+jj*10,boxOpacity=1.0) | ||
scene.zoomTo() # This makes the scene zoom to the boxes | ||
showmol(scene,width=800,height=800) # This shows the scene in the streamlit web app |