Jonas Wiesli commited on
Commit
c35fe56
·
1 Parent(s): 39193db

added missing buttons, shortened function definition code

Browse files
Files changed (1) hide show
  1. app.py +25 -29
app.py CHANGED
@@ -49,6 +49,7 @@ with gr.Blocks() as iface:
49
  with gr.Row() as chatRow:
50
  with gr.Column(scale=2):
51
  questionCounter = gr.Label(label="Remaining Questions", value="24")
 
52
  finishButton = gr.Button("Try to Solve")
53
  with gr.Column(scale=10):
54
  i = 0
@@ -62,6 +63,10 @@ with gr.Blocks() as iface:
62
  characterImage = gr.Label(label="")
63
  i += 1
64
 
 
 
 
 
65
  with gr.Row(visible=False) as solvingRow:
66
  i = 0
67
  while i < len(roles):
@@ -69,6 +74,8 @@ with gr.Blocks() as iface:
69
  accusationButtons.append(gr.Button(roles[i]))
70
  i += 1
71
 
 
 
72
  with gr.Row(visible=False) as resultRow:
73
  with gr.Column():
74
  resultLabel = gr.Label(label="Result")
@@ -135,6 +142,12 @@ with gr.Blocks() as iface:
135
 
136
  def tryToSolve():
137
  return {solvingRow: gr.update(visible=True)}
 
 
 
 
 
 
138
 
139
  def showResult():
140
  return {chatRow: gr.update(visible=False), solvingRow: gr.update(visible=False), resultRow: gr.update(visible=True)}
@@ -146,37 +159,20 @@ with gr.Blocks() as iface:
146
  return "Congratulations, you found the killer! "
147
 
148
  # again, ugly workaround
149
- msg[0].submit(user, [msg[0], chatbot[0]], [msg[0], chatbot[0]], queue=False).then(
150
- bot0, [chatbot[0], questionCounter], chatbot[0]
151
- ).then(
152
- updateQuestions, questionCounter, questionCounter
153
- )
154
-
155
- msg[1].submit(user, [msg[1], chatbot[1]], [msg[1], chatbot[1]], queue=False).then(
156
- bot1, [chatbot[1], questionCounter], chatbot[1]
157
- ).then(
158
- updateQuestions, questionCounter, questionCounter
159
- )
160
-
161
- msg[2].submit(user, [msg[2], chatbot[2]], [msg[2], chatbot[2]], queue=False).then(
162
- bot2, [chatbot[2], questionCounter], chatbot[2]
163
- ).then(
164
- updateQuestions, questionCounter, questionCounter
165
- )
166
-
167
- msg[3].submit(user, [msg[3], chatbot[3]], [msg[3], chatbot[3]], queue=False).then(
168
- bot3, [chatbot[3], questionCounter], chatbot[3]
169
- ).then(
170
- updateQuestions, questionCounter, questionCounter
171
- )
172
-
173
- msg[4].submit(user, [msg[4], chatbot[4]], [msg[4], chatbot[4]], queue=False).then(
174
- bot4, [chatbot[4], questionCounter], chatbot[4]
175
- ).then(
176
- updateQuestions, questionCounter, questionCounter
177
- )
178
 
 
 
179
  finishButton.click(tryToSolve, None, solvingRow)
 
180
 
181
  i = 0
182
  while i < len(roles):
 
49
  with gr.Row() as chatRow:
50
  with gr.Column(scale=2):
51
  questionCounter = gr.Label(label="Remaining Questions", value="24")
52
+ mapButton = gr.Button("Show Floor Plan")
53
  finishButton = gr.Button("Try to Solve")
54
  with gr.Column(scale=10):
55
  i = 0
 
63
  characterImage = gr.Label(label="")
64
  i += 1
65
 
66
+ with gr.Row(visible=False) as mapRow:
67
+ with gr.Column():
68
+ closeMapButton = gr.Button("X")
69
+
70
  with gr.Row(visible=False) as solvingRow:
71
  i = 0
72
  while i < len(roles):
 
74
  accusationButtons.append(gr.Button(roles[i]))
75
  i += 1
76
 
77
+ closeSolvingButton = gr.Button("X")
78
+
79
  with gr.Row(visible=False) as resultRow:
80
  with gr.Column():
81
  resultLabel = gr.Label(label="Result")
 
142
 
143
  def tryToSolve():
144
  return {solvingRow: gr.update(visible=True)}
145
+ def showMap():
146
+ return {mapRow: gr.update(visible=True)}
147
+ def hideSolveBox():
148
+ return {solvingRow: gr.update(visible=False)}
149
+ def hideMap():
150
+ return {mapRow: gr.update(visible=False)}
151
 
152
  def showResult():
153
  return {chatRow: gr.update(visible=False), solvingRow: gr.update(visible=False), resultRow: gr.update(visible=True)}
 
159
  return "Congratulations, you found the killer! "
160
 
161
  # again, ugly workaround
162
+ botfunctions = [bot0, bot1, bot2, bot3, bot4]
163
+ i = 0
164
+ while i < len(roles):
165
+ msg[i].submit(user, [msg[i], chatbot[i]], [msg[i], chatbot[i]], queue=False).then(
166
+ botfunctions[i], [chatbot[i], questionCounter], chatbot[i]
167
+ ).then(
168
+ updateQuestions, questionCounter, questionCounter
169
+ )
170
+ i += 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
+ mapButton.click(showMap, None, mapRow)
173
+ closeMapButton.click(hideMap, None, mapRow)
174
  finishButton.click(tryToSolve, None, solvingRow)
175
+ closeSolvingButton.click(hideSolveBox, None, solvingRow)
176
 
177
  i = 0
178
  while i < len(roles):