hmb HF Staff commited on
Commit
9e6b00c
·
verified ·
1 Parent(s): deb7f0f

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +119 -194
app.py CHANGED
@@ -1,217 +1,142 @@
1
- import time
2
-
3
  import gradio as gr
4
- from gradio.themes.utils.theme_dropdown import create_theme_dropdown
5
-
6
- dropdown, js = create_theme_dropdown()
7
-
8
- # Windows 95 custom CSS for authentic styling
9
- WINDOWS_95_CSS = """
10
- /* Windows 95 Taskbar Footer */
11
- footer {
12
- position: fixed !important;
13
- bottom: 0 !important;
14
- left: 0 !important;
15
- right: 0 !important;
16
- margin: 0 !important;
17
- padding: 4px 8px !important;
18
- background: #C0C0C0 !important;
19
- border-top: 2px solid #FFFFFF !important;
20
- box-shadow: inset 0 1px 0 0 #DFDFDF, inset 0 -1px 0 0 #808080, 0 -1px 0 0 #404040 !important;
21
- justify-content: flex-start !important;
22
- gap: 8px !important;
23
- z-index: 9999 !important;
24
- }
25
-
26
- footer button, footer a {
27
- background: #C0C0C0 !important;
28
- color: #000000 !important;
29
- border: none !important;
30
- padding: 4px 12px !important;
31
- box-shadow: inset -1px -1px 0px 0px #808080, inset 1px 1px 0px 0px #FFFFFF, inset -2px -2px 0px 0px #404040, inset 2px 2px 0px 0px #DFDFDF !important;
32
- }
33
-
34
- footer .divider { display: none !important; }
35
- footer img, button img, a img, svg { box-shadow: none !important; }
36
- .gradio-container { padding-bottom: 40px !important; }
37
-
38
- /* 3D Buttons */
39
- button { border-radius: 0 !important; }
40
-
41
- /* Sunken inputs */
42
- input, textarea, select {
43
- border-radius: 0 !important;
44
- box-shadow: inset 1px 1px 0px 0px #808080, inset -1px -1px 0px 0px #FFFFFF, inset 2px 2px 0px 0px #404040, inset -2px -2px 0px 0px #DFDFDF !important;
45
- }
46
-
47
- /* Windows 95 Scrollbars */
48
- *::-webkit-scrollbar { width: 16px !important; height: 16px !important; }
49
- *::-webkit-scrollbar-track { background: #DFDFDF !important; }
50
- *::-webkit-scrollbar-thumb {
51
- background: #C0C0C0 !important;
52
- box-shadow: inset -1px -1px 0px 0px #808080, inset 1px 1px 0px 0px #FFFFFF, inset -2px -2px 0px 0px #404040, inset 2px 2px 0px 0px #DFDFDF !important;
53
- }
54
-
55
- /* Selection */
56
- ::selection { background: #000080 !important; color: #FFFFFF !important; }
57
-
58
- /* Tabs */
59
- .tabs { gap: 0 !important; }
60
- .tab-container::after { display: none !important; }
61
- .tabs button[role="tab"] {
62
- background: #C0C0C0 !important;
63
- border-radius: 0 !important;
64
- box-shadow: inset 1px 1px 0px 0px #FFFFFF, inset -1px 0px 0px 0px #808080, inset 2px 2px 0px 0px #DFDFDF, inset -2px 0px 0px 0px #404040 !important;
65
- }
66
-
67
- /* Code highlighting - white text on navy */
68
- .highlight, span.highlight, .code.highlight {
69
- background: #000080 !important;
70
- color: #FFFFFF !important;
71
- }
72
-
73
- pre span[style*="background"], code span[style*="background"] {
74
- color: #FFFFFF !important;
75
- }
76
- """
77
 
78
  with gr.Blocks() as demo:
79
- with gr.Row(equal_height=True):
80
- with gr.Column(scale=10):
81
- gr.Markdown(
82
- """
83
- # Theme preview: `windows95`
84
- To use this theme, set `theme='hmb/windows95'` in the `launch()` method of `gr.Blocks()` or `gr.Interface()`.
85
- You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
86
- of this theme.
87
- """
88
  )
