-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.py
173 lines (154 loc) · 5.87 KB
/
init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import base64
import os.path
from typing import Optional, List
from h2o_wave import Q, ui
from PIL import Image
from func_data_vis import init_graph_params
async def init_page(q):
""" 更改之前没有async和if条件判断 """
# 确认已初始化
# q.client.initialized = True
init_graph_params(q)
if q.args['#'] is None:
render_start_page(q) # meta,header,sidebar,footer
def render_start_page(q: Q):
render_meta(q)
render_header(q)
render_sidebar(q)
render_footer(q)
path = 'https://s1.ax1x.com/2023/04/06/ppov8Cn.png'
q.client.cards.add('welcome')
# q.page['welcome'] = ui.form_card(
# box=ui.box('panel'),
# items=[
# ui.image(title='1', path=path, width='1250px')
# ],
# )
content = '''
Have a wonderful trip with this app! :)
'''
q.page['welcome'] = ui.tall_article_preview_card(
box=ui.box('panel'),
title='Welcome to my DV Project',
subtitle='Start from your left',
name='tall_article',
image=path,
content=content,
items=[
ui.buttons(items=[
ui.button(name='like', icon='Like'),
ui.button(name='comment', icon='CommentAdd'),
ui.button(name='share', icon='Share'),
]),
]
)
def render_meta(q: Q):
# 元数据设置
q.page['meta'] = ui.meta_card(
box='',
layouts=[ui.layout(breakpoint='xs', zones=[ # 定义三个区域
ui.zone(name='header'),
ui.zone(name='body', direction=ui.ZoneDirection.ROW,
zones=[
ui.zone(name='sidebar', size='15%'),
ui.zone(name='panel', size='85%', direction=ui.ZoneDirection.ROW)
],
size='100%'),
ui.zone(name='footer')
])],
themes=[
ui.theme(
name='theme1',
primary='#145152',
text='#2b2b2b',
card='#ededed',
page='#d1d1d1',
),
ui.theme(
name='theme2',
primary='#a9bfcc',
text='#e8e8e8',
card='#3d3d3d',
page='#1f1f1f',
),
ui.theme(
name='theme3',
primary='#51a9ad',
text='#ebebeb',
card='#292929',
page='#000000',
)
],
title='Kiwi DV Project NEW GUI',
theme='theme3'
)
def render_header(q: Q):
# Header
q.page['header'] = ui.header_card(
box=ui.box('header'),
title='🐷Piggy Visual',
subtitle='Data Visualizing ALL in ONE',
items=[ui.menu(image='https://s1.ax1x.com/2023/04/06/ppovrCR.jpg', items=[
ui.command(name='profile', label='Profile', icon='Contact'),
ui.command(name='preferences', label='Preferences', icon='Settings'),
ui.command(name='logout', label='Logout', icon='SignOut'),
])],
secondary_items=[
ui.mini_button(name="btn_visualizing", label="Vis", icon='Savings'),
ui.mini_button(name="btn_community", label="COMMUNITY", icon='Home'),
ui.mini_button(name="btn_donate", label="DONATE", icon='Money'),
ui.mini_button(name="btn_help", label="HELP", icon='EditContact'),
],
)
def render_sidebar(q: Q):
# Sidebar
q.page['nav'] = ui.nav_card(
box=ui.box('sidebar'),
items=[
ui.nav_group('Data Visualizing', items=[
ui.nav_item(name='#upload', label='Data Upload'),
ui.nav_item(name='#data_summary', label='Data Summary'),
ui.nav_item(name='#data_vis', label='Visualizing'),
ui.nav_item(name='#building', label='Developing', disabled=True),
]),
ui.nav_group('Data Preprocessing', items=[
ui.nav_item(name='#preprocessing', label='Data Preprocessing', disabled=True),
]),
ui.nav_group('Others', items=[
ui.nav_item(name='#about', label='About', icon='Info'),
ui.nav_item(name='#support', label='Support', icon='Help'),
])
]
)
def render_footer(q: Q):
# Footer
q.page['footer'] = ui.footer_card(
box=ui.box('footer'),
caption='Thanks for using!💛',
items=[
ui.inline(justify='end', items=[
ui.links(label='Basic', width='200px', items=[
ui.link(label='Pandas', path='https://pandas.pydata.org/', target='_blank'),
ui.link(label='H2O Wave', path='https://wave.h2o.ai/', target='_blank'),
ui.link(label='Kaggle', path='https://www.kaggle.com/', target='_blank'),
]),
ui.links(label='Plotting', width='200px', items=[
ui.link(label='Seaborn', path='https://seaborn.pydata.org/', target='_blank'),
ui.link(label='Scikit-Learn', path='https://scikit-learn.org/stable/', target='_blank'),
ui.link(label='Numpy', path='https://www.numpy.org.cn/reference/', target='_blank'),
]),
ui.links(label='Developing', width='200px', items=[
ui.link(label='Matplotlib', path='https://matplotlib.org/stable/api/index.html', target='_blank'),
ui.link(label='PyCharm', path='https://www.jetbrains.com/pycharm/', target='_blank'),
ui.link(label='Sample link', path='https://www.h2o.ai/', target='_blank'),
]),
]),
]
)
def clear_cards(q, ignore: Optional[List[str]] = []) -> None:
if not q.client.cards:
return
for name in q.client.cards.copy():
if name not in ignore:
del q.page[name]
q.client.cards.remove(name)