Interactive Use of wxPython

I am having difficulties trying to get an interactive program working with wxPython. Previously, I was successful with a Tcl/Tk interface, but I thought it would be good to 'modernize' with wxPython.

1) Using google I found out the preferred method for connecting an interactive program to a wxPython GUI is to use wx.GUIEventLoop
but after some time I found this is not available in wxPython 2.8

2) next, I download from github and tried building with the results:
sudo python2.7 build-wxpython.py --build_dir=../bld --install

with the error message

Can't find or import /home/martin/programming/build/tools/build-wxwidgets.py, exiting.

I don't have any ideas how to resolve this error

3) next, I download the source ball wxPython-src-3.0.0.0.tar.bz2 uncompressed it
and tried to compile:

python2.7 build-wxpython.py --build_dir=../bld

It ran for awhlle but failed with:

checking for GTK+ version…

checking for pkg-config… /usr/bin/pkg-config

checking for GTK+ - version >= 2.6.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occurred. This usually means GTK+ is incorrectly installed.

checking for pkg-config… (cached) /usr/bin/pkg-config

checking for GTK+ - version >= 3.0.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occured. This usually means GTK+ is incorrectly installed.

checking for gtk-config… no

checking for GTK - version >= 1.2.7… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

checking for gtk-config… (cached) no

checking for GTK - version >= 1.2.3… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

configure: error:

The development files for GTK+ were not found. For GTK+ 2, please

ensure that pkg-config is in the path and that gtk±2.0.pc is

installed. For GTK+ 1.2 please check that gtk-config is in the path,

and that the version is 1.2.3 or above. Also check that the

libraries returned by ‘pkg-config gtk±2.0 --libs’ or 'gtk-config

–libs’ are in the LD_LIBRARY_PATH or equivalent.

Error running configure

ERROR: failed building wxWidgets

Traceback (most recent call last):

File “build-wxpython.py”, line 378, in

wxbuild.main(wxscript, build_options)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 364, in main

“Error running configure”)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 80, in exitIfError

raise builder.BuildError(msg)

BuildError


but I have gtk installed:

  > ai libgtk-3-bin
Reading package lists... Done
Building dependency tree Reading state information... Done
libgtk-3-bin is already the newest version.
The following package was automatically installed and is no longer required:
openjdk-7-jre-lib
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 43 not upgraded.
>


In addition, I can not find any repositories for aclocal which is not
included in Ubuntu.
Summary: upgrading to a version that can use wx.GUIEventLoop() in Ubuntu 13.10 is
difficult; I am worried that even if I am eventually successful, it will
still be difficult for others to use the program as they will also need to upgrade; any suggestions? Would it be better if I gave up on wxPython and started over with PyQt? Any suggestions are appreciated. Thanks.
Bit_Pusher

You will need the -dev packages in order to compile wxPython from source. I ran into this same issue when building wxPython. For example, I had to install libgtk-2.0-dev, along with the dev packages for all other wxPython dependencies.

···

On Sunday, March 9, 2014 7:01:48 PM UTC-4, Bit_Pusher wrote:

I am having difficulties trying to get an interactive program working with wxPython. Previously, I was successful with a Tcl/Tk interface, but I thought it would be good to 'modernize' with wxPython.


1) Using google I found out the preferred method for connecting an interactive program to a wxPython GUI is to use wx.GUIEventLoop
but after some time I found this is not available in wxPython 2.8


2) next, I download from github and tried building with the results:
sudo python2.7 build-wxpython.py --build_dir=../bld --install

with the error message

Can't find or import /home/martin/programming/build/tools/build-wxwidgets.py, exiting.

I don't have any ideas how to resolve this error


3) next, I download the source ball wxPython-src-3.0.0.0.tar.bz2 uncompressed it
and tried to compile:


python2.7 build-wxpython.py --build_dir=../bld

It ran for awhlle but failed with:

checking for GTK+ version…

checking for pkg-config… /usr/bin/pkg-config

checking for GTK+ - version >= 2.6.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occurred. This usually means GTK+ is incorrectly installed.

