← Back to team overview

kicad-developers team mailing list archive

[PATCH] Tkinter doesn't working in Pcbnew

 

The Tkinter module is the standard Python interface to the Tk GUI toolkit.
Inside KiCad Tkinter doesn't work and gives next error:

from Tkinter import *
> root = Tk()
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
>   File "C:\Program Files\KiCad\lib\python2.7\lib-tk/Tkinter.py", line
> 1814, in __init__
>     baseName = os.path.basename(sys.argv[0])
> AttributeError: 'module' object has no attribute 'argv'


Attached patch resolves this issue by transfering values of argc and argv
variables to python environment.

For more details see:
https://github.com/KiCad/kicad-winbuilder/issues/60
From 053067985680dd534f046e41d17c179653a8fc49 Mon Sep 17 00:00:00 2001
From: Baranovskiy Konstantin <baranovskiykonstantin@xxxxxxxxx>
Date: Fri, 6 Jul 2018 20:38:11 +0300
Subject: [PATCH 2/2] Values of argc and argv transfers to python environment.

---
 pcbnew/swig/python_scripting.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pcbnew/swig/python_scripting.cpp b/pcbnew/swig/python_scripting.cpp
index 8321249bc..2d988a914 100644
--- a/pcbnew/swig/python_scripting.cpp
+++ b/pcbnew/swig/python_scripting.cpp
@@ -145,6 +145,7 @@ bool pcbnewInitPythonScripting( const char * aUserScriptingPath )
     swigSwitchPythonBuiltin();  // switch the python builtin modules to our new list
 
     Py_Initialize();
+    PySys_SetArgv(Pgm().App().argc, Pgm().App().argv);
 
 #ifdef KICAD_SCRIPTING_WXPYTHON
     PyEval_InitThreads();
-- 
2.18.0


Follow ups