Comments (10)
[I 13:56:06 flexx.app] Starting Flexx event loop.
[I 13:56:08 flexx.app] New session ScrollExample ky0OsXaBn39pI0US7jcJ0ful
JS: C: foo changed:
JS: from 0 to 0
JS: C: foo changed:
JS: from 0 to 5
JS: from 5 to 0
continue
Exception in thread Thread-3:
Traceback (most recent call last):
File "d:\pythonversion38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "d:\pythonversion38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "d:/yolov5_deepsort/Yolov5_DeepSort_Pytorch/taucher_seminar/flexCart/scrollable.py", line 68, in check
event_var.set_foo(n)
File "D:.virtualenvs\smartcart\lib\site-packages\flexx\app_component2.py", line 41, in flx_proxy_action
self._proxy_action(flx_name, *args)
File "D:.virtualenvs\smartcart\lib\site-packages\flexx\app_component2.py", line 499, in _proxy_action
self._session.send_command('INVOKE', self._id, name, args)
File "D:.virtualenvs\smartcart\lib\site-packages\flexx\app_session.py", line 528, in send_command
self._ws.write_command(command)
File "D:.virtualenvs\smartcart\lib\site-packages\flexx\app_tornadoserver.py", line 614, in write_command
self.write_message(bb, binary=True)
File "D:.virtualenvs\smartcart\lib\site-packages\tornado\websocket.py", line 340, in write_message
return self.ws_connection.write_message(message, binary=binary)
File "D:.virtualenvs\smartcart\lib\site-packages\tornado\websocket.py", line 1096, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File "D:.virtualenvs\smartcart\lib\site-packages\tornado\websocket.py", line 1073, in _write_frame
return self.stream.write(frame)
File "D:.virtualenvs\smartcart\lib\site-packages\tornado\iostream.py", line 540, in write
future = Future() # type: Future[None]
File "d:\pythonversion38\lib\asyncio\events.py", line 639, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-3'.
JS: C: foo changed:
JS: from 0 to 1
from flexx.
my code here:
class ScrollExample(flx.Widget):
CSS = """
.flx-ScrollExample {
overflow-y: scroll; // scroll or auto
}
"""
foo = event.IntProp(0, settable=True)
def init(self):
# self.c=Test()
with flx.Widget():
with flx.VBox(flex=1) as self.VB:
for i in range(100):
flx.Button(text="button " + str(i))
@flx.reaction('VB.pointer_click')
def set_value(self,*e):
self.set_foo(3)
print('clicked')
@event.reaction('foo')
def react_to_foo_c(self, *events):
print('C: foo changed:')
for ev in events:
print(' from %i to %i' % (ev.old_value, ev.new_value))
with self.VB:
flx.Button(text='button_add')
from threading import Thread
def check(event_var):
n=0
print('Get thread started')
while True:
event_var.set_foo(n)
time.sleep(3)
print('continue')
n+=1
if name == 'main':
m = flx.launch(ScrollExample)
thread=Thread(target=check,args=(m,),daemon=True)
thread.start()
m.set_foo(5)
flx.run()
from flexx.
I have stranded with the issue for days, I am some new for flexx, hope somebodies can help solve it
from flexx.
I recommend you send a file instead of putting the code in a comment.
In its current form, I think most people won't take the time to try to clean the code and run it.
At least I won't :-P
from flexx.
from flexx.
Thank you for your response, I attached the code file above.
from flexx.
I recommend you send a file instead of putting the code in a comment.
In its current form, I think most people won't take the time to try to clean the code and run it.
At least I won't :-P
hi, konubinx:
I am just a new one for flexx. I have attached the program above, you may help me solve my issue. I would appreciate for it
Thks a lot
from flexx.
I think you are doing it wrong. I would use threading to do this, but
rather use the asyncio call_later function.
I think you can manage to do something using threads, but it comes with
a lot of issues to deal with concurrency.
Here is what I would do:
- have a PyComponent to deal with the server side of stuff
- use call_later in the PyComponent to update the UI
There are alternative designs, like
- keeping only one Widget and use the async loop of the browser to call later
- insist on using threads
But I changed the code to make it more like I feel is the best way to go.
JS: C: foo changed:
JS: from 0 to 0
JS: C: foo changed:
JS: from 0 to 1
JS: from 1 to 8
JS: C: foo changed:
JS: from 8 to 9
JS: C: foo changed:
JS: from 9 to 10
JS: clicked
JS: C: foo changed:
JS: from 10 to 3
JS: C: foo changed:
JS: from 3 to 4
JS: C: foo changed:
JS: from 4 to 5
JS: C: foo changed:
JS: from 5 to 6
Hope that helps and gets out started.
from flexx.
konubinix:
Thank you very much. that is so helpful.
from flexx.
I agree with @Konubinix's answer: asyncio call_later
is the way to go on the Python side.
For completeness, if you're only interested in a timer on the JS side, use window.setTimeout or window.setInterval.
from flexx.
Related Issues (20)
- the pycomponents has conflicts with js? HOT 8
- Run as a desktop app, how to close the incognito window? HOT 1
- How to Change the "Starting Flexx App"? HOT 2
- Run as a desktop app, how to hide or remove the close button on the browser ? HOT 1
- Trying to build a SPA / Saas with Flexx HOT 1
- Flexx lacks of a lot of features HOT 4
- I couldn't find any example of sending ajax request and getting response HOT 1
- PlotlyWidget in offline mode HOT 2
- "Lost connection to server" on every little connection error/timeout HOT 6
- Is there a way to send data from my client side js widget to server side (for example images, videos)? HOT 5
- 使用freeze失败
- Error 404 on leaflet.py example HOT 9
- _mutate_xxx‘s bug or for some other reason HOT 2
- No certificate found HOT 2
- Lost connection with server: message too big (1009) HOT 1
- ui css:max-height < min-height HOT 6
- 'Too many open files' error HOT 14
- Use flx.create_element to create a label in the for loop, bind the onclick event, and dynamically transfer parameters. lambda fun error HOT 1
- use multiprocessing in flexx after freeze, The window keeps popping up HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexx.