any simple example about pyqt and crossbar.io client (or server)

#1

Hi,

I have a small PyQt application and would like to combine it with Wamp / crossbar.io.

How would I do this?
Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:
a) one button: if pressed sending a publish event
b) one button if pressed sending a call
c) one label being updated via i subscribed signal
d) one piece of code, that updates a label and returns a value to crossbar (registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main thread, so I had to start the twisted loop of a crossbar client in a secondary thread.

a) not sure how to do this from a qt thread which is NOT the twisted thread. in the worst case I could add a web service publish url to the crossbar and use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread *or would there be better)

d) not sure how to do this
Can this cause any problems?

Any ideas suggestions?
Any pitfalls / special considerations?
Did anybody combine already PYQt and a crossbar client (or even the crossbar server?)

thanks in advance for your comments.

0 Likes

#2

Hi Gelonida!

Just one remark (I’m not big on Python and entirely unfamiliar with PyQT): When using AutobahnPython, there is no requirement for Twisted. You can also do things using asyncio.

Regards,

Alex

···

Am Sonntag, 25. Oktober 2015 22:53:28 UTC+1 schrieb Gelonida Gel:

Hi,

I have a small PyQt application and would like to combine it with Wamp / crossbar.io.

How would I do this?
Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:
a) one button: if pressed sending a publish event
b) one button if pressed sending a call
c) one label being updated via i subscribed signal
d) one piece of code, that updates a label and returns a value to crossbar (registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main thread, so I had to start the twisted loop of a crossbar client in a secondary thread.

a) not sure how to do this from a qt thread which is NOT the twisted thread. in the worst case I could add a web service publish url to the crossbar and use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread *or would there be better)

d) not sure how to do this
Can this cause any problems?

Any ideas suggestions?
Any pitfalls / special considerations?
Did anybody combine already PYQt and a crossbar client (or even the crossbar server?)

thanks in advance for your comments.

0 Likes

#3

Thanks for your reply Alexander,

Hi Gelonida!

Just one remark (I’m not big on Python and entirely unfamiliar with PyQT): When using AutobahnPython, there is no requirement for Twisted. You can also do things using asyncio.

True though it doesn’t change a lot the basic question, which I did not express very clearly.
How to combine an existing application PyQT or another non asynchronously programmed app with a crossbar client, which follows
an asynchronous programming paradigm?

How can messages be passed between an asyncronous event loop and other (potentially blocking) threads.

···

On Thursday, October 29, 2015 at 12:49:52 PM UTC+1, Alexander Gödde wrote:

Regards,

Alex

Am Sonntag, 25. Oktober 2015 22:53:28 UTC+1 schrieb Gelonida Gel:

Hi,

I have a small PyQt application and would like to combine it with Wamp / crossbar.io.

How would I do this?
Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:
a) one button: if pressed sending a publish event
b) one button if pressed sending a call
c) one label being updated via i subscribed signal
d) one piece of code, that updates a label and returns a value to crossbar (registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main thread, so I had to start the twisted loop of a crossbar client in a secondary thread.

a) not sure how to do this from a qt thread which is NOT the twisted thread. in the worst case I could add a web service publish url to the crossbar and use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread *or would there be better)

d) not sure how to do this
Can this cause any problems?

Any ideas suggestions?
Any pitfalls / special considerations?
Did anybody combine already PYQt and a crossbar client (or even the crossbar server?)

thanks in advance for your comments.

0 Likes

#4

Hi Gelonida,

Hi,

I have a small PyQt application and would like to combine it with Wamp /
crossbar.io.

How would I do this?
Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:
a) one button: if pressed sending a publish event
b) one button if pressed sending a call
c) one label being updated via i subscribed signal
d) one piece of code, that updates a label and returns a value to crossbar
(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main thread,
so I had to start the twisted loop of a crossbar client in a secondary
thread.

a) not sure how to do this from a qt thread which is NOT the twisted thread.
in the worst case I could add a web service publish url to the crossbar and
use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread *or
would there be better)

d) not sure how to do this
Can this cause any problems?

Any ideas suggestions?
Any pitfalls / special considerations?
Did anybody combine already PYQt and a crossbar client (or even the crossbar
server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is
not necessary. What we do is make use of qt4reactor [1], a bridge that
makes it possible to run the event loops of Qt and Twisted in tandem.

I don't have minimal example like you describe ready, and I can't
really share the code of the clients we have at work. But if I find
time I'll try to make such an example.

In the meantime, this is a very rough recipe:

1) Create your QApplication object.
2) Create your Autobahn Application object.
3) Install the Qt Twisted reactor with qt4reactor.install().
4) Run your application with app.run(url="your router URL", realm=u"your realm")

You should not call QApplication.exec(..), it will be done for you by
when the reactor starts.

It should be possible to use with the ApplicationSession API as well,
but the simplified Application API is what we're using at the moment.

Here's an example snippet of how we make an async RPC call inside a
slot connected to a Qt button click:

    @pyqtSlot()
    @inlineCallbacks
    def on_startButton_clicked(self):
        self.statusBar().showMessage('Preparing for acquisition')

        yield self.wapp.session.call(u'com.example.x1.prepare_for_acquisition',
num_frames=500, frame_rate=5, binning=1)

        self.statusBar().showMessage('Acquiring...')

        yield self.wapp.session.call(
            u'com.orexplore.x1.start_acquisition',
            options=CallOptions(on_progress=self.onFrame))

        self.statusBar().showMessage('Acquisition done')

