Java Swing to wxPython

Purely for fun I'm converting a Java application into Python. I've had no problem with the "plain" Java to Python part, but I've no idea about how to convert the GUI elements. My searching hasn't turned up anything obvious. Has anybody got any experience of such work, if so I'd be delighted to hear about it. If not can I safely assume that the alternative is to obtain copious supplies of coffee and sandwiches, wear sweatbands, roll up sleeves and just get on with it?

···

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

Hi, Mark,

Purely for fun I'm converting a Java application into Python. I've had no
problem with the "plain" Java to Python part, but I've no idea about how to
convert the GUI elements. My searching hasn't turned up anything obvious.
Has anybody got any experience of such work, if so I'd be delighted to hear
about it. If not can I safely assume that the alternative is to obtain
copious supplies of coffee and sandwiches, wear sweatbands, roll up sleeves
and just get on with it?

Which part you are struggling with?
Controls? Positioning? Something else?

Thank you.

···

On Fri, Dec 20, 2013 at 9:27 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:

--
My fellow Pythonistas, ask not what our language can do for you, ask what
you can do for our language.

Mark Lawrence

--
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/groups/opt_out.

Getting going :frowning: Consider the following imports from the first part of the original GUI.

import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

I can hazard a reasonable guess as to what they represent or even spend time looking them up online, but I've obviously got to translate these into their wxPython equivalents at some point. I was hoping that someone here may have already done work along these lines, something that I could build on, which would be terrific. If not, I'm left with a lot of graft as I suggested in my final sentence above.

···

On 21/12/2013 06:01, Igor Korot wrote:

Hi, Mark,

On Fri, Dec 20, 2013 at 9:27 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:

Purely for fun I'm converting a Java application into Python. I've had no
problem with the "plain" Java to Python part, but I've no idea about how to
convert the GUI elements. My searching hasn't turned up anything obvious.
Has anybody got any experience of such work, if so I'd be delighted to hear
about it. If not can I safely assume that the alternative is to obtain
copious supplies of coffee and sandwiches, wear sweatbands, roll up sleeves
and just get on with it?

Which part you are struggling with?
Controls? Positioning? Something else?

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

Hi Mark,

It sounds like a big project. Maybe looking at similar projects in other languages will help.

This page compares Java Swing to C++ Qt - http://www.cis.gvsu.edu/~dulimarh/CS367/Notes/Qt-vs-Swing.html

wxPython is built from the C++ wxWidgets toolkit by Robin using a SWIG wrapper - http://www.swig.org/ http://www.wxpython.org/builddoc.php

Maybe you could do something similar? How? Dunno. That’s way above my pay grade. :wink:

HTH a little. Good luck.

Cheers,

Scott.

···

On Sun, Dec 22, 2013 at 12:08 PM, Mark Lawrence breamoreboy@yahoo.co.uk wrote:

On 21/12/2013 06:01, Igor Korot wrote:

Hi, Mark,

On Fri, Dec 20, 2013 at 9:27 PM, Mark Lawrence breamoreboy@yahoo.co.uk wrote:

Purely for fun I’m converting a Java application into Python. I’ve had no

problem with the “plain” Java to Python part, but I’ve no idea about how to

convert the GUI elements. My searching hasn’t turned up anything obvious.

Has anybody got any experience of such work, if so I’d be delighted to hear

about it. If not can I safely assume that the alternative is to obtain

copious supplies of coffee and sandwiches, wear sweatbands, roll up sleeves

and just get on with it?

Which part you are struggling with?

Controls? Positioning? Something else?

Getting going :frowning: Consider the following imports from the first part of the original GUI.

import javax.swing.JLabel;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import java.awt.FlowLayout;

import java.awt.GridBagLayout;

import java.awt.GridBagConstraints;

I can hazard a reasonable guess as to what they represent or even spend time looking them up online, but I’ve obviously got to translate these into their wxPython equivalents at some point. I was hoping that someone here may have already done work along these lines, something that I could build on, which would be terrific. If not, I’m left with a lot of graft as I suggested in my final sentence above.

