From your description, you have 3 files that have the same CreateGUI::init function and your main function must call one of those but you want to select which one based on filename. So :
file1.tcl :
namespace eval CreateGUI {
proc init { toplevel } {
button $toplevel.b1 -text "file1.tcl" -command { puts "file1" }
pack $toplevel.b1 -side top -fill both -expand 1
}
}
file2.tcl :
namespace eval CreateGUI {
proc init { toplevel } {
button $toplevel.b2 -text "file2.tcl" -command { puts "file2" }
pack $toplevel.b2 -side top -fill both -expand 1
}
}
file3.tcl :
namespace eval CreateGUI {
proc init { toplevel } {
button $toplevel.b3 -text "file3.tcl" -command { puts "file3" }
pack $toplevel.b3 -side top -fill both -expand 1
}
}
main.tcl:
package require Tk
set filename [lindex $argv 0 ] ; # first arg on command line note this is
# problematic on windows
proc GUI1 { file } {
toplevel .createGui1Dlg
source $file
CreateGUI::init .createGui1Dlg
}
GUI1 $filename
to run on commmandline : tclsh8.6 main.tcl file1.tcl