From 265d49240f7224aff91c107b0c6da28ec3b5f8a4 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Mon, 29 May 2023 11:37:43 +0800 Subject: [PATCH 1/7] requirements.txt update and test to pc 0.1.32 --- chatroom/requirements.txt | 2 +- clock/requirements.txt | 2 +- counter/requirements.txt | 2 +- crm/requirements.txt | 2 +- dalle/requirements.txt | 2 +- fragments/requirements.txt | 2 +- gpt/requirements.txt | 2 +- nba/requirements.txt | 2 +- quiz/requirements.txt | 2 +- sales/requirements.txt | 2 +- snakegame/requirements.txt | 2 +- todo/requirements.txt | 2 +- translator/requirements.txt | 2 +- traversal/requirements.txt | 2 +- twitter/requirements.txt | 2 +- upload/requirements.txt | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/chatroom/requirements.txt b/chatroom/requirements.txt index ed7f9e3c..0bcdaa63 100644 --- a/chatroom/requirements.txt +++ b/chatroom/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 \ No newline at end of file +pynecone>=0.1.32 \ No newline at end of file diff --git a/clock/requirements.txt b/clock/requirements.txt index 58d0ed59..3d80aaf8 100644 --- a/clock/requirements.txt +++ b/clock/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 pytz==2022.7.1 \ No newline at end of file diff --git a/counter/requirements.txt b/counter/requirements.txt index 695cbb6e..0087fc61 100644 --- a/counter/requirements.txt +++ b/counter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 diff --git a/crm/requirements.txt b/crm/requirements.txt index ed7f9e3c..0bcdaa63 100644 --- a/crm/requirements.txt +++ b/crm/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 \ No newline at end of file +pynecone>=0.1.32 \ No newline at end of file diff --git a/dalle/requirements.txt b/dalle/requirements.txt index 0bcdfdb5..59dda755 100644 --- a/dalle/requirements.txt +++ b/dalle/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 openai diff --git a/fragments/requirements.txt b/fragments/requirements.txt index ed7f9e3c..0bcdaa63 100644 --- a/fragments/requirements.txt +++ b/fragments/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 \ No newline at end of file +pynecone>=0.1.32 \ No newline at end of file diff --git a/gpt/requirements.txt b/gpt/requirements.txt index 0bcdfdb5..59dda755 100644 --- a/gpt/requirements.txt +++ b/gpt/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 openai diff --git a/nba/requirements.txt b/nba/requirements.txt index 84563ea6..5858deea 100644 --- a/nba/requirements.txt +++ b/nba/requirements.txt @@ -1,4 +1,4 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 plotly-express plotly pandas diff --git a/quiz/requirements.txt b/quiz/requirements.txt index 695cbb6e..0087fc61 100644 --- a/quiz/requirements.txt +++ b/quiz/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 diff --git a/sales/requirements.txt b/sales/requirements.txt index 0bcdfdb5..59dda755 100644 --- a/sales/requirements.txt +++ b/sales/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 openai diff --git a/snakegame/requirements.txt b/snakegame/requirements.txt index ed7f9e3c..0bcdaa63 100644 --- a/snakegame/requirements.txt +++ b/snakegame/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 \ No newline at end of file +pynecone>=0.1.32 \ No newline at end of file diff --git a/todo/requirements.txt b/todo/requirements.txt index 695cbb6e..0087fc61 100644 --- a/todo/requirements.txt +++ b/todo/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 diff --git a/translator/requirements.txt b/translator/requirements.txt index 312a7cfb..e76385b3 100644 --- a/translator/requirements.txt +++ b/translator/requirements.txt @@ -1,3 +1,3 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 googletrans-py==4.0.0 requests>=2.28.1 diff --git a/traversal/requirements.txt b/traversal/requirements.txt index ed7f9e3c..0bcdaa63 100644 --- a/traversal/requirements.txt +++ b/traversal/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 \ No newline at end of file +pynecone>=0.1.32 \ No newline at end of file diff --git a/twitter/requirements.txt b/twitter/requirements.txt index 695cbb6e..0087fc61 100644 --- a/twitter/requirements.txt +++ b/twitter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 +pynecone>=0.1.32 diff --git a/upload/requirements.txt b/upload/requirements.txt index ed7f9e3c..0bcdaa63 100644 --- a/upload/requirements.txt +++ b/upload/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.31 \ No newline at end of file +pynecone>=0.1.32 \ No newline at end of file From 27c0707a78b8893b9ce3d75f63ec1ca7a89080b4 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Mon, 29 May 2023 11:41:10 +0800 Subject: [PATCH 2/7] change back --- chatroom/requirements.txt | 2 +- clock/requirements.txt | 2 +- counter/requirements.txt | 2 +- crm/requirements.txt | 2 +- dalle/requirements.txt | 2 +- fragments/requirements.txt | 2 +- gpt/requirements.txt | 2 +- nba/requirements.txt | 2 +- quiz/requirements.txt | 2 +- sales/requirements.txt | 2 +- snakegame/requirements.txt | 2 +- todo/requirements.txt | 2 +- translator/requirements.txt | 2 +- traversal/requirements.txt | 2 +- twitter/requirements.txt | 2 +- upload/requirements.txt | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/chatroom/requirements.txt b/chatroom/requirements.txt index 0bcdaa63..ed7f9e3c 100644 --- a/chatroom/requirements.txt +++ b/chatroom/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.31 \ No newline at end of file diff --git a/clock/requirements.txt b/clock/requirements.txt index 3d80aaf8..58d0ed59 100644 --- a/clock/requirements.txt +++ b/clock/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 pytz==2022.7.1 \ No newline at end of file diff --git a/counter/requirements.txt b/counter/requirements.txt index 0087fc61..695cbb6e 100644 --- a/counter/requirements.txt +++ b/counter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 diff --git a/crm/requirements.txt b/crm/requirements.txt index 0bcdaa63..ed7f9e3c 100644 --- a/crm/requirements.txt +++ b/crm/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.31 \ No newline at end of file diff --git a/dalle/requirements.txt b/dalle/requirements.txt index 59dda755..0bcdfdb5 100644 --- a/dalle/requirements.txt +++ b/dalle/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 openai diff --git a/fragments/requirements.txt b/fragments/requirements.txt index 0bcdaa63..ed7f9e3c 100644 --- a/fragments/requirements.txt +++ b/fragments/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.31 \ No newline at end of file diff --git a/gpt/requirements.txt b/gpt/requirements.txt index 59dda755..0bcdfdb5 100644 --- a/gpt/requirements.txt +++ b/gpt/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 openai diff --git a/nba/requirements.txt b/nba/requirements.txt index 5858deea..84563ea6 100644 --- a/nba/requirements.txt +++ b/nba/requirements.txt @@ -1,4 +1,4 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 plotly-express plotly pandas diff --git a/quiz/requirements.txt b/quiz/requirements.txt index 0087fc61..695cbb6e 100644 --- a/quiz/requirements.txt +++ b/quiz/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 diff --git a/sales/requirements.txt b/sales/requirements.txt index 59dda755..0bcdfdb5 100644 --- a/sales/requirements.txt +++ b/sales/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 openai diff --git a/snakegame/requirements.txt b/snakegame/requirements.txt index 0bcdaa63..ed7f9e3c 100644 --- a/snakegame/requirements.txt +++ b/snakegame/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.31 \ No newline at end of file diff --git a/todo/requirements.txt b/todo/requirements.txt index 0087fc61..695cbb6e 100644 --- a/todo/requirements.txt +++ b/todo/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 diff --git a/translator/requirements.txt b/translator/requirements.txt index e76385b3..312a7cfb 100644 --- a/translator/requirements.txt +++ b/translator/requirements.txt @@ -1,3 +1,3 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 googletrans-py==4.0.0 requests>=2.28.1 diff --git a/traversal/requirements.txt b/traversal/requirements.txt index 0bcdaa63..ed7f9e3c 100644 --- a/traversal/requirements.txt +++ b/traversal/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.31 \ No newline at end of file diff --git a/twitter/requirements.txt b/twitter/requirements.txt index 0087fc61..695cbb6e 100644 --- a/twitter/requirements.txt +++ b/twitter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.31 diff --git a/upload/requirements.txt b/upload/requirements.txt index 0bcdaa63..ed7f9e3c 100644 --- a/upload/requirements.txt +++ b/upload/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.31 \ No newline at end of file From 57f6dd695c827fb4d3c83ba8614da1aa81492937 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Fri, 2 Jun 2023 22:20:29 +0800 Subject: [PATCH 3/7] coolaborative example --- collaborative-counter/.gitignore | 4 + collaborative-counter/assets/favicon.ico | Bin 0 -> 15406 bytes .../collaborative_counter/__init__.py | 0 .../collaborative_counter.py | 128 ++++++++++++++++++ collaborative-counter/pcconfig.py | 10 ++ 5 files changed, 142 insertions(+) create mode 100644 collaborative-counter/.gitignore create mode 100644 collaborative-counter/assets/favicon.ico create mode 100644 collaborative-counter/collaborative_counter/__init__.py create mode 100644 collaborative-counter/collaborative_counter/collaborative_counter.py create mode 100644 collaborative-counter/pcconfig.py diff --git a/collaborative-counter/.gitignore b/collaborative-counter/.gitignore new file mode 100644 index 00000000..3ea4b7ab --- /dev/null +++ b/collaborative-counter/.gitignore @@ -0,0 +1,4 @@ +pynecone.db +.web +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/collaborative-counter/assets/favicon.ico b/collaborative-counter/assets/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8a93bfa72ad182e4a21385b6daac8106eb16158e GIT binary patch literal 15406 zcmeI1X{eP|6o$X6=1^H?2{!4mEF>DV%qEJ+XwD)Eq!1b?3Mm>iiXyZhO%M$blz_D|T2;5xVnUIG6s)LsOQnbRF^BQOt6h11}ph1&XznbQ@9;JgF!iByZ>&u~Ja zwmxI#nA;U*;QR<41-<__3$^tbGp9Q^Kks=KysOw=-wkJ#Yje88^#sgc4M)PS;Mc|0 zXUv@LFqyy_I0a6JCl_k#GiFYA*q*?_@GNMriwd>%88heK(2s=I;L1X6eLcZ`B)eav zb|binBDvMVbEXE5g`Q7sv{#_P6&Ot2qppq*ppT4SvmYN^>% zOsBwioXbn$0>OO8!rlXpg7Ll+u{;_x$6RY7rdCf; zf9}jL0#`DIZvA*w$uT#_8aao2AIlorXTtt4_H~ZC|BRWF{n~2v6gyCm&lq*Sf%<*l z^I3~Ne$M)gnG=3THS{-vk15Jp%ek%r3_>{X$yd0R(c73gt;ErYZ-mh^Mt#OM2OgkF^o?=O z=4f1c3}fs}bI{heIpO!-xOeUU15eOYw$WaJ_6jtx0^_I|56_3~-$_`6HrgxDUV*J) z1v`^=dX{)wJ~$d&A$yrd?9{&v}MVQ9Q|EzCfpTHfUmOt$@GRxjwnyO0F+}#sZTt*2A2qt`S!4vJ)4CZLiSYuGw42WE_=f_pgoOg$2`x&UR8K5qxr_niFs

