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 |
}
|
|
@@ -56,7 +56,33 @@ def main():
|
|
| 56 |
50% { color: #feb47b; }
|
| 57 |
100% { color: #00b4d8; }
|
| 58 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
""") as demo:
|
|
|
|
| 60 |
gr.Markdown("# Weight Calculator on Different Planets")
|
| 61 |
gr.Markdown("Enter your weight on Earth and choose a planet to find your weight on it.")
|
| 62 |
|
|
@@ -68,7 +94,27 @@ def main():
|
|
| 68 |
|
| 69 |
# Submit button and interaction
|
| 70 |
button = gr.Button("Calculate Weight")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
button.click(calculate_weight, inputs=[earth_weight_input, planet_input], outputs=output)
|
|
|
|
| 72 |
|
| 73 |
demo.launch()
|
| 74 |
|
|
|
|
| 33 |
def main():
|
| 34 |
with gr.Blocks(css="""
|
| 35 |
.gradio-container {
|
| 36 |
+
background: url('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQrpx_alD_MY29yHYIZryYkBbT-LB-Kb1PpdhDmhb4MPfAIX2WCfOIhYW_6WaxAmR6LW5U&usqp=CAU') no-repeat center center fixed;
|
| 37 |
background-size: cover;
|
| 38 |
min-height: 100vh;
|
| 39 |
}
|
|
|
|
| 56 |
50% { color: #feb47b; }
|
| 57 |
100% { color: #00b4d8; }
|
| 58 |
}
|
| 59 |
+
|
| 60 |
+
/* Balloon Animation */
|
| 61 |
+
.balloon {
|
| 62 |
+
position: absolute;
|
| 63 |
+
bottom: 0;
|
| 64 |
+
animation: rise 6s ease-in-out forwards, float 4s ease-in-out infinite;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
@keyframes rise {
|
| 68 |
+
0% { bottom: 0; opacity: 1; }
|
| 69 |
+
100% { bottom: 90%; opacity: 0; }
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
@keyframes float {
|
| 73 |
+
0% { transform: translateX(0); }
|
| 74 |
+
50% { transform: translateX(30px); }
|
| 75 |
+
100% { transform: translateX(0); }
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.balloon-text {
|
| 79 |
+
font-size: 1.5rem;
|
| 80 |
+
color: white;
|
| 81 |
+
text-align: center;
|
| 82 |
+
font-weight: bold;
|
| 83 |
+
}
|
| 84 |
""") as demo:
|
| 85 |
+
|
| 86 |
gr.Markdown("# Weight Calculator on Different Planets")
|
| 87 |
gr.Markdown("Enter your weight on Earth and choose a planet to find your weight on it.")
|
| 88 |
|
|
|
|
| 94 |
|
| 95 |
# Submit button and interaction
|
| 96 |
button = gr.Button("Calculate Weight")
|
| 97 |
+
|
| 98 |
+
# Function to trigger balloon effect using JavaScript
|
| 99 |
+
def trigger_balloon_effect():
|
| 100 |
+
return """
|
| 101 |
+
const balloonCount = 5; // Number of balloons to show
|
| 102 |
+
for (let i = 0; i < balloonCount; i++) {
|
| 103 |
+
let balloon = document.createElement('div');
|
| 104 |
+
balloon.classList.add('balloon');
|
| 105 |
+
balloon.style.left = Math.random() * 100 + 'vw'; // Random horizontal position
|
| 106 |
+
let balloonText = document.createElement('div');
|
| 107 |
+
balloonText.classList.add('balloon-text');
|
| 108 |
+
balloonText.textContent = '🎈'; // Emoji or custom text for the balloon
|
| 109 |
+
balloon.appendChild(balloonText);
|
| 110 |
+
document.body.appendChild(balloon);
|
| 111 |
+
setTimeout(() => balloon.remove(), 6000); // Remove balloon after animation
|
| 112 |
+
}
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
# Connect button click to calculate weight and trigger the balloon effect
|
| 116 |
button.click(calculate_weight, inputs=[earth_weight_input, planet_input], outputs=output)
|
| 117 |
+
button.click(trigger_balloon_effect)
|
| 118 |
|
| 119 |
demo.launch()
|
| 120 |
|