EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

Tkinter after

Home » Software Development » Software Development Tutorials » Python Tutorial » Tkinter after

Tkinter after

Introduction to Tkinter after

The Tkinter after() is one of the methods for the Tkinter package and this method is used to calculate the time intervals for the functions in the application parallel. It calculates the time using milliseconds format whether the widget seems to be delayed or not since the Tkinter is a GUI based library also it’s a most powerful object-oriented interface so whenever the UI widgets like button etc. It automatically calls the specific function behavior and it also passed the parameters is to be used for the data-binding arguments if we have no specific values of the specific argument then it goes to the default state behavior.

Syntax

The Tkinter most powerful GUI based widget it has the most advanced library methods in the python. It has more number of global methods hence after() also one of the global methods it can be used directly on the specific root functions of the widget or application. It has its own syntax and default parameters.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

from tkinter import Tk //import the library in python
from tkinter.ttk import Button //import the library in python
variablename =functionName() //Tk library function
variablename.after(time(if it’s in delay status or not),callback)

–some python code logics—

In the above code we used first to import the specific libraries and we declared one variable name with the specific function it must be Tk library function and the same variable will be called as another method called after() in that we passed the two arguments one is a delay time interval and another one is callback method if it is in delay then it will be executed another time interval.

How to after() method Works in Tkinter?

Tkinter package has a set of built-in functions that has been used for covering the UI parts in the web application. It has the most interactive and advanced  library it can be calculated the functionalities for the time, speed, and even though some AI based functionality also covered in this widget. Basically, we want to decorate the UI has buttons, views, scroll box, etc mostly button will be the UI area to navigate the web pages or applications. Once we clicked the button it operates and works the backend areas. We also calculate the time intervals in the chrome or some other browsers if it seems to be a web-based application. Whenever the button is clicked by the user the function will be called using the backend command-line options with the help of function names we would like to call when the button is to be clicked by the user. If we have not given any specific values to the method after(delay,callback) it can take only the default values. For example, we have not given any delay times and callback argument values the callback has taken None value delay argument has default called sleep() method of the python code. Also, it has taken milliseconds as the time format instead of the seconds.

The after() method also calls all the Tkinter widgets of the python apps. Tkinter will be supported on the multiple OS like windows, Linux, etc. It is a standard library also we can create the desktop based applications using python Tkinter also its not a complex task we can use the Tkinter basic widgets like “Button,Canvas,Checkbutton,Frame,Label,Listbox,Menu,Message,Radiobutton,Text, etc” these widgets mostly covered in the UI part and these widget packages utilize the method called after() in all the widgets. Mostly time related logic it has been covered and the multi-threading applications also most important part in these particular method in the Tkinter library. The Tkinter have separate modules and it has the own interface like Tkinter interface is located in the module called a binary module and it’s named as _tkinter and also it accepts the Boolean type of values.

Popular Course in this category
Tkinter Course (1 Course, 1 Project)1 Online Courses | 1 Hands-on Projects | 6+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (2,812 ratings)
Course Price

View Course

Related Courses
Python Training Program (36 Courses, 13+ Projects)Programming Languages Training (41 Courses, 13+ Projects, 4 Quizzes)Angular JS Training Program (9 Courses, 7 Projects)

Examples of Tkinter after

Lets us discuss the examples of Tkinter after.

Example 1

from tkinter import *
from time import time
from tkinter.ttk import Button
demos= Tk()
b = Button(demos, text = 'Welcome To My Domain')
b.pack(pady = 77,side = TOP)
pink = Button(demos, text = "pink")
pink.pack( side = TOP)
green = Button(demos, text = "green")
green.pack( side = BOTTOM )
violet = Button(demos, text = "violet")
violet.pack( side = LEFT )
yellow = Button(demos, text = "yellow")
yellow.pack( side = RIGHT)
print('The Tk Widget is running on the screen...')
startingtime = time()
demos.after(200000, demos.destroy)
demos.mainloop()
endingtime = time()
print('The Tk Widget is closed after % d seconds' % (endingtime-startingtime))

Output:

tkinter after 1-1

Example 2

