Change names of variables to make lines shorter
This commit is contained in:
parent
5815e82160
commit
c4adddb94b
16
main.py
16
main.py
|
@ -51,30 +51,30 @@ def start_game(rows, cols, mines):
|
||||||
|
|
||||||
def play_pressed(option_box):
|
def play_pressed(option_box):
|
||||||
try:
|
try:
|
||||||
row_input = int(option_box.children['!frame'].children['!spinbox'].get())
|
rows = int(option_box.children['!frame'].children['!spinbox'].get())
|
||||||
col_input = int(option_box.children['!frame2'].children['!spinbox'].get())
|
cols = int(option_box.children['!frame2'].children['!spinbox'].get())
|
||||||
mine_input = int(option_box.children['!frame3'].children['!spinbox'].get())
|
mines = int(option_box.children['!frame3'].children['!spinbox'].get())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
messagebox.showerror("Input Error", "Please enter whole numbers!")
|
messagebox.showerror("Input Error", "Please enter whole numbers!")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (5 <= row_input <= 99) or not (5 <= col_input <= 99):
|
if not (5 <= rows <= 99) or not (5 <= cols <= 99):
|
||||||
messagebox.showerror("Input Error",
|
messagebox.showerror("Input Error",
|
||||||
"Rows and columns must be between 5 and 99")
|
"Rows and columns must be between 5 and 99")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (1 <= mine_input):
|
if not (1 <= mines):
|
||||||
messagebox.showerror("Input Error", "There must be at least one mine")
|
messagebox.showerror("Input Error", "There must be at least one mine")
|
||||||
return
|
return
|
||||||
|
|
||||||
max_mines = row_input * col_input - 1
|
max_mines = rows * cols - 1
|
||||||
if mine_input > max_mines:
|
if mines > max_mines:
|
||||||
messagebox.showerror("Input Error",
|
messagebox.showerror("Input Error",
|
||||||
"Board is too small for this many mines!")
|
"Board is too small for this many mines!")
|
||||||
return
|
return
|
||||||
|
|
||||||
option_box.destroy()
|
option_box.destroy()
|
||||||
start_game(row_input, col_input, mine_input)
|
start_game(rows, cols, mines)
|
||||||
|
|
||||||
# These lines will not execute until the game is over
|
# These lines will not execute until the game is over
|
||||||
play_again_box = tkinter.Tk()
|
play_again_box = tkinter.Tk()
|
||||||
|
|
Loading…
Reference in New Issue