You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gradio/components.py
+42-28Lines changed: 42 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,12 @@
16
16
importPIL
17
17
fromffmpyimportFFmpeg
18
18
frommarkdown_itimportMarkdownIt
19
+
importmatplotlib.figure
19
20
20
21
fromgradioimportprocessing_utils, test_data
21
22
fromgradio.blocksimportBlock
22
23
24
+
23
25
classComponent(Block):
24
26
"""
25
27
A base class for defining the methods that all gradio components should have.
@@ -752,27 +754,27 @@ class CheckboxGroup(Component):
752
754
753
755
def__init__(
754
756
self,
755
-
default_value: List[str] =None,
756
-
*,
757
757
choices: List[str],
758
+
*,
759
+
default_selected: List[str] =None,
758
760
type: str="value",
759
761
label: Optional[str] =None,
760
762
css: Optional[Dict] =None,
761
763
**kwargs,
762
764
):
763
765
"""
764
766
Parameters:
765
-
default_value (List[str]): default selected list of options.
766
767
choices (List[str]): list of options to select from.
768
+
default_selected (List[str]): default selected list of options.
767
769
type (str): Type of value to be returned by component. "value" returns the list of strings of the choices selected, "index" returns the list of indicies of the choices selected.
768
770
label (str): component name in interface.
769
771
"""
770
772
if (
771
-
default_valueisNone
773
+
default_selectedisNone
772
774
): # Mutable parameters shall not be given as default parameters in the function.
773
-
default_value= []
775
+
default_selected= []
774
776
self.choices=choices
775
-
self.default=default_value
777
+
self.default=default_selected
776
778
self.type=type
777
779
self.test_input=self.choices
778
780
self.interpret_by_tokens=False
@@ -880,25 +882,27 @@ class Radio(Component):
880
882
881
883
def__init__(
882
884
self,
883
-
default_value: Optional[str] =None,
884
-
*,
885
885
choices: List[str],
886
+
*,
887
+
default_selected: Optional[str] =None,
886
888
type: str="value",
887
889
label: Optional[str] =None,
888
890
css: Optional[Dict] =None,
889
891
**kwargs,
890
892
):
891
893
"""
892
894
Parameters:
893
-
default_value (str): the button selected by default. If None, no button is selected by default.
894
895
choices (List[str]): list of options to select from.
896
+
default_selected (str): the button selected by default. If None, no button is selected by default.
895
897
type (str): Type of value to be returned by component. "value" returns the string of the choice selected, "index" returns the index of the choice selected.
default_value (str): default value selected in dropdown. If None, no value is selected by default.
997
1000
choices (List[str]): list of options to select from.
1001
+
default_selected (str): default value selected in dropdown. If None, no value is selected by default.
998
1002
type (str): Type of value to be returned by component. "value" returns the string of the choice selected, "index" returns the index of the choice selected.
999
1003
label (str): component name in interface.
1000
1004
"""
1001
1005
# Everything is same with Dropdown and Radio, so let's make use of it :)
0 commit comments