Fixed 'Undefined Offset' error in Tk.php