0
import tkinter as tki
from deneme import Komutlar

obj=Komutlar()

panel.bind("w",obj.forward)

if obj.komutlar["w"] == "True":
    print("w")

panel.mainloop()

I made some changes to the code. I create an "Komutlar" object. When I press "w" printing "True". Here the Komutlar py:

class Komutlar():

    def __init__(self):
        self.komutlar={"w":"False","s":"False","a":"False","d":"False"}

def forward(self,event):

    self.komutlar["w"] = "True"
    print(self.komutlar["w"])

İt is working. But I want to make a action with if statement. İf statment still not working. İs it about mainloop again?

Coder123
  • 31
  • 1
  • 5

0 Answers0