checking for pkg-config… (cached) /usr/bin/pkg-config

checking for GTK+ - version >= 3.0.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occured. This usually means GTK+ is incorrectly installed.

checking for gtk-config… no

checking for GTK - version >= 1.2.7… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

checking for gtk-config… (cached) no

checking for GTK - version >= 1.2.3… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

configure: error:

The development files for GTK+ were not found. For GTK+ 2, please

ensure that pkg-config is in the path and that gtk±2.0.pc is

installed. For GTK+ 1.2 please check that gtk-config is in the path,

and that the version is 1.2.3 or above. Also check that the

libraries returned by ‘pkg-config gtk±2.0 --libs’ or 'gtk-config

–libs’ are in the LD_LIBRARY_PATH or equivalent.

Error running configure

ERROR: failed building wxWidgets

Traceback (most recent call last):

File “build-wxpython.py”, line 378, in

wxbuild.main(wxscript, build_options)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 364, in main

“Error running configure”)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 80, in exitIfError

raise builder.BuildError(msg)

BuildError



but I have gtk installed:


  > ai libgtk-3-bin
Reading package lists... Done
Building dependency tree Reading state information... Done
libgtk-3-bin is already the newest version.
The following package was automatically installed and is no longer required:
openjdk-7-jre-lib
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 43 not upgraded.
>



In addition, I can not find any repositories for aclocal which is not
included in Ubuntu.
Summary: upgrading to a version that can use wx.GUIEventLoop() in Ubuntu 13.10 is
difficult; I am worried that even if I am eventually successful, it will
still be difficult for others to use the program as they will also need to upgrade; any suggestions? Would it be better if I gave up on wxPython and started over with PyQt? Any suggestions are appreciated. Thanks.
Bit_Pusher

I’m a litlle confused about your question. The title is “Interactive Use of wxPython”, but it seems you’re really looking of help in building wxPython.

Nevertheless, I"ll chime in with a bit about interactive use with wxPython:

What do you want to do? For teh most part, if you have a primarily command-line program, but want to be able to op up some dialog boxes to gather data from the user, you don’t need to override the event loop.

Here’s an example:

https://github.com/PythonCHB/wxPythonDemos/blob/master/ProceduralTest.py

Also – if you want an interactive prompt in a GUI program, you may want to use pyCrust/ pyShell:

http://www.wxpython.org/py.php

rather than trying to use the terminal and having to mess about with the event loop.

And then youi can use 2.8, and not have to deal with building…

HTH,

-Chris

···

On Sun, Mar 9, 2014 at 4:01 PM, Bit_Pusher ken.w.martin@gmail.com wrote:

I am having difficulties trying to get an interactive program working with wxPython. Previously, I was successful with a Tcl/Tk interface, but I thought it would be good to 'modernize' with wxPython.


1) Using google I found out the preferred method for connecting an interactive program to a wxPython GUI is to use wx.GUIEventLoop
but after some time I found this is not available in wxPython 2.8


2) next, I download from github and tried building with the results:
sudo python2.7 build-wxpython.py --build_dir=../bld --install

with the error message

Can't find or import /home/martin/programming/build/tools/build-wxwidgets.py, exiting.

I don't have any ideas how to resolve this error


3) next, I download the source ball wxPython-src-3.0.0.0.tar.bz2 uncompressed it
and tried to compile:


python2.7 build-wxpython.py --build_dir=../bld

It ran for awhlle but failed with:

checking for GTK+ version…

checking for pkg-config… /usr/bin/pkg-config

checking for GTK+ - version >= 2.6.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occurred. This usually means GTK+ is incorrectly installed.

checking for pkg-config… (cached) /usr/bin/pkg-config

checking for GTK+ - version >= 3.0.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occured. This usually means GTK+ is incorrectly installed.

checking for gtk-config… no

checking for GTK - version >= 1.2.7… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

checking for gtk-config… (cached) no

checking for GTK - version >= 1.2.3… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

configure: error:

The development files for GTK+ were not found. For GTK+ 2, please

