Advice on embedding tkcon...

tcl

    Next

  • 1. small, windows, static binary?
    I need a small, static, windows binary of only tclsh. I do not need the full ActiveState Tcl installation. Does someone have just tclsh I can copy to windows boxes and use as a standard shell? Mike

Advice on embedding tkcon...

Postby Georgios Petasis » Fri, 20 Nov 2009 05:42:30 GMT

Hi all,

I am trying to embed the latest tkcon (2.5):

proc console {} {
   if {![info exists ::tkcon::PRIV(root)]} {
     global argv argc
     namespace eval ::tkcon {}
     set ::tkcon::OPT(usehistory)    0
     ::tkcon::Init -color-bg white -font {arial 14}\
                   -exec {} -root .tkcon
     tkcon title "some title"
     tkcon attach Main
     wm protocol .tkcon WM_DELETE_WINDOW {tkcon hide}
   } else {
     ## Start a new window
     set interpreter [uplevel \#0 tkcon new]
     $interpeter eval tkcon eval wm protocol . WM_DELETE_WINDOW \
                               [list tkcon destroy]
     $interpeter eval tkcon attach Main
     $interpeter eval tkcon console configure \
         -bg white -font {arial 14}
   }
}

While opening the first tk console works, subsequent calls to "tkcon 
new" result in an empty tk window. Can am I doing wrong?

George

Re: Advice on embedding tkcon...

Postby Jeff Hobbs » Sun, 22 Nov 2009 06:51:19 GMT

On Nov 18, 12:42m, Georgios Petasis < XXXX@XXXXX.COM >


> amespace eval ::tkcon>{}
> et ::tkcon::OPT(usehistor>) 
> :tkcon::Init -color-bg white -font {>rial 14}\
> >xec {} -root .tkcon
> k>on title "some title"
> m protocol .tkcon WM_>ELETE_WINDOW >tkcon hide}
>  else {>
> # Start a new window
> et int>rpreter [uplevel \#0 tkcon new]
> interpeter eval tkcon ev>l wm protocol . WM_DELETE_WINDOW \
> gt;list tkco> destroy]
> interpeter eval tkcon attach>Main
> interpeter eval tkc>n cons>le>conf>gu>e \
> bg white -font {arial 14}
> 
>
> }
>
> While >pening the first tk console works, subsequent calls to "tkcon
> new" result in an empty tk window. Can am I doing wrong?

When running this in a quick Tcl session, I found this error happened
to prevent the second one:

% console
% console
can't read "interpeter": no such variable
% set errorInfo
can't read "interpeter": no such variable
    while executing
"$interpeter eval tkcon eval wm protocol . WM_DELETE_WINDOW  [list
tkcon destroy]"
    (procedure "console" line 13)
    invoked from within
"console"

Note the spelling error.

Jeff

Re: Advice on embedding tkcon...

Postby George Petasis » Sun, 22 Nov 2009 07:17:49 GMT

/H Jeff Hobbs :

Dear Jeff,

I am sorry, this was just a copy/paste mistake while adapting the code
for presenting it here. The actual code is he following:

## gut_Console
# Open the a TkCon Console
proc gut_Console {} {
global tcl_platform GUI_Options
## Initialise only if we haven't yet
##
if {![info exists ::tkcon::PRIV(root)]} {
global HomeDir ApplicationName argv argc
## Set some tkcon's default values to match our look'n'feel...
namespace eval ::tkcon {}
set ::tkcon::OPT(usehistory) 0
::tkcon::Init -color-bg $GUI_Options(TextBg) -font TextFont \
-exec {} -root .tkcon

gut_ConsoleConfigure {} title "$ApplicationName Main Console..."
gut_ConsoleConfigure {} attach Main
wm protocol .tkcon WM_DELETE_WINDOW {gut_ConsoleConfigure {} hide}
## In the main console, we bind our own text popup...
bind .tkcon <<TkCon_Popup>> {}
return {}
} else {
if {[winfo exists .tkcon] && [string equal [wm state .tkcon]
withdrawn]} {
wm deiconify .tkcon
#tkcon show
return {}
} else {
set interpreter [uplevel \#0 tkcon new]
gut_ConsoleConfigure $interpreter eval wm protocol .
WM_DELETE_WINDOW \
[list tkcon destroy]
gut_ConsoleConfigure $interpreter attach Main
set font [$interpreter eval font create \
[font actual TextFont]]
gut_ConsoleConfigure $interpreter console configure \
-bg $GUI_Options(TextBg) -font $font \
-width $GUI_Options(TextWidth) -height $GUI_Options(TextHeight)
return $interpreter
}
}
}

## gut_ConsoleConfigure
proc gut_ConsoleConfigure {interpeter args} {
if {![string length $interpeter]} {
return [eval tkcon $args]
} else {
return [$interpeter eval tkcon $args]
}
}

George

Re: Advice on embedding tkcon...

Postby Jeff Hobbs » Wed, 25 Nov 2009 11:27:44 GMT




Again, just run this in the console and you'll see than an error is
thrown.  In this case because not enough special vars are defined
ahead of time.  I think this may be a lower level bug in tkcon when
mixing the use of exec {}, but I'm not getting what you are trying to
do.  I suspect it simply isn't a supported use case.

Really, all you should do is source tkcon.tcl and then do 'tkcon
show'.  You can set usehistory and the protocol as well, but 'tkcon
show' is meant to handle most cases.  Can you explain what the extra
magic is trying to do?

Jeff

Similar Threads:

1.Embedding Tkcon

I know that 'console show' causes a wish console to pop up. But that
console is too large. I want to make it fit into a very small Tk window
I keep running on my Desktop, a mini-console. It would be a lot lot
better if it could be Tkcon instead of the vanilla wish console. In
either case, I have no idea of how I can do it. I'd love to get a few
pointers, please.

Thank you.

-- 
Luciano ES
Santos, SP - Brasil

2.embedded startup - general advice requested


I'm starting with a blank workbench appart from solder station/dvm
etc. This is a garden shed type startup (UK based)

I have a good deal of outdated experience but have  done nothing
lately.

I'm starting a small project and need to use an embedded controler 
and select a suitable development environment to work with.

The final product needs to be 

1. Quick to develop 

2. Cheap to produce in low-medium quantities

3. as future proof as possible (ie no "end of line items")

4. as leading edge as possible 

5. free from license issues (NO GPL or royalties  etc)

6. quick to get to market/end user status 

Would anyone like to help me select a good environment please?

Obviously I'm looking to use embedded forth if at all possible but
what hardware/support software etc would be a good choice.
Would something like Femtoos OS be any real use to me?


Which forth would be the best for this type of work and with controler
family should I be looking at for it?
(By best I mean programming environment / IDE / professionalism etc)

I know about PIC but nothing at all about AVR?  
I dont want to spend a couple of hundred "just to get started" and
have to upgrade later - if there's a good setup I can use I dont mind
spending a little extra to get going.

Does anything in the market stand out ?

Any comments welcome.

thanks

john.

3.Advice requested on Tcl embedding (inside QT)

I've searched through many of the archives, and have found SOME interesting
information about embedding Tcl inside QT or QT inside Tcl.

I've even managed to "roll my own" QT inside Tcl/Tk where a QT application
becomes a loadable Tcl extension, and connect the Tcl interpreter and have
it call QT methods and have QT call Tcl, etc.. (using SWIG).
(i.e. had QT and Tk co-existing and exchanging information)

However, that solution isn't entirely satisfactory.. Tcl still uses the
standard console, which we're trying to get around with a GUI, obviously.

Here's what I'd like to do:

1) write a multi-threaded QT app with one thread for GUI, and a couple of
other threads for data processing (I know, not exactly "easy", but I've got
a prototype up and running and doing ok). Should be portable to Windows. I'm
using as much of the QThread stuff, etc. as I can, to hopefully be portable.

2) add a 4th thread for embedding/running Tcl in the app, including putting
Tcl inside a QT window. Sort of like the QConsole demo that's on the 'net,
but QConsole BLOCKS if you do something like "after 10000; puts abc". I
suppose this wouldn't really matter if it's in its own thread, but part of
the code is GPL (LGPL?) and I'm working on a commercial app. Also, I'm not
exactly comfortable with the "QInterceptor", especially since it doesn't
work on Windows.

3) I think I've got a way of capturing the output of anything Tcl does
(including running "exec ls", etc) - create a slave interpreter to "eval"
every command, and capture the results. We're already doing that elsewhere,
and it works quite well. You can't redirect stdin that way (i.e. "exec wc"
and then manually typing in stuff doesn't work), but that's beyond what we
need to do.

So, what I'm after is a summary of what I need to make Tcl live inside its
own thread, with a nonexistant stdin/stdout. Rather, I'll feed it commands
and let it process them however it wants.

I'm guessing I'd need to use "Tcl_QueueEvent()" for commands typed in at the
console, and the thread itself that's running Tcl will just call
"Tcl_ServiceAll()" for it to handle those commands (after the appropriate
Tcl_Init, of course).  Output will be via a customized puts (see #3) that
calls a C/C++ function to write to the text widget. Will that then allow
most everything that's part of Tcl to work (fileevents, after, etc)? Or do I
actually have to (re)write the entire Notifier suite for that stuff to work?

OR, can I just call Tcl_Main from the Tcl thread, have it set up a socket to
read commands from, and write results to, and I pipe stuff in and read from
it?

Thanks for any hints,
Mattias

4.::tkcon::OPT(maxlinelen)

I'm trying to prevent really long results from getting printed in
tkcon.  The documentation led me to believe that ::tkcon::OPT
(maxlinelen) might help me do this, but whether I set it to 20, 200,
or 2000, it doesn't seem to have any effect on what gets printed in
the console.  (To test it, I'm using commands like [string repeat
"long string " 10000].  I'm also using [tkcon set ::tkcon::OPT
(maxlinelen)] to verify that it's set to something other than 0.)
Coincidentally, I can't find the string "maxlinelen" anywhere in the
tkcon code--is that to be expected?  Can somebody explain what the
maxlinelen option is supposed to do?  Does it work for you?

As always, thanks for your help.

Aric

5.TkCon on Mac OS X - problem selecting text

I am having a problem using TkCon on Mac OS X. When I try to select
text within either the TkCon window or a window containg a Text
widget, the selection occurs on text which is nowhere need the
cursor!

It appears to me that the initial mouse press is not consistently
setting the start point/cusor position.

Any help greatly appreciated

regards
Julian H J Loaring

6. 8.5, teacup & tkcon...

7. trying to customize tkcon

8. wrapping tkcon



Return to tcl

 

Who is online

Users browsing this forum: No registered users and 10 guest