Isn't it enough just using remove_tab method?
If not, and you need to simulate a click on a button:
Lets think you connect your "my_button" button like this:
my_button.connect("button_down",self,"on_button_click")
And you have the "on button click" function:
func on_button_click():
print("hello")
First create an InputEventAction and set an action name you are not using in your InputMaps, for example "custom_action", and set it pressed:
var ie = InputEventAction.new()
ie.action = "custom_action"
ie.pressed = true
Then parse it to Input to be handled:
Input.parse_input_event(ie)
Now in the button, override input method and make it emit the "button down" signal that you connected to the method that handles the button click, when the "custom_action" event reaches Input:
func _input(event):
if event.is_action_pressed("custom_action"):
emit_signal("button_down")
That's all, every time you want to emulate the click, parse the custom event to Input.
EDIT: Well, you actually need to register the action in the InputMap on your project setting to avoid errors on debug.