ensure that pkg-config is in the path and that gtk±2.0.pc is

installed. For GTK+ 1.2 please check that gtk-config is in the path,

and that the version is 1.2.3 or above. Also check that the

libraries returned by ‘pkg-config gtk±2.0 --libs’ or 'gtk-config

–libs’ are in the LD_LIBRARY_PATH or equivalent.

Error running configure

ERROR: failed building wxWidgets

Traceback (most recent call last):

File “build-wxpython.py”, line 378, in

wxbuild.main(wxscript, build_options)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 364, in main

“Error running configure”)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 80, in exitIfError

raise builder.BuildError(msg)

BuildError



but I have gtk installed:


  > ai libgtk-3-bin
Reading package lists... Done
Building dependency tree Reading state information... Done
libgtk-3-bin is already the newest version.
The following package was automatically installed and is no longer required:
openjdk-7-jre-lib
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 43 not upgraded.
>



In addition, I can not find any repositories for aclocal which is not
included in Ubuntu.
Summary: upgrading to a version that can use wx.GUIEventLoop() in Ubuntu 13.10 is
difficult; I am worried that even if I am eventually successful, it will
still be difficult for others to use the program as they will also need to upgrade; any suggestions? Would it be better if I gave up on wxPython and started over with PyQt? Any suggestions are appreciated. Thanks.
Bit_Pusher

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

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

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

Hi Chris, I’m running a logic simulator in a subprocess. Historically, I did this using expect in the tcl/tk environment. In the python/wxpython envirinment, I originally used pexpect, but couldn’t solve problems with the stdio not sending everything even though I was flushing the buffers. I am now trying to get things working by running the simulator in a subprocess object started in a separate thread. The communication between the simulator and the GUI is via stdin and stdout. I copy what is typed in a textcntl window, send it to the simulator, and it then sends commands back to the GUI which I first capture using regular expression matching and then dependent on what they are, update my various windows. The commands start with special codes like “_01 …” and “_02 …” etc. After the special codes (which indicate which window to write into for example) I delete the special codes and then send the rest of the line to the appropriate window. Summary, two separate processes running concurrently that I can’t have lock up. Again, this wasn’t too difficult to get working previously using tcl/tk, but is proving to be a challenge with wxpython. I’m probably going to stay with 2.8 as I don’t think many potential users will be able to get 3.0 working in Ubuntu, and wouldn’t be able to use the simulator if it requires 3.0; I currently looking as using the timer event to ensure the GUI windows get updated without locking.

···

On Monday, March 10, 2014 12:21:33 PM UTC-4, Chris Barker wrote:

I’m a litlle confused about your question. The title is “Interactive Use of wxPython”, but it seems you’re really looking of help in building wxPython.

Nevertheless, I"ll chime in with a bit about interactive use with wxPython:

What do you want to do? For teh most part, if you have a primarily command-line program, but want to be able to op up some dialog boxes to gather data from the user, you don’t need to override the event loop.

Here’s an example:

https://github.com/PythonCHB/wxPythonDemos/blob/master/ProceduralTest.py

Also – if you want an interactive prompt in a GUI program, you may want to use pyCrust/ pyShell:

http://www.wxpython.org/py.php

rather than trying to use the terminal and having to mess about with the event loop.

And then youi can use 2.8, and not have to deal with building…

HTH,

-Chris

On Sun, Mar 9, 2014 at 4:01 PM, Bit_Pusher ken.w....@gmail.com wrote:

I am having difficulties trying to get an interactive program working with wxPython. Previously, I was successful with a Tcl/Tk interface, but I thought it would be good to 'modernize' with wxPython.


1) Using google I found out the preferred method for connecting an interactive program to a wxPython GUI is to use wx.GUIEventLoop
but after some time I found this is not available in wxPython 2.8


2) next, I download from github and tried building with the results:
sudo python2.7 build-wxpython.py --build_dir=../bld --install

with the error message

Can't find or import /home/martin/programming/build/tools/build-wxwidgets.py, exiting.

I don't have any ideas how to resolve this error


