From 265d49240f7224aff91c107b0c6da28ec3b5f8a4 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Mon, 29 May 2023 11:37:43 +0800 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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!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 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 1c11166554454a79e1b64a2462210f9dfcfa20d3 Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Sun, 11 Jun 2023 16:16:49 +0800 Subject: [PATCH 05/10] requirements.txt update and test to pc 0.1.33 --- 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..0a8f4c6e 100644 --- a/chatroom/requirements.txt +++ b/chatroom/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.33 \ No newline at end of file diff --git a/clock/requirements.txt b/clock/requirements.txt index 3d80aaf8..121baecc 100644 --- a/clock/requirements.txt +++ b/clock/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 pytz==2022.7.1 \ No newline at end of file diff --git a/counter/requirements.txt b/counter/requirements.txt index 0087fc61..40c44025 100644 --- a/counter/requirements.txt +++ b/counter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 diff --git a/crm/requirements.txt b/crm/requirements.txt index 0bcdaa63..0a8f4c6e 100644 --- a/crm/requirements.txt +++ b/crm/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.33 \ No newline at end of file diff --git a/dalle/requirements.txt b/dalle/requirements.txt index 59dda755..4f5c74bb 100644 --- a/dalle/requirements.txt +++ b/dalle/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 openai diff --git a/fragments/requirements.txt b/fragments/requirements.txt index 0bcdaa63..0a8f4c6e 100644 --- a/fragments/requirements.txt +++ b/fragments/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.33 \ No newline at end of file diff --git a/gpt/requirements.txt b/gpt/requirements.txt index 59dda755..4f5c74bb 100644 --- a/gpt/requirements.txt +++ b/gpt/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 openai diff --git a/nba/requirements.txt b/nba/requirements.txt index 5858deea..754263c8 100644 --- a/nba/requirements.txt +++ b/nba/requirements.txt @@ -1,4 +1,4 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 plotly-express plotly pandas diff --git a/quiz/requirements.txt b/quiz/requirements.txt index 0087fc61..40c44025 100644 --- a/quiz/requirements.txt +++ b/quiz/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 diff --git a/sales/requirements.txt b/sales/requirements.txt index 59dda755..4f5c74bb 100644 --- a/sales/requirements.txt +++ b/sales/requirements.txt @@ -1,2 +1,2 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 openai diff --git a/snakegame/requirements.txt b/snakegame/requirements.txt index 0bcdaa63..0a8f4c6e 100644 --- a/snakegame/requirements.txt +++ b/snakegame/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.33 \ No newline at end of file diff --git a/todo/requirements.txt b/todo/requirements.txt index 0087fc61..40c44025 100644 --- a/todo/requirements.txt +++ b/todo/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 diff --git a/translator/requirements.txt b/translator/requirements.txt index e76385b3..78587dd7 100644 --- a/translator/requirements.txt +++ b/translator/requirements.txt @@ -1,3 +1,3 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 googletrans-py==4.0.0 requests>=2.28.1 diff --git a/traversal/requirements.txt b/traversal/requirements.txt index 0bcdaa63..0a8f4c6e 100644 --- a/traversal/requirements.txt +++ b/traversal/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.33 \ No newline at end of file diff --git a/twitter/requirements.txt b/twitter/requirements.txt index 0087fc61..40c44025 100644 --- a/twitter/requirements.txt +++ b/twitter/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 +pynecone>=0.1.33 diff --git a/upload/requirements.txt b/upload/requirements.txt index 0bcdaa63..0a8f4c6e 100644 --- a/upload/requirements.txt +++ b/upload/requirements.txt @@ -1 +1 @@ -pynecone>=0.1.32 \ No newline at end of file +pynecone>=0.1.33 \ No newline at end of file From 9d72deff6e4aba376a07ac60f4381ff7e47fb09e Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Sun, 11 Jun 2023 16:29:04 +0800 Subject: [PATCH 06/10] update .gitignore --- chatroom/.gitignore | 4 +++- clock/.gitignore | 4 +++- counter/.gitignore | 4 +++- crm/.gitignore | 4 +++- dalle/.gitignore | 4 +++- fragments/.gitignore | 4 +++- gpt/.gitignore | 4 +++- nba/.gitignore | 4 +++- quiz/.gitignore | 4 ++-- sales/.gitignore | 4 +++- todo/.gitignore | 4 +++- translator/.gitignore | 4 +++- traversal/.gitignore | 4 +++- twitter/.gitignore | 4 +++- upload/.gitignore | 2 +- 15 files changed, 42 insertions(+), 16 deletions(-) diff --git a/chatroom/.gitignore b/chatroom/.gitignore index 58c9e931..42649afd 100644 --- a/chatroom/.gitignore +++ b/chatroom/.gitignore @@ -1,2 +1,4 @@ .web -pynecone.db \ No newline at end of file +pynecone.db +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/clock/.gitignore b/clock/.gitignore index 58c9e931..42649afd 100644 --- a/clock/.gitignore +++ b/clock/.gitignore @@ -1,2 +1,4 @@ .web -pynecone.db \ No newline at end of file +pynecone.db +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/counter/.gitignore b/counter/.gitignore index 40e62451..42649afd 100644 --- a/counter/.gitignore +++ b/counter/.gitignore @@ -1,2 +1,4 @@ +.web pynecone.db -.web \ No newline at end of file +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/crm/.gitignore b/crm/.gitignore index 40e62451..42649afd 100644 --- a/crm/.gitignore +++ b/crm/.gitignore @@ -1,2 +1,4 @@ +.web pynecone.db -.web \ No newline at end of file +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/dalle/.gitignore b/dalle/.gitignore index 40e62451..42649afd 100644 --- a/dalle/.gitignore +++ b/dalle/.gitignore @@ -1,2 +1,4 @@ +.web pynecone.db -.web \ No newline at end of file +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/fragments/.gitignore b/fragments/.gitignore index 40e62451..42649afd 100644 --- a/fragments/.gitignore +++ b/fragments/.gitignore @@ -1,2 +1,4 @@ +.web pynecone.db -.web \ No newline at end of file +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/gpt/.gitignore b/gpt/.gitignore index 58c9e931..42649afd 100644 --- a/gpt/.gitignore +++ b/gpt/.gitignore @@ -1,2 +1,4 @@ .web -pynecone.db \ No newline at end of file +pynecone.db +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/nba/.gitignore b/nba/.gitignore index 58c9e931..42649afd 100644 --- a/nba/.gitignore +++ b/nba/.gitignore @@ -1,2 +1,4 @@ .web -pynecone.db \ No newline at end of file +pynecone.db +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/quiz/.gitignore b/quiz/.gitignore index 3b844328..42649afd 100644 --- a/quiz/.gitignore +++ b/quiz/.gitignore @@ -1,4 +1,4 @@ -*.py[cod] .web pynecone.db -__pycache__/ \ No newline at end of file +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/sales/.gitignore b/sales/.gitignore index 58c9e931..42649afd 100644 --- a/sales/.gitignore +++ b/sales/.gitignore @@ -1,2 +1,4 @@ .web -pynecone.db \ No newline at end of file +pynecone.db +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/todo/.gitignore b/todo/.gitignore index 40e62451..42649afd 100644 --- a/todo/.gitignore +++ b/todo/.gitignore @@ -1,2 +1,4 @@ +.web pynecone.db -.web \ No newline at end of file +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/translator/.gitignore b/translator/.gitignore index 58c9e931..42649afd 100644 --- a/translator/.gitignore +++ b/translator/.gitignore @@ -1,2 +1,4 @@ .web -pynecone.db \ No newline at end of file +pynecone.db +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/traversal/.gitignore b/traversal/.gitignore index 58c9e931..42649afd 100644 --- a/traversal/.gitignore +++ b/traversal/.gitignore @@ -1,2 +1,4 @@ .web -pynecone.db \ No newline at end of file +pynecone.db +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/twitter/.gitignore b/twitter/.gitignore index 40e62451..42649afd 100644 --- a/twitter/.gitignore +++ b/twitter/.gitignore @@ -1,2 +1,4 @@ +.web pynecone.db -.web \ No newline at end of file +__pycache__/ +*.py[cod] \ No newline at end of file diff --git a/upload/.gitignore b/upload/.gitignore index 3ea4b7ab..42649afd 100644 --- a/upload/.gitignore +++ b/upload/.gitignore @@ -1,4 +1,4 @@ -pynecone.db .web +pynecone.db __pycache__/ *.py[cod] \ No newline at end of file From 68711ea28f2ed8b606a94fce230a370a4f62105d Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Sun, 11 Jun 2023 16:33:12 +0800 Subject: [PATCH 07/10] delete the empty pynecone.db generated by app in default --- translator/pynecone.db | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 translator/pynecone.db diff --git a/translator/pynecone.db b/translator/pynecone.db deleted file mode 100644 index e69de29b..00000000 From 5652a7c026bcbe2efb7a7c4c7a6098f80c5afcde Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Mon, 12 Jun 2023 09:56:14 +0800 Subject: [PATCH 08/10] Sync .gitignore to latest clock example --- clock/.gitignore | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/clock/.gitignore b/clock/.gitignore index 2c2ec6a1..ac196dbd 100644 --- a/clock/.gitignore +++ b/clock/.gitignore @@ -1,9 +1,3 @@ .web -<<<<<<< HEAD -pynecone.db -__pycache__/ -*.py[cod] -======= pynecone.db*.py[cod] -__pycache__/ ->>>>>>> upstream/main +__pycache__/ \ No newline at end of file From 678063651a4179fad333c28c1cffb0d7377ac51f Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Mon, 12 Jun 2023 09:57:44 +0800 Subject: [PATCH 09/10] fix bug in clock/.gitignore --- clock/.gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clock/.gitignore b/clock/.gitignore index ac196dbd..6a17243b 100644 --- a/clock/.gitignore +++ b/clock/.gitignore @@ -1,3 +1,4 @@ .web -pynecone.db*.py[cod] +pynecone.db +*.py[cod] __pycache__/ \ No newline at end of file From 53faf1918741ad99b8184117798d9e5c47b4ac4c Mon Sep 17 00:00:00 2001 From: milochen0418 Date: Mon, 12 Jun 2023 12:44:38 +0800 Subject: [PATCH 10/10] show default value of time-zone on pc.select --- clock/clock/clock.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clock/clock/clock.py b/clock/clock/clock.py index af7d7628..05cac925 100644 --- a/clock/clock/clock.py +++ b/clock/clock/clock.py @@ -66,6 +66,7 @@ def time_info(self) -> dict[str, Any]: def on_load(self): """Switch the clock off when the page refreshes.""" self.running = False + self.zone = "US/Pacific" async def tick(self): """Update the clock every second.""" @@ -160,6 +161,7 @@ def timezone_select() -> pc.Component: TIMEZONES, placeholder="Select a time zone.", on_change=State.set_zone, + value=State.zone, bg="#white", )