-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfgui.py
86 lines (54 loc) · 2.1 KB
/
confgui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import dearpygui.dearpygui as dpg
from config import Config as c,Temp as t
from gui import run
from multiprocessing import Process
from testGrids import Grids
import copy
from threading import Thread
from advsolve import findPossi
# Callbacks
def butcallback(sender, data):
basesize=dpg.get_value(name="Basesize")
sleeptime=dpg.get_value(name="Delay in ms")/1000
print(f"Basesize: {basesize}")
print(sleeptime)
def updateconfig(sender,data):
c.basesize=dpg.get_value("Basesize")
c.sleeptime=dpg.get_value("Delay in ms")/1000
def startPygame(sender,data):
if not t.pygameActive:
t.pygameActive=True
dpg.run_async_function("asyncrun",())
else:
print("Pygame is already running")
def asyncrun(s,d):
run()
def resetGrid(s=None,d=None):
t.currGrid = copy.deepcopy(Grids.gridBases[c.basesize]["Easy1"])
print(findPossi(t.currGrid))
def stopSudoku(s,d):
t.pygameActive=False
print("Pygame Stoping")
def clearGrid(s,d):
t.currGrid=grid = [[0 for i in range(c.basesize**2)]for j in range(c.basesize**2)]
def setGridone(s,d):
t.currGrid = copy.deepcopy(Grids.gridBases[c.basesize]["Easy1"])
def setupconfig():
dpg.set_main_window_size(600,300)
dpg.set_main_window_title("Sudoku Config")
dpg.add_text(name="Sudoku Config")
dpg.add_slider_int(name="Basesize",default_value=c.basesize,min_value=2,max_value=5,callback="updateconfig")
dpg.add_slider_float(name="Delay in ms",default_value=c.sleeptime*1000,min_value=0,max_value=400,callback="updateconfig")
# dpg.add_button(name="Print Values",callback="butcallback")
dpg.add_button(name="Start Solver",callback="startPygame")
dpg.add_same_line()
dpg.add_button(name="Stop Pygame",callback="stopSudoku")
dpg.add_button(name="Reset Grid",callback="resetGrid")
dpg.add_same_line()
dpg.add_button(name="Set a Grid",callback="setGridone")
# dpg.add_listbox(name="Grid Selection",items=Grids.gridBases[3])
def confguirun():
dpg.start_dearpygui()
if __name__ == "__main__":
setupconfig()
confguirun()