duongthienz commited on
Commit
29f76a6
·
verified ·
1 Parent(s): 1bde9fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +124 -113
app.py CHANGED
@@ -676,29 +676,31 @@ try:
676
  pass
677
  printV("Pie1 files written",4)
678
  with col1_1:
679
- printV("Pie1 in col1_1",4)
680
- with open('ascn_pie1.pdf','rb') as f:
681
- printV("Pie1 in file open",4)
682
- st.download_button(
683
- "Save As PDF",
684
- f,
685
- 'sonogram-voice-category-'+currPlainName+'.pdf',
686
- 'application/pdf',
687
- key='download-pdf1',
688
- on_click="ignore",
689
- )
690
- printV("Pie1 after col1_1",4)
 
691
  with col1_2:
692
- with open('ascn_pie1.svg','rb') as f:
693
- st.download_button(
694
- "Save As SVG",
695
- f,
696
- 'sonogram-voice-category-'+currPlainName+'.svg',
697
- 'image/svg+xml',
698
- key='download-svg1',
699
- on_click="ignore",
700
- )
701
- printV("Pie1 in col1_2",4)
 
702
  printV("Pie1 post plotly",4)
703
 
704
  with pie2:
@@ -726,25 +728,27 @@ try:
726
  except Exception:
727
  pass
728
  with col2_1:
729
- with open('ascn_pie2.pdf','rb') as f:
730
- st.download_button(
731
- "Save As PDF",
732
- f,
733
- 'sonogram-speaker-percent-'+currPlainName+'.pdf',
734
- 'application/pdf',
735
- key='download-pdf2',
736
- on_click="ignore",
737
- )
 
738
  with col2_2:
739
- with open('ascn_pie2.svg','rb') as f:
740
- st.download_button(
741
- "Save As SVG",
742
- f,
743
- 'sonogram-speaker-percent-'+currPlainName+'.svg',
744
- 'image/svg+xml',
745
- key='download-svg2',
746
- on_click="ignore",
747
- )
 
748
 
749
  with sunburst1:
750
  df5 = st.session_state.summaries[currFileIndex]["df5"].copy()
@@ -782,25 +786,27 @@ try:
782
  except Exception:
783
  pass
784
  with col3_1:
785
- with open('ascn_sunburst.pdf','rb') as f:
786
- st.download_button(
787
- "Save As PDF",
788
- f,
789
- 'sonogram-speaker-categories-'+currPlainName+'.pdf',
790
- 'application/pdf',
791
- key='download-pdf3',
792
- on_click="ignore",
793
- )
 
794
  with col3_2:
795
- with open('ascn_sunburst.svg','rb') as f:
796
- st.download_button(
797
- "Save As SVG",
798
- f,
799
- 'sonogram-speaker-categories-'+currPlainName+'.svg',
800
- 'image/svg+xml',
801
- key='download-svg3',
802
- on_click="ignore",
803
- )
 
804
 
805
  with treemap1:
806
  df5 = st.session_state.summaries[currFileIndex]["df5"].copy()
@@ -838,26 +844,27 @@ try:
838
  except Exception:
839
  pass
840
  with col4_1:
841
- with open('ascn_treemap.pdf','rb') as f:
842
- st.download_button(
843
- "Save As PDF",
844
- f,
845
- 'sonogram-treemap-'+currPlainName+'.pdf',
846
- 'application/pdf',
847
- key='download-pdf4',
848
- on_click="ignore",
849
- )
 
850
  with col4_2:
851
- with open('ascn_treemap.svg','rb') as f:
852
- st.download_button(
853
- "Save As SVG",
854
- f,
855
- 'sonogram-treemap-'+currPlainName+'.svg',
856
- 'image/svg+xml',
857
- key='download-svg4',
858
- on_click="ignore",
859
- )
860
- st.plotly_chart(fig3, use_container_width=True,config=config)
861
 
862
  # generate plotting window
863
 
