Python Forum
code is not working , can anybody help?
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code is not working , can anybody help?
#1
so, i was making a tic-tac toe program with tkinter . but when i open the program,and press a button;main window dont change.
here is the code:
import tkinter
play = 1


def playermove(buton,x1,y1):
    if play == 1:
        play = 2
        buton = tkinter.Label(text='            X\n            ',command='',fg='white',bg='black')
        buton.place(x=x1,y=y1)
    elif play == 2:
        play = 1
        button = tkinter.Label(text='            O\n            ',command='',fg='white',bg='black')
        buton.place(x=x1,y=y1)


pencere = tkinter.Tk()
pencere.title('tic tac toe')
pencere.geometry("100x100+250+120")
pencere.configure(bg="green")

kare1 = tkinter.Button(text='             \n            ',command='playermove(kare1,0,0)',fg='yellow',bg='red')
kare2 = tkinter.Button(text='             \n            ',command='playermove(kare2,40,0)',fg='yellow',bg='red')
kare3 = tkinter.Button(text='             \n            ',command='playermove(kare3,80,0)',fg='yellow',bg='red')
kare4 = tkinter.Button(text='             \n            ',command='playermove(kare4,0,30)',fg='yellow',bg='red')
kare5 = tkinter.Button(text='             \n            ',command='playermove(kare5,40,30)',fg='yellow',bg='red')
kare6 = tkinter.Button(text='             \n            ',command='playermove(kare6,80,30)',fg='yellow',bg='red')
kare7 = tkinter.Button(text='             \n            ',command='playermove(kare7,0,60)',fg='yellow',bg='red')
kare8 = tkinter.Button(text='             \n            ',command='playermove(kare8,40,60)',fg='yellow',bg='red')
kare9 = tkinter.Button(text='             \n            ',command='playermove(kare9,80,60)',fg='yellow',bg='red')

kare1.place(x=0,y=0)
kare2.place(x=40,y=0)
kare3.place(x=80,y=0)
kare4.place(x=0,y=30)
kare5.place(x=40,y=30)
kare6.place(x=80,y=30)
kare7.place(x=0,y=60)
kare8.place(x=40,y=60)
kare9.place(x=80,y=60)

pencere.mainloop()
Reply


Messages In This Thread
code is not working , can anybody help? - by RandomPerson69 - Mar-22-2021, 11:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  New to Python - Not sure why this code isn't working - Any help appreciated TheGreatNinx 4 970 Jul-22-2023, 10:21 PM
Last Post: Pedroski55
  code not working when executed from flask app ThomasDC 1 897 Jul-18-2023, 07:16 AM
Last Post: ThomasDC
  I am new to python and Could someone please explain how this below code is working? kartheekdas 2 1,017 Dec-19-2022, 05:24 PM
Last Post: kartheekdas
Exclamation My code is not working as I expected and I don't know why! Marinho 4 1,085 Oct-13-2022, 08:09 PM
Last Post: deanhystad
  My Code isn't working... End3r 4 1,941 Mar-21-2022, 10:12 AM
Last Post: End3r
  I don't undestand why my code isn't working. RuyCab 2 1,998 Jun-17-2021, 03:06 PM
Last Post: RuyCab
  Short code for EventGhost not working Patricia 8 3,704 Feb-09-2021, 07:49 PM
Last Post: Patricia
  Code no longer working yk303 14 10,228 Dec-21-2020, 10:58 PM
Last Post: bowlofred
  autocomplete working code sample not working... aviper4u 0 1,647 Oct-24-2020, 03:04 AM
Last Post: aviper4u
  code not working, NameError: name 's' is not defined ridgerunnersjw 4 3,833 Oct-05-2020, 07:03 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020