luminoussg commited on
Commit
d63f614
·
verified ·
1 Parent(s): b9b13af

Update textbox_with_upload.py

Browse files
Files changed (1) hide show
  1. 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
- @component
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 get_template_context(self):
23
- context = super().get_template_context()
24
- if self.upload_button:
25
- context["upload_button"] = self.upload_button.get_template_context()
26
- return context
27
 
28
- def get_block_name(self):
29
- return "textboxwithupload"
 
 
 
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])