Mar-31-2018, 09:34 AM
(This post was last modified: Mar-31-2018, 09:34 AM by Gribouillis.)
(Mar-31-2018, 09:18 AM)Zatox11 Wrote: but even after waiting for several minutes nothing happens.What happens if you run solvesudo.py alone? After some time it should raise SolutionFound and stop.
Also, based on this answer, you can try to put code in tksudo.py in a if __name__ == '__main__' block, for example
# tksudo.py if __name__ == '__main__': from tkinter import Tk, Frame, Entry, Label, Button, IntVar, StringVar, LEFT from tkinter import messagebox from tkcallasync import tk_call_async, MULTIPROCESSING import solvesudo def do_solve(sudoku): status = solvesudo.wsolve(sudoku) return status, sudoku disabled = False def execute_solver(): global disabled if disabled: messagebox.showinfo("warning", "It's still calculating...") return def callback(result): global disabled disabled = False status, sudoku = result solvesudo.printSUDOKU(sudoku) result_var.set('Found!' if status else 'Not Found!') disabled = True tk_call_async(root, do_solve, args=(solvesudo.sudoku,), callback=callback, method=MULTIPROCESSING) root = Tk() row = Frame(root) row.pack() Button(row, text="Solve Sudoku", command =execute_solver).pack(side=LEFT) Button(row, text="It's responsive", command= lambda: messagebox.showinfo("info", "it's responsive")).pack(side=LEFT) result_var = StringVar() Label(root, textvariable=result_var).pack() root.mainloop()