Dec-21-2020, 08:55 AM
(This post was last modified: Dec-21-2020, 08:55 AM by steve_shambles.)
"""Spinning reel test. Small working example. How can I make the cards look like they are spinning, like in a real slot machine? There will be 5 reels in the game eventually. Also, how do I make sure the card images do not eat up memory when thet are re-called time and again? """ import time from tkinter import Tk, Frame, Label, PhotoImage root = Tk() root.geometry("300x300") cards_frame = Frame(root) cards_frame.grid() def change_card(filename): """Spin reel one. Pass filename to photoimage and display.""" reel_one = Label(cards_frame) PHOTO = PhotoImage(file=filename) reel_one.config(image=PHOTO) reel_one.grid(row=0, column=0) reel_one.photo = PHOTO reel_one.update() time.sleep(0.1) def spin_reels(): """Pass 3 card images 10 times to be displayed, will be random cards in game.""" for spins in range(9): change_card(r'cards/AH.png') change_card(r'cards/KD.png') change_card(r'cards/QC.png') spin_reels()The cards folder can be found on github, vsmall download.
https://github.com/steveshambles/spin-re...in-test.py
This related to my Slot machine, Freespin Frenzy,
https://github.com/steveshambles/Freespin-Frenzy
but I want to build a new slot from scratch with 5 reels, but I
have to get these two problems sorted before i can start.
https://python-forum.io/Thread-Gui-slot-...mory-error
Thanks for any help.