Create A Deck Of Cards And Deal Them Out - Python Tkinter GUI Tutorial 206
In this video I'll show you how to create a deck of cards with images for Tkinter and Python.
We'll shuffle the deck of cards, and deal out a card to a dealer and a player. Then we'll create a button to deal out two more cards.
We'll keep track of who has what cards, and when the deck is empty, the game will end.
This is a good foundation for creating just about any card game with Tkinter.
#tkinter #codemy #JohnElder
Timecodes
0:00 - Introduction
1:45 - Create Basic GUI
6:02 - Add Shuffle Function
6:21 - Define Card Suits
6:44 - Define Card Values
7:22 - Create Deck Of Cards With Loops
8:43 - Check Number Of Cards In Deck
9:08 - Create Dealer And Player
9:22 - Select Random Card From Deck For Dealer
9:52 - Remove Selected Card From Deck
10:12 - Add Selected Card To Dealer List
10:30 - Output Card Text To Screen
10:55 - Select Random Card From Deck For Player
11:34 - Output Card Count On Titlebar
12:29 - Create Deal_Cards Function
12:59 - Create Try/Except Block
13:27 - Shuffle Out New Dealer Card
14:01 - Shuffle Out New Player Card
14:10 - Update Titlebar With Remaining Card Count
14:53 - Shuffle The Cards On Start
15:40 - Explore Card Images
16:58 - From PIL Import Image, ImageTK
17:25 - Create Resize_Card Function
18:07 - Create Dealer Image Path
19:33 - Add Dealer Image To Label
19:53 - Create Player Image Path
20:27 - Open The Image
20:46 - Resize The Image
21:25 - Output The Card To Variable
21:50 - Return The Image
22:11 - Add Images To Deal Cards Function
23:13 - Conclusion
Пікірлер: 39
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My KZread Channel: bit.ly/2UFLKgj bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN ▶️ Get The Code bit.ly/3qDIwNl
Finally figured out how to get it work on my mac. Great tutorial! Thank you so much!
@Codemycom
Жыл бұрын
Glad you got it sorted out!
Awesome! Had planned on creating various unique card games, especially logic solitaires... meaning they can always be solved if the 500+ strategies are figured out.
@Codemycom
2 жыл бұрын
Cool
Awesome!
@Codemycom
2 жыл бұрын
Thanks!
Plan simple easy to understand thank you working on a bigger project this will be ver helpful thanks
@Codemycom
7 ай бұрын
glad you enjoyed it
Great idea!!!
@Codemycom
2 жыл бұрын
Thank you! 😊
you deserve more views
@Codemycom
2 жыл бұрын
Thanks, tell your friends ;-)
I followed the lines for the gui and the buttons but my Player frame and Dealer frame are somehow "connected", I cant seem to split them up even after changing the row and column values, any idea where I went wrong?
hey, where did you get the pictures for the cards? i tried online but everything costs money.
@Codemycom
Жыл бұрын
Don't remember...take mine, they're on my github.
hi i just want to know that is it POSSIBLE to make a 2d functional rubiks cube game with buttons on tkinter im currently trying to make one or should i use pygame, ursina or something like that
@Codemycom
Жыл бұрын
sure, anything is possible
How can you show shuffling animation in python?
Is there a way of getting card templates so that we can create designs for our own cards?
@Codemycom
2 жыл бұрын
Of course...any image will work.
Hey how are you? my python doesn't recognise the PIL from my line: "from PIL import Image, ImageTK" even though i downloaded pillow would you guys know why?
@Codemycom
Жыл бұрын
No clue
@panda8you640
Жыл бұрын
hey, I had the same error and I think I managed to solve it just by re-opening the python code as a whole. Thought I'd just mention this in case you still hadn't solved the issue.
great tutorial , where you downloaded the images ?
@Codemycom
2 жыл бұрын
Can't remember, use any images you like. You can find them in my github if you just have to use the same ones
can u upload the file of deck of cards here... please
@Codemycom
2 жыл бұрын
You can find it on my github, link to the code is always on the pinned comment
i cant run it on my pc because of icon bitmap path where can i find it
@Codemycom
Жыл бұрын
add any icon you want, or remove the line that defines the icon in the code
Hi john! Can you upload tutorials on html and css?
@Codemycom
2 жыл бұрын
Have them already at Codemy.com
which is more useful python or c
@sylver9547
2 жыл бұрын
All languages are useful
@Codemycom
2 жыл бұрын
There's no way to answer that. It depends entirely on what you're using them for.
You talk so fast that I have trouble understanding you. Slow down a bit. We won't mind if the video is 2 minutes longer.
@Codemycom
10 ай бұрын
Uh huh...you can slow the video speed by clicking the gear icon on the bottom corner of the video player. Or watch it again. But you know what? Nothing in my tutorial is particularly fast.