import org.python.util.PythonInterpreter; import org.python.core.*; String string = "Type \"app.radius(int)\" or \"app.colour(int,int,int)\" here"; // setup a global interpreter PythonInterpreter interp = new PythonInterpreter(); TextField commandLine = new TextField( string ); void initCommandLine() { // set up our command line Panel inputPanel = new Panel(); inputPanel.setLayout( new BorderLayout() ); add( inputPanel ); inputPanel.setBounds( 4, height-24, width-8, 20 ); commandLine = new TextField( string ); inputPanel.add( commandLine ); setLayout( new BorderLayout() ); commandLine.addActionListener( new MyActionListener() ); interp.set( "app", this ); } // issue a command void interact( String command) { interp.exec( command ); } // listen for carriage return on our rudimentary command line public class MyActionListener implements ActionListener { public void actionPerformed( ActionEvent e ) { interp.exec( commandLine.getText() ); commandLine.setText( "" ); } }