0

I am trying to display some textvariables that live update as it is a sort of currency system, but where they are there is just blank space. The label exists and can display text normally, but when i display any text variable, nothing comes up.

import tkinter as tk
from tkinter import *
import os


def raise_frame(frame):
    frame.tkraise()


root = tk.Tk()
root.geometry('300x500')
root.title('o')

rootg = tk.Tk()
rootg.geometry('300x500')
rootg.title('o')

roots = tk.Tk()
roots.geometry('300x500')
roots.title('o')


f1 = tk.Frame(root)
f2 = tk.Frame(rootg)
s = tk.Frame(roots)

root.resizable(width=False, height=False)
rootg.resizable(width=False, height=False)
roots.resizable(width=False, height=False)

for frame in (f1, f2, s):
    frame.grid(row=3000, column=2000, sticky='news')


clicks = IntVar()
inc = IntVar()


def increase(event=None):
    inc.set(inc.get() + 1)


def clicked(event=None):
   clicks.set(clicks.get() + inc.get())

#img = PhotoImage(file='Assets\c.png')
#gc = tk.Label(f2,image=img).place(x=10, y=10)


#game frame
gl = tk.Label(rootg, width=5, height=5, text='Game', fg="dark green").place(x=270, y=10, anchor='c')
b3 = tk.Button(rootg, width=15, height=5,  text='Return to menu', fg="dark green", bg="white", command=lambda:[rootg.withdraw(), root.deiconify()]).place(x=175, y=410)
b4 = tk.Button(rootg, width=15, height=5, text='Go to the shop', fg="dark green", bg="white", command=lambda:[roots.deiconify(), root.withdraw()]).place(x=10, y=410)
ic = tk.Button(rootg, width=10, height=5, text="Increase", command=clicked, fg="dark green", bg="white").place(x=150, y=300, anchor='c')
ca = tk.Label(rootg, width=5, height=5, textvariable=clicks.get(), fg="dark green").place(x=150, y=100, anchor='c')

#shop frame
st = tk.Label(roots, width=6, height=5, text='The shop', fg="dark green").place(x=270, y=10, anchor='c')
s1 = tk.Button(roots, width=15, height=5, text='Return', fg="dark green", bg="white", command=lambda:[rootg.deiconify(), roots.withdraw()]).place(x=175, y=410)
bb1 = tk.Button(roots, width=15, height=5, text="Test (+2 ppc)", command=increase, fg="dark green", bg="white").place(x=1, y=50)
ds = tk.Label(roots, width=5, height=5, textvariable=clicks.get(), fg="dark green").place(x=175, y=150, anchor = 'c')
mp = tk.Label(roots, width=5, height=5, textvariable=inc.get(), fg="dark green").place(x=175, y=100, anchor='c')

(This isnt all the code, just the bits involving the issue because stackoverflow ownt let me post it)

  • 2
    don't use multiple instances of `Tk`, use `Toplevel` for additional windows, that is your main issue – Matiiss Dec 03 '21 at 13:51

0 Answers0