Exemplo n.º 1
0
h = bs_in + 100

g.nSol = None  # Solution window number

g.top_fr = Frame(mw)
g.top_fr.pack(side='top')
control_fr = Frame(g.top_fr)
control_fr.pack(side='top')
app = SelectWindow(
    g.Display_mw,
    title="Playing Sudoku",
    arrange_selection=False,
    pgmExit=prime_exit,
    file_open=file_open,
)
app.add_menu_command("Puzzle", file_open)  # Dedicated puzzle menu item
app.add_menu_command("Contols", set_controls)  # Display variable controls
mw.geometry(f"{w}x{h}")
mw.update()

solve_puzzle = Button(
    control_fr,
    text="Solve Puzzle",  # Guess all remaining
    command=solve_main_puzzle,
)
solve_puzzle.pack(side='left')

make_puzzle_b = Button(
    control_fr,
    text="Make Puzzle",
    command=make_puzzle,
Exemplo n.º 2
0
def setup_app():
    """ Setup / Resetup app window
    :returns: app reference
    """
    global app, first_set_app
    global mw, width, height
    global run_resets, min_xlen, nx, ny, loop, loop_after, show_ties 
    global speed_step
    global first_app_set
    global board_change

        
    if first_set_app:
        app = SelectWindow(mw,
                        title="Dots",
                        pgmExit=play_exit,
                        cmd_proc=True,
                        cmd_file=None,
                        file_open=file_open,
                        file_save=file_save,
                        arrange_selection=False,
                        game_control=game_control
                        )
        app.add_menu_command("CmdFile", cmd_file)
        app.add_menu_separator()
        app.add_menu_command("NewGame", new_game)
        app.add_menu_separator()
        app.add_menu_command("Run", run_cmd)
        app.add_menu_command("Pause", pause_cmd)
        app.add_menu_command("Step", step_cmd)
        app.add_menu_separator()
        app.add_menu_separator()
        app.add_menu_command("Players", show_players_window)
        app.add_menu_command("Game Control", show_score_window)
        app.add_menu_command("Score", show_score_window)
    
        if is_in_pgm_args("loop"):
            game_control.set_prop_val("running.loop", loop)
        else:
            loop = game_control.get_prop_val("running.loop", loop)
            
        if is_in_pgm_args("loop_after"):
            game_control.set_prop_val("running.loop_after", loop_after)
        else:
            loop_after = game_control.get_prop_val("running.loop_after", loop_after)
            
        if is_in_pgm_args("run_resets"):
            game_control.set_prop_val("scoring.run_resets", run_resets)
        else:
            run_resets = game_control.get_prop_val("scoring.run_resets", run_resets)
            
        if is_in_pgm_args("show_ties"):
            game_control.set_prop_val("scoring.show_ties", show_ties)
        else:
            show_ties = game_control.get_prop_val("scoring.show_ties", show_ties)
            
        if is_in_pgm_args("speed_step"):
            game_control.set_prop_val("running.speed_step", speed_step)
        else:
            speed_step = game_control.get_prop_val("running.speed_step", speed_step)
            
        if is_in_pgm_args("min_xlen"):
            game_control.set_prop_val("viewing.min_xlen", min_xlen)
        else:
            min_xlen = game_control.get_prop_val("viewing.min_xlen", min_xlen)
            
        if is_in_pgm_args("nx"):
            game_control.set_ctl("viewing.columns", nx)
        else:
            nx = game_control.get_prop_val("viewing.columns", nx)
            
        if is_in_pgm_args("ny"):
            game_control.set_ctl("viewing.rows", ny)
        else:
            ny = game_control.get_prop_val("viewing.rows", ny)

    loop = game_control.get_prop_val("running.loop", loop)
    loop_after = game_control.get_prop_val("running.loop_after", loop_after)
    speed_step = game_control.get_prop_val("running.speed_step", speed_step)
    run_resets = game_control.get_prop_val("scroring.run_resets", run_resets)
    show_ties = game_control.get_prop_val("scoring.show_ties", show_ties)
    min_xlen = game_control.get_prop_val("viewing.min_xlen", min_xlen)    
    nx = game_control.get_prop_val("viewing.columns", nx)    
    ny = game_control.get_prop_val("viewing.rows", ny)
            
    if not is_in_pgm_args("width"):        
        width = app.get_current_val("window_width", width)
        if width < 100:
            width = 100
    width = int(width)
    if not is_in_pgm_args("height"):
        height = app.get_current_val("window_height", height)
        if height < 100:
            height = 100
    height = int(height)
    
    if not is_in_pgm_args("nx"):
        nx = app.get_current_val("figure_columns", nx)
    if not is_in_pgm_args("ny"):
        ny = app.get_current_val("figure_rows", ny)
        

        
        
    return app
Exemplo n.º 3
0
def cmd_file():
    """ Setup command file processing
    """
    CommandFile(title="Command File", cmd_execute=sp.user_cmd)


def run_cmd():
    """ Run / continue game
	"""
    global sp
    if sp is not None:
        sp.run_cmd()


def pause_cmd():
    """ Pause game
	"""
    global sp
    if sp is not None:
        sp.pause_cmd()


app.add_menu_command("NewGame", new_game)
app.add_menu_command("Players", change_players)
app.add_menu_command("Score", show_score_window)
app.add_menu_command("CmdFile", cmd_file)
app.add_menu_command("Run", run_cmd)
app.add_menu_command("Pause", pause_cmd)
set_squares_button()

mainloop()
Exemplo n.º 4
0
def setup_app(app_old):
    """ Setup / Resetup app window
    :app: current app instance
    :returns: new app reference
    """
    global first_set_app
    global mw, width, height, game_control
    global run_resets, min_xlen, nx, ny, loop, loop_after, show_ties 
    global speed_step
    global first_app_set
    
    if game_control is not None:
        game_control.destroy()
        game_control = None
            
    if app_old is not None:
        app_old.destroy()
        ###return app_old
        
    app = SelectWindow(mw,
                    title="crs_squares",
                    pgmExit=play_exit,
                    cmd_proc=True,
                    cmd_file=None,
                    arrange_selection=False
                    )
    
    game_control = app.get_game_control()
    if first_set_app:
        if is_in_pgm_args("loop"):
            game_control.set_prop_val("running.loop", loop)
        else:
            loop = game_control.get_prop_val("running.loop", loop)
            
        if is_in_pgm_args("loop_after"):
            game_control.set_prop_val("running.loop_after", loop_after)
        else:
            loop_after = game_control.get_prop_val("running.loop_after", loop_after)
            
        if is_in_pgm_args("run_resets"):
            game_control.set_prop_val("scoring.run_resets", run_resets)
        else:
            run_resets = game_control.get_prop_val("scoring.run_resets", run_resets)
            
        if is_in_pgm_args("show_ties"):
            game_control.set_prop_val("scoring.show_ties", show_ties)
        else:
            show_ties = game_control.get_prop_val("scoring.show_ties", show_ties)
            
        if is_in_pgm_args("speed_step"):
            game_control.set_prop_val("running.speed_step", speed_step)
        else:
            speed_step = game_control.get_prop_val("running.speed_step", speed_step)
            
        if is_in_pgm_args("min_xlen"):
            game_control.set_prop_val("viewing.min_xlen", min_xlen)
        else:
            min_xlen = game_control.get_prop_val("viewing.min_xlen", min_xlen)
            
        if is_in_pgm_args("nx"):
            game_control.set_ctl("viewing.columns", nx)
        else:
            nx = game_control.get_prop_val("viewing.columns", nx)
            
        if is_in_pgm_args("ny"):
            game_control.set_ctl("viewing.rows", ny)
        else:
            ny = game_control.get_prop_val("viewing.rows", ny)
    else:
        loop = game_control.get_prop_val("running.loop", loop)
        loop_after = game_control.get_prop_val("running.loop_after", loop_after)
        speed_step = game_control.get_prop_val("running.speed_step", speed_step)
        run_resets = game_control.get_prop_val("scroring.run_resets", run_resets)
        show_ties = game_control.get_prop_val("scoring.show_ties", show_ties)
        min_xlen = game_control.get_prop_val("viewing.min_xlen", min_xlen)    
        nx = game_control.get_prop_val("viewing.columns", nx)    
        ny = game_control.get_prop_val("viewing.rows", ny)
            
    if not is_in_pgm_args("width"):        
        width = app.get_current_val("window_width", width)
        if width < 100:
            width = 100
    width = int(width)
    if not is_in_pgm_args("height"):
        height = app.get_current_val("window_height", height)
        if height < 100:
            height = 100
    height = int(height)
    
    if not is_in_pgm_args("nx"):
        nx = app.get_current_val("figure_columns", nx)
    if not is_in_pgm_args("ny"):
        ny = app.get_current_val("figure_rows", ny)
        

    
    app.add_menu_command("NewGame", new_game)
    app.add_menu_command("Players", show_players_window)
    app.add_menu_command("Score", show_score_window)
    app.add_menu_command("CmdFile", cmd_file)
    app.add_menu_command("Run", run_cmd)
    app.add_menu_command("Pause", pause_cmd)
        
        
    return app