from tkinter import *
user = Tk()
uname = Label(user,text = "uname").grid(row =0, column = 0)
un= Entry(user).grid(row = 0, column = 0)
passw = Label(user,text = "pass").grid(row = 1, column = 1)
ps = Entry(user).grid(row = 1, column = 1)
result = Button(user, text = "submit").grid(row = 3, column = 3)
user.mainloop()
try:
import tkinter as tk
except ImportError:
import Tkinter as tk
class Timer:
def __init__(first, second):
first.seconds = 1
first.label = tk.Label(second, text="1s", font="Arial 25", width=17)
first.label.pack()
first.label.after(3000, first.demo)
def demo(first):
first.seconds += 1
first.label.configure(text="%i s" % first.seconds)
first.label.after(2000, first.demo)
if __name__ == "__main__":
demos = tk.Tk()
tme = Timer(demos)
demos.mainloop()

Output:

tkinter after 1-2

tkinter after 1-3

Example 3

from tkinter import Tk, mainloop, TOP
from tkinter.ttk import Button
from tkinter.messagebox import _show
sample = Tk()
btn = Button(sample, text = 'Welcome To my Domain')
btn.pack(side = TOP, pady = 7)
b2 = Button(sample, text = 'Welcome To my Domain')
b2.pack(side = TOP, pady = 7)
b3 = Button(sample, text = 'Welcome To my Domain')
b3.pack(side = TOP, pady = 7)
b4 = Button(sample, text = 'Welcome To my Domain')
b4.pack(side = TOP, pady = 7)
sample.after(3400, lambda : _show('user', 'Have a Nice Day'))
sample.after(5400, sample.destroy)
btn.pack(side = TOP, pady = 7)
b5 = Button(sample, text = 'Welcome To my Domain')
b5.pack(side = TOP, pady = 7)
b6 = Button(sample, text = 'Welcome To my Domain')
b6.pack(side = TOP, pady = 7)
b7 = Button(sample, text = 'Welcome To my Domain')
b7.pack(side = TOP, pady = 7)
mainloop()
b8 = Button(sample, text = 'Welcome To my Domain')
b8.pack(side = TOP, pady = 7)
b9 = Button(sample, text = 'Welcome To my Domain')
b9.pack(side = TOP, pady = 7)
b10 = Button(sample, text = 'Welcome To my Domain')
b10.pack(side = TOP, pady = 7)
mainloop()

Output:

Example 3

Example 3-1

Conclusion

The after() is one of the methods in the Tkinter library of the python script using that we can create the different types of GUI presentations and also it has been more user-friendly when compared to the other GUI based technologies. Likewise, the python Tkinter library have default methods to create UI widgets in both desktop and web based applications.

Recommended Articles

This is a guide to Tkinter after. Here we discuss the Introduction and working of Tkinter after along with different examples and code implementation. You may also have a look at the following articles to learn more –

  1. Tkinter Menubutton
  2. Tkinter Text
  3. Tkinter Widgets
  4. Python Tkinter Button

Tkinter Course (1 Course, 1 Project)

1 Online Courses

1 Hands-on Projects