@@ -899,25 +906,27 @@ try:
899
  except Exception:
900
  pass
901
  with col5_1:
902
- with open('ascn_timeline.pdf','rb') as f:
903
- st.download_button(
904
- "Save As PDF",
905
- f,
906
- 'sonogram-timeline-'+currPlainName+'.pdf',
907
- 'application/pdf',
908
- key='download-pdf5',
909
- on_click="ignore",
910
- )
 
911
  with col5_2:
912
- with open('ascn_timeline.svg','rb') as f:
913
- st.download_button(
914
- "Save As SVG",
915
- f,
916
- 'sonogram-timeline-'+currPlainName+'.svg',
917
- 'image/svg+xml',
918
- key='download-svg5',
919
- on_click="ignore",
920
- )
 
921
 
922
  with bar1:
923
  df2 = st.session_state.summaries[currFileIndex]["df2"].copy()
@@ -950,25 +959,27 @@ try:
950
  except Exception:
951
  pass
952
  with col6_1:
953
- with open('ascn_bar.pdf','rb') as f:
954
- st.download_button(
955
- "Save As PDF",
956
- f,
957
- 'sonogram-speaker-time-'+currPlainName+'.pdf',
958
- 'application/pdf',
959
- key='download-pdf6',
960
- on_click="ignore",
961
- )
 
962
  with col6_2:
963
- with open('ascn_bar.svg','rb') as f:
964
- st.download_button(
965
- "Save As SVG",
966
- f,
967
- 'sonogram-speaker-time-'+currPlainName+'.svg',
968
- 'image/svg+xml',
969
- key='download-svg6',
970
- on_click="ignore",
971
- )
 
972
 
973
  except ValueError:
974
  pass
 
676
  pass
677
  printV("Pie1 files written",4)
678
  with col1_1:
679
+ if os.path.exists('ascn_pie1.pdf'):
680
+ printV("Pie1 in col1_1",4)
681
+ with open('ascn_pie1.pdf','rb') as f:
682
+ printV("Pie1 in file open",4)
683
+ st.download_button(
684
+ "Save As PDF",
685
+ f,
686
+ 'sonogram-voice-category-'+currPlainName+'.pdf',
687
+ 'application/pdf',
688
+ key='download-pdf1',
689
+ on_click="ignore",
690
+ )
691
+ printV("Pie1 after col1_1",4)
692
  with col1_2:
693
+ if os.path.exists('ascn_pie1.svg'):
694
+ with open('ascn_pie1.svg','rb') as f:
695
+ st.download_button(
696
+ "Save As SVG",
697
+ f,
698
+ 'sonogram-voice-category-'+currPlainName+'.svg',
699
+ 'image/svg+xml',
700
+ key='download-svg1',
701
+ on_click="ignore",
702
+ )
703
+ printV("Pie1 in col1_2",4)
704
  printV("Pie1 post plotly",4)
705
 
706
  with pie2:
 
728
  except Exception:
729
  pass
730
  with col2_1:
731
+ if os.path.exists('ascn_pie2.pdf'):
732
+ with open('ascn_pie2.pdf','rb') as f:
733
+ st.download_button(
734
+ "Save As PDF",
735
+ f,
736
+ 'sonogram-speaker-percent-'+currPlainName+'.pdf',
737
+ 'application/pdf',
738
+ key='download-pdf2',
739
+ on_click="ignore",
740
+ )
741
  with col2_2:
742
+ if os.path.exists('ascn_pie2.svg'):
743
+ with open('ascn_pie2.svg','rb') as f:
744
+ st.download_button(
745
+ "Save As SVG",
746
+ f,
747
+ 'sonogram-speaker-percent-'+currPlainName+'.svg',
748
+ 'image/svg+xml',
749
+ key='download-svg2',
750
+ on_click="ignore",
751
+ )
752
 
753
  with sunburst1:
754
  df5 = st.session_state.summaries[currFileIndex]["df5"].copy()
 
