jeudi 6 septembre 2018

How do I run an if loop constantly?

I want to constantly run an if loop outside of my functions but I can't figure out how to do it. I made a mock up of the code here it is:

import tkinter
from tkinter import *

code = Tk()

T = 1
X = 0



def printx():
    global X
    print(X);
def teez():
    global T
    T = 0;
def teeo():
    global T
    T = 1;

if T == 1:
    X = 5
else:
    X = 6

button1 = Button(code, text = "Print X", command = printx)
button1.pack()
button2 = Button(code, text = "T = 0", command = teez)
button2.pack()
button2 = Button(code, text = "T = 1", command = teeo)
button2.pack()

code.mainloop()

I essentially want my if loop to change x based on what my functions do but the if loop seems to not run. How would I fix this?

Aucun commentaire:

Enregistrer un commentaire