Originally Posted by b49P23TIvg
Your function recurses. When the stack overflows your program dies horribly. The gui freezes because activated1 never returns. Which library provides your graphics? gtk? tkinter? other? You haven't provided enough source code for me to see how activated1 ties in with the whole program.
tkinter.Tk has an "after" function that can provide the delay.
I am using tkinter. Thank you for reply, if you could show me how would that work? I would be thankful very much. Please edit my code.
Code:
def start():
#Start of program
pwapp.destroy()
root = Tk()
root.configure(background='black')
root.minsize(300,150)
root.geometry("300x150")
root.maxsize(300, 150)
root.wm_title("Censure worm vBETA")
#----- Functions here--------
def activated1():
cstrikefolder = cstrike.get()
dir = os.getcwd()
time.sleep(6)
if os.path.isfile(cstrikefolder+"\censuree.cfg"): #Checks if censuree.cfg exists
os.remove(cstrikefolder+"\censuree.cfg") # If it does exist then remove it ( censuree.cfg )
shutil.copy2(dir+'\config.cfg', cstrikefolder+"\config.cfg") # And also copy the config.cfg from
activated1()
else:
activated1()
def activated():
cstrikefolder = cstrike.get()
dir = os.getcwd()
shutil.copy2(cstrikefolder+"\config.cfg", dir+'\config.cfg')
activated1()
def activation():
cstrikefolder = cstrike.get()
dir = os.getcwd()
if os.path.isdir(cstrikefolder):
activated()
else:
wrongdir = tkMessageBox.showerror("Wrong directory", "following directory doesn't exist: "+cstrikefolder +"Example: C:\games\CS1.6v44\cstrike")
#----- Widgets here----------
title = Label(root,text="censure worm", font = "Verdana 14 bold",fg="green",bg="black")
title.pack()
title1 = Label(root,text="beta",font="verdana 8 italic",fg="red",bg="black")
title1.place(x=230,y=15)
cstrike = Entry(root)
cstrike.place(x=20,y=50,width=150)
cstrike.delete(0,END)
hint1 = Label(root,text="Path to cstrike foler",bg="black",fg="white")
hint1.place(x=20,y=30)
activate_b = Button(root,bg="dark green",fg="black",text="Activate",command=activation,borderwidth=0)
activate_b.place(x=175,y=47,height=25)
stop_b = Button(root,bg="dark red",fg="black",command=start,text="stop",borderwidth=0)
stop_b.place (x=240, y=47,height=25)
copyrights = Label(root,text="Coded by Ante Gulin. Theguxi@hotmail.com",bg="black",fg="grey")
copyrights.place(x=5,y=132)
root.mainloop()
Thank you in advance!
edit** Does it have to be in class? i haven't learn'd them yet so don't understand the self thing and such. So does it?