Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6107511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:11:47+00:00 2026-05-23T14:11:47+00:00

So I want to exequte TCL code inside my programm. I want it to

  • 0

So I want to exequte TCL code inside my programm. I want it to be capable of reaching some of my C++ functions and classes. So I use C++/TCL. All general TCL to C++ binding works fine for me. But now I want to have some little UI on top (so I have lot on general TCL code that interacts with my app and now I want to add Tk gui to it.) How to create simple tk button inside of the window with some name I want using C++/TCL? I do not want to use C++/TK at all.

Update
What have I tried:

Put all Tk (.tcl) files into ../../tk folder and try this… it fails

#include <string>
#include "cpptcl.h"

int main(int argc, char *argv[])
{
    std::string script = 
        "package require Tcl 8.5\n"
        "set auto_path [linsert $auto_path 0 [file join [file dirname [info script]] ../../tk]]\n"
        "package require Tk 8.5\n";
    Tcl::interpreter tcl_interpreter;
    tcl_interpreter.eval(script);
    return 0;
}

Also I tried stuff like

#include <string>
#include "cpptcl.h"
int main(int argc, char *argv[])
{
    std::string script = 
        "package require Tcl 8.5\n"
        "foreach tkFile [glob -nocomplain -directory ../../tk *] {\n"
        "    source $tkFile\n"
        "}\n"
        "package require Tk 8.5\n";
    Tcl::interpreter tcl_interpreter;
    tcl_interpreter.eval(script);
    return 0;
}

Which also fails.

Also I tried to put tk85.dll near to my app and call

#include <string>
#include "cpptcl.h"
int main(int argc, char *argv[])
{
    std::string script = 
        "package require Tcl 8.5\n"
        "load tk85.dll \n";
    Tcl::interpreter tcl_interpreter;
    tcl_interpreter.eval(script);
    return 0;
}

and this

#include <string>
#include "cpptcl.h"
int main(int argc, char *argv[])
{
    std::string script = 
        "package require Tcl 8.5\n"
        "interp create slave \n"
        "load {} Tk slave \n"
    ;
    Tcl::interpreter tcl_interpreter;
    tcl_interpreter.eval(script);
    return 0;
}

as described here. this also fails.

This

#include <string>
#include "cpptcl.h"

int main(int argc, char *argv[])
{
    std::string script = 
        "package require Tcl 8.5\n"
        " interp create a\n"
        " a eval {set argv {-display :0}; package require Tk; button \".b\" -text \"Say Hello\"; pack \".b\" -padx 20 -pady 6;}\n"
        ;
    Tcl::interpreter tcl_interpreter;
    tcl_interpreter.eval(script);
    std::cin.get();
    return 0;
}

compiles and runs but does not show ani window or anething else.(

What to do? How to load Tk?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:11:47+00:00Added an answer on May 23, 2026 at 2:11 pm

    You haven’t said what fails, but this isn’t going to work. To have a GUI, you need an event loop.

    I’d recommend a different approach: make your C++ code into a Tcl-loadable module, then your script can run under wish and use both Tk and your objects implemented in C++.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute some Python code, typed at runtime, so I get the
I want to execute javascript code inside of an iframe as soon as the
I want to execute some code when the user selects a row in a
I want to execute some code at 12 o clock everyday. The only way
I want to execute some Unix commands from the java code. I want to
I want to execute a php-script from php that will use different constants and
I want to execute some mysql statements that are stored in a text file
I want to execute a function on all the objects within a List of
I want to execute a script every 30mins, but i want to use it
I want to execute a particular number of statements after some delay. For eg:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.