3) next, I download the source ball wxPython-src-3.0.0.0.tar.bz2 uncompressed it
and tried to compile:


python2.7 build-wxpython.py --build_dir=../bld

It ran for awhlle but failed with:

checking for GTK+ version…

checking for pkg-config… /usr/bin/pkg-config

checking for GTK+ - version >= 2.6.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occurred. This usually means GTK+ is incorrectly installed.

checking for pkg-config… (cached) /usr/bin/pkg-config

checking for GTK+ - version >= 3.0.0… no

*** Could not run GTK+ test program, checking why…

*** The test program failed to compile or link. See the file config.log for the

*** exact error that occured. This usually means GTK+ is incorrectly installed.

checking for gtk-config… no

checking for GTK - version >= 1.2.7… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

checking for gtk-config… (cached) no

checking for GTK - version >= 1.2.3… no

*** The gtk-config script installed by GTK could not be found

*** If GTK was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the GTK_CONFIG environment variable to the

*** full path to gtk-config.

configure: error:

The development files for GTK+ were not found. For GTK+ 2, please

ensure that pkg-config is in the path and that gtk±2.0.pc is

installed. For GTK+ 1.2 please check that gtk-config is in the path,

and that the version is 1.2.3 or above. Also check that the

libraries returned by ‘pkg-config gtk±2.0 --libs’ or 'gtk-config

–libs’ are in the LD_LIBRARY_PATH or equivalent.

Error running configure

ERROR: failed building wxWidgets

Traceback (most recent call last):

File “build-wxpython.py”, line 378, in

wxbuild.main(wxscript, build_options)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 364, in main

“Error running configure”)

File “/home/martin/Dropbox/Programming/Python/wxPython-src-3.0.0.0/build/tools/build-wxwidgets.py”, line 80, in exitIfError

raise builder.BuildError(msg)

BuildError



but I have gtk installed:


  > ai libgtk-3-bin
Reading package lists... Done
Building dependency tree Reading state information... Done
libgtk-3-bin is already the newest version.
The following package was automatically installed and is no longer required:
openjdk-7-jre-lib
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 43 not upgraded.
>



In addition, I can not find any repositories for aclocal which is not
included in Ubuntu.
Summary: upgrading to a version that can use wx.GUIEventLoop() in Ubuntu 13.10 is
difficult; I am worried that even if I am eventually successful, it will
still be difficult for others to use the program as they will also need to upgrade; any suggestions? Would it be better if I gave up on wxPython and started over with PyQt? Any suggestions are appreciated. Thanks.
Bit_Pusher

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.

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

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....@noaa.gov

Hi Chris, I'm running a logic simulator in a subprocess. Historically, I
did this using expect in the tcl/tk environment. In the python/wxpython
envirinment, I originally used pexpect, but couldn't solve problems with
the stdio not sending everything even though I was flushing the buffers.

Hmm -- odd -- though I've never used pexpect -- so not sure about the
tricks there.

I am now trying to get things working by running the simulator in a
subprocess object started in a separate thread.

both a separate thread and subprocess? Is that so the thread can sit around
waiting for the subprocess? That should work...

.....

Summary, two separate processes running concurrently that I can't have
lock up.

OK -- that shouldn't be problem with subprocess...

I currently looking as using the timer event to ensure the GUI windows
get updated without locking.

Where would the Timer be running?

Anyway, you should be abel to get this going by being very careful to:

ONLY call wx functions from the main thread -- except those known to be
thread-safe.

Never put anything that takes long to run in a callback in the main thread.

So you should be able to have your secondary thread monitoring the
subprocess doing all the work, and send a message to the GUI t update
when necessary: wx.CallAfter() is the easiest way to do that.

It should be OK to have the monitoring thread lock up while waiting for the
worker process, so no need for timer and polling.

But the devil is in the details with this stuff. You might try do do a
really simple example so you can post here for help....

-Chris

···

On Mon, Mar 17, 2014 at 11:39 AM, Bit_Pusher <ken.w.martin@gmail.com> wrote:

--

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