SHAMIL SHAHBAZ AWAN
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ def calculate_weight(earth_weight, planet):
|
|
| 33 |
def main():
|
| 34 |
with gr.Blocks(css="""
|
| 35 |
.gradio-container {
|
| 36 |
-
background: url('https://
|
| 37 |
background-size: cover;
|
| 38 |
min-height: 100vh;
|
| 39 |
}
|
|
@@ -90,31 +90,38 @@ def main():
|
|
| 90 |
earth_weight_input = gr.Number(label="Enter your weight on Earth (kg)", interactive=True)
|
| 91 |
planet_input = gr.Dropdown(choices=list(gravity_factors.keys()), label="Choose a planet", interactive=True)
|
| 92 |
|
|
|
|
| 93 |
output = gr.Textbox(label="Equivalent Weight on Planet", interactive=False)
|
| 94 |
|
| 95 |
-
#
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
setTimeout(() => balloon.remove(), 6000); // Remove balloon after animation
|
| 112 |
}
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
#
|
| 116 |
-
button
|
| 117 |
-
button.click(
|
| 118 |
|
| 119 |
demo.launch()
|
| 120 |
|
|
|
|
| 33 |
def main():
|
| 34 |
with gr.Blocks(css="""
|
| 35 |
.gradio-container {
|
| 36 |
+
background: url('https://img.freepik.com/free-photo/purple-black-futuristic-aztec-abstract-background-with-squares-neon-lights_181624-27830.jpg') no-repeat center center fixed;
|
| 37 |
background-size: cover;
|
| 38 |
min-height: 100vh;
|
| 39 |
}
|
|
|
|
| 90 |
earth_weight_input = gr.Number(label="Enter your weight on Earth (kg)", interactive=True)
|
| 91 |
planet_input = gr.Dropdown(choices=list(gravity_factors.keys()), label="Choose a planet", interactive=True)
|
| 92 |
|
| 93 |
+
# Output section for the equivalent weight
|
| 94 |
output = gr.Textbox(label="Equivalent Weight on Planet", interactive=False)
|
| 95 |
|
| 96 |
+
# HTML component for balloon effect trigger
|
| 97 |
+
balloon_script = gr.HTML("""
|
| 98 |
+
<script>
|
| 99 |
+
function triggerBalloonEffect() {
|
| 100 |
+
const balloonCount = 5; // Number of balloons to show
|
| 101 |
+
for (let i = 0; i < balloonCount; i++) {
|
| 102 |
+
let balloon = document.createElement('div');
|
| 103 |
+
balloon.classList.add('balloon');
|
| 104 |
+
balloon.style.left = Math.random() * 100 + 'vw'; // Random horizontal position
|
| 105 |
+
let balloonText = document.createElement('div');
|
| 106 |
+
balloonText.classList.add('balloon-text');
|
| 107 |
+
balloonText.textContent = '🎈'; // Emoji or custom text for the balloon
|
| 108 |
+
balloon.appendChild(balloonText);
|
| 109 |
+
document.body.appendChild(balloon);
|
| 110 |
+
setTimeout(() => balloon.remove(), 6000); // Remove balloon after animation
|
| 111 |
+
}
|
|
|
|
| 112 |
}
|
| 113 |
+
</script>
|
| 114 |
+
""")
|
| 115 |
+
|
| 116 |
+
# Function to trigger balloon effect and then calculate weight
|
| 117 |
+
def trigger_balloon_and_weight(earth_weight, planet):
|
| 118 |
+
result = calculate_weight(earth_weight, planet)
|
| 119 |
+
balloon_script.trigger() # Trigger the balloon effect
|
| 120 |
+
return result
|
| 121 |
|
| 122 |
+
# Submit button and interaction
|
| 123 |
+
button = gr.Button("Calculate Weight")
|
| 124 |
+
button.click(trigger_balloon_and_weight, inputs=[earth_weight_input, planet_input], outputs=output)
|
| 125 |
|
| 126 |
demo.launch()
|
| 127 |
|