89
- with gr.Column(scale=3):
90
- with gr.Group():
91
- dropdown.render()
92
- toggle_dark = gr.Button(value="Toggle Dark")
93
-
94
- dropdown.change(None, dropdown, None, js=js)
95
- toggle_dark.click(
96
- None,
97
- js="""
98
- () => {
99
- document.body.classList.toggle('dark');
100
- }
101
- """,
102
- )
103
 
104
- name = gr.Textbox(
105
- label="Name",
106
- info="Full name, including middle name. No special characters.",
107
- placeholder="John Doe",
108
- value="John Doe",
109
- interactive=True,
110
- )
111
 
112
- with gr.Row():
113
- slider1 = gr.Slider(label="Slider 1")
114
- slider2 = gr.Slider(label="Slider 2")
115
- gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
 
 
116
 
117
- with gr.Row():
118
- with gr.Column(variant="panel", scale=1):
119
- gr.Markdown("## Panel 1")
120
- radio = gr.Radio(
121
- ["A", "B", "C"],
122
- label="Radio",
123
- info="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
124
  )
125
- drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
126
- drop_2 = gr.Dropdown(
127
- ["Option A", "Option B", "Option C"],
128
- multiselect=True,
129
- value=["Option A"],
130
- label="Dropdown",
131
- interactive=True,
 
 
 
132
  )
133
- check = gr.Checkbox(label="Go")
134
- with gr.Column(variant="panel", scale=2):
135
- img = gr.Image(
136
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg",
137
- label="Image",
138
- height=320,
139
  )
 
 
 
 
 
 
140
  with gr.Row():
141
- go_btn = gr.Button("Go", variant="primary")
142
- clear_btn = gr.Button("Clear", variant="secondary")
 
143
 
144
- def go(*_args):
145
- time.sleep(3)
146
- return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg"
147
 
148
- go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
 
 
149
 
150
- def clear():
151
- time.sleep(0.2)
152
 
153
- clear_btn.click(clear, None, img)
154
 
155
- with gr.Row():
156
- btn1 = gr.Button("Button 1", size="sm")
157
- btn2 = gr.UploadButton(size="sm")
158
- stop_btn = gr.Button("Stop", size="sm", variant="stop")
 
 
 
 
 
 
159
 
160
- with gr.Row():
161
- gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
162
- gr.JSON(
163
- value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
164
  )
165
- gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
166
- gr.File()
167
- with gr.Row():
168
- gr.ColorPicker()
169
- gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
170
- gr.Gallery(
171
- [
172
- (
173
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
174
- "lion",
175
- ),
176
- (
177
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
178
- "logo",
179
- ),
180
- (
181
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
182
- "tower",
183
- ),
184
- ],
185
- height=200,
186
  )
187
 
188
- with gr.Row():
189
- with gr.Column(scale=2):
190
- chatbot = gr.Chatbot([
191
- {"role": "user", "content": "Hello"},
192
- {"role": "assistant", "content": "Hi"}
193
- ], label="Chatbot")
194
- chat_btn = gr.Button("Add messages")
195
-
196
- def add_messages(history):
197
- time.sleep(2)
198
- return history + [
199
- {"role": "user", "content": "How are you?"},
200
- {"role": "assistant", "content": "I am good."}
201
- ]
202
-
203
- chat_btn.click(
204
- add_messages,
205
- chatbot,
206
- chatbot,
207
- )
208
- with gr.Column(scale=1):
209
- with gr.Accordion("Advanced Settings"):
210
- gr.Markdown("Hello")
211
- gr.Number(label="Chatbot control 1")
212
- gr.Number(label="Chatbot control 2")
213
- gr.Number(label="Chatbot control 3")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
 
216
  if __name__ == "__main__":
217
- demo.queue().launch(theme='hmb/windows95', css=WINDOWS_95_CSS)
 
 
 
1
  import gradio as gr
