yes, its a turn based multiplayer game. It will be a lot like chess.
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Posts made by walterwang
-
RE: How can i pass data between different scenes and/or ui views
-
RE: How can i pass data between different scenes and/or ui views
Hi JonB thanks for the advice. sorry the code I posted here was too simplified, (My actual code was just a single if statement testing a boolean variable) But I have changed it to a better way of adding subview, I don't know why it didn't work at first. So the login code is in the setup now. I haven't tried using pause yet, so far I am just using add_subview when initializing the scene for the first time, and scene.hidden =True to hide the previous menu.
Thanks for all the help!
-
RE: How can i pass data between different scenes and/or ui views
@JonB, I can do that with the request cookies part of the login, but there is also additional information that needs to be rendered only once. This information is only available once you log in.
-
RE: How can i pass data between different scenes and/or ui views
@mikael I have a login screen which when authenticated gets a request.cookie that is used to identify the user as a session in flask. The setup screen requires information from the user's account, and therefore cannot be updated or rendered until the user logs in from the login screen. But once logged in, I only need to post the request once to get the needed information. So far I have a try block and a setup_query_once = True boolean, which is set to false after setting up once in the update function.
-
RE: How can i pass data between different scenes and/or ui views
I get a completely black screen when set pause to true and then set it to false
-
RE: How can i pass data between different scenes and/or ui views
What I have kinda works right now, but I am not sure if its best practice. For example setting the view to hidden, still results in the scene being updated. Since its updated before the value that I want to pass is set, I have to put it in a try block so it won’t have unreferenced error
import ui from scene import * import requests import time server_ip='http://0.0.0.0:5000/' class MyScene(Scene): def setup(self): self.background_color = 'midnightblue' self.querysetup = True def update(self): try: if client.login_request is not None: r = requests.get(server_ip+'get_setup',cookies=client.login_request.cookies).content except: pass class SwitchViews(ui.View): def __init__(self): self.login_view = self.create_login_view() self.scene_view = SceneView() self.scene_view.scene = MyScene() self.add_subview(self.scene_view) self.add_subview(self.login_view) self.background_color = 'white' self.present(style = 'sheet', hide_title_bar=True) self.scene_view.hidden = True self.login_request = None def create_login_view(self): def login_tapped(sender): self.login_request = requests.post(server_ip+'login', data = {'username':view['username'].text, 'password':view['password'].text}) if 'authenticated' in str(self.login_request.content): self.scene_view.hidden = False self.login_view.hidden = True def register_tapped(sender): r = requests.post(server_ip+'register', data = {'username':view['username'].text, 'password':view['password'].text}) print(r.content) view = ui.View(frame=(0,0,736, 414)) view.background_color = 'white' username = ui.TextField(frame=(view.width/2-70,view.height/2-80,140,25)) username.name = 'username' username.alignment = ui.ALIGN_CENTER username.placeholder = 'username' view.add_subview(username) password = ui.TextField(frame=(view.width/2-70, view.height/2-50, 140, 25)) password.name = 'password' password.secure = True password.alignment = ui.ALIGN_CENTER password.placeholder = 'password' view.add_subview(password) login_button = ui.Button(name = 'login', frame=(view.width/2-70, view.height/2-20, 65, 25)) login_button.title = 'Login' login_button.border_color = 'blue' login_button.border_width = 1 login_button.corner_radius = 5 login_button.action = login_tapped view.add_subview(login_button) register_button = ui.Button(name = 'Register', frame = (view.width/2, view.height/2-20, 65, 25)) register_button.title = 'Register' register_button.border_color = 'blue' register_button.border_width = 1 register_button.corner_radius = 5 register_button.action = register_tapped view.add_subview(register_button) return view client = SwitchViews()
-
How can i pass data between different scenes and/or ui views
I have a login ui view that when authenticated will show a setup scene. This scene is added to the root view with SceneView(). However, I would like the scene view to get some information from ui view. But I am not sure how to pass that information from the ui to the scene. Any help would be greatly appreciated