PyGest: A Python tkinter Tutorial, Introduction

In this tutorial series, we are going to build a simple file hashing application using the Python standard library's interface to the TK GUI toolkit: tkinter. One can find some resistance to using tkinter in the Python community. However, my interest in tkinter was recently rekindled after watching "Tinkering with Tkinter", a presentation by Russel Keith-Magee, in which the Django developer makes a strong case for revisiting this often overlooked and under-appreciated component of the Python standard library . . .

As Keith-Magee points out, these days tkinter has a number of arguments in its favor: 1) it is in the standard library, 2) it has been greatly improved in recent years, with additions to its basic functionality (more widgets!) as well as improvements in the look and feel of the GUIs it can generate, and 3) new resources such as the website TkDocs provide a ton of information to get Python tkinter GUI apps up and running in a relatively short period of time. Keith-Magee walks the walk as well, having built Cricket – a GUI tool for running Django and Python test suites – entirely with tkinter.

Our goal here is much more modest. We're going to build a single view file hashing utility in a manner appropriate for people with some experience programming in Python, but little or even no experience in Python GUI programming. Why would anyone want to build a file hashing utility? Simply put, hash functions can help determine the integrity of a file. For example, if a developer provides the hash value of a given file along with a download, you can check the hash value of the file you've downloaded against the one supplied by the developer to test whether the file was corrupted or modified in transit. (If you're new to the concept of hash functions or need a refresher, check out our past article on How and Why to Check a File's Hash Value.)

With that determination, we can already specify the basic functionality that we'd like our tutorial application to have. It should be able to: 1) generate hash digests of a specified file, 2) check the result against a known hash value, 3) alert the user as to whether or not there is a match, and 4) provide a choice of hash functions to use in the process.

Our application will thus need: 1) a number of labels to orient the user, 2) input fields for the file's path and the hash value to check against, 3) mutually exclusive radio buttons to choose the hash value, and 4) some buttons to run the program and clear the contents of the input fields. The project will thus provide us with the opportunity to play around with the basic elements of any GUI application. Here's a simple mockup:


We are going to use Python 3.4 throughout, but much of the code that follows should also work in Python 2.7, and I'll try to provide pointers as to when and why it might not. In case anyone is interested, I'm building this using the PyCharm Free Community Edition IDE on a Macbook laptop. Please note, there may be, or rather, it is virtually certain that there are far better ways to code the application presented in this tutorial. I built the GUI on the basis of my own idiosyncratic research into the tkinter library, and have organized the project to make it easier to present and digest in this tutorial series.

In the next article, we'll begin by laying out the bare bones structure of the application. Then we'll use a grid layout manager to construct our primary view as a set of grids within grids. This post will be updated with links to each successive article in the series as it is uploaded to the site. Enjoy! As always, any and all suggestions, comments and critiques are welcome in the comments. You can follow along with the tutorial using the links below:

PyGest: A Python tkinter Tutorial, Part 1 
PyGest: A Python tkinter Tutotial, Part 2
PyGest: A Python tkinter Tutorial, Part 3 
PyGest: A Python tkinter Tutorial, Part 4 
PyGest: A Python tkinter Tutorial, Part 5 
PyGest: A Python tkinter Tutorial, Conclusion

31 comments:

  1. Thank you for useful post. It's great to learn somwthing new, that can be helpful. It can help in studying, for example at university. By the way, if you're studying at university here some new writing tools.

    ReplyDelete
  2. Python is one of the most important programming language, which you easily get learned to gain college credits for work experience which will provide ease to qualify in professional life

    ReplyDelete
  3. Good admin.keep it up.your blog was informative.The Millionaire Guide On
    Software Testing Training in Bangalore To Help You Get Rich.Learn more details.... Java Training in Bangalore
    Thank you for sharing.

    ReplyDelete

  4. I want to to thank you for this good read!! I definitely enjoyed every
    little bit of it.

    iOS Training in Bangalore
    Advanced java Training in Bangalore
    Java Training in Bangalore

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Good job in presenting the correct content with the clear explanation. The content looks real with valid information. Good Work

    DevOps is currently a popular model currently organizations all over the world moving towards to it. Your post gave a clear idea about knowing the DevOps model and its importance.

    Good to learn about DevOps at this time.


    devops training in chennai | devops training in chennai with placement | devops training in chennai omr | devops training in velachery | devops training in chennai tambaram | devops institutes in chennai | devops certification in chennai | trending technologies list 2018

    ReplyDelete
  7. Interesting information and attractive.This blog is really rocking... Yes, the post is very interesting and I really like it.I never seen articles like this. I meant it's so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job.
    Kindly visit us @
    Sathya Online Shopping
    Online AC Price | Air Conditioner Online | AC Offers Online | AC Online Shopping
    Inverter AC | Best Inverter AC | Inverter Split AC
    Buy Split AC Online | Best Split AC | Split AC Online
    LED TV Sale | Buy LED TV Online | Smart LED TV | LED TV Price
    Laptop Price | Laptops for Sale | Buy Laptop | Buy Laptop Online
    Full HD TV Price | LED HD TV Price
    Buy Ultra HD TV | Buy Ultra HD TV Online
    Buy Mobile Online | Buy Smartphone Online in India

    ReplyDelete
  8. The article is very interesting and very understood to be read, may be useful for the people. I wanted to thank you for this great read!! I definitely enjoyed every little bit of it. I have to bookmarked to check out new stuff on your post. Thanks for sharing the information keep updating, looking forward for more posts..
    Kindly visit us @
    Madurai Travels
    Best Travels in Madurai
    Cabs in Madurai
    Tours and Travels in Madurai

    ReplyDelete
  9. Excellent Blog. I really want to admire the quality of this post. I like the way of your presentation of ideas, views and valuable content. No doubt you are doing great work. I’ll be waiting for your next post. Thanks .Keep it up! Kindly visit us @ Christmas Gift Boxes | Wallet Box | Perfume Box Manufacturer
    Candle Packaging Boxes
    Luxury Leather Box
    Luxury Clothes Box
    Luxury Cosmetics Box
    Shoe Box Manufacturer
    Luxury Watch Box

    ReplyDelete
  10. Wow, what an awesome spot to spend hours and hours! It's beautiful and I'm also surprised that you had it all to yourselves! we are the one of the best HIV treatment hospital in India..Click here for more details Best HIV Treatment in India | Top HIV Hospital in India | HIV AIDS Treatment in Mumbai | HIV Specialist in Bangalore | HIV Positive Treatment in India | Medicine for AIDS in India

    ReplyDelete
  11. We Offer all types of Finance Business Personal Cash
    Quick Cash Advance. Fast Credit Check. Cash Today.
    Fast Cash Online
    low interest rate as low as 2%
    Financial Cash Available Here
    Business Personal Cash
    I'll advise All Cash seeker should contact us
    Contact Us At : abdullahibrahimlender@gmail.com
    whatspp Number +918929490461
    Mr Abdullah Ibrahim

    ReplyDelete
  12. The very next time I read a blog, I hope that it does not disappoint me as much as this one. I mean, I know it was my choice to read, but I truly thought you would probably have something useful to say. All I hear is a bunch of crying about something that you could possibly fix if you were not too busy searching for attention.

    Huawei mobile LCD screen replacement in Whitefield
    Vivo mobile LCD screen replacement in Marathahalli
    Motorola mobile LCD screen replacement in Whitefield
    Asus mobile LCD screen replacement in Whitefield
    LG Stylus 2 mobile LCD screen replacement in Whitefield

    ReplyDelete
  13. I highly recommend a particular trader to everyone looking for forex, crypto and stocks trader. He can earn $9000 with $700 weekly, For more details, Contact Email: danielbohm232@gmail.com
    WhatsApp: +1 (631) 973-9487

    ReplyDelete
  14. You have brought up a very wonderful points , regards for the post.
    brother printer support

    ReplyDelete