From 112fdb000f8632e92519ab4842b0ff340aec52ab Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 9 Nov 2020 10:47:08 +0000 Subject: Allow "package require tk" in addition to "package require Tk" --- doc/console.n | 2 +- generic/tkTest.c | 2 +- generic/tkWindow.c | 8 ++++++-- library/demos/square | 4 ++-- library/iconlist.tcl | 2 +- library/megawidget.tcl | 2 +- tests/all.tcl | 2 +- tests/constraints.tcl | 2 +- tests/safePrimarySelection.test | 2 +- tests/ttk/all.tcl | 2 +- tests/ttk/checkbutton.test | 2 +- tests/ttk/combobox.test | 2 +- tests/ttk/entry.test | 2 +- tests/ttk/image.test | 2 +- tests/ttk/labelframe.test | 2 +- tests/ttk/layout.test | 2 +- tests/ttk/notebook.test | 2 +- tests/ttk/panedwindow.test | 2 +- tests/ttk/progressbar.test | 2 +- tests/ttk/radiobutton.test | 2 +- tests/ttk/scrollbar.test | 2 +- tests/ttk/spinbox.test | 2 +- tests/ttk/treetags.test | 2 +- tests/ttk/treeview.test | 2 +- tests/ttk/ttk.test | 2 +- tests/ttk/validate.test | 2 +- tests/ttk/vsapi.test | 2 +- unix/Makefile.in | 9 ++++++--- unix/configure | 4 ++-- unix/configure.ac | 2 +- win/Makefile.in | 6 ++++-- win/makefile.vc | 6 ++++-- 32 files changed, 50 insertions(+), 39 deletions(-) diff --git a/doc/console.n b/doc/console.n index 40b7426..0a9a794 100644 --- a/doc/console.n +++ b/doc/console.n @@ -23,7 +23,7 @@ the \fBconsole\fR command. The behaviour of the console window is defined mainly through the contents of the \fIconsole.tcl\fR file in the Tk library. Except for TkAqua, this command is not available when Tk is loaded into a tclsh interpreter with -.QW "\fBpackage require Tk\fR" , +.QW "\fBpackage require tk\fR" , as a conventional terminal is expected to be present in that case. In TkAqua, this command is disabled when there is a startup script and stdin is \fB/dev/null\fR (as is the case e.g. when a bundled application diff --git a/generic/tkTest.c b/generic/tkTest.c index 4347600..0bab9a9 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -247,7 +247,7 @@ Tktest_Init( * Create additional commands for testing Tk. */ - if (Tcl_PkgProvideEx(interp, "Tktest", TK_PATCH_LEVEL, NULL) == TCL_ERROR) { + if (Tcl_PkgProvideEx(interp, "tk::test", TK_PATCH_LEVEL, NULL) == TCL_ERROR) { return TCL_ERROR; } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index eb8e928..da895a6 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3283,10 +3283,14 @@ Initialize( } /* - * Provide Tk and its stub table. + * Provide "tk" and its stub table. */ - code = Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL, +#ifndef TK_NO_DEPRECATED + Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL, + (ClientData) &tkStubs); +#endif + code = Tcl_PkgProvideEx(interp, "tk", TK_PATCH_LEVEL, (ClientData) &tkStubs); if (code != TCL_OK) { goto done; diff --git a/library/demos/square b/library/demos/square index 9f200ba..ee6dd31 100644 --- a/library/demos/square +++ b/library/demos/square @@ -11,8 +11,8 @@ exec wish "$0" ${1+"$@"} # Button-1 press/drag: moves square to mouse # "a": toggle size animation on/off -package require Tk ;# We use Tk generally, and... -package require Tktest ;# ... we use the square widget too. +package require tk ;# We use Tk generally, and... +package require tk::test ;# ... we use the square widget too. square .s pack .s -expand yes -fill both diff --git a/library/iconlist.tcl b/library/iconlist.tcl index 0dddebc..fb372a3 100644 --- a/library/iconlist.tcl +++ b/library/iconlist.tcl @@ -26,7 +26,7 @@ # selection includes # selection set ?? -package require Tk +package require tk ::tk::Megawidget create ::tk::IconList ::tk::FocusableWidget { variable w canvas sbar accel accelCB fill font index \ diff --git a/library/megawidget.tcl b/library/megawidget.tcl index c09d0da..ff7b2ce 100644 --- a/library/megawidget.tcl +++ b/library/megawidget.tcl @@ -10,7 +10,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. # -package require Tk +package require tk ::oo::class create ::tk::Megawidget { superclass ::oo::class diff --git a/tests/all.tcl b/tests/all.tcl index 46721a2..c6b50d3 100644 --- a/tests/all.tcl +++ b/tests/all.tcl @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require Tk ;# This is the Tk test suite; fail early if no Tk! +package require tk ;# This is the Tk test suite; fail early if no Tk! package require tcltest 2.2 tcltest::configure {*}$argv tcltest::configure -testdir [file normalize [file dirname [info script]]] diff --git a/tests/constraints.tcl b/tests/constraints.tcl index ee073cf..a89605a 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -5,7 +5,7 @@ if {[namespace exists tk::test]} { return } -package require Tk +package require tk tk appname tktest wm title . tktest # If the main window isn't already mapped (e.g. because the tests are diff --git a/tests/safePrimarySelection.test b/tests/safePrimarySelection.test index 713eedc..366c2bf 100644 --- a/tests/safePrimarySelection.test +++ b/tests/safePrimarySelection.test @@ -63,7 +63,7 @@ proc ::_test_tmp::unsafeInterp {name} { set ::_test_tmp::script { - package require Tk + package require tk namespace eval ::_test_tmp {} proc ::_test_tmp::getPrimarySelection {} { diff --git a/tests/ttk/all.tcl b/tests/ttk/all.tcl index 8a75ba7..071674b 100644 --- a/tests/ttk/all.tcl +++ b/tests/ttk/all.tcl @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require Tk ;# This is the Tk test suite; fail early if no Tk! +package require tk ;# This is the Tk test suite; fail early if no Tk! package require tcltest 2.2 tcltest::configure {*}$argv tcltest::configure -testdir [file normalize [file dirname [info script]]] diff --git a/tests/ttk/checkbutton.test b/tests/ttk/checkbutton.test index 39a6e35..9c58a7b 100644 --- a/tests/ttk/checkbutton.test +++ b/tests/ttk/checkbutton.test @@ -2,7 +2,7 @@ # ttk::checkbutton widget tests. # -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/combobox.test b/tests/ttk/combobox.test index 48179f3..dd1a7f9 100644 --- a/tests/ttk/combobox.test +++ b/tests/ttk/combobox.test @@ -2,7 +2,7 @@ # ttk::combobox widget tests # -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test index 501bad6..7e3fe88 100644 --- a/tests/ttk/entry.test +++ b/tests/ttk/entry.test @@ -2,7 +2,7 @@ # Tile package: entry widget tests # -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/image.test b/tests/ttk/image.test index bb593fc..51f0f00 100644 --- a/tests/ttk/image.test +++ b/tests/ttk/image.test @@ -1,4 +1,4 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/labelframe.test b/tests/ttk/labelframe.test index 9ffffd8..3bbf584 100644 --- a/tests/ttk/labelframe.test +++ b/tests/ttk/labelframe.test @@ -1,4 +1,4 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/layout.test b/tests/ttk/layout.test index 5dfce9b..31ef1f5 100644 --- a/tests/ttk/layout.test +++ b/tests/ttk/layout.test @@ -1,4 +1,4 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test index e58812a..50047cf 100644 --- a/tests/ttk/notebook.test +++ b/tests/ttk/notebook.test @@ -1,4 +1,4 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/panedwindow.test b/tests/ttk/panedwindow.test index 528d56b..e45a3a9 100644 --- a/tests/ttk/panedwindow.test +++ b/tests/ttk/panedwindow.test @@ -1,4 +1,4 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/progressbar.test b/tests/ttk/progressbar.test index 8e2fdb9..ac8bbf1 100644 --- a/tests/ttk/progressbar.test +++ b/tests/ttk/progressbar.test @@ -1,4 +1,4 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/radiobutton.test b/tests/ttk/radiobutton.test index 09abcb8..9140805 100644 --- a/tests/ttk/radiobutton.test +++ b/tests/ttk/radiobutton.test @@ -2,7 +2,7 @@ # ttk::radiobutton widget tests. # -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/scrollbar.test b/tests/ttk/scrollbar.test index 75d11e7..1ee63a3 100644 --- a/tests/ttk/scrollbar.test +++ b/tests/ttk/scrollbar.test @@ -1,4 +1,4 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index 673f3bf..a2b8558 100644 --- a/tests/ttk/spinbox.test +++ b/tests/ttk/spinbox.test @@ -2,7 +2,7 @@ # ttk::spinbox widget tests # -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/treetags.test b/tests/ttk/treetags.test index d7fa23a..428212b 100644 --- a/tests/ttk/treetags.test +++ b/tests/ttk/treetags.test @@ -1,5 +1,5 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index 8e31fe9..3000d95 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -3,7 +3,7 @@ # what it currently does) # -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index fdd3eae..dee3179 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -1,5 +1,5 @@ -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/tests/ttk/validate.test b/tests/ttk/validate.test index 5430903..8b48d2a 100644 --- a/tests/ttk/validate.test +++ b/tests/ttk/validate.test @@ -3,7 +3,7 @@ ## Derived from core test suite entry-19.1 through entry-19.20 ## -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* diff --git a/tests/ttk/vsapi.test b/tests/ttk/vsapi.test index ec4e9e7..076a815 100644 --- a/tests/ttk/vsapi.test +++ b/tests/ttk/vsapi.test @@ -1,7 +1,7 @@ # -*- tcl -*- # -package require Tk +package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands diff --git a/unix/Makefile.in b/unix/Makefile.in index edf0587..e35209f 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -730,13 +730,16 @@ install-binaries: $(TK_STUB_LIB_FILE) $(TK_LIB_FILE) ${WISH_EXE} echo "if {[catch {package present Tcl 8.6-}]} return";\ relative=`echo | awk '{ORS=" "; split("$(TK_PKG_DIR)",a,"/"); for (f in a) {print ".."}}'`;\ if test "x$(DLL_INSTALL_DIR)" != "x$(BIN_INSTALL_DIR)"; then \ - echo "package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE)]] Tk]";\ + echo "package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE)]]]";\ + echo "package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE)]]]";\ else \ echo "if {(\$$::tcl_platform(platform) eq \"unix\") && ([info exists ::env(DISPLAY)]";\ echo " || ([info exists ::argv] && (\"-display\" in \$$::argv)))} {";\ - echo " package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin $(TK_LIB_FILE)]] Tk]";\ + echo " package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin $(TK_LIB_FILE)]]]";\ + echo " package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin $(TK_LIB_FILE)]]]";\ echo "} else {";\ - echo " package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin tk${MAJOR_VERSION}${MINOR_VERSION}.dll]] Tk]";\ + echo " package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin tk${MAJOR_VERSION}${MINOR_VERSION}.dll]]]";\ + echo " package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin tk${MAJOR_VERSION}${MINOR_VERSION}.dll]]]";\ echo "}";\ fi \ ) > "$(PKG_INDEX)"; \ diff --git a/unix/configure b/unix/configure index e942099..674cdee 100755 --- a/unix/configure +++ b/unix/configure @@ -6604,10 +6604,10 @@ fi if test "$TCL_PREFIX" != "$prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Different --prefix selected for Tk and Tcl! - [package require Tk] may not work correctly in tclsh." >&5 + [package require tk] may not work correctly in tclsh." >&5 $as_echo "$as_me: WARNING: Different --prefix selected for Tk and Tcl! - [package require Tk] may not work correctly in tclsh." >&2;} + [package require tk] may not work correctly in tclsh." >&2;} fi #-------------------------------------------------------------------- diff --git a/unix/configure.ac b/unix/configure.ac index 3c3d427..5bac7e4 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -145,7 +145,7 @@ fi if test "$TCL_PREFIX" != "$prefix"; then AC_MSG_WARN([ Different --prefix selected for Tk and Tcl! - [[package require Tk]] may not work correctly in tclsh.]) + [[package require tk]] may not work correctly in tclsh.]) fi #-------------------------------------------------------------------- diff --git a/win/Makefile.in b/win/Makefile.in index c4744f1..71cccc9 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -488,9 +488,11 @@ install-binaries: binaries echo "if {[catch {package present Tcl 8.6-}]} return";\ echo "if {(\$$::tcl_platform(platform) eq \"unix\") && ([info exists ::env(DISPLAY)]";\ echo " || ([info exists ::argv] && (\"-display\" in \$$::argv)))} {";\ - echo " package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtk$(VERSION).dll]] Tk]";\ + echo " package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtk$(VERSION).dll]]]";\ + echo " package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtk$(VERSION).dll]]]";\ echo "} else {";\ - echo " package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin $(TK_DLL_FILE)]] Tk]";\ + echo " package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin $(TK_DLL_FILE)]]]";\ + echo " package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin $(TK_DLL_FILE)]]]";\ echo "}";\ ) > $(PKG_INDEX); @for i in tkConfig.sh $(TK_LIB_FILE) $(TK_STUB_LIB_FILE); \ diff --git a/win/makefile.vc b/win/makefile.vc index 56c9dea..73474b0 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -668,9 +668,11 @@ install-binaries: if {[catch {package present Tcl 8.6-}]} { return } if {($$::tcl_platform(platform) eq "unix") && ([info exists ::env(DISPLAY)] || ([info exists ::argv] && ("-display" in $$::argv)))} { - package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin libtk$(DOTVERSION).dll] Tk] + package ifneeded tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin libtk$(DOTVERSION).dll]] + package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin libtk$(DOTVERSION).dll]] } else { - package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin $(TKLIBNAME)] Tk] + package ifneeded tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin $(TKLIBNAME)]] + package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin $(TKLIBNAME)]] } << @$(CPY) $(OUT_DIR)\pkgIndex.tcl "$(SCRIPT_INSTALL_DIR)\" -- cgit v0.12