Giter Club home page Giter Club logo

python-tkinter-tutorial's Introduction

Python-Tkinter-Tutorial

Examples used as part of a Python Tkinter Tutorial

In order to create Graphical User Interfaces, Python comes with Tkinter as standard. Tkinter isn't fully features or particularly beautiful but it provides basic widget types that you can use to quickly create application that you can run on your Raspberry Pi.

Lets sort out some terminology first. A window is what you see when you open any graphical program on your computer, it will include the minimise, maximise and close buttons depending on your operating system. It will also show the name of the application. A frame is a blank object that exists inside a window. It can contain buttons, text entry fields, labels, checkboxes and many more, these are all called widgets. A widgets are object that can be used as part of your application these can be buttons, text entries, check boxes or something more complex like a a collection of widgets that are joined together to create something more complicated, we will create an example of this in this tutorial.

All the examples in this tutorial have been developed for Python 3 using IDLE3 on a Raspberry Pi. You can find IDLE3 on Raspbain in the programming menu.

Tutorial 1 - Our First Tkinter Program

Our first example isn't very exciting but it does introduce you to the basics needed to get create a create a simple Tkinter Class and make this visible to the user. Open IDLE3 from the programming menu, and from the "File" menu select "New File". This will bring up a blank text editor window. Enter the python code in the box below. Python is very strict with indentation so make sure you put the correct number of spaces before each line of code. To save the file, select "Save" from the "File" menu. Give the file a name remembering to give the file the .py extension and press "Save". Now that we've saved the file lets run it and see what happens. To run the program, either press F5 or click on "Run Module" from the "Run" menu. Not very impressive is it!! What we have done is to tell python to create a Tkinter window and draw a blank Frame on to the window.

Tutorial 2 - Adding some widgets.

We are going to modify the code we created in the first tutorial to add two widgets; a Text Label and a Button. Label is a widget class; inside the Tkinter code it describes how to draw this widget on to the screen, what text should be displayed inside it along with lots of different properties that we can set like its Foreground Colour.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.