7ijOARPX*DwJVJ|-ed-oQnAmHCd_jCt522L*a2*&4N zo|Cp~XnsIjUwxjnYN)HG+S=yZ)85U(V1%Z@U*S7&3=~t~k1)?|J=e3LHBwt&&avhU zDAZC@ZF^YLOl*tT47d_H2Y=JM2X;Vv&4GDt+RNd6h1&ITYphj6Ej7)thrR6CEVy@9 z!#oGq%KwuI_o@3e$N$OBds_{)a=yLd8N%!}4nZORUn6>bfZx3;PKWi+XXNE^ZOOI9 zS~YT9+g|o;7Dgk~)%yO1e-`w7910(V8({r>;@a3l&|GU~K{X;CqrFDMW?>hEUVx#W z$EEo9FO3dm^g740-AT+GVNG|r_OfTQ;9B`C=DB41Sz>W!+<@KHXQ1y!D9p7cYh>GA z_G~7uMr=LIeZuzah_l-NdA-<0-a>raLt$>5H=z-uJ?zzNc+UR>qfZ`R#h*WKpS|x= zuJ%M2FxQ%_5w<<-)okpC;MXwvIC@U_9ytPv{?PM$AiM<{m$yQF#>^4cSZh3M+QVMW z#^)18S;mkIjieGzvY;Cc8J%=7b^yreKcpXQjG&s#44cbv@({Jxv-VJ+7(`^+)7ufg-> zAy~gp^4yJ?6Mu&>`xFjiHud``&)=9ieHHzf*bJEGob8#!%<0P*!sMQZdEVOkjBN=x zkV$sJxCd>0TM9haXG6bRtt)n4IqR9uf5Pr$`OYu3+i0&qdj;An&|ZP|3ba?CtiWIG CTt?CW literal 0 HcmV?d00001 diff --git a/collaborative-counter/collaborative_counter/__init__.py b/collaborative-counter/collaborative_counter/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/collaborative-counter/collaborative_counter/collaborative_counter.py b/collaborative-counter/collaborative_counter/collaborative_counter.py new file mode 100644 index 00000000..37e31024 --- /dev/null +++ b/collaborative-counter/collaborative_counter/collaborative_counter.py @@ -0,0 +1,128 @@ +import pynecone as pc +import asyncio +import typing as t +# refer https://github.com/pynecone-io/pynecone/issues/438 +class State(pc.State): + counter: int = 0 + async def counter_up(self): + self.counter = self.counter + 1 + await set_state_count(self.counter) + + async def counter_down(self): + self.counter = self.counter - 1 + await set_state_count(self.counter) + + def set_counter(self, counter: t.SupportsInt) -> None: + self.counter = counter + async def counter_change(self, counter:t.SupportsInt) -> None: + self.counter = counter + await broadcast_counter() + + +async def broadcast_counter() -> None: + """Simulate State.set_counter event with updated nick list from all clients.""" + counters = [] + for state in app.state_manager.states.values(): + counters.append(state.counter) + await broadcast_event("state.set_counter", payload=dict(counter=counters)) + +async def broadcast_event(name: str, payload: t.Dict[str, t.Any] = {}) -> None: + """Simulate frontend event with given name and payload from all clients.""" + event_ns = app.sio.namespace_handlers["/event"] + responses = [] + for state in app.state_manager.states.values(): + update = await state._process( + event=pc.event.Event( + token=state.get_token(), + name=name, + router_data=state.router_data, + payload=payload, + ), + ) + # Emit the event. + responses.append( + event_ns.emit( + str(pc.constants.SocketEvent.EVENT), update.json(), to=state.get_sid() + ), + ) + for response in responses: + await response + + +def index(): + return pc.center( + pc.vstack( + pc.heading("Counter", + font_size="2em", + background_image="linear-gradient(271.68deg, #211344 25%, #443213 50% )", + background_clip="text", + ), + pc.hstack( + pc.button("+", + border="0.15em solid", + on_click=State.counter_up, + border_radius="0.5em", + padding="0.5em", + _hover={ + "color": "rgb(107,99,246)", + }, + ), + + pc.button("-", + border="0.15em solid", + on_click=State.counter_down, + border_radius="0.5em", + padding="0.5em", + _hover={ + "color": "rgb(107,99,246)", + }, + ), + ), + pc.link( + State.counter, + href="#", + border="0.1em solid", + padding="0.1em", + border_radius="0.5em", + _hover={ + "color": "rgb(107,99,246)", + }, + font_size=["2em", "3em", "3em", "4em"], + font_weight=800, + font_family="Inter", + background_image="linear-gradient(271.68deg, #EE756A 25%, #756AEE 50%)", + background_clip="text", + ), + spacing="1.5em", + font_size="2em", + ), + padding_top="10%", + ) + + + +async def set_state_count(count_val:int): + print("count_val = "+str(count_val)) + keys = list(app.state_manager.states) #convert the keys of dict into the list + ret_count_val: int = count_val + for token in keys: # change state.count for all current running frontend + state = app.state_manager.get_state(token) + state.counter = count_val + app.state_manager.set_state(token, state) + return {"state_count":ret_count_val} + +meta = [ + {"name": "theme_color", "content": "#FFFFFF"}, + {"char_set": "UTF-8"}, + {"property": "og:url", "content": "url"}, +] +# Add state and page to the app. +app = pc.App(state=State) +app.add_page( + index, + meta=meta, + title="Collaborative Counter App", + description="A collaborative counter app", + ) +app.api.add_api_route("/state_count/{count_val}", set_state_count) +app.compile() diff --git a/collaborative-counter/pcconfig.py b/collaborative-counter/pcconfig.py new file mode 100644 index 00000000..26d01082 --- /dev/null +++ b/collaborative-counter/pcconfig.py @@ -0,0 +1,10 @@ +import pynecone as pc + +class CollaborativecounterConfig(pc.Config): + pass + +config = CollaborativecounterConfig( + app_name="collaborative_counter", + db_url="sqlite:///pynecone.db", + env=pc.Env.DEV, +) \ No newline at end of file From 5783772ee345e1da1dcd9e6d4b6506868c7ec7d5 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Sat, 3 Jun 2023 16:24:30 +0800 Subject: [PATCH 4/7] sync --- collaborative-counter/.gitignore | 4 - collaborative-counter/assets/favicon.ico | Bin 15406 -> 0 bytes .../collaborative_counter/__init__.py | 0 .../collaborative_counter.py | 128 ------------------ collaborative-counter/pcconfig.py | 10 -- 5 files changed, 142 deletions(-) delete mode 100644 collaborative-counter/.gitignore delete mode 100644 collaborative-counter/assets/favicon.ico delete mode 100644 collaborative-counter/collaborative_counter/__init__.py delete mode 100644 collaborative-counter/collaborative_counter/collaborative_counter.py delete mode 100644 collaborative-counter/pcconfig.py diff --git a/collaborative-counter/.gitignore b/collaborative-counter/.gitignore deleted file mode 100644 index 3ea4b7ab..00000000 --- a/collaborative-counter/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -pynecone.db -.web -__pycache__/ -*.py[cod] \ No newline at end of file diff --git a/collaborative-counter/assets/favicon.ico b/collaborative-counter/assets/favicon.ico deleted file mode 100644 index 8a93bfa72ad182e4a21385b6daac8106eb16158e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15406 zcmeI1X{eP|6o$X6=1^H?2{!4mEF>DV%qEJ+XwD)Eq!1b?3Mm>iiXyZhO%M$blz_D|T2;5xVnUIG6s)LsOQnbRF^BQOt6h11}ph1&XznbQ@9;JgF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Pv{?PM$AiM<{m$yQF#>^4cSZh3M+QVMW z#^)18S;mkIjieGzvY;Cc8J%=7b^yreKcpXQjG&s#44cbv@({Jxv-VJ+7(`^+)7ufg-> zAy~gp^4yJ?6Mu&>`xFjiHud``&)=9ieHHzf*bJEGob8#!%<0P*!sMQZdEVOkjBN=x zkV$sJxCd>0TM9haXG6bRtt)n4IqR9uf5Pr$`OYu3+i0&qdj;An&|ZP|3ba?CtiWIG CTt?CW diff --git a/collaborative-counter/collaborative_counter/__init__.py b/collaborative-counter/collaborative_counter/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/collaborative-counter/collaborative_counter/collaborative_counter.py b/collaborative-counter/collaborative_counter/collaborative_counter.py deleted file mode 100644 index 37e31024..00000000 --- a/collaborative-counter/collaborative_counter/collaborative_counter.py +++ /dev/null @@ -1,128 +0,0 @@ -import pynecone as pc -import asyncio -import typing as t -# refer https://github.com/pynecone-io/pynecone/issues/438 -class State(pc.State): - counter: int = 0 - async def counter_up(self): - self.counter = self.counter + 1 - await set_state_count(self.counter) - - async def counter_down(self): - self.counter = self.counter - 1 - await set_state_count(self.counter) - - def set_counter(self, counter: t.SupportsInt) -> None: - self.counter = counter - async def counter_change(self, counter:t.SupportsInt) -> None: - self.counter = counter - await broadcast_counter() - - -async def broadcast_counter() -> None: - """Simulate State.set_counter event with updated nick list from all clients.""" - counters = [] - for state in app.state_manager.states.values(): - counters.append(state.counter) - await broadcast_event("state.set_counter", payload=dict(counter=counters)) - -async def broadcast_event(name: str, payload: t.Dict[str, t.Any] = {}) -> None: - """Simulate frontend event with given name and payload from all clients.""" - event_ns = app.sio.namespace_handlers["/event"] - responses = [] - for state in app.state_manager.states.values(): - update = await state._process( - event=pc.event.Event( - token=state.get_token(), - name=name, - router_data=state.router_data, - payload=payload, - ), - ) - # Emit the event. - responses.append( - event_ns.emit( - str(pc.constants.SocketEvent.EVENT), update.json(), to=state.get_sid() - ), - ) - for response in responses: - await response - - -def index(): - return pc.center( - pc.vstack( - pc.heading("Counter", - font_size="2em", - background_image="linear-gradient(271.68deg, #211344 25%, #443213 50% )", - background_clip="text", - ), - pc.hstack( - pc.button("+", - border="0.15em solid", - on_click=State.counter_up, - border_radius="0.5em", - padding="0.5em", - _hover={ - "color": "rgb(107,99,246)", - }, - ), - - pc.button("-", - border="0.15em solid", - on_click=State.counter_down, - border_radius="0.5em", - padding="0.5em", - _hover={ - "color": "rgb(107,99,246)", - }, - ), - ), - pc.link( - State.counter, - href="#", - border="0.1em solid", - padding="0.1em", - border_radius="0.5em", - _hover={ - "color": "rgb(107,99,246)", - }, - font_size=["2em", "3em", "3em", "4em"], - font_weight=800, - font_family="Inter", - background_image="linear-gradient(271.68deg, #EE756A 25%, #756AEE 50%)", - background_clip="text", - ), - spacing="1.5em", - font_size="2em", - ), - padding_top="10%", - ) - - - -async def set_state_count(count_val:int): - print("count_val = "+str(count_val)) - keys = list(app.state_manager.states) #convert the keys of dict into the list - ret_count_val: int = count_val - for token in keys: # change state.count for all current running frontend - state = app.state_manager.get_state(token) - state.counter = count_val - app.state_manager.set_state(token, state) - return {"state_count":ret_count_val} - -meta = [ - {"name": "theme_color", "content": "#FFFFFF"}, - {"char_set": "UTF-8"}, - {"property": "og:url", "content": "url"}, -] -# Add state and page to the app. -app = pc.App(state=State) -app.add_page( - index, - meta=meta, - title="Collaborative Counter App", - description="A collaborative counter app", - ) -app.api.add_api_route("/state_count/{count_val}", set_state_count) -app.compile() diff --git a/collaborative-counter/pcconfig.py b/collaborative-counter/pcconfig.py deleted file mode 100644 index 26d01082..00000000 --- a/collaborative-counter/pcconfig.py +++ /dev/null @@ -1,10 +0,0 @@ -import pynecone as pc - -class CollaborativecounterConfig(pc.Config): - pass - -config = CollaborativecounterConfig( - app_name="collaborative_counter", - db_url="sqlite:///pynecone.db", - env=pc.Env.DEV, -) \ No newline at end of file From 78c86f62ff28527de1d595a57ebbf6f6959065f3 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Tue, 6 Jun 2023 12:38:55 +0800 Subject: [PATCH 5/7] change requirements.txt for alpha test 0.1.33a1 --- chatroom/requirements.txt | 2 +- clock/requirements.txt | 2 +- counter/requirements.txt | 2 +- crm/requirements.txt | 2 +- dalle/requirements.txt | 2 +- fragments/requirements.txt | 2 +- gpt/requirements.txt | 2 +- nba/requirements.txt | 2 +- quiz/requirements.txt | 2 +- sales/requirements.txt | 2 +- snakegame/requirements.txt | 2 +- todo/requirements.txt | 2 +- translator/requirements.txt | 2 +- traversal/requirements.txt | 2 +- twitter/requirements.txt | 2 +- upload/requirements.txt | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/chatroom/requirements.txt b/chatroom/requirements.txt index 0bcdaa63..514fd407 100644 --- a/chatroom/requirements.txt +++ b/chatroom/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone==0.1.33a1 \ No newline at end of file diff --git a/clock/requirements.txt b/clock/requirements.txt index 3d80aaf8..a54820b7 100644 --- a/clock/requirements.txt +++ b/clock/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 pytz==2022.7.1 \ No newline at end of file diff --git a/counter/requirements.txt b/counter/requirements.txt index 0087fc61..0a844927 100644 --- a/counter/requirements.txt +++ b/counter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 diff --git a/crm/requirements.txt b/crm/requirements.txt index 0bcdaa63..514fd407 100644 --- a/crm/requirements.txt +++ b/crm/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone==0.1.33a1 \ No newline at end of file diff --git a/dalle/requirements.txt b/dalle/requirements.txt index 59dda755..607117f1 100644 --- a/dalle/requirements.txt +++ b/dalle/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 openai diff --git a/fragments/requirements.txt b/fragments/requirements.txt index 0bcdaa63..514fd407 100644 --- a/fragments/requirements.txt +++ b/fragments/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone==0.1.33a1 \ No newline at end of file diff --git a/gpt/requirements.txt b/gpt/requirements.txt index 59dda755..607117f1 100644 --- a/gpt/requirements.txt +++ b/gpt/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 openai diff --git a/nba/requirements.txt b/nba/requirements.txt index 5858deea..072e5cd0 100644 --- a/nba/requirements.txt +++ b/nba/requirements.txt @@ -1,4 +1,4 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 plotly-express plotly pandas diff --git a/quiz/requirements.txt b/quiz/requirements.txt index 0087fc61..0a844927 100644 --- a/quiz/requirements.txt +++ b/quiz/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 diff --git a/sales/requirements.txt b/sales/requirements.txt index 59dda755..607117f1 100644 --- a/sales/requirements.txt +++ b/sales/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 openai diff --git a/snakegame/requirements.txt b/snakegame/requirements.txt index 0bcdaa63..514fd407 100644 --- a/snakegame/requirements.txt +++ b/snakegame/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone==0.1.33a1 \ No newline at end of file diff --git a/todo/requirements.txt b/todo/requirements.txt index 0087fc61..0a844927 100644 --- a/todo/requirements.txt +++ b/todo/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 diff --git a/translator/requirements.txt b/translator/requirements.txt index e76385b3..f4b6a050 100644 --- a/translator/requirements.txt +++ b/translator/requirements.txt @@ -1,3 +1,3 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 googletrans-py==4.0.0 requests>=2.28.1 diff --git a/traversal/requirements.txt b/traversal/requirements.txt index 0bcdaa63..514fd407 100644 --- a/traversal/requirements.txt +++ b/traversal/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone==0.1.33a1 \ No newline at end of file diff --git a/twitter/requirements.txt b/twitter/requirements.txt index 0087fc61..0a844927 100644 --- a/twitter/requirements.txt +++ b/twitter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone==0.1.33a1 diff --git a/upload/requirements.txt b/upload/requirements.txt index 0bcdaa63..514fd407 100644 --- a/upload/requirements.txt +++ b/upload/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone==0.1.33a1 \ No newline at end of file From db5481b5dffd62f931e357fb5bff531de0c5a6a6 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Wed, 7 Jun 2023 00:16:23 +0800 Subject: [PATCH 6/7] update quiz example code to fit the latest pr with pc 0.1.32 --- quiz/quiz/quiz.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/quiz/quiz/quiz.py b/quiz/quiz/quiz.py index 6c50a61e..e399e650 100644 --- a/quiz/quiz/quiz.py +++ b/quiz/quiz/quiz.py @@ -1,6 +1,9 @@ """Welcome to Pynecone! This file outlines the steps to create a basic app.""" import pynecone as pc +import copy from .results import results +from typing import Any +from typing import List question_style = { "bg": "white", @@ -13,10 +16,12 @@ class State(pc.State): """The app state.""" - - answers = ["False", "None", [False, False, False, False, False]] + default_answers = [None, None, [False, False, False, False, False]] + answers:List[Any] answer_key = ["False", "[10, 20, 30, 40]", [False, False, True, True, True]] score: int + def onload(self): + self.answers = copy.deepcopy(self.default_answers) def set_answers(self, answer, index, sub_index=None): if sub_index is None: @@ -29,10 +34,7 @@ def submit(self): for i in range(len(self.answers)): if self.answers[i] == self.answer_key[i]: correct += 1 - else: - print(self.answers[i], self.answer_key[i]) total += 1 - self.score = int(correct / total * 100) return pc.redirect("/result") @@ -58,7 +60,10 @@ def question1(): ), pc.divider(), pc.radio_group( - ["True", "False"], on_change=lambda answer: State.set_answers(answer, 0) + ["True", "False"], + default_value=State.default_answers[0], + default_checked=True, + on_change=lambda answer: State.set_answers(answer, 0) ), style=question_style, ) @@ -77,6 +82,8 @@ def question2(): ), pc.radio_group( ["[10, 20, 30, 40]", "[10, 20]"], + default_value=State.default_answers[1], + default_check=True, on_change=lambda answer: State.set_answers(answer, 1), ), style=question_style, @@ -150,6 +157,6 @@ def result(): # Add state and page to the app. app = pc.App(state=State) -app.add_page(index, title="Pynecone Quiz") +app.add_page(index, title="Pynecone Quiz", on_load=State.onload) app.add_page(result, title="Quiz Results") app.compile() From c2e656b3d01257f8dc8257e3897c9531402a7089 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Wed, 7 Jun 2023 00:31:46 +0800 Subject: [PATCH 7/7] fix issue to show icon on browser's tag by setup favicon.ico --- sales/assets/favicon.ico | Bin 0 -> 15406 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sales/assets/favicon.ico diff --git a/sales/assets/favicon.ico b/sales/assets/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8a93bfa72ad182e4a21385b6daac8106eb16158e GIT binary patch literal 15406 zcmeI1X{eP|6o$X6=1^H?2{!4mEF>DV%qEJ+XwD)Eq!1b?3Mm>iiXyZhO%M$blz_D|T2;5xVnUIG6s)LsOQnbRF^BQOt6h11}ph1&XznbQ@9;JgF!iByZ>&u~Ja zwmxI#nA;U*;QR<41-<__3$^tbGp9Q^Kks=KysOw=-wkJ#Yje88^#sgc4M)PS;Mc|0 zXUv@LFqyy_I0a6JCl_k#GiFYA*q*?_@GNMriwd>%88heK(2s=I;L1X6eLcZ`B)eav zb|binBDvMVbEXE5g`Q7sv{#_P6&Ot2qppq*ppT4SvmYN^>% zOsBwioXbn$0>OO8!rlXpg7Ll+u{;_x$6RY7rdCf; zf9}jL0#`DIZvA*w$uT#_8aao2AIlorXTtt4_H~ZC|BRWF{n~2v6gyCm&lq*Sf%<*l z^I3~Ne$M)gnG=3THS{-vk15Jp%ek%r3_>{X$yd0R(c73gt;ErYZ-mh^Mt#OM2OgkF^o?=O z=4f1c3}fs}bI{heIpO!-xOeUU15eOYw$WaJ_6jt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