wxpython app that can take input from an external application

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?

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.

  • Mike

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.

- Mike

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--

Christopher Barker, Ph.D.
Oceanographer

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

Chris.Barker@noaa.gov

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.

  • Mike

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 Thu, Aug 9, 2012 at 6:50 PM, Kim ksadil@gmail.com wrote:

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.

  • Mike

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

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

···

On Friday, 10 August 2012 08:55:48 UTC+10, scholli wrote:

On Thu, Aug 9, 2012 at 6:50 PM, Kim ksa...@gmail.com wrote:

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.

  • Mike

To unsubscribe, send email to wxPython-user...@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

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

--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

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?

···

On Thu, Aug 9, 2012 at 11:17 PM, Kim ksadil@gmail.com wrote:

On Friday, 10 August 2012 08:55:48 UTC+10, scholli wrote:

On Thu, Aug 9, 2012 at 6:50 PM, Kim ksa...@gmail.com wrote:

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.

  • Mike

To unsubscribe, send email to wxPython-user...@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

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 !)

Karsten

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)]

···

On Friday, 10 August 2012 21:46:45 UTC+10, scholli wrote:

On Thu, Aug 9, 2012 at 11:17 PM, Kim ksa...@gmail.com wrote:

ok, and what version of wxPython are you using?

···

On Sat, Aug 11, 2012 at 8:00 AM, Kim ksadil@gmail.com wrote:

On Friday, 10 August 2012 21:46:45 UTC+10, scholli wrote:

On Thu, Aug 9, 2012 at 11:17 PM, Kim ksa...@gmail.com 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)]

wx.VERSION

(2, 9, 4, 0, ‘’)

···

On Saturday, 11 August 2012 22:41:17 UTC+10, scholli wrote:

On Sat, Aug 11, 2012 at 8:00 AM, Kim ksa...@gmail.com wrote:

On Friday, 10 August 2012 21:46:45 UTC+10, scholli wrote:

On Thu, Aug 9, 2012 at 11:17 PM, Kim ksa...@gmail.com 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?

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.

--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

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?

Oliver

···

On Sat, Aug 11, 2012 at 10:49 PM, Kim ksadil@gmail.com wrote:

Kim ksa...@gmail.com wrote:

Kim ksa...@gmail.com wrote:

Thanks, I will look into that.

Cheers,

Kim

···

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

just fine.

Karsten


GPG key ID E4071346 @ gpg-keyserver.de

E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Actually your commands shown above work just fine.

So pubsub is included. I think I will just stick to Linux while my mac skills improve.

···

On Monday, 13 August 2012 00:08:33 UTC+10, scholli wrote:

Friendly note: Please avoid top-posting, it makes the thread difficult to following in the email.

On Sat, Aug 11, 2012 at 10:49 PM, Kim ksa...@gmail.com wrote:

scholli wrote:

Kim ksa...@gmail.com wrote:

scholli wrote:

Kim ksa...@gmail.com 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?

Oliver