Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PySimpleGUI] How to startup in a repl.it friendly way #280

Closed
MikeTheWatchGuy opened this issue Feb 18, 2019 · 10 comments
Closed

[PySimpleGUI] How to startup in a repl.it friendly way #280

MikeTheWatchGuy opened this issue Feb 18, 2019 · 10 comments

Comments

@MikeTheWatchGuy
Copy link

I'm able to run my programs locally with no trouble.

I'm able to sometimes run my repl.it versions of the same program with no issues.

BUT, I'm finding if I have a browser window open with another repl.it script running, then my scripts have issues. At least I think that's part of the problem.

I also find that the MyApp object's init call is made several times.

Here is my current "start" call:

        remi.start(self.MyApp, title=self.Title ,debug=False, address='0.0.0.0', port=0,  start_browser=True, update_interval=.00001, userdata=(self,))

Here's my repl.it code: https://repl.it/@PySimpleGUI/Design-Pattern-1-One-shot-Window

And here's the errors I got despite it working

Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
starting up...
starting up...
172.18.0.1 - - [18/Feb/2019 22:38:51] "HEAD / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:51] "HEAD / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:51] "GET / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:51] "GET / HTTP/1.1" 200 -

Exception happened during processing of request from ('172.18.0.1',41676)
172.18.0.1 - - [18/Feb/2019 22:38:51] "HEAD / HTTP/1.1" 200 -
Traceback (most recent call last):
File "/usr/local/lib/python3.6/socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/lib/python3.6/socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/home/runner/.site-packages/PySimpleGUIWeb/PySimpleGUIWeb.py", line 3214, in init
super(Window.MyApp, self).init(*args)
File "/home/runner/.site-packages/remi/server.py", line 305, in init
super(App, self).init(request, client_address, server)
File "/usr/local/lib/python3.6/socketserver.py", line 696, in init
self.handle()
File "/usr/local/lib/python3.6/http/server.py", line 418, in handle
self.handle_one_request()
File "/usr/local/lib/python3.6/http/server.py", line 406, in handle_one_request
method()
File "/home/runner/.site-packages/remi/server.py", line 558, in do_GET
ws = WebSocketsHandler(self.headers, self.request, self.client_address, self.server)
File "/home/runner/.site-packages/remi/server.py", line 122, in init
socketserver.StreamRequestHandler.init(self, *args, **kwargs)
File "/usr/local/lib/python3.6/socketserver.py", line 696, in init
self.handle()
File "/home/runner/.site-packages/remi/server.py", line 138, in handle
clients[self.session].websockets.remove(self)
ValueError: list.remove(x): x not in list


Exception happened during processing of request from ('172.18.0.1',41344)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/lib/python3.6/socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/home/runner/.site-packages/PySimpleGUIWeb/PySimpleGUIWeb.py", line 3214, in init
super(Window.MyApp, self).init(*args)
File "/home/runner/.site-packages/remi/server.py", line 305, in init
super(App, self).init(request, client_address, server)
File "/usr/local/lib/python3.6/socketserver.py", line 696, in init
self.handle()
File "/usr/local/lib/python3.6/http/server.py", line 418, in handle
self.handle_one_request()
File "/usr/local/lib/python3.6/http/server.py", line 406, in handle_one_request
method()
File "/home/runner/.site-packages/remi/server.py", line 558, in do_GET
ws = WebSocketsHandler(self.headers, self.request, self.client_address, self.server)
File "/home/runner/.site-packages/remi/server.py", line 122, in init
socketserver.StreamRequestHandler.init(self, *args, **kwargs)
File "/usr/local/lib/python3.6/socketserver.py", line 696, in init
self.handle()
File "/home/runner/.site-packages/remi/server.py", line 138, in handle
clients[self.session].websockets.remove(self)
ValueError: list.remove(x): x not in list

172.18.0.1 - - [18/Feb/2019 22:38:52] "GET / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:52] "HEAD / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:52] "GET / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:52] "GET / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:57] "HEAD / HTTP/1.1" 200 -
172.18.0.1 - - [18/Feb/2019 22:38:57] "GET / HTTP/1.1" 200 -

@dddomodossola
Copy link
Collaborator

Hello @MikeTheWatchGuy ,
I've seen the same problem on repl.it. Now I'm making some tests to make remi working on Heroku.
We can't solve the problem on repl.it without the technical support of the repl's staff.

@MikeTheWatchGuy
Copy link
Author

Whew! I'm glad it's not just me!

I took a peek at Heroku. You're fearless! I couldn't make sense of any of it, but I'm not a web guy.

@dddomodossola
Copy link
Collaborator

@MikeTheWatchGuy got it working on Heroku https://remitest.herokuapp.com/
I will give you some directions tonight

@MikeTheWatchGuy
Copy link
Author

Oh wow! You're SO productive! This is amazing

@dddomodossola
Copy link
Collaborator

Here is an heroku "tutorial":

Download Heroku console from here heroku
Open a windows console (cmd) and run the following command "heroku login", then login to heroku
Open the heroku dashboard
Create a new App named pysimpleguitest and click on "Create app"
From the windows console type "heroku git:clone -a pysimpleguitest" and press enter
then "cd pysimpleguitest"
in this folder create a file named "runtime.txt" and write in it python-3.7.2 and save
create another file named "requirements.txt" and write inside the dependencies i.e. "remi"
create your script named my_app.py, here is the content:

import remi.gui as gui
from remi import start, App
import os

class MyApp(App):
    def main(self):
        main_container = gui.VBox(width=300, height=200, style={'margin':'0px auto'})
        return main_container

if __name__ == "__main__":
    heroku_port = int(os.environ['PORT'])
    start(MyApp, address='0.0.0.0', port=heroku_port, start_browser=False)

create a file named "Procfile" without extension and write inside web: python my_app.py

From the windows console type the following commands

git add *
git commit -am "first commit"
git push heroku master
heroku ps:scale web=1
heroku open

let me know if it works for you ;-)

@khink
Copy link
Contributor

khink commented Mar 22, 2019

Following these steps works. Thanks @dddomodossola !

@dddomodossola
Copy link
Collaborator

you are welcome ;-)

@MikeTheWatchGuy
Copy link
Author

I never completed getting it working... I've got too many other fixes to put into my code that you've already given me.

@MikeTheWatchGuy
Copy link
Author

Oh, I do have a question.... I am unable to run some of my repl.it scripts if it is loaded on another web page. I tried experimenting with the startup settings but didn't find a workaround. As long as it's the only repl.it thing running, It all works great.

@MikeTheWatchGuy
Copy link
Author

This one can be closed as I've been working with repl.it folks for any problems I've had on there recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants