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

  • @Codemycom
    @Codemycom2 жыл бұрын

    ▶️ 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

  • @vinnaweng
    @vinnaweng Жыл бұрын

    Finally figured out how to get it work on my mac. Great tutorial! Thank you so much!

  • @Codemycom

    @Codemycom

    Жыл бұрын

    Glad you got it sorted out!

  • @ThankYouESM
    @ThankYouESM2 жыл бұрын

    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

    @Codemycom

    2 жыл бұрын

    Cool

  • @P.L.D.
    @P.L.D.2 жыл бұрын

    Awesome!

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Thanks!

  • @xbdj7420
    @xbdj74207 ай бұрын

    Plan simple easy to understand thank you working on a bigger project this will be ver helpful thanks

  • @Codemycom

    @Codemycom

    7 ай бұрын

    glad you enjoyed it

  • @meesiphht2769
    @meesiphht27692 жыл бұрын

    Great idea!!!

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Thank you! 😊

  • @skyline-wd3gr
    @skyline-wd3gr2 жыл бұрын

    you deserve more views

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Thanks, tell your friends ;-)

  • @cylis9219
    @cylis92193 ай бұрын

    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?

  • @noam_gonen_4743
    @noam_gonen_4743 Жыл бұрын

    hey, where did you get the pictures for the cards? i tried online but everything costs money.

  • @Codemycom

    @Codemycom

    Жыл бұрын

    Don't remember...take mine, they're on my github.

  • @aa779
    @aa779 Жыл бұрын

    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

    @Codemycom

    Жыл бұрын

    sure, anything is possible

  • @kaushalsuvarna5156
    @kaushalsuvarna51568 ай бұрын

    How can you show shuffling animation in python?

  • @Myah_W
    @Myah_W2 жыл бұрын

    Is there a way of getting card templates so that we can create designs for our own cards?

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Of course...any image will work.

  • @noam_gonen_4743
    @noam_gonen_4743 Жыл бұрын

    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

    @Codemycom

    Жыл бұрын

    No clue

  • @panda8you640

    @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.

  • @lucianoacevedo5974
    @lucianoacevedo59742 жыл бұрын

    great tutorial , where you downloaded the images ?

  • @Codemycom

    @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

  • @rajureddy1459
    @rajureddy14592 жыл бұрын

    can u upload the file of deck of cards here... please

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    You can find it on my github, link to the code is always on the pinned comment

  • @mostafamoha.6388
    @mostafamoha.6388 Жыл бұрын

    i cant run it on my pc because of icon bitmap path where can i find it

  • @Codemycom

    @Codemycom

    Жыл бұрын

    add any icon you want, or remove the line that defines the icon in the code

  • @dhanalakahmisuryanarayanan8954
    @dhanalakahmisuryanarayanan89542 жыл бұрын

    Hi john! Can you upload tutorials on html and css?

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Have them already at Codemy.com

  • @skyline-wd3gr
    @skyline-wd3gr2 жыл бұрын

    which is more useful python or c

  • @sylver9547

    @sylver9547

    2 жыл бұрын

    All languages are useful

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    There's no way to answer that. It depends entirely on what you're using them for.

  • @terryphelps4204
    @terryphelps420410 ай бұрын

    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

    @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.