PyQt5 + Autobahn/Twisted/Python 2 version of Gauges demo

#1

Hi folks,

Like the subject says, I've created such a demo at

   https://github.com/estan/gauges

Try it out against the CB demo router instance with:

   $ git clone git@github.com:estan/gauges.git
   $ virtualenv2 --system-site-packages ~/demo_env
   $ source ~/demo_env/bin/activate
   $ cd gauges
   $ pip install -e .
   $ gauges-qt --url wss://demo.crossbar.io/ws

If time permits, I'll try to make more Qt examples with other
combinations (Python 3 / asyncio, Python 3 / Twisted, Qt 4, ...). This
was a Qt 5 example, but at work we use Qt 4 and Twisted.

Some points:

- It uses qt5reactor, which is called qt5reactor-fork on PyPI [1].
- It explicity .stop()s reactor.threadpool when shutting down [2].
- It integrates the QMainWindow and ApplicationSession as a single class [3].
- It doesn't look as sexy as the JS version :slight_smile:

Cheers,
Elvis

[1] See https://github.com/nehbit/aether-public/issues/31 for the
reason for this name. It will probably change to just qt5reactor in
the future.
[2] Seems this was required when using wss:// or else the QApplication
wouldn't terminate properly (maybe bug in qt5reactor).
[3] Other setups are possible, separating the two, or using
Application instead of ApplicationSession. But this was the most
compact.

0 Likes

#2

Forgot the obligatory screenshot..

Elvis

···

2015-11-01 20:19 GMT+01:00 Elvis Stansvik <elvs...@gmail.com>:

Hi folks,

Like the subject says, I've created such a demo at

   https://github.com/estan/gauges

Try it out against the CB demo router instance with:

   $ git clone git@github.com:estan/gauges.git
   $ virtualenv2 --system-site-packages ~/demo_env
   $ source ~/demo_env/bin/activate
   $ cd gauges
   $ pip install -e .
   $ gauges-qt --url wss://demo.crossbar.io/ws

If time permits, I'll try to make more Qt examples with other
combinations (Python 3 / asyncio, Python 3 / Twisted, Qt 4, ...). This
was a Qt 5 example, but at work we use Qt 4 and Twisted.

Some points:

- It uses qt5reactor, which is called qt5reactor-fork on PyPI [1].
- It explicity .stop()s reactor.threadpool when shutting down [2].
- It integrates the QMainWindow and ApplicationSession as a single class [3].
- It doesn't look as sexy as the JS version :slight_smile:

Cheers,
Elvis

[1] See https://github.com/nehbit/aether-public/issues/31 for the
reason for this name. It will probably change to just qt5reactor in
the future.
[2] Seems this was required when using wss:// or else the QApplication
wouldn't terminate properly (maybe bug in qt5reactor).
[3] Other setups are possible, separating the two, or using
Application instead of ApplicationSession. But this was the most
compact.

0 Likes

#3

Hi folks,

Like the subject says, I've created such a demo at

   https://github.com/estan/gauges

Try it out against the CB demo router instance with:

   $ git clone git@github.com:estan/gauges.git
   $ virtualenv2 --system-site-packages ~/demo_env
   $ source ~/demo_env/bin/activate
   $ cd gauges
   $ pip install -e .
   $ gauges-qt --url wss://demo.crossbar.io/ws

If time permits, I'll try to make more Qt examples with other
combinations (Python 3 / asyncio, Python 3 / Twisted, Qt 4, ...). This
was a Qt 5 example, but at work we use Qt 4 and Twisted.

Some points:

- It uses qt5reactor, which is called qt5reactor-fork on PyPI [1].
- It explicity .stop()s reactor.threadpool when shutting down [2].
- It integrates the QMainWindow and ApplicationSession as a single class [3].
- It doesn't look as sexy as the JS version :slight_smile:

Cheers,
Elvis

[1] See https://github.com/nehbit/aether-public/issues/31 for the
reason for this name. It will probably change to just qt5reactor in
the future.

The author has now changed the PyPI package name to just "qt5reactor" [1].

Elvis

[1] https://pypi.python.org/pypi/qt5reactor

···

2015-11-01 20:19 GMT+01:00 Elvis Stansvik <elvs...@gmail.com>:

[2] Seems this was required when using wss:// or else the QApplication
wouldn't terminate properly (maybe bug in qt5reactor).
[3] Other setups are possible, separating the two, or using
Application instead of ApplicationSession. But this was the most
compact.

0 Likes

#4

Hi Elvis,

coool! =)

That's a neat example. Nice, clean, readable code. Shows how to really put UIs of vastly different tech. on top of the same backend.

I think this example could make a good intro. And we have an equivalent version written in JS/HTML, which allows to directly compare code.