My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

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/groups/opt_out.

Thanks, I'll take a look, certainly better than a kick in the head or other more tender parts of the anatomy :slight_smile:

···

On 22/12/2013 17:29, grunculus wrote:

Hi Mark,

It sounds like a big project. Maybe looking at similar projects in
other languages will help.

This page compares Java Swing to C++ Qt -
http://www.cis.gvsu.edu/~dulimarh/CS367/Notes/Qt-vs-Swing.html

wxPython is built from the C++ wxWidgets toolkit by Robin using a SWIG
wrapper - http://www.swig.org/ http://www.wxpython.org/builddoc.php

Maybe you could do something similar? How? Dunno. That's way above my
pay grade. :wink:

HTH a little. Good luck.

Cheers,
Scott.

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

Dead link at URL: http://www.wxpython.org/builddoc.php
There is listed for “wxPython: Building wxPython 3” a URL that gives a 404 not found at: http://wxpython.wxcommunity.com/tools/

···

On Sunday, December 22, 2013 12:29:16 PM UTC-5, grun...@gmail.com wrote:

… wxPython is built from the C++ wxWidgets toolkit by Robin using a SWIG wrapper - http://www.swig.org/ http://www.wxpython.org/builddoc.php

Scott.

Hi Mark,

Getting going :frowning: Consider the following imports from the first part of
the original GUI.

import javax.swing.JLabel;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import java.awt.FlowLayout;

import java.awt.GridBagLayout;

import java.awt.GridBagConstraints;

Actually a lot of these have almost direct ports. In wxPython land, you would probably want the following:

import wx

wx.StaticText
wx.Button
wx.BoxSizer
wx.GridBagSizer

I’m not sure what ImageIcon is. If it’s just for setting an icon in the toolbar, then you might find the following useful:

If that is some kind of oddly named image display widget, then you’ll probably want wx.StaticBitmap. I wrote a tutorial on how to create an image viewer that might help you:

I would also recommend downloading the wxPython demo package. It shows you what almost all of the widgets look like and how to use them.

  • Mike

Thanks for this, everything helps.

FTR I'll say that I've decided to learn to crawl prior to running a marathon. I've already grabbed several different packages from the wxPython wiki, I'll also get the demo. As I want to go direct to Phoenix I expected a right battle. Instead I've been very pleasantly surprised by just how easy it is. This suggests a great job by Robin Dunn, well done and giga thanks :slight_smile:

···

On 02/01/2014 21:58, Mike Driscoll wrote:

Hi Mark,

    Getting going :frowning: Consider the following imports from the first part of
    the original GUI.

    import javax.swing.JLabel;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import java.awt.FlowLayout;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;

Actually a lot of these have almost direct ports. In wxPython land, you
would probably want the following:

import wx

wx.StaticText
wx.Button
wx.BoxSizer
wx.GridBagSizer

I'm not sure what ImageIcon is. If it's just for setting an icon in the
toolbar, then you might find the following useful:

  -
http://nedbatchelder.com/blog/200501/nice_windows_icons_with_wxpython.html
  -
http://www.blog.pythonlibrary.org/2008/07/02/wxpython-working-with-menus-toolbars-and-accelerators/

If that is some kind of oddly named image display widget, then you'll
probably want wx.StaticBitmap. I wrote a tutorial on how to create an
image viewer that might help you:

  -
http://www.blog.pythonlibrary.org/2010/03/26/creating-a-simple-photo-viewer-with-wxpython/

I would also recommend downloading the wxPython demo package. It shows
you what almost all of the widgets look like and how to use them.

- Mike

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

DevPlayer wrote:

Dead link at URL: http://www.wxpython.org/builddoc.php
There is listed for "wxPython: Building wxPython 3" a URL that gives a
404 not found at: http://wxpython.wxcommunity.com/tools/

Sorry, that's at http://wxpython.kosoftworks.com/tools/ now. I'll update the doc.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org