786
  except Exception:
787
  pass
788
  with col3_1:
789
+ if os.path.exists('ascn_sunburst.pdf'):
790
+ with open('ascn_sunburst.pdf','rb') as f:
791
+ st.download_button(
792
+ "Save As PDF",
793
+ f,
794
+ 'sonogram-speaker-categories-'+currPlainName+'.pdf',
795
+ 'application/pdf',
796
+ key='download-pdf3',
797
+ on_click="ignore",
798
+ )
799
  with col3_2:
800
+ if os.path.exists('ascn_sunburst.svg'):
801
+ with open('ascn_sunburst.svg','rb') as f:
802
+ st.download_button(
803
+ "Save As SVG",
804
+ f,
805
+ 'sonogram-speaker-categories-'+currPlainName+'.svg',
806
+ 'image/svg+xml',
807
+ key='download-svg3',
808
+ on_click="ignore",
809
+ )
810
 
811
  with treemap1:
812
  df5 = st.session_state.summaries[currFileIndex]["df5"].copy()
 
844
  except Exception:
845
  pass
846
  with col4_1:
847
+ if os.path.exists('ascn_treemap.pdf'):
848
+ with open('ascn_treemap.pdf','rb') as f:
849
+ st.download_button(
850
+ "Save As PDF",
851
+ f,
852
+ 'sonogram-treemap-'+currPlainName+'.pdf',
853
+ 'application/pdf',
854
+ key='download-pdf4',
855
+ on_click="ignore",
856
+ )
857
  with col4_2:
858
+ if os.path.exists('ascn_treemap.svg'):
859
+ with open('ascn_treemap.svg','rb') as f:
860
+ st.download_button(
861
+ "Save As SVG",
862
+ f,
863
+ 'sonogram-treemap-'+currPlainName+'.svg',
864
+ 'image/svg+xml',
865
+ key='download-svg4',
866
+ on_click="ignore",
867
+ )
868
 
869
  # generate plotting window
870
 
 
906
  except Exception:
907
  pass
908
  with col5_1:
909
+ if os.path.exists('ascn_timeline.pdf'):
910
+ with open('ascn_timeline.pdf','rb') as f:
911
+ st.download_button(
912
+ "Save As PDF",
913
+ f,
914
+ 'sonogram-timeline-'+currPlainName+'.pdf',
915
+ 'application/pdf',
916
+ key='download-pdf5',
917
+ on_click="ignore",
918
+ )
919
  with col5_2:
920
+ if os.path.exists('ascn_timeline.svg'):
921
+ with open('ascn_timeline.svg','rb') as f:
922
+ st.download_button(
923
+ "Save As SVG",
924
+ f,
925
+ 'sonogram-timeline-'+currPlainName+'.svg',
926
+ 'image/svg+xml',
927
+ key='download-svg5',
928
+ on_click="ignore",
929
+ )
930
 
931
  with bar1:
932
  df2 = st.session_state.summaries[currFileIndex]["df2"].copy()
 
959
  except Exception:
960
  pass
961
  with col6_1:
962
+ if os.path.exists('ascn_bar.pdf'):
963
+ with open('ascn_bar.pdf','rb') as f:
964
+ st.download_button(
965
+ "Save As PDF",
966
+ f,
967
+ 'sonogram-speaker-time-'+currPlainName+'.pdf',
968
+ 'application/pdf',
969
+ key='download-pdf6',
970
+ on_click="ignore",
971
+ )
972
  with col6_2:
973
+ if os.path.exists('ascn_bar.svg'):
974
+ with open('ascn_bar.svg','rb') as f:
975
+ st.download_button(
976
+ "Save As SVG",
977
+ f,
978
+ 'sonogram-speaker-time-'+currPlainName+'.svg',
979
+ 'image/svg+xml',
980
+ key='download-svg6',
981
+ on_click="ignore",
982
+ )
983
 
984
  except ValueError:
985
  pass