|
| 1 | +import random |
| 2 | + |
| 3 | +def get_textbox(id, type="str" , default="" , title="" , description=""): |
| 4 | + |
| 5 | + types = {"str" : "text" , "int" : "number" , "float" : "number"} |
| 6 | + |
| 7 | + return { |
| 8 | + "id": str(random.randint(0,19989999)), |
| 9 | + "component": "InputWithDesc", |
| 10 | + "title": title, |
| 11 | + "description":description , |
| 12 | + "children": [ |
| 13 | + { |
| 14 | + "id": id, |
| 15 | + "component": "Textbox", |
| 16 | + "placeholder" : "", |
| 17 | + "default_value" : default , |
| 18 | + "type" : types[type], |
| 19 | + "output_type" :type , |
| 20 | + "is_persistant" : False |
| 21 | + } |
| 22 | + ] |
| 23 | + } |
| 24 | + |
| 25 | +def get_output_text(text): |
| 26 | + return { |
| 27 | + "id": str(random.randint(0,19989999)), |
| 28 | + "component": "OutputText", |
| 29 | + "text" : text |
| 30 | + } |
| 31 | +def get_output_img(img_path, save_ext='.png' , is_save=False): |
| 32 | + return { |
| 33 | + "id": str(random.randint(0,19989999)), |
| 34 | + "component": "OutputImage", |
| 35 | + "img_path" : img_path, |
| 36 | + "is_save" : is_save , |
| 37 | + "save_ext" : save_ext |
| 38 | + } |
| 39 | + |
| 40 | +def get_file_textbox(id , path_type="", title="" , description="" ): |
| 41 | + return { |
| 42 | + "id": str(random.randint(0,19989999)), |
| 43 | + "component": "InputWithDesc", |
| 44 | + "full_width": True, |
| 45 | + "title": title, |
| 46 | + "description": description, |
| 47 | + "children": [ |
| 48 | + { |
| 49 | + "id": id , |
| 50 | + "component": "FilePathTextBox", |
| 51 | + "placeholder" : "", |
| 52 | + "is_persistant" : False, |
| 53 | + "path_type" : path_type |
| 54 | + }, |
| 55 | + ] |
| 56 | + } |
| 57 | + |
| 58 | +def get_textarea(id , title="" , description="" ): |
| 59 | + return { |
| 60 | + "id": str(random.randint(0,19989999)), |
| 61 | + "component": "InputWithDesc", |
| 62 | + "full_width": True, |
| 63 | + "title": title, |
| 64 | + "description": description, |
| 65 | + "children": [ |
| 66 | + { |
| 67 | + "id": id , |
| 68 | + "component": "Textarea", |
| 69 | + "placeholder" : title , |
| 70 | + "is_small" : True, |
| 71 | + "is_persistant" : False, |
| 72 | + }, |
| 73 | + ] |
| 74 | + } |
| 75 | + |
0 commit comments