|
1 | | -from Tkinter import Tk, Label, Frame, BOTH |
2 | | -from tkFont import Font |
| 1 | +from tkinter import Tk, Label, Frame, BOTH |
| 2 | +from tkinter.font import Font |
3 | 3 | from game2048 import Game2048, UP, DOWN, LEFT, RIGHT, ndenumerate, copy, isnan |
4 | 4 |
|
5 | 5 | key_map = {'Up': UP, 'Down': DOWN, 'Left': LEFT, 'Right': RIGHT} |
@@ -33,10 +33,10 @@ def input_listener(event=None, game=None, tk_root=None, labels=None): |
33 | 33 |
|
34 | 34 | grid, labels = game.get_grid(), [] |
35 | 35 | for (i, j), value in ndenumerate(grid): |
36 | | - frame = Frame(root, width=window_size/4-2, height=window_size/4-2) |
37 | | - font = Font(family='Helvetica', weight='bold', size=window_size/15) |
| 36 | + frame = Frame(root, width=window_size//4-2, height=window_size//4-2) |
| 37 | + font = Font(family='Helvetica', weight='bold', size=window_size//15) |
38 | 38 | frame.pack_propagate(0) |
39 | | - frame.place(x=j*window_size/4+1, y=i*window_size/4+1) |
| 39 | + frame.place(x=j*window_size//4+1, y=i*window_size//4+1) |
40 | 40 | (text, color) = ('', color_map['base']) if isnan(value) else ('{}'.format(int(value)), color_map[value][0]) |
41 | 41 | label = Label(frame, text=text, font=font, fg=color, bg=color_map['base'] if isnan(value) else color_map[value][1]) |
42 | 42 | label.pack(fill=BOTH, expand=True) |
|
0 commit comments