Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

The Snake class

Let's now create the Snake class. We have already passed a task to generate our food to the central queue. However, no additional thread was involved in the task. We could also generate our Snake class without using threads. However, because we are talking about ways to implement multithreaded applications, let's implement our Snake class to work from a separate thread (see 9.04_game_of_snake.py):

class Snake(threading.Thread):    is_game_over = False  def __init__(self, queue):    threading.Thread.__init__(self)    self.queue = queue    self.daemon = True    self.points_earned = 0    self.snake_points = [(495, 55), (485, 55), (475, 55), (465, 55),       (455, 55)]    self.food = Food(queue)    self.direction = 'Left'    self.start()  def run(self): while ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content