Hope you have enough info to get going. But I'll see if I can make a
minimal working example when I have time.

Cheers,
Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

···

2015-10-25 22:53 GMT+01:00 Gelonida Gel <gelo...@gmail.com>:

thanks in advance for your comments.

--
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/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#5

Hi Gelonida,

Hi,

I have a small PyQt application and would like to combine it with Wamp /
crossbar.io.

How would I do this?
Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:
a) one button: if pressed sending a publish event
b) one button if pressed sending a call
c) one label being updated via i subscribed signal
d) one piece of code, that updates a label and returns a value to crossbar
(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main thread,
so I had to start the twisted loop of a crossbar client in a secondary
thread.

a) not sure how to do this from a qt thread which is NOT the twisted thread.
in the worst case I could add a web service publish url to the crossbar and
use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread *or
would there be better)

d) not sure how to do this
Can this cause any problems?

Any ideas suggestions?
Any pitfalls / special considerations?
Did anybody combine already PYQt and a crossbar client (or even the crossbar
server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is
not necessary. What we do is make use of qt4reactor [1], a bridge that
makes it possible to run the event loops of Qt and Twisted in tandem.

I don't have minimal example like you describe ready, and I can't
really share the code of the clients we have at work. But if I find
time I'll try to make such an example.

In the meantime, this is a very rough recipe:

1) Create your QApplication object.
2) Create your Autobahn Application object.
3) Install the Qt Twisted reactor with qt4reactor.install().
4) Run your application with app.run(url="your router URL", realm=u"your realm")

You should not call QApplication.exec(..), it will be done for you by
when the reactor starts.

It should be possible to use with the ApplicationSession API as well,
but the simplified Application API is what we're using at the moment.

Here's an example snippet of how we make an async RPC call inside a
slot connected to a Qt button click:

    @pyqtSlot()
    @inlineCallbacks
    def on_startButton_clicked(self):
        self.statusBar().showMessage('Preparing for acquisition')

        yield self.wapp.session.call(u'com.example.x1.prepare_for_acquisition',
num_frames=500, frame_rate=5, binning=1)

        self.statusBar().showMessage('Acquiring...')

        yield self.wapp.session.call(
            u'com.orexplore.x1.start_acquisition',
            options=CallOptions(on_progress=self.onFrame))

        self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow
subclass, and self.wapp is a reference to the Autobahn Application
object which was passed in and saved as a member when the window was
constructed.

Elvis

···

2015-10-31 15:26 GMT+01:00 Elvis Stansvik <elvs...@gmail.com>:

2015-10-25 22:53 GMT+01:00 Gelonida Gel <gelo...@gmail.com>:

Hope you have enough info to get going. But I'll see if I can make a
minimal working example when I have time.

Cheers,
Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

--
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/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#6

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.
Will try it out

···

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik elv...@gmail.com:

Hi Gelonida,

2015-10-25 22:53 GMT+01:00 Gelonida Gel gel...@gmail.com:

Hi,

I have a small PyQt application and would like to combine it with Wamp /

crossbar.io.

How would I do this?

Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:

a) one button: if pressed sending a publish event

b) one button if pressed sending a call

c) one label being updated via i subscribed signal

d) one piece of code, that updates a label and returns a value to crossbar

(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main thread,

so I had to start the twisted loop of a crossbar client in a secondary

thread.

a) not sure how to do this from a qt thread which is NOT the twisted thread.

in the worst case I could add a web service publish url to the crossbar and

use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread *or

would there be better)

d) not sure how to do this

Can this cause any problems?

Any ideas suggestions?

Any pitfalls / special considerations?

