Пример #1
0
def solution_search_display_setup():

    title = "Solution Searching"
    SudokuPly.setDisplay(display_rtn, gb.Display_time)

    searching_mw = Toplevel()
    searching_mw.protocol("WM_DELETE_WINDOW", search_stop)
    searching_mw.title(title)
    x = 400
    y = 600
    searching_mw.geometry(f"+{x}+{y}")
    
    top_fr = Frame(searching_mw)
    top_fr.pack(side = 'top')
    c1 = Button(top_fr, 
        text = "Close",               # Guess one
        command = search_stop,
            )
    c1.pack(side = 'left')
    if gb.res_group.get("searching_board") is not None:
        gb.res_group.destroy("searching_board")
    data = SudokuData.vals2data(gb.main_puzzle)  
    searching_board = SudokuBoard(mw=searching_mw,
                            data = data,
                            bdWidth=gb.sSize*.8,
                            bdHeight=gb.sSize*.8,
                            initialData=gb.Initial_data,
                            puzzle=gb.main_puzzle
                            )
    searching_board.showData(force=True)
    gb.res_group.add(ResourceEntry(searching_board), name="searching_board")
    gb.main_puzzle.set_start_time()
Пример #2
0
def solve_main_puzzle_display(r_solution, title=None, nth=None, nsol=None):
    """ Add solution display
    :r_position of solution:
    :nth: ord positionof solution
    :nsol: Number of solutions
    """

    if title is not None:
        title = "Solution"
    if nsol is not None:
        nsol = 1

    mw = Toplevel()
    mw.protocol("WM_DELETE_WINDOW", search_stop)
    mw.title(title)
    x = 400
    y = 200
    x += 100 * nth
    y += 100 * nth
    mw.geometry(f"+{x}+{y}")
    # Find first empty slot, extending if necessary
    top_fr = Frame(mw)
    top_fr.pack(side='top')
    c1 = Button(
        top_fr,
        text="Close",  # Guess one
        command=[solve_puzzle_close, nth],
    )
    c1.pack(side='left')
    if nsol > 1:
        c2 = Button(
            top_fr,
            text="Close All",  # Close all
            command=solve_puzzle_close_all,
        )
        c2.pack(side='left')

    board = SudokuBoard(
        mw=mw,
        data=r_solution,
        bdWidth=g.sSize,
        bdHeight=g.sSize,
        initialData=g.Initial_data,
    )
    g.res_group.add(ResourceEntry(mw), number=nth)
    board.showData(force=True)