I want to make an app that “listens” for information from another application as well as gui events. I am thinking a web service, JSON or something. Is this easy with wxpython. Any good threads examples for this sort of thing? I guess it is a bit like a instant messenger client in that the app is a gui that needs to stay responsive to the user but always listens for info from another source.
On Thursday, August 9, 2012 6:53:30 AM UTC-5, Kim wrote:
Hi,
I want to make an app that “listens” for information from another application as well as gui events. I am thinking a web service, JSON or something. Is this easy with wxpython. Any good threads examples for this sort of thing? I guess it is a bit like a instant messenger client in that the app is a gui that needs to stay responsive to the user but always listens for info from another source.
Thoughts?
My first thought is pubsub. You can read about it here or on the wiki. I wrote up an example of threads and pubsub on my blog or you can read several good examples on threading on the wiki. I’ve also heard you can use Python’s SocketServer for this sort of thing, but I’ve never really looked into it.
I want to make an app that "listens" for information from another
application as well as gui events. I am thinking a web service, JSON or
something. Is this easy with wxpython. Any good threads examples for this
sort of thing? I guess it is a bit like a instant messenger client in that
the app is a gui that needs to stay responsive to the user but always
listens for info from another source.
Thoughts?
My first thought is pubsub. You can read about it here or on the wiki. I
wrote up an example of threads and pubsub on my blog or you can read several
good examples on threading on the wiki.
That's only half the solution -- but it is the wx half ---..
i.e. pubsub (or simple wx.CallAfter() ) will let you pass a message
from an external thread to your main wx GUI thread.
So: you'll want to create a secondary thread to handle your
communication with external apps. When it gets an message, it can send
ti to your gUI with pubsub, etc.
In the external thread, what you want depends on what you need to do,
and what protocol you want to use, but:
- you can use raw sockets -- see the socket module
- Otherwise, I'd probably use an existing protocol, http, for
instance. Dependingon how complex your messages with be, the stdlib
SimpleHTTPServer could work fine, and be easy to set up and run.
-Chris
I've also heard you can use Python's
···
On Thu, Aug 9, 2012 at 7:14 AM, Mike Driscoll <kyosohma@gmail.com> wrote:
On Thursday, August 9, 2012 6:53:30 AM UTC-5, Kim wrote:
SocketServer for this sort of thing, but I've never really looked into it.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Is pubsub an additional package to download or should it be distributed with wxpython?
···
On Friday, 10 August 2012 00:14:41 UTC+10, Mike Driscoll wrote:
Hi Kim,
On Thursday, August 9, 2012 6:53:30 AM UTC-5, Kim wrote:
Hi,
I want to make an app that “listens” for information from another application as well as gui events. I am thinking a web service, JSON or something. Is this easy with wxpython. Any good threads examples for this sort of thing? I guess it is a bit like a instant messenger client in that the app is a gui that needs to stay responsive to the user but always listens for info from another source.
Thoughts?
My first thought is pubsub. You can read about it here or on the wiki. I wrote up an example of threads and pubsub on my blog or you can read several good examples on threading on the wiki. I’ve also heard you can use Python’s SocketServer for this sort of thing, but I’ve never really looked into it.
On Friday, 10 August 2012 00:14:41 UTC+10, Mike Driscoll wrote:
Hi Kim,
On Thursday, August 9, 2012 6:53:30 AM UTC-5, Kim wrote:
Hi,
I want to make an app that “listens” for information from another application as well as gui events. I am thinking a web service, JSON or something. Is this easy with wxpython. Any good threads examples for this sort of thing? I guess it is a bit like a instant messenger client in that the app is a gui that needs to stay responsive to the user but always listens for info from another source.
Thoughts?
My first thought is pubsub. You can read about it here or on the wiki. I wrote up an example of threads and pubsub on my blog or you can read several good examples on threading on the wiki. I’ve also heard you can use Python’s SocketServer for this sort of thing, but I’ve never really looked into it.
Is pubsub an additional package to download or should it be distributed with wxpython?
A version is distributed with Python and there is also the standalone version available from pubsub.sf.net. Use “from wx.lib.pubsub import pub”.
On Friday, 10 August 2012 00:14:41 UTC+10, Mike Driscoll wrote:
Hi Kim,
On Thursday, August 9, 2012 6:53:30 AM UTC-5, Kim wrote:
Hi,
I want to make an app that “listens” for information from another application as well as gui events. I am thinking a web service, JSON or something. Is this easy with wxpython. Any good threads examples for this sort of thing? I guess it is a bit like a instant messenger client in that the app is a gui that needs to stay responsive to the user but always listens for info from another source.
Thoughts?
My first thought is pubsub. You can read about it here or on the wiki. I wrote up an example of threads and pubsub on my blog or you can read several good examples on threading on the wiki. I’ve also heard you can use Python’s SocketServer for this sort of thing, but I’ve never really looked into it.
Regardless of that I wonder how pubsub is to enable a
wxPython app to take input from an EXTERNAL application ?
Better think about something like:
A listener thread within the app
- constantly reading a file/pipe/socket
- or listening on a port (HTTP/XML-RPC/...)
- or ...
- and injecting calls into the app (wx.CallAfter !)
Karsten
···
On Thu, Aug 09, 2012 at 08:17:14PM -0700, Kim wrote:
hmm
This is what I get:
Traceback (most recent call last):
File "wxthread.py", line 5, in <module>
from wx.lib.pubsub import Publisher
ImportError: cannot import name Publisher
Is pubsub an additional package to download or should it be distributed with wxpython?
A version is distributed with Python and there is also the standalone version available from pubsub.sf.net. Use “from wx.lib.pubsub import pub”.
On Friday, 10 August 2012 00:14:41 UTC+10, Mike Driscoll wrote:
Hi Kim,
On Thursday, August 9, 2012 6:53:30 AM UTC-5, Kim wrote:
Hi,
I want to make an app that “listens” for information from another application as well as gui events. I am thinking a web service, JSON or something. Is this easy with wxpython. Any good threads examples for this sort of thing? I guess it is a bit like a instant messenger client in that the app is a gui that needs to stay responsive to the user but always listens for info from another source.
Thoughts?
My first thought is pubsub. You can read about it here or on the wiki. I wrote up an example of threads and pubsub on my blog or you can read several good examples on threading on the wiki. I’ve also heard you can use Python’s SocketServer for this sort of thing, but I’ve never really looked into it.
There’s always RabbitMQ, but I think that’s too big of a hammer for something like this. I still think you could use a subprocess or a little Python server.
Mike
···
On Friday, August 10, 2012 2:51:15 AM UTC-5, Karsten Hilbert wrote:
On Thu, Aug 09, 2012 at 08:17:14PM -0700, Kim wrote:
hmm
This is what I get:
Traceback (most recent call last):
File “wxthread.py”, line 5, in
from wx.lib.pubsub import Publisher
ImportError: cannot import name Publisher
Regardless of that I wonder how pubsub is to enable a
wxPython app to take input from an EXTERNAL application ?
Better think about something like:
A listener thread within the app
- constantly reading a file/pipe/socket
- or listening on a port (HTTP/XML-RPC/...)
- or ...
- and injecting calls into the app (wx.CallAfter !)
In GNUmed we use a subprocess running an XMLRPCServer. Works
just fine.
Karsten
···
On Fri, Aug 10, 2012 at 06:41:15AM -0700, Mike Driscoll wrote:
> Regardless of that I wonder how pubsub is to enable a
> wxPython app to take input from an EXTERNAL application ?
>
> Better think about something like:
>
> A listener thread within the app
>
> - constantly reading a file/pipe/socket
> - or listening on a port (HTTP/XML-RPC/...)
> - or ...
> - and injecting calls into the app (wx.CallAfter !)
>
> Karsten
>
There's always RabbitMQ, but I think that's too big of a hammer for
something like this. I still think you could use a subprocess or a little
Python server.
Friendly note: Please avoid top-posting, it makes the thread difficult to following in the email.
scholli wrote:
scholli wrote:
hmm
This is what I get:
Traceback (most recent call last):
File “wxthread.py”, line 5, in
from wx.lib.pubsub import Publisher
ImportError: cannot import name Publisher
What version of wxPython are you using?
print sys.version
2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
ok, and what version of wxPython are you using?
wx.VERSION
(2, 9, 4, 0, ‘’)
So if you open a console (shell) window on your Mac and try to import pub from wx.lib.pubsub, you get the traceback you showed?
python -i
…
from wx.lib.pubsub import pub
help(pub)
Has anyone else tried wx 2.9.4.x on Mac and been unable to import pub from pubsub? I don’t have access to a Mac, unfortunately. Does anyone know of a Mac VM image or other way of testing software on Mac OS without having a Mac machine?
On Sunday, 12 August 2012 20:45:53 UTC+10, Karsten Hilbert wrote:
On Fri, Aug 10, 2012 at 06:41:15AM -0700, Mike Driscoll wrote:
Regardless of that I wonder how pubsub is to enable a
wxPython app to take input from an EXTERNAL application ?
Better think about something like:
A listener thread within the app
- constantly reading a file/pipe/socket
- or listening on a port (HTTP/XML-RPC/...)
- or ...
- and injecting calls into the app (wx.CallAfter !)
Karsten
There’s always RabbitMQ, but I think that’s too big of a hammer for
something like this. I still think you could use a subprocess or a little
Python server.
In GNUmed we use a subprocess running an XMLRPCServer. Works
So if you open a console (shell) window on your Mac and try to import pub from wx.lib.pubsub, you get the traceback you showed?
python -i
…
from wx.lib.pubsub import pub
help(pub)
Has anyone else tried wx 2.9.4.x on Mac and been unable to import pub from pubsub? I don’t have access to a Mac, unfortunately. Does anyone know of a Mac VM image or other way of testing software on Mac OS without having a Mac machine?