Sure, you can do that in code. Here's an example, though you'll likely need to season it to taste based on your code strucuture.
$TextureRect.connect("mouse_entered", self, "_on_mouse_entered")
$TextureRect.connect("mouse_exited", self, "_on_mouse_exited")
Here, I'm referencing a
TextureRect instance that I created in the editor, but it doesn't matter. Just replace my
$TextureRect with your code-created reference.