29#include <wx/filename.h>
32#include <pybind11/eval.h>
39#include <python_scripting.h>
67 std::string pymodule(
"_pcbnew" );
69 if( !SCRIPTING::IsModuleLoaded( pymodule ) )
73 PyImport_AddModule( pymodule.c_str() );
74 PyObject* mod = pcbnew_init();
75 PyObject* sys_mod = PyImport_GetModuleDict();
76 PyDict_SetItemString( sys_mod,
"_pcbnew", mod );
120 if(
Pgm().GetCommonSettings()->m_Api.enable_server )
121 Pgm().GetPluginManager().ReloadPlugins();
127 frame()->ReCreateMenuBar();
129 frame()->ReCreateHToolbar();
131 frame()->PostSizeEvent();
141 using namespace pybind11::literals;
143 auto locals = pybind11::dict(
144 "sys_path"_a =
TO_UTF8( SCRIPTING::PyScriptingPath( SCRIPTING::PATH_TYPE::STOCK ) ),
145 "user_path"_a =
TO_UTF8( SCRIPTING::PyScriptingPath( SCRIPTING::PATH_TYPE::USER ) ),
146 "third_party_path"_a =
147 TO_UTF8( SCRIPTING::PyPluginsPath( SCRIPTING::PATH_TYPE::THIRDPARTY ) ) );
152pcbnew.LoadPlugins( sys_path, user_path, third_party_path )
154 pybind11::globals(), locals );
160 wxString pluginpath( SCRIPTING::PyPluginsPath( SCRIPTING::PATH_TYPE::USER ) );
162 if( wxFileName::DirExists( pluginpath ) )
166 wxMessageBox( wxString::Format(
_(
"Unable to open plugin directory '%s'." ), pluginpath ),
167 _(
"Plugin Directory" ), wxOK | wxICON_ERROR );
173 wxString msg = wxString::Format(
_(
"The plugin directory '%s' does not exist. Create it?" ), pluginpath );
175 wxMessageDialog dlg(
nullptr, msg,
_(
"Plugin Directory" ), wxYES_NO | wxICON_QUESTION );
177 if( dlg.ShowModal() == wxID_YES )
179 if( wxFileName::Mkdir( pluginpath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
183 wxMessageBox( wxString::Format(
_(
"Unable to open plugin directory '%s'." ), pluginpath ),
184 _(
"Plugin Directory" ), wxOK | wxICON_ERROR );
189 wxMessageBox( wxString::Format(
_(
"Unable to create plugin directory '%s'." ), pluginpath ),
190 _(
"Plugin Directory" ), wxOK | wxICON_ERROR );
Class PCBNEW_ACTION_PLUGINS.
static TOOL_ACTION pluginsReload
static void UnloadAll()
Unload (deregister) all action plugins.
static TOOL_ACTION pluginsShowFolder
Scripting Actions.
@ KIFACE_SCRIPTING_LEGACY
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
This file contains miscellaneous commonly used macros and functions.
PGM_BASE & Pgm()
The global program "get" accessor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Implement a participant in the KIWAY alchemy.
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)