From: Kevin Walzer on
I'm confused about something I frequently see in source files that make
use of Tk's C API: Tk_Window and TkWindow. Here's an example that
returns the interpreter associated with a Tk window:

Tcl_Interp * ip(Tk_Window tkwin) {
if (tkwin != NULL && ((TkWindow *)tkwin)->mainPtr != NULL) {
return ((TkWindow *)tkwin)->mainPtr->interp;
}
return NULL;
}

I understand that Tk_Window refers to a Tk window; it's a publicly
exported function defined in the man pages.

But what's a "TkWindow"? It appears to be some sort of struct, and I see
a reference to it in tkInt.h, but I see no discussion of it in the man
pages. As a result, I don't understand how to use it in my extension
code, or even if I should use it.

Can someone clarify this for me?

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
From: George Petasis on
O/H Kevin Walzer έγραψε:
> I'm confused about something I frequently see in source files that make
> use of Tk's C API: Tk_Window and TkWindow. Here's an example that
> returns the interpreter associated with a Tk window:
>
> Tcl_Interp * ip(Tk_Window tkwin) {
> if (tkwin != NULL && ((TkWindow *)tkwin)->mainPtr != NULL) {
> return ((TkWindow *)tkwin)->mainPtr->interp;
> }
> return NULL;
> }
>
> I understand that Tk_Window refers to a Tk window; it's a publicly
> exported function defined in the man pages.
>
> But what's a "TkWindow"? It appears to be some sort of struct, and I see
> a reference to it in tkInt.h, but I see no discussion of it in the man
> pages. As a result, I don't understand how to use it in my extension
> code, or even if I should use it.
>
> Can someone clarify this for me?
>
> --Kevin
>

TkWindow is an internal to Tk structure. It is not supposed to be used
by extensions. Tk_Window is the structure that can be used by extensions...

In essence, both are the same structure. But Tk_Window has some
structure fields hidden, because they are internal to Tk...

George
From: Donal K. Fellows on
On 5 Nov, 03:27, Kevin Walzer <k...(a)codebykevin.com> wrote:
> As a result, I don't understand how to use [TkWindow] in my extension
> code, or even if I should use it.

It's not described because is in fact part of the implementation, not
the interface. Don't use it if you're not writing Tk itself.

Donal.
From: George Petasis on
O/H Donal K. Fellows έγραψε:
> On 5 Nov, 03:27, Kevin Walzer <k...(a)codebykevin.com> wrote:
>> As a result, I don't understand how to use [TkWindow] in my extension
>> code, or even if I should use it.
>
> It's not described because is in fact part of the implementation, not
> the interface. Don't use it if you're not writing Tk itself.
>
> Donal.

There are cases where you cannot avoid using it. For sure I have used it
at least in one of my extensions...
(I don't remeber in which one though :-) )

George
From: Don Porter on
George Petasis wrote:
> O/H Donal K. Fellows έγραψε:
>> On 5 Nov, 03:27, Kevin Walzer <k...(a)codebykevin.com> wrote:
>>> As a result, I don't understand how to use [TkWindow] in my extension
>>> code, or even if I should use it.
>>
>> It's not described because is in fact part of the implementation, not
>> the interface. Don't use it if you're not writing Tk itself.
>>
>> Donal.
>
> There are cases where you cannot avoid using it. For sure I have used it
> at least in one of my extensions...
> (I don't remeber in which one though :-) )

Where can we find your Feature Request laying out the inadequacies
of the Tk public interface?

--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter(a)nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|