Did anybody combine already PYQt and a crossbar client (or even the crossbar

server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is

not necessary. What we do is make use of qt4reactor [1], a bridge that

makes it possible to run the event loops of Qt and Twisted in tandem.

I don’t have minimal example like you describe ready, and I can’t

really share the code of the clients we have at work. But if I find

time I’ll try to make such an example.

In the meantime, this is a very rough recipe:

  1. Create your QApplication object.
  1. Create your Autobahn Application object.
  1. Install the Qt Twisted reactor with qt4reactor.install().
  1. Run your application with app.run(url=“your router URL”, realm=u"your realm")

You should not call QApplication.exec(…), it will be done for you by

when the reactor starts.

It should be possible to use with the ApplicationSession API as well,

but the simplified Application API is what we’re using at the moment.

Here’s an example snippet of how we make an async RPC call inside a

slot connected to a Qt button click:

@pyqtSlot()
@inlineCallbacks
def on_startButton_clicked(self):
    self.statusBar().showMessage('Preparing for acquisition')
    yield self.wapp.session.call(u'com.example.x1.prepare_for_acquisition',

num_frames=500, frame_rate=5, binning=1)

    self.statusBar().showMessage('Acquiring...')
    yield self.wapp.session.call(
        u'com.orexplore.x1.start_acquisition',
        options=CallOptions(on_progress=self.onFrame))
    self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow

subclass, and self.wapp is a reference to the Autobahn Application

object which was passed in and saved as a member when the window was

constructed.

Elvis

Hope you have enough info to get going. But I’ll see if I can make a

minimal working example when I have time.

Cheers,

Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

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 cros...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#7

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.
Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo
ready. It just needs a little polishing. I'll post to this list when
it's up on GitHub.

Elvis

···

2015-11-01 15:31 GMT+01:00 Gelonida Gel <gelo...@gmail.com>:

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik <elv...@gmail.com>:
> Hi Gelonida,
>
> 2015-10-25 22:53 GMT+01:00 Gelonida Gel <gel...@gmail.com>:
>> Hi,
>>
>>
>> I have a small PyQt application and would like to combine it with Wamp
>> /
>> crossbar.io.
>>
>> How would I do this?
>> Does anybody have a very simple example?
>>
>> The 'simple example I imagine would be a QT widget with:
>> a) one button: if pressed sending a publish event
>> b) one button if pressed sending a call
>> c) one label being updated via i subscribed signal
>> d) one piece of code, that updates a label and returns a value to
>> crossbar
>> (registered RPC call)
>>
>>
>> My ideas so far:
>>
>> Up to my understanding i MUST start the PyQT event loop in the main
>> thread,
>> so I had to start the twisted loop of a crossbar client in a secondary
>> thread.
>>
>> a) not sure how to do this from a qt thread which is NOT the twisted
>> thread.
>> in the worst case I could add a web service publish url to the crossbar
>> and
>> use crossbarconnect
>>
>> b) same as a)?
>>
>> c) subscribe from the twisted thread and send a signal to the QT thread
>> *or
>> would there be better)
>>
>> d) not sure how to do this
>> Can this cause any problems?
>>
>>
>> Any ideas suggestions?
>> Any pitfalls / special considerations?
>> Did anybody combine already PYQt and a crossbar client (or even the
>> crossbar
>> server?)
>
> We have several PyQt + Autobahn/Twisted clients at work. Threading is
> not necessary. What we do is make use of qt4reactor [1], a bridge that
> makes it possible to run the event loops of Qt and Twisted in tandem.
>
> I don't have minimal example like you describe ready, and I can't
> really share the code of the clients we have at work. But if I find
> time I'll try to make such an example.
>
> In the meantime, this is a very rough recipe:
>
> 1) Create your QApplication object.
> 2) Create your Autobahn Application object.
> 3) Install the Qt Twisted reactor with qt4reactor.install().
> 4) Run your application with app.run(url="your router URL", realm=u"your
> realm")
>
> You should not call QApplication.exec(..), it will be done for you by
> when the reactor starts.
>
> It should be possible to use with the ApplicationSession API as well,
> but the simplified Application API is what we're using at the moment.
>
> Here's an example snippet of how we make an async RPC call inside a
> slot connected to a Qt button click:
>
> @pyqtSlot()
> @inlineCallbacks
> def on_startButton_clicked(self):
> self.statusBar().showMessage('Preparing for acquisition')
>
> yield
> self.wapp.session.call(u'com.example.x1.prepare_for_acquisition',
> num_frames=500, frame_rate=5, binning=1)
>
> self.statusBar().showMessage('Acquiring...')
>
> yield self.wapp.session.call(
> u'com.orexplore.x1.start_acquisition',
> options=CallOptions(on_progress=self.onFrame))
>
> self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow
subclass, and self.wapp is a reference to the Autobahn Application
object which was passed in and saved as a member when the window was
constructed.

Elvis

>
> Hope you have enough info to get going. But I'll see if I can make a
> minimal working example when I have time.
>
> Cheers,
> Elvis
>
> [1] https://pypi.python.org/pypi/qt4reactor/1.6
>
>>
>> thanks in advance for your comments.
>>
>> --
>> 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 crossba...@googlegroups.com.
>> To post to this group, send email to cros...@googlegroups.com.
>> To view this discussion on the web visit
>>
>> https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

--
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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#8

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.
Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo
ready. It just needs a little polishing. I'll post to this list when
it's up on GitHub.

It's now up at https://github.com/estan/gauges

Elvis

···

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

2015-11-01 15:31 GMT+01:00 Gelonida Gel <gelo...@gmail.com>:

Elvis

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik <elv...@gmail.com>:
> Hi Gelonida,
>
> 2015-10-25 22:53 GMT+01:00 Gelonida Gel <gel...@gmail.com>:
>> Hi,
>>
>>
>> I have a small PyQt application and would like to combine it with Wamp
>> /
>> crossbar.io.
>>
>> How would I do this?
>> Does anybody have a very simple example?
>>
>> The 'simple example I imagine would be a QT widget with:
>> a) one button: if pressed sending a publish event
>> b) one button if pressed sending a call
>> c) one label being updated via i subscribed signal
>> d) one piece of code, that updates a label and returns a value to
>> crossbar
>> (registered RPC call)
>>
>>
>> My ideas so far:
>>
>> Up to my understanding i MUST start the PyQT event loop in the main
>> thread,
>> so I had to start the twisted loop of a crossbar client in a secondary
>> thread.
>>
>> a) not sure how to do this from a qt thread which is NOT the twisted
>> thread.
>> in the worst case I could add a web service publish url to the crossbar
>> and
>> use crossbarconnect
>>
>> b) same as a)?
>>
>> c) subscribe from the twisted thread and send a signal to the QT thread
>> *or
>> would there be better)
>>
>> d) not sure how to do this
>> Can this cause any problems?
>>
>>
>> Any ideas suggestions?
>> Any pitfalls / special considerations?
>> Did anybody combine already PYQt and a crossbar client (or even the
>> crossbar
>> server?)
>
> We have several PyQt + Autobahn/Twisted clients at work. Threading is
> not necessary. What we do is make use of qt4reactor [1], a bridge that
> makes it possible to run the event loops of Qt and Twisted in tandem.
>
> I don't have minimal example like you describe ready, and I can't
> really share the code of the clients we have at work. But if I find
> time I'll try to make such an example.
>
> In the meantime, this is a very rough recipe:
>
> 1) Create your QApplication object.
> 2) Create your Autobahn Application object.
> 3) Install the Qt Twisted reactor with qt4reactor.install().
> 4) Run your application with app.run(url="your router URL", realm=u"your
> realm")
>
> You should not call QApplication.exec(..), it will be done for you by
> when the reactor starts.
>
> It should be possible to use with the ApplicationSession API as well,
> but the simplified Application API is what we're using at the moment.
>
> Here's an example snippet of how we make an async RPC call inside a
> slot connected to a Qt button click:
>
> @pyqtSlot()
> @inlineCallbacks
> def on_startButton_clicked(self):
> self.statusBar().showMessage('Preparing for acquisition')
>
> yield
> self.wapp.session.call(u'com.example.x1.prepare_for_acquisition',
> num_frames=500, frame_rate=5, binning=1)
>
> self.statusBar().showMessage('Acquiring...')
>
> yield self.wapp.session.call(
> u'com.orexplore.x1.start_acquisition',
> options=CallOptions(on_progress=self.onFrame))
>
> self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow
subclass, and self.wapp is a reference to the Autobahn Application
object which was passed in and saved as a member when the window was
constructed.

Elvis

>
> Hope you have enough info to get going. But I'll see if I can make a
> minimal working example when I have time.
>
> Cheers,
> Elvis
>
> [1] https://pypi.python.org/pypi/qt4reactor/1.6
>
>>
>> thanks in advance for your comments.
>>
>> --
>> 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 crossba...@googlegroups.com.
>> To post to this group, send email to cros...@googlegroups.com.
>> To view this discussion on the web visit
>>
>> https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

--
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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#9

Hi Elvis!

Thanks for the demo! Could I add this to the crossbarexamples repository? I think this would make it easier to find for people.

Regards,

Alex

···

Am Sonntag, 1. November 2015 21:06:02 UTC+1 schrieb Elvis Stansvik:

2015-11-01 18:39 GMT+01:00 Elvis Stansvik elvs...@gmail.com:

2015-11-01 15:31 GMT+01:00 Gelonida Gel gelo...@gmail.com:

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.

Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo

ready. It just needs a little polishing. I’ll post to this list when

it’s up on GitHub.

It’s now up at https://github.com/estan/gauges

Elvis

Elvis

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik elv...@gmail.com:

Hi Gelonida,

2015-10-25 22:53 GMT+01:00 Gelonida Gel gel...@gmail.com:

Hi,

I have a small PyQt application and would like to combine it with Wamp

/

crossbar.io.

How would I do this?

Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:

a) one button: if pressed sending a publish event

