My code is not working out for some reason. But when I don't open my file in a function it will work. So I need help opening a python file in my menu file. Here is the code:
first file:
from tkinter import *
def Game():
mult = 1
clicks = 0
clickgame = Tk()
clickgame.geometry("500x500")
clickgame.title("Techno Clicker")
def buttonCommand():
global clicks
clicks += 1*(mult)
clickslabel.config(text=clicks)
def multiplyerX1():
global clicks
global mult
if clicks > 99:
clicks -= 100
mult += 1
clickslabel.config(text=clicks)
else:
lickslabel.config(text="Not Enough clicks")
def multiplyerX5():
global clicks
global mult
if clicks > 499:
clicks -= 500
mult += 5
clickslabel.config(text=clicks)
else:
clickslabel.config(text="Not Enough clicks")
def multiplyerX10():
global clicks
global mult
if clicks > 999:
clicks -= 1000
mult += 10
clickslabel.config(text=clicks)
else:
clickslabel.config(text="Not Enough clicks")
Background_btn = PhotoImage(file="/Users/PrivateInfo/Desktop/ClickImage-3.png")
clickslabel = Label(clickgame, text="0 Clicks")
clickButton = Button(clickgame, image=Background_btn, command=buttonCommand, borderwidth=0)
clickmultX1 = Button(clickgame, text="Buy Click Multiplyer x1 (Costs 100C)", command=multiplyerX1, padx = 10, pady = 5)
clickmultX5 = Button(clickgame, text="Buy Click Multiplyer x5 (Costs 500C)", command=multiplyerX5, padx = 10, pady = 5)
clickmultX10 = Button(clickgame, text="Buy Click Multiplyer x10 (Costs 10000C)", command=multiplyerX10, padx = 10, pady = 5)
clickslabel.pack()
clickButton.pack()
clickmultX1.pack()
clickmultX5.pack()
clickmultX10.pack()
clickgame.mainloop()
Second File:
from tkinter import *
import os
import sys
import ClickingGame
mult = 1
clicks = 0
menu = Tk()
q = 0
def firegame():
global q
ClickingGame.Game()
TitleLabel = Label(menu, text='Welcome To Techno Play')
GameLabel = Label(menu, text='Games:')
ClickingGameButton = Button(menu, text='Clicking Game', command=firegame)
TitleLabel.pack()
GameLabel.pack()
ClickingGameButton.pack()
Everytime I run this I get a error saying _tkinter.TclError: image "pyimage1
doesn't exist". But the first file runs fine if I run it alone. I am using python idle 3.8.2.