Noob Question - Importing graphcs module
#1
Hi All,

I've been learning a bit about graphics in python using John Zelle's graphics.py module. This is working fine in the version of Idle that comes with the stand-alone python package, so I thought I'd try and see if it would work in an XBMC addon. If so I could create the most minimalist bouncing-ball visualisation in history, but good in the run up to Wimbledon!! Anyway, I think I'm misunderstanding how to add additional modules to a python script (or even if it's possible).

In my addon folder I dropped graphics.py next to my default.py I then included a line in default.py to say:
Code:
import xbmc
import xbmcgui
from graphics import *

I then draw some shapes and end by trying to load a window by:

Code:
my_win = GraphWin()

When I run the code though I get the following script error:
Code:
ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class '_tkinter.TclError'>
Error Contents: Can't find a usable init.tcl in the following directories:
{C:/Program Files (x86)/XBMC/system/python/lib/tcl8.5} {C:/Program Files (x86)/lib/tcl8.5} C:/lib/tcl8.5 {C:/Program Files (x86)/library} C:/library C:/tcl8.5.2/library C:/tcl8.5.2/library
This probably means that Tcl wasn't installed properly.
                                            
Traceback (most recent call last):
File "C:\Users\Paul\AppData\Roaming\XBMC\addons\script.graphics\default.py", line 4, in <module>
from graphics import *
File "C:\Users\Paul\AppData\Roaming\XBMC\addons\script.graphics\graphics.py", line 172, in <module>
  _root = tk.Tk()
File "C:\Program Files (x86)\XBMC\system\python\lib\lib-tk\Tkinter.py", line 1643, in __init__
   self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: Can't find a usable init.tcl in the following directories:
{C:/Program Files (x86)/XBMC/system/python/lib/tcl8.5} {C:/Program Files (x86)/lib/tcl8.5} C:/lib/tcl8.5 {C:/Program Files (x86)/library} C:/library C:/tcl8.5.2/library C:/tcl8.5.2/library

This probably means that Tcl wasn't installed properly.
-->End of Python script error report<--

So, I can see in the stand alone python package it has a separate lib folder for tkinter including the _init_.py file, whereas in XBMC python there is just a lib folder called lib-tk but this has a very different structure with no _init_.py.

I'm not sure if this is due to differing versions of python or if XBMC python is just not intended to run graphics modules like this. Is anyone able to confirm what I'm dong wrong, or know a graphics module that will work with XBMC python, if there isn't one built into existing libraries?

Thanks
Reply

Logout Mark Read Team Forum Stats Members Help
Noob Question - Importing graphcs module0