How can I make the turtle program wait for an event/response from user before running?

I’m trying to use the tkinter module to gain betting input for the minigame I created. However, whenever I run the program, both the tkinter and turtle modules run in sync. How can I make so that the turtle module code can wait till the user presses the button in the tkinter entry widget?

import random
import turtle
from tkinter import *



Bank_account = 0


def enter_input():

    global turtle_bet
    global bet_amount

    turtle_bet = user_turtle_bet.get()
    bet_amount = user_bet_amount.get()

    return turtle_bet, bet_amount
    
    


## Tkinter Entry Setup
tk = Tk()

user_turtle_bet = StringVar()
user_bet_amount = StringVar()

user_turtle_label = Label(tk, text="Turtle Bet", font=('Times', 13, 'bold'))
user_turtle_entry = Entry(tk, textvariable=user_turtle_bet, font=('Times', 13, 'normal'))

user_amount_label = Label(tk, text="Bet Amount", font=('Times', 13, 'bold'))
user_amount_entry = Entry(tk, textvariable=user_bet_amount, font=('Times', 13, 'normal'))

enter_button = Button(tk, text="ENTER", command=enter_input)

user_turtle_label.grid(row=0, column=0)
user_turtle_entry.grid(row=0, column=1)
user_amount_label.grid(row=1, column=0)
user_amount_entry.grid(row=1, column=1)
enter_button.grid(row=2, column=1)


## Turtle Game Setup
turtle.screensize(canvwidth=500, canvheight=500, bg="pink")
t = turtle.Pen()
s = turtle.Pen()

t.forward(50)
s.left(90)
s.forward(50)

Answer

As Matiiss said, place the turtle code inside a function and then call said function on user interaction. As an aside, if you are returning the values of turtle_bet and bet_amount, I would suspect declaring them as global variables is unecessary.

import turtle
from tkinter import *

Bank_account = 0


def turtle_stuff():
    ## Turtle Game Setup
    turtle.screensize(canvwidth=500, canvheight=500, bg="pink")
    t = turtle.Pen()
    s = turtle.Pen()

    t.forward(50)
    s.left(90)
    s.forward(50)



def enter_input():
    global turtle_bet # probably not necessary
    global bet_amount # probably not necessary

    turtle_bet = user_turtle_bet.get()
    bet_amount = user_bet_amount.get()
    turtle_stuff() # trigger the turtle code
    return turtle_bet, bet_amount


## Tkinter Entry Setup
tk = Tk()

user_turtle_bet = StringVar()
user_bet_amount = StringVar()

user_turtle_label = Label(tk, text="Turtle Bet", font=('Times', 13, 'bold'))
user_turtle_entry = Entry(tk, textvariable=user_turtle_bet, font=('Times', 13, 'normal'))

user_amount_label = Label(tk, text="Bet Amount", font=('Times', 13, 'bold'))
user_amount_entry = Entry(tk, textvariable=user_bet_amount, font=('Times', 13, 'normal'))

enter_button = Button(tk, text="ENTER", command=enter_input)

user_turtle_label.grid(row=0, column=0)
user_turtle_entry.grid(row=0, column=1)
user_amount_label.grid(row=1, column=0)
user_amount_entry.grid(row=1, column=1)
enter_button.grid(row=2, column=1)
tk.mainloop()