Main code:
import tkinter as tk
import time as t
import threading as th
count = 0
cursors = 0
cursorprice = 20
def addcookie():
global count, sent
count += 1
sent = "You own " + str(count) + " cookies"
c['text'] = sent
def addcursor():
global cursorprice, count, cursors
if count >= cursorprice:
count -= cursorprice
cursorprice += 10
cursors += 1
sent = "You own " + str(cursors) + " cursors"
cursor['text'] = sent
btn2['text'] = "Press for cursors" + "Price:" + str(cursorprice)
sent = "You own " + str(count) + " cookies"
c['text'] = sent
else:
btn2['text'] = "Not enough cookies!"
t.sleep(1)
btn2['text'] = "Press for cursors " + "Price:" + str(cursorprice)
sent = "You own " + str(count) + " cookies"
c['text'] = sent
def Ccheck():
while True:
t.sleep(10)
for i in range(cursors):
addcookie()
t1 = th.Thread(target=Ccheck)
t1.start()
root = tk.Tk()
root.title("Cookie Clicker Replica")
root.geometry('1920x1080')
btn = tk.Button(root, text="Press for Cookies", width=30, height=2, bg='brown', command=addcookie)
btn.place(x=0, y=0)
btn2 = tk.Button(root, text="Press for cursors" + "Price:20", width=30, height=2, command=addcursor)
btn2.pack(side='left', padx=10, pady=20)
c = tk.Label(root, text="You own 0 cookies")
cursor = tk.Label(root, text="You own 0 cursors")
skipline = tk.Label(root, text=" ")
btn.pack()
c.pack()
skipline.pack()
btn2.pack()
cursor.pack()
root.mainloop()
The .place() and .pack() functions both don't work on my button attributes I've tried everything like padx, ipadx, x, relx, and nothing works. I'm trying to line up the buttons close to the left side
I literally copied a code online and it works perfectly fine, so I copied its format and still failed The code online and how it should look like
import tkinter as tk
app = tk.Tk()
app.geometry('300x300')
labelA = tk.Label(app, text = "Label (0, 0)", fg="blue", bg="#FF0")
labelB = tk.Label(app, text = "Label (20, 20)", fg="green", bg="#300")
labelC = tk.Label(app, text = "Label (40, 50)", fg="black", bg="#f03")
labelD = tk.Label(app, text = "Label (0.5, 0.5)", fg="orange", bg="#0ff")
labelA.place(x=0, y=0)
labelB.place(x=20, y=20)
labelC.place(x=40, y=50)
labelD.place(relx=0.5, rely=0.5)
app.mainloop()
How it should look like is that every single attribute is placed according to the coordinates provided