https://github.com/crossbario/crossbardocs/issues/46

FWIW, I also filed

https://github.com/crossbario/crossbardocs/issues/45

as I now remembered we have

https://github.com/crossbario/crossbarexamples/tree/master/demos/votes/kivy

which is a Kivy version of the Votes demo.

Kivy is another Python UI toolkit http://kivy.org/ - Focus is I guess slightly different from Qt.

Cheers,
/Tobias

···

Am 01.11.2015 um 20:19 schrieb Elvis Stansvik:

Hi folks,

Like the subject says, I've created such a demo at

    https://github.com/estan/gauges

Try it out against the CB demo router instance with:

    $ git clone git@github.com:estan/gauges.git
    $ virtualenv2 --system-site-packages ~/demo_env
    $ source ~/demo_env/bin/activate
    $ cd gauges
    $ pip install -e .
    $ gauges-qt --url wss://demo.crossbar.io/ws

If time permits, I'll try to make more Qt examples with other
combinations (Python 3 / asyncio, Python 3 / Twisted, Qt 4, ...). This
was a Qt 5 example, but at work we use Qt 4 and Twisted.

Some points:

  - It uses qt5reactor, which is called qt5reactor-fork on PyPI [1].
  - It explicity .stop()s reactor.threadpool when shutting down [2].
  - It integrates the QMainWindow and ApplicationSession as a single class [3].
  - It doesn't look as sexy as the JS version :slight_smile:

Cheers,
Elvis

[1] See https://github.com/nehbit/aether-public/issues/31 for the
reason for this name. It will probably change to just qt5reactor in
the future.
[2] Seems this was required when using wss:// or else the QApplication
wouldn't terminate properly (maybe bug in qt5reactor).
[3] Other setups are possible, separating the two, or using
Application instead of ApplicationSession. But this was the most
compact.

0 Likes

#5

Hi Tobias,

Hi Elvis,

coool! =)

That's a neat example. Nice, clean, readable code. Shows how to really put
UIs of vastly different tech. on top of the same backend.

Thanks for the kind words.

I think this example could make a good intro. And we have an equivalent
version written in JS/HTML, which allows to directly compare code.

https://github.com/crossbario/crossbardocs/issues/46

Thanks for filing this. I hope I can make some more examples when time
permits, so you have something meatier to link to.

If so, I'll probably unify them in a single repo ("crossbar-demos-qt"
or some such).

FWIW, I also filed

https://github.com/crossbario/crossbardocs/issues/45

as I now remembered we have

https://github.com/crossbario/crossbarexamples/tree/master/demos/votes/kivy

which is a Kivy version of the Votes demo.

Kivy is another Python UI toolkit http://kivy.org/ - Focus is I guess
slightly different from Qt.

Yep, I've heard of Kivy but never tried it myself. It's on my TODO. My
background in FOSS is with Qt/KDE, and it's also what we use at work.

Elvis

···

2015-11-02 22:21 GMT+01:00 Tobias Oberstein <tobias.o...@gmail.com>:

Cheers,
/Tobias

Am 01.11.2015 um 20:19 schrieb Elvis Stansvik:

Hi folks,

Like the subject says, I've created such a demo at

    https://github.com/estan/gauges

Try it out against the CB demo router instance with:

    $ git clone git@github.com:estan/gauges.git
    $ virtualenv2 --system-site-packages ~/demo_env
    $ source ~/demo_env/bin/activate
    $ cd gauges
    $ pip install -e .
    $ gauges-qt --url wss://demo.crossbar.io/ws

If time permits, I'll try to make more Qt examples with other
combinations (Python 3 / asyncio, Python 3 / Twisted, Qt 4, ...). This
was a Qt 5 example, but at work we use Qt 4 and Twisted.

Some points:

  - It uses qt5reactor, which is called qt5reactor-fork on PyPI [1].
  - It explicity .stop()s reactor.threadpool when shutting down [2].
  - It integrates the QMainWindow and ApplicationSession as a single class
[3].
  - It doesn't look as sexy as the JS version :slight_smile:

Cheers,
Elvis

[1] See https://github.com/nehbit/aether-public/issues/31 for the
reason for this name. It will probably change to just qt5reactor in
the future.
[2] Seems this was required when using wss:// or else the QApplication
wouldn't terminate properly (maybe bug in qt5reactor).
[3] Other setups are possible, separating the two, or using
Application instead of ApplicationSession. But this was the most
compact.

--
You received this message because you are subscribed to the Google Groups
"Crossbar" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to crossbario+...@googlegroups.com.
To post to this group, send email to cross...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/crossbario/5637D3C6.6000505%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#6

Hi Tobias,

Hi Elvis,

coool! =)

