Minor enhancement in python console: remove margins around the client area. simplify code.

This commit is contained in:
jean-pierre charras 2015-08-24 20:32:56 +02:00
parent 7ba02bad7c
commit 204eb49ce5
2 changed files with 17 additions and 21 deletions

View File

@ -38,27 +38,31 @@
* Class PYTHON_CONSOLE_FRAME is a simple derived class from wxMiniFrame * Class PYTHON_CONSOLE_FRAME is a simple derived class from wxMiniFrame
* to handle the scripting python console * to handle the scripting python console
*/ */
#define PC_STYLE wxCAPTION|wxCLOSE_BOX|wxRESIZE_BORDER
class PYTHON_CONSOLE_FRAME : public wxMiniFrame class PYTHON_CONSOLE_FRAME : public wxMiniFrame
{ {
private: private:
static wxSize m_frameSize; ///< The size of the frame, stored during a session static wxSize m_frameSize; ///< The size of the frame, stored during a session
static wxPoint m_framePos; ///< The position of the frame, stored during a session static wxPoint m_framePos; ///< The position of the frame, stored during a session
wxWindow * m_pythonPanel; ///< the window managed by the python shell
public: public:
PYTHON_CONSOLE_FRAME( wxWindow* aParent, const wxString& aFramenameId ) PYTHON_CONSOLE_FRAME( wxWindow* aParent, const wxString& aFramenameId )
: wxMiniFrame( aParent, wxID_ANY, wxT("Python console"), wxDefaultPosition, wxDefaultSize, : wxMiniFrame( aParent, wxID_ANY, wxT("Python console"), wxDefaultPosition, wxDefaultSize,
wxCAPTION|wxCLOSE_BOX|wxRESIZE_BORDER|wxFRAME_FLOAT_ON_PARENT, PC_STYLE | wxFRAME_FLOAT_ON_PARENT, aFramenameId )
aFramenameId )
{ {
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
SetSizer( sizer );
SetMinSize( wxSize( 500, 200 ) );
#if defined(KICAD_SCRIPTING_WXPYTHON) #if defined(KICAD_SCRIPTING_WXPYTHON)
wxWindow * pythonPanel = CreatePythonShellWindow( this ); m_pythonPanel = CreatePythonShellWindow( this );
sizer->Add( pythonPanel, 1, wxEXPAND | wxALL, 5 ); sizer->Add( m_pythonPanel, 1, wxEXPAND, 0 );
#else
m_pythonPanel = NULL;
#endif #endif
SetSizer( sizer );
SetMinSize( wxSize( 400, 200 ) );
if( m_frameSize.x <= 0 || m_frameSize.y <= 0 ) if( m_frameSize.x <= 0 || m_frameSize.y <= 0 )
SetSize( wxSize( 600, 300 ) ); SetSize( wxSize( 600, 300 ) );
@ -73,13 +77,15 @@ public:
Layout(); Layout();
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PYTHON_CONSOLE_FRAME::OnClose ) ); this->Connect( wxEVT_CLOSE_WINDOW,
wxCloseEventHandler( PYTHON_CONSOLE_FRAME::OnClose ) );
} }
~PYTHON_CONSOLE_FRAME() ~PYTHON_CONSOLE_FRAME()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PYTHON_CONSOLE_FRAME::OnClose ) ); this->Disconnect( wxEVT_CLOSE_WINDOW,
wxCloseEventHandler( PYTHON_CONSOLE_FRAME::OnClose ) );
} }
private: private:

View File

@ -233,21 +233,11 @@ wxWindow* CreatePythonShellWindow( wxWindow* parent )
"import wx\n" "import wx\n"
"from wx.py import shell, version\n" "from wx.py import shell, version\n"
"\n" "\n"
"class PyCrustPanel(wx.Panel):\n" "intro = \"PyCrust %s - KiCAD Python Shell\" % version.VERSION\n"
"\tdef __init__(self, parent):\n"
"\t\twx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)\n"
"\t\t\n"
"\t\t\n"
"\t\tintro = \"Welcome To PyCrust %s - KiCAD Python Shell\" % version.VERSION\n"
"\t\tpycrust = shell.Shell(self, -1, introText=intro)\n"
"\t\t\n"
"\t\tsizer = wx.BoxSizer(wx.VERTICAL)\n\n"
"\t\tsizer.Add(pycrust, 1, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 10)\n\n"
"\t\tself.SetSizer(sizer)\n\n"
"\n" "\n"
"def makeWindow(parent):\n" "def makeWindow(parent):\n"
" shell_window = PyCrustPanel(parent)\n" " pycrust = shell.Shell(parent, -1, introText=intro)\n"
" return shell_window\n" " return pycrust\n"
"\n"; "\n";