• event generate $w <>

    From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Dec 18 13:17:07 2025
    From Newsgroup: comp.lang.tcl

    I just realized that my Copy procedure for entries does not work anymore.

    So I have some ttk entries with some text inside.
    I select the text in one entry, either hit "CTRL-C" or right click to
    show a customized context menu and ultimatelly the command is executed:

    event generate $w <<Copy>>

    The error I get is:

    *** START OF ERROR MESSAGE ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    *** ERROR INFO ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    while executing
    "catch {tk::EntryGetSelection $win} tk::Priv(data)"
    (procedure "::numentry::Snit_methodCopyVal" line 8)
    invoked from within ".vpan.main.workframe.detailsframe.sw.sf.mf.cf.measure.props.f.f5.y CopyVal"
    ("uplevel" body line 1)
    invoked from within
    "uplevel 1 [linsert $args 0 $self]"
    invoked from within
    "::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal"
    (command bound to event)
    *** ERROR STACK ***
    INNER:::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal
    UP:1

    *** END OF ERROR MESSAGE ***

    Is this a bug in Tcl 9.0.2?
    I don't think this happend in Tcl 8.

    Thanks
    Alex
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Thu Dec 18 13:26:14 2025
    From Newsgroup: comp.lang.tcl

    Am 18.12.2025 um 13:17 schrieb meshparts:
    I just realized that my Copy procedure for entries does not work anymore.

    So I have some ttk entries with some text inside.
    I select the text in one entry, either hit "CTRL-C" or right click to
    show a customized context menu and ultimatelly the command is executed:

    event generate $w <<Copy>>

    The error I get is:

    *** START OF ERROR MESSAGE ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    *** ERROR INFO ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    -a-a-a while executing
    "catch {tk::EntryGetSelection $win} tk::Priv(data)"
    -a-a-a (procedure "::numentry::Snit_methodCopyVal" line 8)
    -a-a-a invoked from within ".vpan.main.workframe.detailsframe.sw.sf.mf.cf.measure.props.f.f5.y
    CopyVal"
    -a-a-a ("uplevel" body line 1)
    -a-a-a invoked from within
    "uplevel 1 [linsert $args 0 $self]"
    -a-a-a invoked from within
    "::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal"
    -a-a-a (command bound to event)
    *** ERROR STACK ***
    INNER:::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal
    UP:1

    *** END OF ERROR MESSAGE ***

    Is this a bug in Tcl 9.0.2?
    I don't think this happend in Tcl 8.

    Thanks
    Alex

    I have seen this in a bug report.
    What is the Tk version ?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Dec 18 13:35:57 2025
    From Newsgroup: comp.lang.tcl

    Am 18.12.2025 um 13:26 schrieb Harald Oehlmann:
    I have seen this in a bug report.
    What is the Tk version ?
    9.0.2
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Dec 18 14:05:27 2025
    From Newsgroup: comp.lang.tcl

    Am 18.12.2025 um 13:17 schrieb meshparts:
    I just realized that my Copy procedure for entries does not work anymore.

    So I have some ttk entries with some text inside.
    I select the text in one entry, either hit "CTRL-C" or right click to
    show a customized context menu and ultimatelly the command is executed:

    event generate $w <<Copy>>

    The error I get is:

    *** START OF ERROR MESSAGE ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    *** ERROR INFO ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    -a-a-a while executing
    "catch {tk::EntryGetSelection $win} tk::Priv(data)"
    -a-a-a (procedure "::numentry::Snit_methodCopyVal" line 8)
    -a-a-a invoked from within ".vpan.main.workframe.detailsframe.sw.sf.mf.cf.measure.props.f.f5.y
    CopyVal"
    -a-a-a ("uplevel" body line 1)
    -a-a-a invoked from within
    "uplevel 1 [linsert $args 0 $self]"
    -a-a-a invoked from within
    "::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal"
    -a-a-a (command bound to event)
    *** ERROR STACK ***
    INNER:::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal
    UP:1

    *** END OF ERROR MESSAGE ***

    Is this a bug in Tcl 9.0.2?
    I don't think this happend in Tcl 8.

    Thanks
    Alex
    It's weird: Not all entries in my app lead to the above error...
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Dec 18 14:06:35 2025
    From Newsgroup: comp.lang.tcl

    Am 18.12.2025 um 13:17 schrieb meshparts:
    I just realized that my Copy procedure for entries does not work anymore.

    So I have some ttk entries with some text inside.
    I select the text in one entry, either hit "CTRL-C" or right click to
    show a customized context menu and ultimatelly the command is executed:

    event generate $w <<Copy>>

    The error I get is:

    *** START OF ERROR MESSAGE ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    *** ERROR INFO ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    -a-a-a while executing
    "catch {tk::EntryGetSelection $win} tk::Priv(data)"
    -a-a-a (procedure "::numentry::Snit_methodCopyVal" line 8)
    -a-a-a invoked from within ".vpan.main.workframe.detailsframe.sw.sf.mf.cf.measure.props.f.f5.y
    CopyVal"
    -a-a-a ("uplevel" body line 1)
    -a-a-a invoked from within
    "uplevel 1 [linsert $args 0 $self]"
    -a-a-a invoked from within
    "::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal"
    -a-a-a (command bound to event)
    *** ERROR STACK ***
    INNER:::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal
    UP:1

    *** END OF ERROR MESSAGE ***

    Is this a bug in Tcl 9.0.2?
    I don't think this happend in Tcl 8.

    Thanks
    Alex
    One thing: The entry was created using "numentry".
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Thu Dec 18 16:46:39 2025
    From Newsgroup: comp.lang.tcl

    * meshparts <alexandru.dadalau@meshparts.de>
    | One thing: The entry was created using "numentry".

    Seems 'numentry' is not part of stock Tk or Tklib.
    Where does it come from?

    R'
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Dec 18 17:06:42 2025
    From Newsgroup: comp.lang.tcl

    Am 18.12.2025 um 16:46 schrieb Ralf Fassel:
    * meshparts <alexandru.dadalau@meshparts.de>
    | One thing: The entry was created using "numentry".

    Seems 'numentry' is not part of stock Tk or Tklib.
    Where does it come from?

    R'
    https://wiki.tcl-lang.org/page/Entry+widget+for+numeric+data
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Rich@rich@example.invalid to comp.lang.tcl on Thu Dec 18 17:29:12 2025
    From Newsgroup: comp.lang.tcl

    meshparts <alexandru.dadalau@meshparts.de> wrote:
    Am 18.12.2025 um 16:46 schrieb Ralf Fassel:
    * meshparts <alexandru.dadalau@meshparts.de>
    | One thing: The entry was created using "numentry".

    Seems 'numentry' is not part of stock Tk or Tklib.
    Where does it come from?

    R'
    https://wiki.tcl-lang.org/page/Entry+widget+for+numeric+data

    See https://www.tcl-lang.com/software/tcltk/9.0.html

    Important Incompatibilities in Tcl 9.0

    Namespace varname resolution: Current namespace, not global.

    The code for that widget does this in it's copyval proc:

    method CopyVal {args} {
    upvar #0 $options(-variable) thevar

    if {![catch {tk::EntryGetSelection $win} tk::Priv(data)]} {
    clipboard clear -displayof $win
    clipboard append -displayof $win $thevar
    unset tk::Priv(data)
    }
    return -code break
    }

    And, as it is also a snit widget, it is impacted by the namespace name resolution rules.

    It should be using absolute paths: ::tk::Priv(data)

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Thu Dec 18 18:42:23 2025
    From Newsgroup: comp.lang.tcl

    * meshparts <alexandru.dadalau@meshparts.de>
    | Am 18.12.2025 um 16:46 schrieb Ralf Fassel:
    | > * meshparts <alexandru.dadalau@meshparts.de>
    | > | One thing: The entry was created using "numentry".
    | > Seems 'numentry' is not part of stock Tk or Tklib.
    | > Where does it come from?
    | > R'
    | https://wiki.tcl-lang.org/page/Entry+widget+for+numeric+data

    Ok. Seems like the only use of the namespace tk:: is in

    method CopyVal {args} {
    upvar #0 $options(-variable) thevar

    if {![catch {tk::EntryGetSelection $win} tk::Priv(data)]} {
    clipboard clear -displayof $win
    clipboard append -displayof $win $thevar
    unset tk::Priv(data)
    }
    return -code break
    }

    On the first glance using tk::Priv(data) here seems unneccessary, you
    could simply use a temporary instead, or since it is not used here
    anyway, just omit it completely

    method CopyVal {args} {
    upvar #0 $options(-variable) thevar

    if {![catch {tk::EntryGetSelection $win}]} {
    clipboard clear -displayof $win
    clipboard append -displayof $win $thevar
    }
    return -code break
    }


    As the name indicates, tk::'Priv' is probably not supposed to be used
    outside of core-tk anyway. This looks like copy/paste code from tk's
    entry.tcl where the code runs in global namespace, thus you can't have a temporary variable and the code resorts to using tk::Priv.

    R'
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Thu Dec 18 18:49:29 2025
    From Newsgroup: comp.lang.tcl

    * Ralf Fassel <ralfixx@gmx.de>
    | On the first glance using tk::Priv(data) here seems unneccessary, you
    | could simply use a temporary instead, or since it is not used here
    | anyway, just omit it completely

    | method CopyVal {args} {
    | upvar #0 $options(-variable) thevar

    | if {![catch {tk::EntryGetSelection $win}]} {
    | clipboard clear -displayof $win
    | clipboard append -displayof $win $thevar
    | }
    | return -code break
    | }

    Or even

    method CopyVal {args} {
    upvar #0 $options(-variable) thevar
    clipboard clear -displayof $win
    clipboard append -displayof $win $thevar
    return -code break
    }

    since calling tk::EntryGetSelection most probably suffers the same
    problem (as Rick indicated due to the namespace resolution changes in
    Tcl9), and the current contents seems to be stored in $thevar
    anyway, instead o having to be fetched from the entry.

    R'
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Dec 18 18:50:47 2025
    From Newsgroup: comp.lang.tcl

    Am 18.12.2025 um 18:29 schrieb Rich:
    It should be using absolute paths: ::tk::Priv(data)
    Thanks Rich! Indeed, now it looks obvious to me. And I could fix the
    issue package myself.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Thu Dec 18 18:55:49 2025
    From Newsgroup: comp.lang.tcl

    Am 18.12.2025 um 18:42 schrieb Ralf Fassel:
    On the first glance using tk::Priv(data) here seems unneccessary, you
    could simply use a temporary instead, or since it is not used here
    anyway, just omit it completely
    Very good observation!
    I could delete it indeed.
    Thanks!
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Emiliano@emiliano@example.invalid to comp.lang.tcl on Thu Dec 18 16:35:49 2025
    From Newsgroup: comp.lang.tcl

    On Thu, 18 Dec 2025 13:17:07 +0100
    meshparts <alexandru.dadalau@meshparts.de> wrote:

    I just realized that my Copy procedure for entries does not work anymore.

    So I have some ttk entries with some text inside.
    I select the text in one entry, either hit "CTRL-C" or right click to
    show a customized context menu and ultimatelly the command is executed:

    event generate $w <<Copy>>

    The error I get is:

    *** START OF ERROR MESSAGE ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    *** ERROR INFO ***
    can't set "tk::Priv(data)": parent namespace doesn't exist
    while executing
    "catch {tk::EntryGetSelection $win} tk::Priv(data)"
    (procedure "::numentry::Snit_methodCopyVal" line 8)
    invoked from within ".vpan.main.workframe.detailsframe.sw.sf.mf.cf.measure.props.f.f5.y CopyVal"
    ("uplevel" body line 1)
    invoked from within
    "uplevel 1 [linsert $args 0 $self]"
    invoked from within
    "::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal"
    (command bound to event)
    *** ERROR STACK ***
    INNER:::snit::RT.CallInstance ::numentry::Snit_inst2 CopyVal
    UP:1

    *** END OF ERROR MESSAGE ***

    Is this a bug in Tcl 9.0.2?

    No, it's a consequence of TIP#278

    https://core.tcl-lang.org/tips/doc/trunk/tip/278.md

    This change is documented in the migration guide:

    https://core.tcl-lang.org/tcl/wiki?name=Migrating+scripts+to+Tcl+9

    In short, any non-fully qualified var name $var now resolves to
    [namespace current]::$var, while the old behaviour was to look in the
    current namespace, then in the global one for an already existing ::$var.

    Given the error message above, I assume you are running the line

    catch {tk::EntryGetSelection $win} tk::Priv(data)

    in a namespace that's not the global one.

    I don't think this happend in Tcl 8.

    This changed in 9.0

    Thanks
    Alex

    Regards
    --
    Emiliano <emiliano@example.invalid>
    --- Synchronet 3.21a-Linux NewsLink 1.2