That's a neat example. Nice, clean, readable code. Shows how to really put
UIs of vastly different tech. on top of the same backend.

Thanks for the kind words.

I think this example could make a good intro. And we have an equivalent
version written in JS/HTML, which allows to directly compare code.

https://github.com/crossbario/crossbardocs/issues/46

Thanks for filing this. I hope I can make some more examples when time
permits, so you have something meatier to link to.

In the meantime, I've at least made a version of the Votes demo:
https://github.com/estan/votes

It uses a slightly different approach, where the main window class and
the application session class are separate.

Elvis

···

2015-11-03 9:28 GMT+01:00 Elvis Stansvik <elvs...@gmail.com>:

2015-11-02 22:21 GMT+01:00 Tobias Oberstein <tobias.o...@gmail.com>:

If so, I'll probably unify them in a single repo ("crossbar-demos-qt"
or some such).

FWIW, I also filed

https://github.com/crossbario/crossbardocs/issues/45

as I now remembered we have

https://github.com/crossbario/crossbarexamples/tree/master/demos/votes/kivy

which is a Kivy version of the Votes demo.

Kivy is another Python UI toolkit http://kivy.org/ - Focus is I guess
slightly different from Qt.

Yep, I've heard of Kivy but never tried it myself. It's on my TODO. My
background in FOSS is with Qt/KDE, and it's also what we use at work.

Elvis

Cheers,
/Tobias

Am 01.11.2015 um 20:19 schrieb Elvis Stansvik:

Hi folks,

Like the subject says, I've created such a demo at

    https://github.com/estan/gauges

Try it out against the CB demo router instance with:

    $ git clone git@github.com:estan/gauges.git
    $ virtualenv2 --system-site-packages ~/demo_env
    $ source ~/demo_env/bin/activate
    $ cd gauges
    $ pip install -e .
    $ gauges-qt --url wss://demo.crossbar.io/ws

If time permits, I'll try to make more Qt examples with other
combinations (Python 3 / asyncio, Python 3 / Twisted, Qt 4, ...). This
was a Qt 5 example, but at work we use Qt 4 and Twisted.

Some points:

  - It uses qt5reactor, which is called qt5reactor-fork on PyPI [1].
  - It explicity .stop()s reactor.threadpool when shutting down [2].
  - It integrates the QMainWindow and ApplicationSession as a single class
[3].
  - It doesn't look as sexy as the JS version :slight_smile:

Cheers,
Elvis

[1] See https://github.com/nehbit/aether-public/issues/31 for the
reason for this name. It will probably change to just qt5reactor in
the future.
[2] Seems this was required when using wss:// or else the QApplication
wouldn't terminate properly (maybe bug in qt5reactor).
[3] Other setups are possible, separating the two, or using
Application instead of ApplicationSession. But this was the most
compact.

--
You received this message because you are subscribed to the Google Groups
"Crossbar" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to crossbario+...@googlegroups.com.
To post to this group, send email to cross...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/crossbario/5637D3C6.6000505%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#7

Hi folks,

Like the subject says, I've created such a demo at

   https://github.com/estan/gauges

Try it out against the CB demo router instance with:

   $ git clone git@github.com:estan/gauges.git
   $ virtualenv2 --system-site-packages ~/demo_env
   $ source ~/demo_env/bin/activate
   $ cd gauges
   $ pip install -e .
   $ gauges-qt --url wss://demo.crossbar.io/ws

If time permits, I'll try to make more Qt examples with other
combinations (Python 3 / asyncio, Python 3 / Twisted, Qt 4, ...). This
was a Qt 5 example, but at work we use Qt 4 and Twisted.

Some points:

- It uses qt5reactor, which is called qt5reactor-fork on PyPI [1].
- It explicity .stop()s reactor.threadpool when shutting down [2].
- It integrates the QMainWindow and ApplicationSession as a single class [3].
- It doesn't look as sexy as the JS version :slight_smile:

Cheers,
Elvis

[1] See https://github.com/nehbit/aether-public/issues/31 for the
reason for this name. It will probably change to just qt5reactor in
the future.
[2] Seems this was required when using wss:// or else the QApplication
wouldn't terminate properly (maybe bug in qt5reactor).

I've discovered this was due to qt5reactor neglecting to clean up the
reactor threadpool when the application exits. I've filed a pull
request (https://github.com/sunu/qt5reactor/pull/1) that fixes it, so
the above workaround should not be necessary in a hopefully near
future (in case someone already copy-pasted things from my demos).

Elvis

···

2015-11-01 20:19 GMT+01:00 Elvis Stansvik <elvs...@gmail.com>:

[3] Other setups are possible, separating the two, or using
Application instead of ApplicationSession. But this was the most
compact.

0 Likes