kbberendsen commited on
Commit
db1622b
1 Parent(s): 5ea99bf

preventing brief error by setting default driver

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-311.pyc +0 -0
  2. app.py +16 -16
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -5,7 +5,6 @@ import matplotlib.pyplot as plt
5
  from matplotlib.collections import LineCollection
6
  from matplotlib import cm
7
  import numpy as np
8
- import shiny.experimental as x
9
  import shinyswatch
10
 
11
  # Define cache folder path
@@ -28,7 +27,8 @@ app_ui = ui.page_fluid(
28
  ),
29
  ui.input_select(
30
  "driver_select", label="Select driver:",
31
- choices = []
 
32
  ),
33
  ui.input_radio_buttons(
34
  "session_type", "Session type:",
@@ -41,7 +41,7 @@ app_ui = ui.page_fluid(
41
  selected = "2023"
42
  ),
43
  width=2
44
- ),
45
 
46
  ui.panel_main(
47
  ui.h3("Gear usage in fastest lap"),
@@ -52,6 +52,19 @@ app_ui = ui.page_fluid(
52
  )
53
 
54
  def server(input, output, session):
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  @reactive.Calc
56
  def get_data():
57
  f1_session = ff1.get_session(int(input.year()), input.track_select(), input.session_type())
@@ -103,18 +116,5 @@ def server(input, output, session):
103
 
104
  plt
105
 
106
- @reactive.Effect()
107
- def _():
108
- if input.year() == "2023":
109
- driver_options = ['Fastest driver', 'RUS', 'VER', 'HAM']
110
- elif input.year() == "2022":
111
- driver_options = ['Fastest driver', 'LEC', 'NOR', 'GAS']
112
-
113
- ui.update_select("driver_select",
114
- label="Select driver:",
115
- choices=driver_options,
116
- selected="Fastest driver"
117
- )
118
-
119
 
120
  app = App(app_ui, server)
 
5
  from matplotlib.collections import LineCollection
6
  from matplotlib import cm
7
  import numpy as np
 
8
  import shinyswatch
9
 
10
  # Define cache folder path
 
27
  ),
28
  ui.input_select(
29
  "driver_select", label="Select driver:",
30
+ choices = ["Fastest driver"],
31
+ selected = "Fastest driver"
32
  ),
33
  ui.input_radio_buttons(
34
  "session_type", "Session type:",
 
41
  selected = "2023"
42
  ),
43
  width=2
44
+ ),
45
 
46
  ui.panel_main(
47
  ui.h3("Gear usage in fastest lap"),
 
52
  )
53
 
54
  def server(input, output, session):
55
+ @reactive.Effect()
56
+ def _():
57
+ if input.year() == "2023":
58
+ driver_options = ['Fastest driver', 'RUS', 'VER', 'HAM']
59
+ elif input.year() == "2022":
60
+ driver_options = ['Fastest driver', 'LEC', 'NOR', 'GAS']
61
+
62
+ ui.update_select("driver_select",
63
+ label="Select driver:",
64
+ choices=driver_options,
65
+ selected=input.driver_select()
66
+ )
67
+
68
  @reactive.Calc
69
  def get_data():
70
  f1_session = ff1.get_session(int(input.year()), input.track_select(), input.session_type())
 
116
 
117
  plt
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
  app = App(app_ui, server)