6+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Python Tutorial
  • Tkinter
    • Tkinter Widgets
    • Python Tkinter Button
    • Python Tkinter Canvas
    • Tkinter Frame
    • Tkinter LabelFrame
    • Python Tkinter Label
    • Tkinter Scrollbar
    • Tkinter Listbox
    • Tkinter Spinbox
    • Tkinter Checkbutton
    • Tkinter Menu
    • Tkinter Menubutton
    • Tkinter OptionMenu
    • Tkinter Messagebox
    • Tkinter Grid
    • Python Tkinter Entry
    • Tkinter after
    • Tkinter Colors
    • Tkinter Font
    • Tkinter PhotoImage
    • Tkinter TreeView
    • Tkinter Notebook
    • Tkinter Bind
    • Tkinter Icon
    • Tkinter Window Size
    • Tkinter Color Chart
    • Tkinter Slider
    • Tkinter Calculator
  • Basics Part I
    • Introduction To Python
    • What Is Python
    • Careers in Python
    • Advantages of Python
    • Uses of Python
    • Python Features
    • Python Fast And python psyco
    • Python ImportError
    • Benefits and Limitations of Using Python
    • What can I do with?Python
    • Is Python a scripting language
    • Is Python Object Oriented
    • Is Python Open Source
    • Python Socket Programming
    • Useful Tips on Python Programming
    • Python You Should Be Using It
    • Python Web Development
    • Python Programming Beginners Tutorails
    • Practical Python Programming for Non-Engineers
    • Python Programming for the Absolute Beginner
    • Versions of?Python
  • Basic Part II
    • Comments in Python
    • Finally in Python
    • Python Multiline Comment
    • Python Data Types
    • Python Variables
    • Python Variable Types
    • Python Global Variable
    • Python Variable Scope
    • Python Private Variables
    • Python Default Arguments
    • Python Command-line Arguments
    • Indentation in Python
    • Object in Python
    • Python Keywords
    • Python Literals
    • Pointers in Python
    • Iterators in Python
    • Python User Input
    • Python Enumerate
    • Python Commands
    • Type Casting in Python
    • Python Identifiers
    • Python Constants
    • What is NumPy in Python?
    • Cheat Sheet Python
  • Frameworks
    • Python Frameworks
    • Python Compilers
    • Python Editors
    • Best Compiler for Python
    • Python IDE for Windows
    • Python IDE on Linux
  • Installation
    • How To Install Python
    • Install Python on Linux
    • Install Python on Windows
    • Install Anaconda Python
  • Operator
    • Python Operators
    • Arithmetic Operators in Python
    • Python Comparison Operators
    • Logical Operators in Python
    • Assignment Operators in Python
    • Unary Operators in Python
    • String Operators in Python
    • Boolean Operators in Python
    • Identity Operators in Python
    • Python Bitwise Operator
    • Python Remainder Operator
    • Python Modulus Operator
  • Control Statement
    • Conditional Statements in Python
    • Control Statements in Python
    • If Condition in Python
    • If Statement in Python
    • If Else Statement in Python
    • else if Statement in Python
    • Nested IF Statement in Python
    • Break Statement in Python
    • Python Switch Statement
  • Loops
    • Loops in Python
    • For Loop in Python
    • While Loop in Python
    • Do While Loop in Python
    • Python Nested Loops
    • Python Infinite Loop
    • Python Event Loop
  • Sorting
    • Sorting in Python
    • Sorting Algorithms in Python
    • Bubble Sort in Python
    • Merge Sort in Python
    • Heap Sort in Python
    • Quick Sort in Python
    • Python Sorted Function
  • Function
    • Python Built-in Functions
    • Math Functions in Python
    • Python String Functions
    • Trigonometric Functions in Python
    • Python Input Function
    • Python Input String
    • Python String Operations
    • Python Stream
    • Python Multiline String
    • Python Regex
    • Python Regex Tester
    • Python regex replace
    • Python File Methods
    • Python Import CSV
    • Python Read CSV File
    • Python write CSV file
    • Python Delete File
    • Python File readline
    • Python if main
    • Python Main Method
    • List Method in Python
    • Python List Length
    • Recursive Function in Python
    • Copy List in Python
    • Python Range Function
    • Python Substring
    • Python list remove()
    • Python List Index
    • Python Set Function
    • Python len Function
    • Python eval()
    • Python Counter
    • ord Function in Python
    • strip Function in Python
    • Split Function in Python
    • Python Round Function
    • Python Map Function
    • Python String Join
    • Python format() Function
    • Python Contextlib
    • Python Compare Strings
    • Python Return Value
    • Python List count
    • Filter in Python
    • Python Slice String
    • Python Absolute Value
    • Python Trim String
    • Python Type Function
    • Lowercase in Python
    • Python xrange
    • Python yield
    • Python Find String
    • Max Function in Python
    • Python Power Function
    • pop() in Python
    • Python argparse
    • Python Pickle
    • Python Zip Function
    • Python Split String
    • super() in Python
    • Python Extend
    • Python String Replace
    • Python PEP8
    • Python Filter Function
    • Python if then else
    • Lambda in Python
    • Python BeautifulSoup
    • Python Sleep
    • Python Function Generator
    • Python @classmethod decorator
    • Python Endswith
    • Python BufferedReader
    • Python Async
    • Python Parser
    • Python SystemExit
    • Python pip
    • Python kwargs
  • Array
    • Arrays in Python
    • 2D Arrays In Python
    • 3d Arrays in Python
    • Multidimensional Array in Python
    • Python Array Functions
    • String Array in Python
    • Python Sort Array
    • Python Array Length
  • Inheritance
    • Inheritance in Python
    • Single Inheritance in Python
    • Multiple Inheritance in Python
    • Interface in Python
  • Exception
    • Python Exception Handling
    • Custom Exception in Python
    • Indentation Error in Python
    • Python IOError
    • Python EOFError
    • Python NotImplementedError
    • Python TypeError
    • Python ValueError
    • Python AssertionError
    • Python Unicode Error
    • Python NameError
    • Python StopIteration
    • Python OverflowError
    • Python KeyboardInterrupt
  • Advanced
    • Scope in Python
    • Python Collections
    • Constructor in Python
    • Destructor in Python
    • Python Overloading
    • Overriding in Python
    • Function Overloading in Python
    • Method Overloading in Python
    • Operator Overloading in Python
    • Method Overriding in Python
    • Encapsulation in Python
    • Static Method in Python
    • Assert in Python
    • Python References
    • Python Virtualenv
    • Python mkdir
    • Logistic Regression in Python
    • Dictionary in Python
    • Regular Expression in Python
    • Python Import Module
    • Python OS Module
    • Python Sys Module
    • Python Generators
    • Abstract Class in Python
    • Python File Operations
    • Sequences in Python
    • Stack in Python
    • Queue in Python
    • Tuples in Python
    • Python Magic Method
    • Python Sets
    • Python Set Methods
    • Priority Queues in Python
    • Reverse Engineering with Python
    • String Formatting in Python
    • Python isinstance
    • String Length Python
    • Python Concurrency
    • Python List
    • Python Initialize List
    • Python Unique List
    • Python Sort List
    • Python Reverse List
    • Python Empty List
    • List Comprehensions Python
    • List Operations in Python
    • Python Database Connection
    • Python SQLite
    • Python SQLite Create Database
    • Send Mail in Python
    • Bash Scripting and Python
    • Violent Python Book
    • NLP in Python
    • Matplotlib In Python
    • Gray Hat Python: Security
    • Python Subprocess
    • Python Threading Timer
    • Python Threadpool
    • Python Statistics Module
    • How to Call a Function in Python?
    • Python Curl
    • JSON in Python
    • Python json.dumps
    • Python Turtle
    • Python Unit Test
    • pass Keyword in Python
    • Tokenization in Python
    • Random Module in Python
    • Python Multiprocessing
    • Python getattr
    • Collection Module in Python
    • Print Statement in Python
    • Python Countdown Timer
    • Python Context Manager
    • File Handling in Python
    • Python Event Handler
    • Python Print Table
    • Python Docstring
    • Python Dictionary Keys
    • Python Iterator Dictionary
    • Python Class Attributes
    • Python Dictionary Methods
    • Namedtuple Python
    • Namedtuple Python
    • Namedtuple Python
    • Python Class Constants
    • Python Validation
    • Python Switch Case
    • Python Rest Server
    • Python Yield vs Return
    • Python Pickle vs JSON
  • Programs
    • Patterns in Python
    • Star Patterns in Python
    • Swapping in Python
    • Factorial in Python
    • Fibonacci Series in Python
    • Reverse Number in Python
    • Palindrome in Python
    • Random Number Generator in Python
    • Prime Numbers in Python
    • Armstrong Number in Python
    • Strong Number in Python
    • Leap Year Program in Python
    • Square Root in Python
    • Python Reverse String
    • Python Object to String
    • Python Object to JSON
    • Python Classmethod vs Staticmethod
  • Python 3
    • Python 3 Commands
    • Python 3 cheat sheet
  • Interview Question
    • Python Interview Questions And Answers

Related Courses

Python Certification Course

Programming Languages Courses

Angular JS Certification Training

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - Tkinter Course (1 Course, 1 Project) Learn More