When i am running my code, it says ‘repl process died unexpectedly: signal: killed’
I don’t undestand why this is happening.
import tkinter as tk
from tkinter import messagebox as msg
import time
import random
import savedata
load_from_save = 'n'
residential = False
Comercial = False
Industrial = False
# Initialize the default root window
root = tk.Tk()
grid_list = savedata.grid_list
class Buttons(tk.Button):
def __init__(self, row: int, column: int, window, load_from_save: str):
self.grass_image = tk.PhotoImage(file="Grass Birds eye.png")
self.residential_image = tk.PhotoImage(file="Residential building.png")
super().__init__(window, command=lambda: self.clicked(row, column), image=self.grass_image, width=50, height=31)
self.grid(row=row, column=column)
if load_from_save.lower() == 'y':
if (grid_list[row][column])["residential"] == True:
self.config(image=self.residential_image)
self.residential = False
grid_list[row].append({"Name": self, "row": row, "column": column, "residential":self.residential})
print(f"{time.time():<18} - Info - Button @ row {row} and column {column} has been created")
def clicked(self, row: int, column: int):
if residential == True:
self.config(image=self.residential_image)
print(f"{time.time():<18} - Info - Button @ row {row} and column {column} has been made residential")
self.residential = True
else:
print(f"{time.time():<18} - Info - Button @ row {row} and column {column} has been clicked")
def setup_game(prev_windows):
print("Hi")
window = tk.Toplevel(root) # Use Toplevel instead of Tk to create a new window
window.title("City Build It")
window.attributes('-fullscreen', True)
for row in range(10):
for column in range(20):
button = Buttons(row, column, window, load_from_save)
time.sleep(0.07)
residential_btn = tk.Button(window, text="Residential zone painter on", command= lambda: residential_painter(residential_btn))
residential_btn.grid(row=11, column=1, columnspan=4)
save_btn = tk.Button(window, text="Save progress", command=lambda: save())
save_btn.grid(row=12, column=1, columnspan=3)
prev_windows.destroy()
print(grid_list[0][2])
def save():
with open("savedata.py", "w") as f:
f.write("")
f.write(f"grid_list = {grid_list}")
def residential_painter(btn):
global residential
if residential == True:
residential = False
btn.config(text="Residential zone painter on")
elif residential == False:
residential = True
btn.config(text="Residential zone painter off")
def load():
global load_from_save
load_from_save = 'y'
def title_screen():
title = tk.Toplevel(root) # Use Toplevel instead of Tk to create a new window
title.title("City Build It")
background_img = tk.PhotoImage(file="City Build It Background.png")
background_label = tk.Label(title, image=background_img)
background_label.pack(fill=tk.BOTH, expand=True)
title.attributes("-fullscreen", True)
play_btn = tk.Button(title, text="Play", command=lambda: (\
play_btn.config(text="loading..."), \
title.after(5000, lambda: setup_game(title))))
play_btn.place(x=740, y=500) # Adjust the coordinates as needed
load_btn = tk.Button(title, text="Load", command=lambda: load())
load_btn.place(x=740, y=530)
title.mainloop()
title_screen()
My usages for this repl are:
- CPU - 48%
- RAM - 99
- Storage - 135
I am on the replit free plan. I have also included a link to the repl so you can test for yourself/
Repl