2
+ from windows95 import Windows95, WINDOWS_95_CSS
3
+
4
+ # Windows 95 Theme Demo
5
+ # This demo showcases the nostalgic Windows 95-inspired theme
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  with gr.Blocks() as demo:
8
+ with gr.Row():
9
+ with gr.Column():
10
+ gr.Markdown("## Input Controls")
11
+
12
+ name_input = gr.Textbox(
13
+ label="Your Name",
14
+ placeholder="Enter your name here...",
15
+ info="Type your name in this text field",
 
16
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ message_input = gr.Textbox(
19
+ label="Message",
20
+ placeholder="Type a message...",
21
+ lines=3,
22
+ info="Multi-line text input",
23
+ )
 
24
 
25
+ dropdown = gr.Dropdown(
26
+ label="Select Option",
27
+ choices=["Option 1", "Option 2", "Option 3"],
28
+ value="Option 1",
29
+ info="Choose from the dropdown menu",
30
+ )
31
 
32
+ slider = gr.Slider(
33
+ label="Volume",
34
+ minimum=0,
35
+ maximum=100,
36
+ value=50,
37
+ step=1,
38
+ info="Drag to adjust the value",
39
  )
40
+
41
+ checkbox = gr.Checkbox(
42
+ label="Enable Feature", value=True, info="Toggle this setting"
43
+ )
44
+
45
+ radio = gr.Radio(
46
+ label="Choose One",
47
+ choices=["Small", "Medium", "Large"],
48
+ value="Medium",
49
+ info="Select a size",
50
  )
51
+
52
+ checkboxgroup = gr.CheckboxGroup(
53
+ label="Select Multiple",
54
+ choices=["Red", "Green", "Blue"],
55
+ value=["Red"],
56
+ info="Pick your favorite colors",
57
  )
58
+
59
+ with gr.Column():
60
+ gr.Markdown("## Output & Actions")
61
+
62
+ output_text = gr.Textbox(label="Output", interactive=False, lines=3)
63
+
64
  with gr.Row():
65
+ submit_btn = gr.Button("OK", variant="primary")
66
+ clear_btn = gr.Button("Cancel", variant="stop")
67
+ secondary_btn = gr.Button("Help", variant="secondary")
68
 
69
+ gr.Markdown("## File Operations")
 
 
70
 
71
+ file_upload = gr.File(
72
+ label="Upload File", file_types=[".txt", ".csv", ".json"]
73
+ )
74
 
75
+ image_input = gr.Image(label="Image Preview", type="pil")
 
76
 
77
+ gr.Markdown("## Data Display")
78
 
79
+ dataframe = gr.Dataframe(
80
+ label="Data Table",
81
+ headers=["Name", "Value", "Status"],
82
+ datatype=["str", "number", "str"],
83
+ value=[
84
+ ["Item 1", 100, "Active"],
85
+ ["Item 2", 200, "Inactive"],
86
+ ["Item 3", 300, "Pending"],
87
+ ],
88
+ )
89
 
90
+ with gr.Accordion("Advanced Settings", open=False):
91
+ gr.Markdown("Additional configuration options would go here.")
92
+ adv_slider = gr.Slider(
93
+ label="Advanced Slider", minimum=0, maximum=100, value=25
94
  )
95
+ adv_text = gr.Textbox(
96
+ label="Advanced Input", placeholder="Enter advanced settings..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  )
98
 
99
+ with gr.Tabs():
100
+ with gr.TabItem("Tab 1"):
101
+ gr.Markdown("Content for Tab 1")
102
+ gr.Textbox(label="Tab 1 Input")
103
+ with gr.TabItem("Tab 2"):
104
+ gr.Markdown("Content for Tab 2")
105
+ gr.Textbox(label="Tab 2 Input")
106
+ with gr.TabItem("Tab 3"):
107
+ gr.Markdown("Content for Tab 3")
108
+ gr.Textbox(label="Tab 3 Input")
109
+
110
+ # Event handlers
111
+ def process_input(name, message, dropdown, slider, checkbox, radio, colors):
112
+ result = f"Name: {name}\n"
113
+ result += f"Message: {message}\n"
114
+ result += f"Dropdown: {dropdown}\n"
115
+ result += f"Slider: {slider}\n"
116
+ result += f"Checkbox: {checkbox}\n"
117
+ result += f"Radio: {radio}\n"
118
+ result += f"Colors: {', '.join(colors)}"
119
+ return result
120
+
121
+ def clear_output():
122
+ return ""
123
+
124
+ submit_btn.click(
125
+ fn=process_input,
126
+ inputs=[
127
+ name_input,
128
+ message_input,
129
+ dropdown,
130
+ slider,
131
+ checkbox,
132
+ radio,
133
+ checkboxgroup,
134
+ ],
135
+ outputs=output_text,
136
+ )
137
+
138
+ clear_btn.click(fn=clear_output, outputs=output_text)
139
 
140
 
141
  if __name__ == "__main__":
142
+ demo.launch(theme=Windows95(), css=WINDOWS_95_CSS)