473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Tcl extensions with Python?

How do you setup a Tcl extension to be accessible through Python? I
understand that I'll have to use native Tcl calls to use it (tk.call()
etc), but I can't figure out where to put the files or how to
initialize them so I can call them.

The package I would like to use is TkPNG: http://www.muonics.com/FreeStuff/TkPNG/

Thanks.
Jul 17 '08 #1
3 1478
On Thu, Jul 17, 2008 at 6:48 PM, C Martin <g.**********@gmail.comwrote:
How do you setup a Tcl extension to be accessible through Python? I
understand that I'll have to use native Tcl calls to use it (tk.call()
etc), but I can't figure out where to put the files or how to
initialize them so I can call them.

The package I would like to use is TkPNG: http://www.muonics.com/FreeStuff/TkPNG/
You can put them anywhere, but if it is on tcl's auto_path then you
just need a call to "package require tkpng". To check what directories
are part of auto_path, start tclsh and enter "set auto_path".

Follows a sample code to demonstrate how to load the required package:

import Tkinter

root = Tkinter.Tk()
tkpnglib = "/usr/lib/tkpng0.9"
root.tk.eval("""
global auto_path
lappend auto_path {%s}""" % tkpnglib)

root.tk.eval("package require tkpng")

If tkpng were installed in some directory belonging to auto_path, then
you wouldn't need that call to tk.eval.

And.. for tkpng specifically, you won't need tk.call to use it, you
just need to create your images using Tkinter.PhotoImage with a "png"
type.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


--
-- Guilherme H. Polo Goncalves
Jul 17 '08 #2
C Martin wrote:
How do you setup a Tcl extension to be accessible through Python? I
understand that I'll have to use native Tcl calls to use it (tk.call()
etc), but I can't figure out where to put the files or how to
initialize them so I can call them.

The package I would like to use is TkPNG: http://www.muonics.com/FreeStuff/TkPNG/

Thanks.
ARGH, Tcl!!! ;-) I know that's not the question, but do you know PIL
(http://www.pythonware.com/products/pil)?
Jul 18 '08 #3
On Jul 17, 5:18 pm, "Guilherme Polo" <ggp...@gmail.comwrote:
[snip]
And.. for tkpng specifically, you won't need tk.call to use it, you
just need to create your images using Tkinter.PhotoImage with a "png"
type.
Thank you Guilherme, that's all great info.
Thomas Troeger <thomas.troeger....@siemens.comwrote:
ARGH, Tcl!!! ;-) I know that's not the question, but do you know PIL
(http://www.pythonware.com/products/pil)?
Yes, I know about PIL. However, I need use PNGs with a full alpha
channel. PIL only seems support simple transparency, whereas TkPNG
seems to work as expected with them. If I am incorrect in this, then
please let me know how to use it!

Thanks.
Jul 18 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: MiLF | last post by:
Is it possible to write a Audio CD Player by using python only?
3
by: Mike C. Fletcher | last post by:
Every few months I get to working on a Python C extension (built with distutils) and discover a pointer error or the like where I'd like to be able to step into my DLL and see where the extension...
2
by: C. Barnes | last post by:
Normally, one uses the following procedure to build and install a C/C++ extension: python setup.py build --compiler=your_compiler python setup.py install For Python 2.3.3 on Windows, with...
30
by: Jive | last post by:
Can someone explain to me why Python 2.4 on MS Windows has these backward compatibility problems? What am I missing? Why won't extensions compiled to run with 2.3 also work with 2.4? Why does it...
1
by: dataangel | last post by:
I'm writing a python app that works as a replacement for the menu that comes with most minimalist wms when you right click the root window. It's prettier and written completely in python. I'd...
6
by: lothar.sch | last post by:
Hi, My python scripts are running as cgi scripts on an IIS on Windows XP. I have to distribute it to IIS on Windows 2003 Server. I tried to set python as cgi scripts in IIS on this machine in...
1
by: TPJ | last post by:
Hello, I have another, probably stupid, question. I'm working on some Python project, and I use some extensions written in C. I do all the development on my GNU/Linux box, so my setup.py script...
2
by: Blair LeGent | last post by:
Following the directions in "Python in a Nutshell" (an excellent book), I entered the C code for "helloworld.c", saved it as a file, and entered this script and saved it as setup.py: from...
26
by: Kevin D. Smith | last post by:
I've written a simple Python extension for UNIX, but I need to get it working on Windows now. I'm having some difficulties figuring out how to do this. I've seen web pages that say that MS Visual...
4
by: andrew.arobert | last post by:
Good afternoon, We have numerous web sites which are currently being manually published via Front Page. Doing one or two sites on an ad-hoc basis was not too bad but we are now over 20 or...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.