kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #21893
PATCH: Enhanced Python Shell - V1
Attached is a patch for the enhanced python shell.
This is what it looks like for me: http://i.imgur.com/je6yv8g.png
The assertions I was getting occur in a debug build and appear to be
normal behaviour of wxpython, and not actual errors.
See: http://wxpython.org/Phoenix/docs/html/Notebook.html
Specifically : "On platforms other than Windows, or if the application
is not using Windows themes, GetThemeBackgroundColour
<http://wxpython.org/Phoenix/docs/html/Notebook.html#Notebook.GetThemeBackgroundColour>
will return an uninitialised colour object"
That is the cause of the exceptions, and according to the docs its what
it should do. If someone knows more about this particular aspect of
wxpython/wxwidgets I would be happy to make them NOT happen in a debug
build.
I have only tested it on Linux, it needs testing on Windows and Mac,
although its all standard wxpython stuff, so I expect it should "just
work" if wxpython works. That's the hope anyway.
Its just the vanilla implementation of the PyAlacarte shell from
wxpython at the moment, there are a few enhancements/changes that can be
made to make it nicer. I am looking at those now, including the error
you can see on the screenshot, which appears to not cause any issues,
but I would like to fix in any event.
Steven
=== modified file 'pcbnew/pcbframe.cpp'
--- pcbnew/pcbframe.cpp 2015-11-29 06:56:27 +0000
+++ pcbnew/pcbframe.cpp 2015-12-13 14:46:14 +0000
@@ -70,8 +70,6 @@
#include <tool/tool_dispatcher.h>
#include <tools/common_actions.h>
-#include <scripting/python_console_frame.h>
-
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
#include <python_scripting.h>
#endif
@@ -980,9 +978,6 @@
}
-wxSize PYTHON_CONSOLE_FRAME::m_frameSize; ///< The size of the PYTHON_CONSOLE_FRAME frame, stored during a session
-wxPoint PYTHON_CONSOLE_FRAME::m_framePos; ///< The position ofPYTHON_CONSOLE_FRAME the frame, stored during a session
-
void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable( wxCommandEvent& aEvent )
{
@@ -990,7 +985,7 @@
bool pythonPanelShown = true;
if( pythonPanelFrame == NULL )
- pythonPanelFrame = new PYTHON_CONSOLE_FRAME( this, pythonConsoleNameId() );
+ pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
else
pythonPanelShown = ! pythonPanelFrame->IsShown();
=== modified file 'scripting/python_scripting.cpp'
--- scripting/python_scripting.cpp 2015-08-24 18:32:56 +0000
+++ scripting/python_scripting.cpp 2015-12-13 14:45:48 +0000
@@ -227,16 +227,17 @@
}
-wxWindow* CreatePythonShellWindow( wxWindow* parent )
+wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId )
{
const char* pycrust_panel =
"import wx\n"
- "from wx.py import shell, version\n"
+ "from wx.py import editor, version\n"
"\n"
"intro = \"PyCrust %s - KiCAD Python Shell\" % version.VERSION\n"
"\n"
"def makeWindow(parent):\n"
- " pycrust = shell.Shell(parent, -1, introText=intro)\n"
+ " pycrust = editor.EditorNotebookFrame(parent, id=-1, title=intro)\n"
+ " pycrust.Show()\n"
" return pycrust\n"
"\n";
@@ -297,6 +298,8 @@
wxASSERT_MSG( success, _T( "Returned object was not a wxWindow!" ) );
Py_DECREF( result );
+
+ window->SetName(aFramenameId);
}
// Release the python objects we still have
=== modified file 'scripting/python_scripting.h'
--- scripting/python_scripting.h 2013-07-19 18:27:22 +0000
+++ scripting/python_scripting.h 2015-12-13 14:37:04 +0000
@@ -31,7 +31,7 @@
#ifdef KICAD_SCRIPTING_WXPYTHON
void RedirectStdio();
-wxWindow* CreatePythonShellWindow( wxWindow* parent );
+wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId );
class PyLOCK
{
References