b) one button if pressed sending a call

c) one label being updated via i subscribed signal

d) one piece of code, that updates a label and returns a value to

crossbar

(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main

thread,

so I had to start the twisted loop of a crossbar client in a secondary

thread.

a) not sure how to do this from a qt thread which is NOT the twisted

thread.

in the worst case I could add a web service publish url to the crossbar

and

use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread

*or

would there be better)

d) not sure how to do this

Can this cause any problems?

Any ideas suggestions?

Any pitfalls / special considerations?

Did anybody combine already PYQt and a crossbar client (or even the

crossbar

server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is

not necessary. What we do is make use of qt4reactor [1], a bridge that

makes it possible to run the event loops of Qt and Twisted in tandem.

I don’t have minimal example like you describe ready, and I can’t

really share the code of the clients we have at work. But if I find

time I’ll try to make such an example.

In the meantime, this is a very rough recipe:

  1. Create your QApplication object.
  1. Create your Autobahn Application object.
  1. Install the Qt Twisted reactor with qt4reactor.install().
  1. Run your application with app.run(url=“your router URL”, realm=u"your

realm")

You should not call QApplication.exec(…), it will be done for you by

when the reactor starts.

It should be possible to use with the ApplicationSession API as well,

but the simplified Application API is what we’re using at the moment.

Here’s an example snippet of how we make an async RPC call inside a

slot connected to a Qt button click:

@pyqtSlot()
@inlineCallbacks
def on_startButton_clicked(self):
    self.statusBar().showMessage('Preparing for acquisition')
    yield

self.wapp.session.call(u’com.example.x1.prepare_for_acquisition’,

num_frames=500, frame_rate=5, binning=1)

    self.statusBar().showMessage('Acquiring...')
    yield self.wapp.session.call(
        u'com.orexplore.x1.start_acquisition',
        options=CallOptions(on_progress=self.onFrame))
    self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow

subclass, and self.wapp is a reference to the Autobahn Application

object which was passed in and saved as a member when the window was

constructed.

Elvis

Hope you have enough info to get going. But I’ll see if I can make a

minimal working example when I have time.

Cheers,

Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

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 cros...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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+unsubscribe@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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#10

Hi Elvis!

Thanks for the demo! Could I add this to the crossbarexamples repository? I think this would make it easier to find for people.

I’ll make a pull request as soon as possible. A bit busy with a school deadline atm.

I guess I’ll follow the general format for examples there then, and not include a setup.py. Maybe I’ll keep my repo as an “upstream” version.

Elvis

···

Den 5 nov 2015 12:49 em skrev “Alexander Gödde” alexande...@googlemail.com:

Regards,

Alex

Am Sonntag, 1. November 2015 21:06:02 UTC+1 schrieb Elvis Stansvik:

2015-11-01 18:39 GMT+01:00 Elvis Stansvik elvs...@gmail.com:

2015-11-01 15:31 GMT+01:00 Gelonida Gel gelo...@gmail.com:

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.

Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo

ready. It just needs a little polishing. I’ll post to this list when

it’s up on GitHub.

It’s now up at https://github.com/estan/gauges

Elvis

Elvis

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik elv...@gmail.com:

Hi Gelonida,

2015-10-25 22:53 GMT+01:00 Gelonida Gel gel...@gmail.com:

Hi,

I have a small PyQt application and would like to combine it with Wamp

/

crossbar.io.

How would I do this?

Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:

a) one button: if pressed sending a publish event

b) one button if pressed sending a call

