Jofthomas commited on
Commit
69df384
·
verified ·
1 Parent(s): 2573183

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -22
app.py CHANGED
@@ -178,7 +178,7 @@ def invite_to_battle(agent_choice: str, username: str):
178
  # iframe code to embed Pokemon Showdown (using official URL)
179
  iframe_code = """
180
  <iframe
181
- src="https://play.pokemonshowdown.com/"
182
  width="100%"
183
  height="800"
184
  style="border: none;"
@@ -191,31 +191,43 @@ def main_app():
191
  # Start agent initialization when the app is defined/loaded
192
  start_agent_initialization()
193
 
 
194
  with gr.Blocks(title="Pokemon Showdown Bot") as demo:
195
  gr.Markdown("# Pokémon Showdown Battle Bot")
196
- gr.Markdown("Select a bot agent, enter **your** Showdown username (the one you are logged in with below), and click Send Invite.")
 
 
 
197
 
 
198
  with gr.Row():
199
- with gr.Column(scale=1):
200
- gr.Markdown("### Configuration")
201
- agent_dropdown = gr.Dropdown(
202
- label="Select Bot Agent",
203
- choices=["Random Player", "OpenAI Agent"],
204
- value="Random Player" # Default choice
205
- )
206
- name_input = gr.Textbox(
207
- label="Your Pokémon Showdown Username",
208
- placeholder="Enter username used in Showdown below"
209
- )
210
- battle_button = gr.Button("Send Battle Invitation")
211
- status_output = gr.Textbox(label="Status", interactive=False, lines=2) # Added for feedback
212
-
213
- with gr.Column(scale=3):
214
- gr.Markdown("### Pokémon Showdown Interface")
215
- gr.Markdown("Log in/use the username you entered above.")
216
- gr.HTML(iframe_code)
217
-
218
- # Connect button click to the invitation function
 
 
 
 
 
 
 
219
  battle_button.click(
220
  fn=invite_to_battle,
221
  inputs=[agent_dropdown, name_input],
@@ -229,4 +241,5 @@ if __name__ == "__main__":
229
  # Create and launch the Gradio app
230
  app = main_app()
231
  # You might need to configure server_name and server_port depending on your deployment environment
 
232
  app.launch() # server_name="0.0.0.0" # To make accessible on network
 
178
  # iframe code to embed Pokemon Showdown (using official URL)
179
  iframe_code = """
180
  <iframe
181
+ src="https://jofthomas.com/play.pokemonshowdown.com/testclient.html"
182
  width="100%"
183
  height="800"
184
  style="border: none;"
 
191
  # Start agent initialization when the app is defined/loaded
192
  start_agent_initialization()
193
 
194
+ # Using gr.Blocks. The default layout should stretch reasonably wide.
195
  with gr.Blocks(title="Pokemon Showdown Bot") as demo:
196
  gr.Markdown("# Pokémon Showdown Battle Bot")
197
+ gr.Markdown(
198
+ "Select a bot agent, enter **your** Showdown username "
199
+ "(the one you are logged in with below), and click Send Invite."
200
+ )
201
 
202
+ # --- Row for Controls at the Top ---
203
  with gr.Row():
204
+ # Place controls here
205
+ agent_dropdown = gr.Dropdown(
206
+ label="Select Bot Agent",
207
+ choices=["Random Player", "OpenAI Agent"],
208
+ value="Random Player",
209
+ scale=1 # Give dropdown reasonable space
210
+ )
211
+ name_input = gr.Textbox(
212
+ label="Your Pokémon Showdown Username",
213
+ placeholder="Enter username used in Showdown below",
214
+ scale=2 # Give name input more relative space
215
+ )
216
+ battle_button = gr.Button("Send Battle Invitation", scale=1) # Button takes less space
217
+ status_output = gr.Textbox(
218
+ label="Status",
219
+ interactive=False,
220
+ lines=1, # Keep status compact initially
221
+ scale=2 # Give status reasonable space
222
+ )
223
+
224
+ # --- Section for the IFrame below the controls ---
225
+ gr.Markdown("### Pokémon Showdown Interface")
226
+ gr.Markdown("Log in/use the username you entered above.")
227
+ # The HTML component containing the iframe will take up the available width
228
+ gr.HTML(iframe_code)
229
+
230
+ # --- Connect button click to the invitation function ---
231
  battle_button.click(
232
  fn=invite_to_battle,
233
  inputs=[agent_dropdown, name_input],
 
241
  # Create and launch the Gradio app
242
  app = main_app()
243
  # You might need to configure server_name and server_port depending on your deployment environment
244
+ # Use app.launch(share=True) for a public link (if needed and safe)
245
  app.launch() # server_name="0.0.0.0" # To make accessible on network