| 1004 | | |
|---|
| | 1004 | |
|---|
| | 1005 | |
|---|
| | 1006 | class TextControl(InteractControl): |
|---|
| | 1007 | def __init__(self, var, data): |
|---|
| | 1008 | """ |
|---|
| | 1009 | A text field interact control |
|---|
| | 1010 | |
|---|
| | 1011 | INPUT: |
|---|
| | 1012 | data -- the HTML value of the text field |
|---|
| | 1013 | |
|---|
| | 1014 | EXAMPLES: |
|---|
| | 1015 | sage: sage.server.notebook.interact.TextControl('x', 'something') |
|---|
| | 1016 | Text Interact Control: something |
|---|
| | 1017 | """ |
|---|
| | 1018 | InteractControl.__init__(self, var, data, label='') |
|---|
| | 1019 | self.__data = data |
|---|
| | 1020 | |
|---|
| | 1021 | def __repr__(self): |
|---|
| | 1022 | """ |
|---|
| | 1023 | Return string representation of this control. |
|---|
| | 1024 | |
|---|
| | 1025 | EXAMPLES: |
|---|
| | 1026 | sage: sage.server.notebook.interact.TextControl('x', 'something').__repr__() |
|---|
| | 1027 | 'Text Interact Control: something' |
|---|
| | 1028 | """ |
|---|
| | 1029 | return 'Text Interact Control: %s'%self.default_value() |
|---|
| | 1030 | |
|---|
| | 1031 | def render(self): |
|---|
| | 1032 | """ |
|---|
| | 1033 | Render this control as an HTML string. |
|---|
| | 1034 | |
|---|
| | 1035 | OUTPUT: |
|---|
| | 1036 | string -- html format |
|---|
| | 1037 | |
|---|
| | 1038 | EXAMPLES: |
|---|
| | 1039 | sage: sage.server.notebook.interact.TextControl('x', 'something').render() |
|---|
| | 1040 | '<div ...>something</div>' |
|---|
| | 1041 | """ |
|---|
| | 1042 | return '<div style="color:black; padding-bottom:5px">%s</div>'%self.default_value() |
|---|
| | 1043 | |
|---|
| | 2027 | class text_control(control): |
|---|
| | 2028 | def __init__(self, value): |
|---|
| | 2029 | """ |
|---|
| | 2030 | Text that can be inserted among other interact controls. |
|---|
| | 2031 | |
|---|
| | 2032 | INPUT: |
|---|
| | 2033 | value -- HTML for the control |
|---|
| | 2034 | |
|---|
| | 2035 | EXAMPLES: |
|---|
| | 2036 | sage: text_control('something') |
|---|
| | 2037 | Text field: something |
|---|
| | 2038 | """ |
|---|
| | 2039 | self.__default = value |
|---|
| | 2040 | control.__init__(self, '') |
|---|
| | 2041 | |
|---|
| | 2042 | def __repr__(self): |
|---|
| | 2043 | """ |
|---|
| | 2044 | Return print representation of this control. |
|---|
| | 2045 | |
|---|
| | 2046 | EXAMPLES: |
|---|
| | 2047 | sage: text_control('something') |
|---|
| | 2048 | Text field: something |
|---|
| | 2049 | """ |
|---|
| | 2050 | return "Text field: %s"%self.__default |
|---|
| | 2051 | |
|---|
| | 2052 | def render(self, var): |
|---|
| | 2053 | """ |
|---|
| | 2054 | Return rendering of the text field |
|---|
| | 2055 | |
|---|
| | 2056 | INPUT: |
|---|
| | 2057 | var -- a string (variable; one of the variable names input to f) |
|---|
| | 2058 | |
|---|
| | 2059 | OUTPUT: |
|---|
| | 2060 | TextControl -- a TextControl instance |
|---|
| | 2061 | """ |
|---|
| | 2062 | return TextControl(var, self.__default) |
|---|
| | 2063 | |
|---|