c) one label being updated via i subscribed signal

d) one piece of code, that updates a label and returns a value to

crossbar

(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main

thread,

so I had to start the twisted loop of a crossbar client in a secondary

thread.

a) not sure how to do this from a qt thread which is NOT the twisted

thread.

in the worst case I could add a web service publish url to the crossbar

and

use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread

*or

would there be better)

d) not sure how to do this

Can this cause any problems?

Any ideas suggestions?

Any pitfalls / special considerations?

Did anybody combine already PYQt and a crossbar client (or even the

crossbar

server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is

not necessary. What we do is make use of qt4reactor [1], a bridge that

makes it possible to run the event loops of Qt and Twisted in tandem.

I don’t have minimal example like you describe ready, and I can’t

really share the code of the clients we have at work. But if I find

time I’ll try to make such an example.

In the meantime, this is a very rough recipe:

  1. Create your QApplication object.
  1. Create your Autobahn Application object.
  1. Install the Qt Twisted reactor with qt4reactor.install().
  1. Run your application with app.run(url=“your router URL”, realm=u"your

realm")

You should not call QApplication.exec(…), it will be done for you by

when the reactor starts.

It should be possible to use with the ApplicationSession API as well,

but the simplified Application API is what we’re using at the moment.

Here’s an example snippet of how we make an async RPC call inside a

slot connected to a Qt button click:

@pyqtSlot()
@inlineCallbacks
def on_startButton_clicked(self):
    self.statusBar().showMessage('Preparing for acquisition')
    yield

self.wapp.session.call(u’com.example.x1.prepare_for_acquisition’,

num_frames=500, frame_rate=5, binning=1)

    self.statusBar().showMessage('Acquiring...')
    yield self.wapp.session.call(
        u'com.orexplore.x1.start_acquisition',
        options=CallOptions(on_progress=self.onFrame))
    self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow

subclass, and self.wapp is a reference to the Autobahn Application

object which was passed in and saved as a member when the window was

constructed.

Elvis

Hope you have enough info to get going. But I’ll see if I can make a

minimal working example when I have time.

Cheers,

Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

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 crossba...@googlegroups.com.

To post to this group, send email to cros...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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/402020cf-4874-4ecf-8a66-98fe07fd2a88%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#11

Hi Elvis!

Thanks for the demo! Could I add this to the crossbarexamples repository? I think this would make it easier to find for people.

Oh wait, you said “can I”. Yes by all means go ahead. You have my permission to use any license you want BTW.

Elvis

···

Den 5 nov 2015 1:09 em skrev “Elvis Stansvik” elvs...@gmail.com:

Den 5 nov 2015 12:49 em skrev “Alexander Gödde” alexande...@googlemail.com:

I’ll make a pull request as soon as possible. A bit busy with a school deadline atm.

I guess I’ll follow the general format for examples there then, and not include a setup.py. Maybe I’ll keep my repo as an “upstream” version.

Elvis

Regards,

Alex

Am Sonntag, 1. November 2015 21:06:02 UTC+1 schrieb Elvis Stansvik:

2015-11-01 18:39 GMT+01:00 Elvis Stansvik elvs...@gmail.com:

2015-11-01 15:31 GMT+01:00 Gelonida Gel gelo...@gmail.com:

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.

Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo

ready. It just needs a little polishing. I’ll post to this list when

it’s up on GitHub.

It’s now up at https://github.com/estan/gauges

Elvis

Elvis

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik elv...@gmail.com:

Hi Gelonida,

2015-10-25 22:53 GMT+01:00 Gelonida Gel gel...@gmail.com:

Hi,

I have a small PyQt application and would like to combine it with Wamp

/

crossbar.io.

How would I do this?

Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:

a) one button: if pressed sending a publish event

b) one button if pressed sending a call

c) one label being updated via i subscribed signal

