xp3857 commited on
Commit
bd88d47
1 Parent(s): 3762c34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -4
app.py CHANGED
@@ -32,6 +32,81 @@ models=[
32
  ]
33
  #o = os.getenv("P")
34
  o = "V"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  def ac():
36
  def clear():
37
  return gr.update(value=0),gr.update(value=0)
@@ -40,14 +115,14 @@ def ac():
40
  stamp = time.time()
41
  return gr.update(value=stamp),gr.update(value=0)
42
  def end(stamp):
43
- ts = stamp + 20
44
  ti = time.time()
45
  if ti > ts and stamp != 0:
46
  print("Cancelling")
47
- return gr.update(value=1)
48
  else:
49
  print("Passing")
50
- return gr.update(value=0)
51
 
52
  def im_fn(put,fac="",h=None):
53
  if h == o:
@@ -61,6 +136,7 @@ def ac():
61
  def cl_fac():
62
  return ""
63
  with gr.Blocks(css=css) as b:
 
64
  with gr.Row():
65
  put = gr.Textbox()
66
  btn1 = gr.Button()
@@ -79,7 +155,7 @@ def ac():
79
  btn1.click(cl_fac,None,fac_b)
80
 
81
  b1=btn1.click(start,None,[t_state,t_switch])
82
- sta = t_state.change(end,t_state,t_switch,every=1)
83
 
84
  b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
85
  b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
 
32
  ]
33
  #o = os.getenv("P")
34
  o = "V"
35
+
36
+ t_out = gr.HTML.update("""
37
+
38
+ <style>
39
+ /* Popup container */
40
+ .popup {
41
+ position: relative;
42
+ display: inline-block;
43
+ cursor: pointer;
44
+ }
45
+
46
+ /* The actual popup (appears on top) */
47
+ .popup .popuptext {
48
+ visibility: hidden;
49
+ width: 160px;
50
+ background-color: #555;
51
+ color: #fff;
52
+ text-align: center;
53
+ border-radius: 6px;
54
+ padding: 8px 0;
55
+ position: absolute;
56
+ z-index: 1;
57
+ bottom: 125%;
58
+ left: 50%;
59
+ margin-left: -80px;
60
+ }
61
+
62
+ /* Popup arrow */
63
+ .popup .popuptext::after {
64
+ content: "";
65
+ position: absolute;
66
+ top: 100%;
67
+ left: 50%;
68
+ margin-left: -5px;
69
+ border-width: 5px;
70
+ border-style: solid;
71
+ border-color: #555 transparent transparent transparent;
72
+ }
73
+
74
+ /* Toggle this class when clicking on the popup container (hide and show the popup) */
75
+ .popup .show {
76
+ visibility: visible;
77
+ -webkit-animation: fadeIn 1s;
78
+ animation: fadeIn 1s
79
+ }
80
+
81
+ /* Add animation (fade in the popup) */
82
+ @-webkit-keyframes fadeIn {
83
+ from {opacity: 0;}
84
+ to {opacity: 1;}
85
+ }
86
+
87
+ @keyframes fadeIn {
88
+ from {opacity: 0;}
89
+ to {opacity:1 ;}
90
+ }
91
+
92
+ </style>
93
+ <div class="popup" onclick="myFunction()">Click me!
94
+ <span class="popuptext" id="myPopup">Popup text...</span>
95
+ </div>
96
+ <script>
97
+ // When the user clicks on <div>, open the popup
98
+ function myFunction() {
99
+ var popup = document.getElementById("myPopup");
100
+ popup.classList.toggle("show");
101
+ }
102
+ </script>
103
+
104
+
105
+
106
+
107
+ """,visible=True)
108
+
109
+
110
  def ac():
111
  def clear():
112
  return gr.update(value=0),gr.update(value=0)
 
115
  stamp = time.time()
116
  return gr.update(value=stamp),gr.update(value=0)
117
  def end(stamp):
118
+ ts = stamp + 10
119
  ti = time.time()
120
  if ti > ts and stamp != 0:
121
  print("Cancelling")
122
+ return gr.update(value=1),t_out
123
  else:
124
  print("Passing")
125
+ return gr.update(value=0),None
126
 
127
  def im_fn(put,fac="",h=None):
128
  if h == o:
 
136
  def cl_fac():
137
  return ""
138
  with gr.Blocks(css=css) as b:
139
+ message=gr.HTML("""""", visible=False)
140
  with gr.Row():
141
  put = gr.Textbox()
142
  btn1 = gr.Button()
 
155
  btn1.click(cl_fac,None,fac_b)
156
 
157
  b1=btn1.click(start,None,[t_state,t_switch])
158
+ sta = t_state.change(end,t_state,[t_switch,message],every=1)
159
 
160
  b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
161
  b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b])