Wajahat698 commited on
Commit
ad645f9
·
verified ·
1 Parent(s): a823727

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -30
app.py CHANGED
@@ -767,26 +767,35 @@ def side():
767
 
768
 
769
 
770
-
771
-
772
-
773
-
774
- # Show Trust Builders Section
775
  trust_buckets = [
776
- {"label": "Stability", "icon": "Bucket_STABILITY.png"},
777
- {"label": "Development", "icon": "Bucket_DEVELOPMENT.png"},
778
- {"label": "Relationship", "icon": "Bucket_RELATIONSHIP.png"},
779
- {"label": "Benefit", "icon": "Bucket_BENEFIT.png"},
780
- {"label": "Vision", "icon": "Bucket_VISION.png"},
781
- {"label": "Competence", "icon": "Bucket_COMPETENCE.png"}
782
  ]
 
 
 
 
 
 
 
 
 
 
 
 
783
  def get_base64(file_path):
784
- with open(file_path, "rb") as f:
785
- return base64.b64encode(f.read()).decode()
786
-
787
-
788
-
789
-
 
 
790
  dropdown_html = """
791
  <style>
792
  .custom-dropdown {
@@ -795,28 +804,38 @@ def side():
795
  margin: 10px auto;
796
  font-family: Arial, sans-serif;
797
  }
798
- .custom-dropdown select {
799
- width: 100%;
800
- padding: 10px;
801
- font-size: 16px;
802
- border: 1px solid #ccc;
803
- border-radius: 5px;
804
- background-color: white;
805
- appearance: none;
806
- -webkit-appearance: none;
807
- -moz-appearance: none;
808
- cursor: pointer;
809
- }
810
  .custom-dropdown option {
811
  display: flex;
812
  align-items: center;
813
  padding: 10px;
814
- background-color: #f9f9f9;
815
  }
816
  </style>
817
  <div class="custom-dropdown">
818
  <select>
819
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
820
  for bucket in trust_buckets:
821
  icon_path = os.path.join(".", bucket["icon"]) # Adjust the path if your icons are in a subdirectory
822
  encoded_img = get_base64(icon_path)
 
767
 
768
 
769
 
 
 
 
 
 
770
  trust_buckets = [
771
+ "Stability",
772
+ "Development",
773
+ "Relationship",
774
+ "Benefit",
775
+ "Vision",
776
+ "Competence",
777
  ]
778
+
779
+ # Icon filenames (ensure these icons are in the same directory as your script)
780
+ icon_files = {
781
+ "Stability": "Bucket_STABILITY.png",
782
+ "Development": "Bucket_DEVELOPMENT.png",
783
+ "Relationship": "Bucket_RELATIONSHIP.png",
784
+ "Benefit": "Bucket_BENEFIT.png",
785
+ "Vision": "Bucket_VISION.png",
786
+ "Competence": "Bucket_COMPETENCE.png",
787
+ }
788
+
789
+ # Function to encode local images as Base64
790
  def get_base64(file_path):
791
+ try:
792
+ with open(file_path, "rb") as f:
793
+ return base64.b64encode(f.read()).decode()
794
+ except FileNotFoundError:
795
+ st.error(f"File not found: {file_path}")
796
+ return ""
797
+
798
+ # Generate HTML for the dropdown
799
  dropdown_html = """
800
  <style>
801
  .custom-dropdown {
 
804
  margin: 10px auto;
805
  font-family: Arial, sans-serif;
806
  }
 
 
 
 
 
 
 
 
 
 
 
 
807
  .custom-dropdown option {
808
  display: flex;
809
  align-items: center;
810
  padding: 10px;
811
+ font-size: 16px;
812
  }
813
  </style>
814
  <div class="custom-dropdown">
815
  <select>
816
  """
817
+
818
+ for bucket in trust_buckets:
819
+ icon_path = icon_files.get(bucket, "")
820
+ if icon_path:
821
+ icon_path = os.path.join(".", icon_path)
822
+ encoded_img = get_base64(icon_path)
823
+ dropdown_html += f"""
824
+ <option style="background-image: url('data:image/png;base64,{encoded_img}');
825
+ background-repeat: no-repeat;
826
+ background-size: 20px 20px;
827
+ background-position: left center;
828
+ padding-left: 40px;">
829
+ {bucket}
830
+ </option>
831
+ """
832
+ else:
833
+ dropdown_html += f"<option>{bucket}</option>"
834
+
835
+ dropdown_html += """
836
+ </select>
837
+ </div>
838
+ """
839
  for bucket in trust_buckets:
840
  icon_path = os.path.join(".", bucket["icon"]) # Adjust the path if your icons are in a subdirectory
841
  encoded_img = get_base64(icon_path)