Spaces:
Sleeping
Sleeping
Update textbox_with_upload.py
Browse files- textbox_with_upload.py +7 -12
textbox_with_upload.py
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
-
from gradio.components import Textbox
|
3 |
-
from gradio.components.base import Component
|
4 |
-
from gradio import component
|
5 |
|
6 |
-
|
7 |
-
class TextboxWithUpload(Textbox):
|
8 |
def __init__(self, *args, **kwargs):
|
9 |
super().__init__(*args, **kwargs)
|
10 |
self.upload_button = None
|
@@ -19,11 +15,10 @@ class TextboxWithUpload(Textbox):
|
|
19 |
return file.name
|
20 |
return ""
|
21 |
|
22 |
-
def
|
23 |
-
|
24 |
-
if self.upload_button:
|
25 |
-
context["upload_button"] = self.upload_button.get_template_context()
|
26 |
-
return context
|
27 |
|
28 |
-
def
|
29 |
-
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
+
class TextboxWithUpload(gr.Textbox):
|
|
|
4 |
def __init__(self, *args, **kwargs):
|
5 |
super().__init__(*args, **kwargs)
|
6 |
self.upload_button = None
|
|
|
15 |
return file.name
|
16 |
return ""
|
17 |
|
18 |
+
def render(self):
|
19 |
+
return self.render_with_upload_button()
|
|
|
|
|
|
|
20 |
|
21 |
+
def render_with_upload_button(self):
|
22 |
+
textbox = super().render()
|
23 |
+
upload_button = self.upload_button.render()
|
24 |
+
return gr.Row([textbox, upload_button])
|