473,462 Members | 1,128 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calling tcl from python and viceversa

Hi!
I want to call tcl from python and python from tcl. The big picture is
that Iīm writing an application GUI with tcl/tk and application logic
with python, so at least I want to call python events from the tk GUI.
I have read about _tkinter and tkapp.call although I couldnīt find any
detailed documentation. And, anyway, that seems to work in one
direction (python->tcl) but I donīt know how to make it work in the
other (tcl->python).
Thank you,
Carlos
Jul 18 '05 #1
4 7294
Carlos P. wrote:
Hi!
I want to call tcl from python and python from tcl. The big picture is
that Iīm writing an application GUI with tcl/tk and application logic
with python, so at least I want to call python events from the tk GUI.
I have read about _tkinter and tkapp.call although I couldnīt find any
detailed documentation. And, anyway, that seems to work in one
direction (python->tcl) but I donīt know how to make it work in the
other (tcl->python).
Thank you,
Carlos


Hello,

I have found an hint in the Tcl Wiki about Tclpython:

http://mini.net/tcl/5630

May be this will help you a little.

Gerard Sookahet

Jul 18 '05 #2
dan
funny -- first look at the board and it's right on subject.

I'm trying to write an app that does some cool stuff with sound
samples, using tkSnack. But I'm stuck on a simple question -- how do
I insert some of my own code into the tkInter mainloop? I need the
sequencer to run in the background while the UI is up.

Forgetting about snack for the moment, how do I run _any_
non-event-driven code while my Tk widgets are active? (for instance,
animation in one window while menus are still available). I can't
find any demos that show this sort of behavior.

All the Tk examples I've seen set up the widgets and run
root.mainloop(). I can't for the life of me figure out what code this
call invokes, but it won't return until a quit command or some such
action is initiated by the user. TCL docs say that Tk_mainloop calls
tcl_DoOneEvent() in a dead loop until a quit flag is set, or something
like that.

My best guess is that I'm supposed to set up another thread to do my
stuff, and send messages to the Tkinter thread that trigger Tk events,
or something like that. But the Tkinter docs are so sketchy I can't
really get a handle on how to do it. Any help or pointers would be
appreciated.

thanks in advance - stumped
cp*****@yahoo.com.ar (Carlos P.) wrote in message news:<45**************************@posting.google. com>...
Hi!
I want to call tcl from python and python from tcl. The big picture is
that Iīm writing an application GUI with tcl/tk and application logic
with python, so at least I want to call python events from the tk GUI.
I have read about _tkinter and tkapp.call although I couldnīt find any
detailed documentation. And, anyway, that seems to work in one
direction (python->tcl) but I donīt know how to make it work in the
other (tcl->python).
Thank you,
Carlos

Jul 18 '05 #3
In article <fb**************************@posting.google.com >,
dan <da*******@yahoo.com> wrote:
funny -- first look at the board and it's right on subject.

I'm trying to write an app that does some cool stuff with sound
samples, using tkSnack. But I'm stuck on a simple question -- how do
I insert some of my own code into the tkInter mainloop? I need the
sequencer to run in the background while the UI is up.

Forgetting about snack for the moment, how do I run _any_
non-event-driven code while my Tk widgets are active? (for instance,
animation in one window while menus are still available). I can't
find any demos that show this sort of behavior.

All the Tk examples I've seen set up the widgets and run
root.mainloop(). I can't for the life of me figure out what code this
call invokes, but it won't return until a quit command or some such
action is initiated by the user. TCL docs say that Tk_mainloop calls
tcl_DoOneEvent() in a dead loop until a quit flag is set, or something
like that.

My best guess is that I'm supposed to set up another thread to do my
stuff, and send messages to the Tkinter thread that trigger Tk events,
or something like that. But the Tkinter docs are so sketchy I can't
really get a handle on how to do it. Any help or pointers would be
appreciated.

Jul 18 '05 #4
You can convert your code so that it runs from callbacks
(after/after_idle), or so that it calls the Tk event handler at reasonable
intervals. The first approach means greatly changing your code (though
you may be able to abuse generator functions here), and the second
approach means that a few Tk things will interact badly with your fake
mainloop (tk_wait). Threading is another possibility, but it's
problematic with Tk because you must make sure all Tk calls happen in
only one thread (the main thread, I think; or maybe the thread that
created the Tk instance)

Jeff

Jul 18 '05 #5

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

Similar topics

1
by: nik | last post by:
hi, my C++ app has embedded the interpreter and calls a python script everytime it creates a certain data structure. This allows the user to put the structure into a database or files or...
3
by: Travis Berg | last post by:
I'm running into a problem when trying to perform a callback to a Python function from a C extension. Specifically, the callback is being made by a pthread that seems to cause the problem. If I...
1
by: Stephen Kellett | last post by:
Hello everyone, I'm trying to do something in C calling Python and its failing. I'd be grateful if you could take a look and hopefully you have an answer. What I'm trying to do is determine...
4
by: soumitra.mishra | last post by:
Hi All, I want to call (execute) some python scripts from my C# program. I know that this can be done but have not idea how. The other option that I can think of is developing python web...
5
by: Mr BigSmoke | last post by:
Hi everybody, I need write an application in c#, but i wnat to use some functions that i have already written in python. Is there an "easy" way to call my python code from c#? I must use COM or...
9
by: Carl | last post by:
I am desperately looking for a way to call Python from Matlab. I have become used to Python's rich syntax and large number of libraries, and feel ridiculously clumsy being stuck with Matlab's...
1
by: jvframework | last post by:
I have a C# .NET cliente calling a Python web services. I pass two string values to web service and I wanna receive a string from the method. But, the server side receive my string values and...
0
varuns
by: varuns | last post by:
if i need to call a python function from c, i can use PyImport _Import() python-c API. Following code shows calling python function "add1" from python module "def1" int add(int x, int y) { ...
1
by: Martin Rubey | last post by:
Dear all, I'm trying to call from common lisp functions written for Sage (www.sagemath.org), which in turn is written in python. To do so, I tried...
9
by: Catherine Moroney | last post by:
I have one script (Match1) that calls a Fortran executable as a sub-process, and I want to write another script (Match4) that spawns off several instances of Match1 in parallel and then waits...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.