Why this program crashes not because of typedef but because of using an uninitialized variable. Look at your code at line #6: You declared static test *p and, without allocating it, used in your int main() function.
On your second post, static test p should work of course because variable p is automatically allocated from the stack.
If you want to use a pointer to your test struct like test *p, you must allocated some memory for it either by using the new operator (as suggested by nullptr) or by any appropriate method.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: