Using Tcl extensions with Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • C Martin

    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.
  • Guilherme Polo

    #2
    Re: Using Tcl extensions with Python?

    On Thu, Jul 17, 2008 at 6:48 PM, C Martin <g.threepwood@g mail.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("p ackage 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.PhotoIm age with a "png"
    type.


    --
    -- Guilherme H. Polo Goncalves

    Comment

    • Thomas Troeger

      #3
      Re: Using Tcl extensions with Python?

      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)?

      Comment

      • C Martin

        #4
        Re: Using Tcl extensions with Python?

        On Jul 17, 5:18 pm, "Guilherme Polo" <ggp...@gmail.c omwrote:
        [snip]
        And.. for tkpng specifically, you won't need tk.call to use it, you
        just need to create your images using Tkinter.PhotoIm age with a "png"
        type.
        Thank you Guilherme, that's all great info.
        Thomas Troeger <thomas.troeger ....@siemens.co mwrote:
        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.

        Comment

        Working...