← Back to team overview

kicad-developers team mailing list archive

Re: Python Scripting Window event handling

 

Le 13/06/2014 15:39, Dick Hollenbeck a écrit :
> The problem is made more difficult by the wxWindow hierarchy chosen.  I don't know if it
> would be possible and easier if everything except the console wxWindow had a common
> wxPanel parent.  That wxPanel injection might make the problem easier to solve, but it
> might not be possible with some children insisting on a wxFrame parent.
> 

For your proposal (everything on a common wxPanel) I am thinking this is
possible: I have a branch where I put all widgets (draw  panel, msg
panel, toolbar ... ) on a wxPanel to build a clone of ViewLib.
This clone can be shown in a Dialog or a Frame with very few specific
code (no more than 20 lines).


However I attached a patch which seems (for me) fix the keys issue.

The change is only using a wxPanel instead of a too generic wxWindow to
manage the PyConsole.

Note, the PyConsole is actually a wxPanel, so I am thinking using a
wxWindow as base type was a bug, or, at least, a bad idea.

I tested the patch on Linux Ubuntu 10, but not on Windows.
(Due to my working environment, It is more difficult for me to test
Kicad on Windows, when it is built with option KICAD_SCRIPTING_WXPYTHON=ON).

Can someone test this patch (On Windows and on Linux) ?
(I did not made a lot of tests)

-- 
Jean-Pierre CHARRAS
=== modified file 'include/wxPcbStruct.h'
--- include/wxPcbStruct.h	2014-05-18 15:16:59 +0000
+++ include/wxPcbStruct.h	2014-06-13 16:32:15 +0000
@@ -106,7 +106,7 @@

 #ifdef KICAD_SCRIPTING_WXPYTHON
     // Panel used to let user talk with internal scripting
-    wxWindow* m_pythonPanel;
+    wxPanel* m_pythonPanel;
     bool m_pythonPanelHidden;
 #endif


=== modified file 'pcbnew/pcbframe.cpp'
--- pcbnew/pcbframe.cpp	2014-06-02 16:16:06 +0000
+++ pcbnew/pcbframe.cpp	2014-06-02 16:28:11 +0000
@@ -454,7 +454,6 @@
     pythonAuiInfo.MinSize( wxSize( 200, 100 ) );
     pythonAuiInfo.BestSize( wxSize( GetClientSize().x/2, 200 ) );
     pythonAuiInfo.Hide();
-
     m_pythonPanel = CreatePythonShellWindow( this );
     m_auimgr.AddPane( m_pythonPanel,
                       pythonAuiInfo.Name( wxT( "PythonPanel" ) ).Bottom().Layer(9) );

=== modified file 'scripting/python_scripting.cpp'
--- scripting/python_scripting.cpp	2014-04-02 13:38:59 +0000
+++ scripting/python_scripting.cpp	2014-06-13 16:33:29 +0000
@@ -200,7 +200,7 @@
 }


-wxWindow* CreatePythonShellWindow( wxWindow* parent )
+wxPanel* CreatePythonShellWindow( wxWindow* parent )
 {
     const char* pycrust_panel =
         "import wx\n"
@@ -224,7 +224,7 @@
         "\n";


-    wxWindow*   window = NULL;
+    wxPanel*   window = NULL;
     PyObject*   result;

     // As always, first grab the GIL

=== modified file 'scripting/python_scripting.h'
--- scripting/python_scripting.h	2013-07-19 18:27:22 +0000
+++ scripting/python_scripting.h	2014-06-13 16:33:27 +0000
@@ -31,7 +31,7 @@
 #ifdef KICAD_SCRIPTING_WXPYTHON

 void        RedirectStdio();
-wxWindow*   CreatePythonShellWindow( wxWindow* parent );
+wxPanel*   CreatePythonShellWindow( wxWindow* parent );

 class PyLOCK
 {


Follow ups

References