https://github.com/vbalalian/cointoss
Practicing OOP, Python, and Tkinter by developing a simple Cointoss game.
https://github.com/vbalalian/cointoss
oop python tkinter
Last synced: 22 days ago
JSON representation
Practicing OOP, Python, and Tkinter by developing a simple Cointoss game.
- Host: GitHub
- URL: https://github.com/vbalalian/cointoss
- Owner: vbalalian
- Created: 2022-12-17T00:16:04.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-19T20:44:23.000Z (over 3 years ago)
- Last Synced: 2025-03-04T18:42:17.143Z (over 1 year ago)
- Topics: oop, python, tkinter
- Language: Python
- Homepage:
- Size: 195 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Coin Toss Game
This program simulates a coin toss game using Python and the tkinter library. It allows the user to guess whether the outcome of a coin flip will be heads or tails, and it keeps track of the user's guesses and the coin flip results. The game provides a graphical interface for user interaction, displaying images of heads and tails during the coin flip.
## Dependencies
- random
- tkinter
- PIL (Pillow) for image processing
- os for file system operations
## Classes
- `coin`: A class representing a coin object with two sides (Heads and Tails).
### Methods
- `flip()`: Flips the coin and updates the coin's side.
- `getHistory()`: Returns the history of coin flips.
- `__str__()`: Returns the current side of the coin.
## Functions
- `results()`: Displays the user's results after the game is finished.
- `playButtons()`: Displays the 'Play again?' buttons.
- `playAgain(YN)`: Determines whether to restart the game or show the results based on the user's choice.
- `callSame(yn)`: Determines whether to make the same call again or ask to play again.
- `click(side)`: Handles the user's coin side call and displays the outcome of the coin flip.
- `subtitle()`: Updates the subtitle text in the interface.
- `buttons()`: Displays the heads and tails buttons.
- `open()`: Initiates the game.
## Usage
1. Create a tkinter window.
2. Initialize a coin object.
3. Load images of heads and tails.
4. Create and configure tkinter widgets (labels, buttons, etc.).
5. Define functions for handling user interactions and updating the interface.
6. Start the tkinter main event loop.