Anne31415 commited on
Commit
fa02bb5
·
1 Parent(s): 32f1f35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -26,8 +26,12 @@ pdf_file_path = "Private_Book/KOMBI_all2.pdf" # Replace with your PDF file path
26
  def cloud_button(label, key=None, color=None, overlap=30):
27
  button_id = f"cloud-button-{key or label}"
28
  color_class = f"color-{color}" if color else ""
 
 
29
  num_circles = max(3, min(12, (len(label) + overlap) // 4))
30
- circle_size = 60
 
 
31
 
32
  # Create circles with text enclosed
33
  circles_html = ''.join([
@@ -37,7 +41,7 @@ def cloud_button(label, key=None, color=None, overlap=30):
37
  circles_html += f'<div class="circle-text">{label}</div>' # Add the text after the circles
38
 
39
  cloud_button_html = f"""
40
- <div class="cloud" id="{button_id}" style="margin-bottom: 30px;">
41
  <div class="wrapper {color_class}">
42
  {circles_html}
43
  </div>
@@ -70,7 +74,6 @@ def cloud_button(label, key=None, color=None, overlap=30):
70
  transform: translate(-50%, -50%);
71
  font-weight: bold;
72
  z-index: 2;
73
- white-space: nowrap; /* Prevent line breaks */
74
  }}
75
  .color-1 .circle {{ background-color: #FFA07A; }}
76
  .color-2 .circle {{ background-color: #FF7F50; }}
 
26
  def cloud_button(label, key=None, color=None, overlap=30):
27
  button_id = f"cloud-button-{key or label}"
28
  color_class = f"color-{color}" if color else ""
29
+
30
+ # Calculate the number of circles based on the length of the text
31
  num_circles = max(3, min(12, (len(label) + overlap) // 4))
32
+
33
+ # Calculate the circle size based on the number of circles and the text length
34
+ circle_size = max(60, (len(label) + overlap) // num_circles)
35
 
36
  # Create circles with text enclosed
37
  circles_html = ''.join([
 
41
  circles_html += f'<div class="circle-text">{label}</div>' # Add the text after the circles
42
 
43
  cloud_button_html = f"""
44
+ <div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
45
  <div class="wrapper {color_class}">
46
  {circles_html}
47
  </div>
 
74
  transform: translate(-50%, -50%);
75
  font-weight: bold;
76
  z-index: 2;
 
77
  }}
78
  .color-1 .circle {{ background-color: #FFA07A; }}
79
  .color-2 .circle {{ background-color: #FF7F50; }}