d) one piece of code, that updates a label and returns a value to

crossbar

(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main

thread,

so I had to start the twisted loop of a crossbar client in a secondary

thread.

a) not sure how to do this from a qt thread which is NOT the twisted

thread.

in the worst case I could add a web service publish url to the crossbar

and

use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread

*or

would there be better)

d) not sure how to do this

Can this cause any problems?

Any ideas suggestions?

Any pitfalls / special considerations?

Did anybody combine already PYQt and a crossbar client (or even the

crossbar

server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is

not necessary. What we do is make use of qt4reactor [1], a bridge that

makes it possible to run the event loops of Qt and Twisted in tandem.

I don’t have minimal example like you describe ready, and I can’t

really share the code of the clients we have at work. But if I find

time I’ll try to make such an example.

In the meantime, this is a very rough recipe:

  1. Create your QApplication object.
  1. Create your Autobahn Application object.
  1. Install the Qt Twisted reactor with qt4reactor.install().
  1. Run your application with app.run(url=“your router URL”, realm=u"your

realm")

You should not call QApplication.exec(…), it will be done for you by

when the reactor starts.

It should be possible to use with the ApplicationSession API as well,

but the simplified Application API is what we’re using at the moment.

Here’s an example snippet of how we make an async RPC call inside a

slot connected to a Qt button click:

@pyqtSlot()
@inlineCallbacks
def on_startButton_clicked(self):
    self.statusBar().showMessage('Preparing for acquisition')
    yield

self.wapp.session.call(u’com.example.x1.prepare_for_acquisition’,

num_frames=500, frame_rate=5, binning=1)

    self.statusBar().showMessage('Acquiring...')
    yield self.wapp.session.call(
        u'com.orexplore.x1.start_acquisition',
        options=CallOptions(on_progress=self.onFrame))
    self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow

subclass, and self.wapp is a reference to the Autobahn Application

object which was passed in and saved as a member when the window was

constructed.

Elvis

Hope you have enough info to get going. But I’ll see if I can make a

minimal working example when I have time.

Cheers,

Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

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 crossba...@googlegroups.com.

To post to this group, send email to cros...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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/402020cf-4874-4ecf-8a66-98fe07fd2a88%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#12

Damn your reading skills :wink:

···

Am Donnerstag, 5. November 2015 13:11:06 UTC+1 schrieb Elvis Stansvik:

Den 5 nov 2015 1:09 em skrev “Elvis Stansvik” elvs...@gmail.com:

Den 5 nov 2015 12:49 em skrev “Alexander Gödde” alexander.goedde@googlemail.com:

Hi Elvis!

Thanks for the demo! Could I add this to the crossbarexamples repository? I think this would make it easier to find for people.

Oh wait, you said “can I”. Yes by all means go ahead. You have my permission to use any license you want BTW.

Elvis

I’ll make a pull request as soon as possible. A bit busy with a school deadline atm.

I guess I’ll follow the general format for examples there then, and not include a setup.py. Maybe I’ll keep my repo as an “upstream” version.

Elvis

Regards,

Alex

Am Sonntag, 1. November 2015 21:06:02 UTC+1 schrieb Elvis Stansvik:

2015-11-01 18:39 GMT+01:00 Elvis Stansvik elvs...@gmail.com:

2015-11-01 15:31 GMT+01:00 Gelonida Gel gelo...@gmail.com:

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.

Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo

ready. It just needs a little polishing. I’ll post to this list when

it’s up on GitHub.

It’s now up at https://github.com/estan/gauges

Elvis

Elvis

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik elv...@gmail.com:

Hi Gelonida,

2015-10-25 22:53 GMT+01:00 Gelonida Gel gel...@gmail.com:

Hi,

I have a small PyQt application and would like to combine it with Wamp

/

crossbar.io.

How would I do this?

Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:

a) one button: if pressed sending a publish event

b) one button if pressed sending a call

c) one label being updated via i subscribed signal

d) one piece of code, that updates a label and returns a value to

crossbar

(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main

thread,

so I had to start the twisted loop of a crossbar client in a secondary

thread.

a) not sure how to do this from a qt thread which is NOT the twisted

thread.

in the worst case I could add a web service publish url to the crossbar

and

use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread

*or

would there be better)

d) not sure how to do this

Can this cause any problems?

Any ideas suggestions?

Any pitfalls / special considerations?

