def __init__(self, board, master=None, **kwargs): super().__init__(master, width=360, height=420, bg='#000000', **kwargs) self._board = board self._selectable_noodles = deque( set(Noodle.select()) - set([noodle.noodle for noodle in self._board.noodles])) noodle_frame = tk.Frame(self, width=360, height=290, bg='#000000') noodle_frame.pack(side='top') self._noodle_canvas = tk.Canvas(noodle_frame, width=360, height=290, bg='#000000', highlightthickness=0) self._noodle_canvas.pack() self._fade = Fade(self._noodle_canvas) control_frame = tk.Frame(self, width=360, height=125, bg='#000000', highlightthickness=0) control_frame.pack(side='top') self._prev, self._next, self._rotate, self._flip = self._init_buttons( control_frame) # The part of the noodle that a user has pressed (0 - 4) self._selected_part = None self._images = []
def __init__(self, board, oncomplete, oncancel, master=None, **kwargs): """Initialise a new GameScreen frame. Args: board: The Board instance. oncomplete: Callback called when the board has been completed. The callback should accept a single argument - the Board instance that has been completed. oncancel: Callback called when the Exit button is pressed. master: The parent widget. **kwargs: Optional keyword arguments to configure this screen. """ super().__init__(master, width=800, height=480, bg='#000000', highlightthickness=1, **kwargs) board_and_noodle = tk.Frame(master=self, width=800, height=420, bg='#000000', highlightthickness=1) board_and_noodle.pack(side='top', fill='x') noodle_selection_frame = NoodleSelectionFrame(board, master=board_and_noodle) board_frame = BoardFrame(board, oncomplete, noodle_selection_frame, master=board_and_noodle) board_frame.pack(side='left') noodle_selection_frame.pack() status_frame = InfoFrame(board, oncancel, master=self) status_frame.pack() # Initialise the cache of noodle images. if not NOODLE_IMAGES: for noodle in Noodle.select(): image = Image.open( os.path.join(os.path.dirname(__file__), 'images', noodle.image)).convert('RGBA') NOODLE_IMAGES[noodle.designation] = ImageTk.PhotoImage( self._flatten_alpha(image))