Skip to content

Commit

Permalink
Format code with autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
garious committed Nov 22, 2016
1 parent 7a3af22 commit d1e3e26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 16 additions & 13 deletions refbox/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

_font_name = 'Consolas'


def sized_frame(master, height, width):
F = tk.Frame(master, height=height, width=width)
F.pack_propagate(0) # Don't shrink
F.pack_propagate(0) # Don't shrink
F.pack()
return F

Expand All @@ -26,7 +27,7 @@ def SizedLabel(root, var, bg, fg, font, height, width):
def SizedButton(root, callback, text, bg, fg, font, height, width):
style = ttk.Style()
style.configure("Sized.TButton", foreground=fg, background=bg, highlightthickness=4,
highlightbackground="dark grey", activebackground=bg, font=font, relief='flat')
highlightbackground="dark grey", activebackground=bg, font=font, relief='flat')

sf = sized_frame(root, height, width)
b = ttk.Button(sf, text=text, command=callback, style="Sized.TButton")
Expand Down Expand Up @@ -156,7 +157,8 @@ def edit_clicked():
edit_continuation()

resume_button = SizedButton(root, resume_clicked,
"RESUME\nPLAY", "green", "black", (_font_name, 50),
"RESUME\nPLAY", "green", "black", (
_font_name, 50),
190, 400)
resume_button.grid(row=0, column=0)

Expand Down Expand Up @@ -266,8 +268,8 @@ def ScoreColumn(root, column, team_color, score_color, refresh_ms, get_score):

score_var = tk.IntVar()
score_label = SizedLabel(root, score_var, "black",
score_color, score_font, score_height,
score_width)
score_color, score_font, score_height,
score_width)
score_label.grid(row=0, column=column)

def refresh_score():
Expand All @@ -277,16 +279,16 @@ def refresh_score():

label_var = tk.StringVar(value=team_color.upper())
label = SizedLabel(root, label_var, score_color, "black",
label_font, label_height, label_width)
label_font, label_height, label_width)
label.grid(row=1, column=column)

button = SizedButton(root, lambda: self.score_change_clicked(),
team_color.upper() + "\nSCORE", "dark cyan", "black",
button_font, button_height, button_width)
team_color.upper() + "\nSCORE", "dark cyan", "black",
button_font, button_height, button_width)
button.grid(row=2, column=column)

penalty = tk.Frame(root, height=penalty_height, width=penalty_width,
bg="black")
bg="black")
penalty.grid(row=3, column=column)

return root
Expand All @@ -310,9 +312,11 @@ def __init__(self, mgr, iomgr, NO_TITLE_BAR):

refresh_ms = 50

ScoreColumn(self.root, 0, 'white', 'white', refresh_ms, lambda: self.mgr.whiteScore())
ScoreColumn(self.root, 0, 'white', 'white',
refresh_ms, lambda: self.mgr.whiteScore())
self.center_column(refresh_ms)
ScoreColumn(self.root, 2, 'black', 'blue', refresh_ms, lambda: self.mgr.blackScore())
ScoreColumn(self.root, 2, 'black', 'blue',
refresh_ms, lambda: self.mgr.blackScore())

def poll_clicker(self):
if self.iomgr.readClicker():
Expand All @@ -323,7 +327,6 @@ def poll_clicker(self):
self.root.after(refresh_ms, lambda: poll_clicker(self))
self.root.after(refresh_ms, lambda: poll_clicker(self))


def center_column(self, refresh_ms):
clock_font = (_font_name, 96)
clock_height = 120
Expand Down Expand Up @@ -354,7 +357,7 @@ def center_column(self, refresh_ms):
self.game_clock_label.grid(row=0, column=1)

status_label = SizedLabel(self.root, self.status_var, "black", "#000fff000", status_font,
status_height, status_width)
status_height, status_width)
status_label.grid(row=1, column=1)

self.game_clock_label.after(refresh_ms, lambda: self.refresh_time())
Expand Down
2 changes: 2 additions & 0 deletions refbox/ui_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
def test_sized_frame():
assert ui.sized_frame(None, 1, 2)


def test_score_column():
root = ui.sized_frame(None, 1, 2)
assert ui.ScoreColumn(root, 2, 'black', 'blue', 5, lambda: 42)


def test_normal_view():
nv = ui.NormalView(GameManager(), IOManager(), NO_TITLE_BAR=True)
assert nv.first_game_started is False

0 comments on commit d1e3e26

Please sign in to comment.