Did anybody combine already PYQt and a crossbar client (or even the

crossbar

server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is

not necessary. What we do is make use of qt4reactor [1], a bridge that

makes it possible to run the event loops of Qt and Twisted in tandem.

I don’t have minimal example like you describe ready, and I can’t

really share the code of the clients we have at work. But if I find

time I’ll try to make such an example.

In the meantime, this is a very rough recipe:

  1. Create your QApplication object.
  1. Create your Autobahn Application object.
  1. Install the Qt Twisted reactor with qt4reactor.install().
  1. Run your application with app.run(url=“your router URL”, realm=u"your

realm")

You should not call QApplication.exec(…), it will be done for you by

when the reactor starts.

It should be possible to use with the ApplicationSession API as well,

but the simplified Application API is what we’re using at the moment.

Here’s an example snippet of how we make an async RPC call inside a

slot connected to a Qt button click:

@pyqtSlot()
@inlineCallbacks
def on_startButton_clicked(self):
    self.statusBar().showMessage('Preparing for acquisition')
    yield

self.wapp.session.call(u’com.example.x1.prepare_for_acquisition’,

num_frames=500, frame_rate=5, binning=1)

    self.statusBar().showMessage('Acquiring...')
    yield self.wapp.session.call(
        u'com.orexplore.x1.start_acquisition',
        options=CallOptions(on_progress=self.onFrame))
    self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow

subclass, and self.wapp is a reference to the Autobahn Application

object which was passed in and saved as a member when the window was

constructed.

Elvis

Hope you have enough info to get going. But I’ll see if I can make a

minimal working example when I have time.

Cheers,

Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

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 cros...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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+unsubscribe@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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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+unsubscribe@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/402020cf-4874-4ecf-8a66-98fe07fd2a88%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#13

Damn your reading skills :wink:

:slight_smile: No but really, it’s no bother, I can make a pull request, it’s just that if I do, it won’t be right now as I have that deadline at 17 tomorrow.

Elvis

···

Den 5 nov 2015 1:59 em skrev “Alexander Gödde” alexande...@googlemail.com:

Am Donnerstag, 5. November 2015 13:11:06 UTC+1 schrieb Elvis Stansvik:

Den 5 nov 2015 1:09 em skrev “Elvis Stansvik” elvs...@gmail.com:

Den 5 nov 2015 12:49 em skrev “Alexander Gödde” alexande...@googlemail.com:

Hi Elvis!

Thanks for the demo! Could I add this to the crossbarexamples repository? I think this would make it easier to find for people.

Oh wait, you said “can I”. Yes by all means go ahead. You have my permission to use any license you want BTW.

Elvis

I’ll make a pull request as soon as possible. A bit busy with a school deadline atm.

I guess I’ll follow the general format for examples there then, and not include a setup.py. Maybe I’ll keep my repo as an “upstream” version.

Elvis

Regards,

Alex

Am Sonntag, 1. November 2015 21:06:02 UTC+1 schrieb Elvis Stansvik:

2015-11-01 18:39 GMT+01:00 Elvis Stansvik elvs...@gmail.com:

2015-11-01 15:31 GMT+01:00 Gelonida Gel gelo...@gmail.com:

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.

Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo

ready. It just needs a little polishing. I’ll post to this list when

it’s up on GitHub.

It’s now up at https://github.com/estan/gauges

Elvis

Elvis

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik elv...@gmail.com:

Hi Gelonida,

2015-10-25 22:53 GMT+01:00 Gelonida Gel gel...@gmail.com:

Hi,

I have a small PyQt application and would like to combine it with Wamp

/

crossbar.io.

How would I do this?

Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:

a) one button: if pressed sending a publish event

b) one button if pressed sending a call

c) one label being updated via i subscribed signal

d) one piece of code, that updates a label and returns a value to

crossbar

(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main

thread,

so I had to start the twisted loop of a crossbar client in a secondary

thread.

a) not sure how to do this from a qt thread which is NOT the twisted

thread.

in the worst case I could add a web service publish url to the crossbar

and

use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread

*or

would there be better)

d) not sure how to do this

Can this cause any problems?

Any ideas suggestions?

Any pitfalls / special considerations?

Did anybody combine already PYQt and a crossbar client (or even the

crossbar

server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is

not necessary. What we do is make use of qt4reactor [1], a bridge that

makes it possible to run the event loops of Qt and Twisted in tandem.

I don’t have minimal example like you describe ready, and I can’t

really share the code of the clients we have at work. But if I find

time I’ll try to make such an example.

In the meantime, this is a very rough recipe:

  1. Create your QApplication object.
  1. Create your Autobahn Application object.
  1. Install the Qt Twisted reactor with qt4reactor.install().
  1. Run your application with app.run(url=“your router URL”, realm=u"your

realm")

You should not call QApplication.exec(…), it will be done for you by

when the reactor starts.

It should be possible to use with the ApplicationSession API as well,

but the simplified Application API is what we’re using at the moment.

Here’s an example snippet of how we make an async RPC call inside a

slot connected to a Qt button click:

@pyqtSlot()
@inlineCallbacks
def on_startButton_clicked(self):
    self.statusBar().showMessage('Preparing for acquisition')
    yield

self.wapp.session.call(u’com.example.x1.prepare_for_acquisition’,

num_frames=500, frame_rate=5, binning=1)

    self.statusBar().showMessage('Acquiring...')
    yield self.wapp.session.call(
        u'com.orexplore.x1.start_acquisition',
        options=CallOptions(on_progress=self.onFrame))
    self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow

subclass, and self.wapp is a reference to the Autobahn Application

object which was passed in and saved as a member when the window was

constructed.

Elvis

Hope you have enough info to get going. But I’ll see if I can make a

minimal working example when I have time.

Cheers,

Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

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 crossba...@googlegroups.com.

To post to this group, send email to cros...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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/402020cf-4874-4ecf-8a66-98fe07fd2a88%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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/af8cbd86-a283-4d7c-b1b6-0fe471dfda84%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#14

No hurry! (And thanks again!)

···

Am Donnerstag, 5. November 2015 14:05:40 UTC+1 schrieb Elvis Stansvik:

Den 5 nov 2015 1:59 em skrev “Alexander Gödde” alexander.goedde@googlemail.com:

Damn your reading skills :wink:

:slight_smile: No but really, it’s no bother, I can make a pull request, it’s just that if I do, it won’t be right now as I have that deadline at 17 tomorrow.

Elvis

Am Donnerstag, 5. November 2015 13:11:06 UTC+1 schrieb Elvis Stansvik:

Den 5 nov 2015 1:09 em skrev “Elvis Stansvik” elvs...@gmail.com:

Den 5 nov 2015 12:49 em skrev “Alexander Gödde” alexander.goedde@googlemail.com:

Hi Elvis!

Thanks for the demo! Could I add this to the crossbarexamples repository? I think this would make it easier to find for people.

Oh wait, you said “can I”. Yes by all means go ahead. You have my permission to use any license you want BTW.

Elvis

I’ll make a pull request as soon as possible. A bit busy with a school deadline atm.

I guess I’ll follow the general format for examples there then, and not include a setup.py. Maybe I’ll keep my repo as an “upstream” version.

Elvis

Regards,

Alex

Am Sonntag, 1. November 2015 21:06:02 UTC+1 schrieb Elvis Stansvik:

2015-11-01 18:39 GMT+01:00 Elvis Stansvik elvs...@gmail.com:

2015-11-01 15:31 GMT+01:00 Gelonida Gel gelo...@gmail.com:

Hi Elvis,

Thanks a lot this sounds lke a good solution fro XB + QT.

Will try it out

I have a PyQt5 + Autobahn/Twisted port of the Crossbar Gauges demo

ready. It just needs a little polishing. I’ll post to this list when

it’s up on GitHub.

It’s now up at https://github.com/estan/gauges

Elvis

Elvis

On Saturday, October 31, 2015 at 3:30:31 PM UTC+1, Elvis Stansvik wrote:

2015-10-31 15:26 GMT+01:00 Elvis Stansvik elv...@gmail.com:

Hi Gelonida,

2015-10-25 22:53 GMT+01:00 Gelonida Gel gel...@gmail.com:

Hi,

I have a small PyQt application and would like to combine it with Wamp

/

crossbar.io.

How would I do this?

Does anybody have a very simple example?

The 'simple example I imagine would be a QT widget with:

a) one button: if pressed sending a publish event

b) one button if pressed sending a call

c) one label being updated via i subscribed signal

d) one piece of code, that updates a label and returns a value to

crossbar

(registered RPC call)

My ideas so far:

Up to my understanding i MUST start the PyQT event loop in the main

thread,

so I had to start the twisted loop of a crossbar client in a secondary

thread.

a) not sure how to do this from a qt thread which is NOT the twisted

thread.

in the worst case I could add a web service publish url to the crossbar

and

use crossbarconnect

b) same as a)?

c) subscribe from the twisted thread and send a signal to the QT thread

*or

would there be better)

d) not sure how to do this

Can this cause any problems?

Any ideas suggestions?

Any pitfalls / special considerations?

Did anybody combine already PYQt and a crossbar client (or even the

crossbar

server?)

We have several PyQt + Autobahn/Twisted clients at work. Threading is

not necessary. What we do is make use of qt4reactor [1], a bridge that

makes it possible to run the event loops of Qt and Twisted in tandem.

I don’t have minimal example like you describe ready, and I can’t

really share the code of the clients we have at work. But if I find

time I’ll try to make such an example.

In the meantime, this is a very rough recipe:

  1. Create your QApplication object.
  1. Create your Autobahn Application object.
  1. Install the Qt Twisted reactor with qt4reactor.install().
  1. Run your application with app.run(url=“your router URL”, realm=u"your

realm")

You should not call QApplication.exec(…), it will be done for you by

when the reactor starts.

It should be possible to use with the ApplicationSession API as well,

but the simplified Application API is what we’re using at the moment.

Here’s an example snippet of how we make an async RPC call inside a

slot connected to a Qt button click:

@pyqtSlot()
@inlineCallbacks
def on_startButton_clicked(self):
    self.statusBar().showMessage('Preparing for acquisition')
    yield

self.wapp.session.call(u’com.example.x1.prepare_for_acquisition’,

num_frames=500, frame_rate=5, binning=1)

    self.statusBar().showMessage('Acquiring...')
    yield self.wapp.session.call(
        u'com.orexplore.x1.start_acquisition',
        options=CallOptions(on_progress=self.onFrame))
    self.statusBar().showMessage('Acquisition done')

I forgot to say: The above method is taken from our QMainWindow

subclass, and self.wapp is a reference to the Autobahn Application

object which was passed in and saved as a member when the window was

constructed.

Elvis

Hope you have enough info to get going. But I’ll see if I can make a

minimal working example when I have time.

Cheers,

Elvis

[1] https://pypi.python.org/pypi/qt4reactor/1.6

thanks in advance for your comments.

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 cros...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/crossbario/77abbe47-2c32-4ffc-9015-2621e675cf1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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+unsubscribe@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/1e2ac060-e19d-4fa0-96b7-37d6d2440046%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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+unsubscribe@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/402020cf-4874-4ecf-8a66-98fe07fd2a88%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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+unsubscribe@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/af8cbd86-a283-4d7c-b1b6-0fe471dfda84%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes