In this PythonTkinter tutorial, we will learn about how to create a Todo list in Python which help us to store our important ideas and daily task.
Python Tkinter Todo List
We create a Python Tkinter Todo List we have an interface with an entry box where we can enter the task and also have a button from which we can save our task.
Block of code:
In the following Python Tkinter Todo list block of code, we import some Tkinter modules from which we can create a Todo List.
from tkinter import *
import tkinter
import random
from tkinter import messagebox
Github Link
Check this code in Repository from Github and you can also fork this code.
Github User Name: PythonT-Point
Block of code:
In the following Python Tkinter Todo List block of code, we will define an update task function in which we can update our task.
- clearlistbox() is used to clear the list box.
- lbltask.insert(“end”, utask) is used to insert the task inside the entry box.
- numtask = len(tasks) is used to describe the length of the task.
def updatetask():
clearlistbox()
for utask in tasks:
lbltask.insert("end", utask)
numtask = len(tasks)
lbldsp_count['text'] = numtask
Read: Python Tkinter temperature converter
Block of code:
In the following block of code, we define a clear list box function in which the task is deleted from the list.
def clearlistbox():
lbltask.delete(0, "end")
Block of code:
In the following block of code, we define the add task function from which we can add our important information to the list.
def addtask():
lbldisplay["text"] = ""
Ntask = txtinput.get()
if Ntask != "":
tasks.append(Ntask)
updatetask()
else:
lbldisplay["text"] = "please enter the text"
txtinput.delete(0, 'end')
Block of code:
In the following block of code, we create a delete all function in which we can delete all the information that we can enter into the list. And also create a delete one function in which we can delete only one information that we are entered.
def deleteall():
conf = messagebox.askquestion(
'delet all??', 'are you sure to delete all task?')
print(conf)
if conf.upper() == "YES":
global tasks
tasks = []
updatetask()
else:
pass
def deleteone():
delt = lbltask.get("active")
if delt in tasks:
tasks.remove(delt)
updatetask()
Read: Python Tkinter Simple Calculator
Block of code:
In the following block of code, we create some functions in which we can sort our task in ascending and descending order. And also generate the number of tasks.
def sortasc():
tasks.sort()
updatetask()
def sortdsc():
tasks.sort(reverse=True)
updatetask()
def randomtsk():
randtask = random.choice(tasks)
lbldisplay["text"] = randtask
def numbertsk():
numtask = len(tasks)
lbldisplay["text"] = numtask
Block of code:
In the following block of code, we create a save function from which we can save our task by simply clicking on the button and our task is saved into the Todolist.
def saveact():
savecon = messagebox.askquestion(
'Save confirmation', 'Save Your Progress?')
if savecon.upper() == "YES":
with open("SaveFile.txt", "w") as filehandle:
for listitem in tasks:
filehandle.write('%s\n' % listitem)
else:
pass
Block of code:
In the following block of code, we create a function load info and load act from which we can load our info into the list and also create a loadact function from which message box is generated if some wrong info enter.
def loadinfo():
messagebox.showinfo(
"info", "This is Todolist \n created by Pythontpoint ",)
def loadact():
loadcon = messagebox.askquestion(
'Save Confirmation', 'save your progress?')
if loadcon.upper() == "YES":
tasks.clear()
with open('SaveFile.txt', 'r') as filereader:
for line in filereader:
currentask = line
tasks.append(currentask)
updatetask()
else:
pass
Block of code:
In the following block of code, we create an exitapp function from which we can exit the app after completing the task.
def exitapp():
confex = messagebox.askquestion(
'Quit confirmation', 'Are you sue you want to quit?')
if confex.upper() == "YES":
wd.destroy()
else:
pass
Code:
In the following code, we will import the tkinter module and create a Todo list in which we can create our notes and add to the list.
from tkinter import *
import tkinter
import random
from tkinter import messagebox
def updatetask():
clearlistbox()
for utask in tasks:
lbltask.insert("end", utask)
numtask = len(tasks)
lbldsp_count['text'] = numtask
def clearlistbox():
lbltask.delete(0, "end")
def addtask():
lbldisplay["text"] = ""
Ntask = txtinput.get()
if Ntask != "":
tasks.append(Ntask)
updatetask()
else:
lbldisplay["text"] = "please enter the text"
txtinput.delete(0, 'end')
def deleteall():
conf = messagebox.askquestion(
'delet all??', 'are you sure to delete all task?')
print(conf)
if conf.upper() == "YES":
global tasks
tasks = []
updatetask()
else:
pass
def deleteone():
delt = lbltask.get("active")
if delt in tasks:
tasks.remove(delt)
updatetask()
def sortasc():
tasks.sort()
updatetask()
def sortdsc():
tasks.sort(reverse=True)
updatetask()
def randomtsk():
randtask = random.choice(tasks)
lbldisplay["text"] = randtask
def numbertsk():
numtask = len(tasks)
lbldisplay["text"] = numtask
def saveact():
savecon = messagebox.askquestion(
'Save confirmation', 'Save Your Progress?')
if savecon.upper() == "YES":
with open("SaveFile.txt", "w") as filehandle:
for listitem in tasks:
filehandle.write('%s\n' % listitem)
else:
pass
def loadinfo():
messagebox.showinfo(
"info", "This is Todolist \n created by Pythontpoint ",)
def loadact():
loadcon = messagebox.askquestion(
'Save Confirmation', 'save your progress?')
if loadcon.upper() == "YES":
tasks.clear()
with open('SaveFile.txt', 'r') as filereader:
for line in filereader:
currentask = line
tasks.append(currentask)
updatetask()
else:
pass
def exitapp():
confex = messagebox.askquestion(
'Quit confirmation', 'Are you sue you want to quit?')
if confex.upper() == "YES":
wd.destroy()
else:
pass
wd = tkinter.Tk()
wd.configure(bg="white")
wd.title("Pythontpoint")
wd.geometry("260x300")
tasks = []
lbltitle = tkinter.Label(wd, text="Todo List", bg="white")
lbltitle.grid(row=0, column=0)
lbldisplay = tkinter.Label(wd, text="", bg="white")
lbldisplay.grid(row=0, column=1)
lbldsp_count = tkinter.Label(wd, text="", bg="white")
lbldsp_count.grid(row=0, column=3)
txtinput = tkinter.Entry(wd, width=15)
txtinput.grid(row=1, column=1)
txtadd_button = tkinter.Button(
wd, text="add todo", bg="white", fg="cyan", width=15, command=addtask)
txtadd_button.grid(row=1, column=0)
delonebutton = tkinter.Button(
wd, text="Done Task", bg="white", width=15, command=deleteone)
delonebutton.grid(row=2, column=0)
delallbutton = tkinter.Button(
wd, text="Delete all", bg="white", width=15, command=deleteall)
delallbutton.grid(row=3, column=0)
sortasc = tkinter.Button(wd, text="sort (ASC)",
bg="White", width=15, command=sortasc)
sortasc.grid(row=4, column=0)
sortdsc = tkinter.Button(wd, text="sort (DSC)",
bg="White", width=15, command=sortdsc)
sortdsc.grid(row=5, column=0)
randombutton = tkinter.Button(
wd, text="random task", bg="White", width=15, command=randomtsk)
randombutton.grid(row=6, column=0)
numbertsk = tkinter.Button(
wd, text="Number of Task", bg="white", width=15, command=numbertsk)
numbertsk.grid(row=7, column=0)
exitbutton = tkinter.Button(wd, text="exit app",
bg="white", width=15, command=exitapp)
exitbutton.grid(row=8, column=0)
savebutton = tkinter.Button(
wd, text="save TodoList", bg="white", width=15, command=saveact)
savebutton.grid(row=10, column=1)
loadbutton = tkinter.Button(
wd, text="Load LastTodolist", bg="white", width=15, command=loadact)
loadbutton.grid(row=10, column=0)
infobutton = tkinter.Button(
wd, text="info", bg="white", width=15, command=loadinfo)
infobutton.grid(row=11, column=0, columnspan=2)
lbltask = tkinter.Listbox(wd)
lbltask.grid(row=2, column=1, rowspan=7)
# main loop
wd.mainloop()
Output:
After running the above code we get the following output in which we can see that the Todo list is created on the screen.
Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Viyana Teknik Üniversitesi, mühendislik, bilgi teknolojisi, doğa bilimleri ve daha birçok alanda sunduğu geniş kapsamlı programlarla dikkat çeker.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://www.binance.com/ur/register?ref=WTOZ531Y
Вся информация, представленная на данном сайте, носит исключительно информационный характер и предназначена для ознакомления с деятельностью онлайн-казино. Сайт не являемся оператором игр и не предоставляем услуг по организации азартных игр. bnrosmuvzj … https://www.perfectpicturephotobooth.co/wp-content/otlichiya-mezhdu-onlayn-kazino-i-traditsionnymi-kazino.html
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I’ve been exploring for a bit for any high-quality articles or weblog posts in this kind
of area . Exploring in Yahoo I at last stumbled upon this website.
Studying this info So i am happy to show that I’ve
a very excellent uncanny feeling I found out exactly what I needed.
I so much undoubtedly will make sure to don?t omit this web site and provides it a
glance regularly.!
Hi! Do you know if they make any plugins to assist with Search Engine Optimization?
I’m trying to get my site to rank for some targeted keywords but I’m not seeing very good success.
If you know of any please share. Many thanks! I saw similar article here:
Eco wool
Her consolation level relies on how she likes to put on her hair and whether she needs to put on all or part of the headpiece throughout the reception.
sugar defender official website Uncovering Sugar
Protector has actually been a game-changer for me, as I have actually always been vigilant about managing my blood
glucose degrees. I currently really feel equipped and positive in my capacity to keep healthy levels,
and my most recent health checks have actually shown this progression. Having a reliable
supplement to match my a huge source of comfort, and I’m absolutely glad for the substantial distinction Sugar
Protector has made in my overall wellness.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
sugar defender ingredients For many years,
I’ve fought uncertain blood sugar level swings that left me really feeling drained pipes and lethargic.
But because incorporating Sugar Defender into my
routine, I have actually seen a substantial improvement in my total energy and stability.
The dreadful mid-day distant memory, and I appreciate that this
natural treatment accomplishes these results without any undesirable
or damaging responses. truthfully been a transformative discovery
for me.
The next time I read a blog, Hopefully it does not disappoint me just as much as this one. After all, Yes, it was my choice to read through, nonetheless I genuinely thought you would probably have something helpful to say. All I hear is a bunch of whining about something you can fix if you were not too busy searching for attention.
When I originally commented I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on every time a comment is added I receive four emails with the same comment. Perhaps there is a way you can remove me from that service? Thank you.
Great web site you have got here.. It’s hard to find excellent writing like yours nowadays. I really appreciate people like you! Take care!!
Great article! We will be linking to this great post on our site. Keep up the great writing.
All these components come collectively each time you hit the ball, and each shot takes flexibility, coordination and steadiness.
Pretty! This was an extremely wonderful article. Thank you for providing these details.
Military Collector and Historian, Vol.21 (Fall 1969), pp.
sugar defender Official website
For several years, I’ve battled unforeseeable blood sugar level swings that left me really feeling drained and
lethargic. Yet because including Sugar Defender right into my routine, I’ve discovered a considerable renovation in my total power and stability.
The feared mid-day thing of the past, and I appreciate that this natural solution attains these outcomes without any undesirable or negative responses.
honestly been a transformative exploration for me.
Throughout 2018, Johnson was signed to the Christians of faith Academy because the athletic director and assistant coach.
The twenty first Century Waterfront incorporated the brand new constructing with River Journey and Ross’s Landing Park, persevering with the theme of Chattanooga’s early history by locating The Passage, an interactive public artwork set up marking the positioning of the beginning of the Path of Tears in Chattanooga, alongside it.
Before you notice the sanding pad at the underside, you assume perhaps it is some kind of beefed-up trim router – not a palm sander with its bulbous prime, nor a half-sheet sander with two hand-holds and the boxy-however-streamlined look of an ’80s Okay-car transformed to a hobbyist dragster.
I’ve been in similar situations before. It is not as easy an answer as you thought it is, its something that you’ll have to write out for yourself over time.
Flagstaff’s summers are additionally notable for the monsoon season in July and August, when thunderstorms happen nearly every day.
Your style is so unique in comparison to other folks I’ve read stuff from. I appreciate you for posting when you have the opportunity, Guess I’ll just bookmark this page.
I really appreciate this post. I have been looking all over for this! Thank goodness I found it on Google. You’ve made my day! Thx again…
hey all, I was simply checking out this blog and I actually admire the idea of the article, and don’t have anything to do, so if anybody want to to have an engrossing convo about it, please contact me on AIM, my identify is heather smith
Hi there! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyhow, I’m definitely delighted I found it and I’ll be book-marking and checking back often!
Hi! I could have sworn I’ve been to your blog before but after looking at some of the articles I realized it’s new to me. Anyhow, I’m definitely pleased I stumbled upon it and I’ll be book-marking it and checking back regularly!
I like this web site so much, saved to my bookmarks .
The next time I learn a weblog, I hope that it doesnt disappoint me as much as this one. I imply, I do know it was my choice to learn, however I actually thought youd have something attention-grabbing to say. All I hear is a bunch of whining about something that you could possibly fix should you werent too busy looking for attention.
hello!,I love your writing so so much! proportion we be in contact more approximately your post on AOL? I need an expert on this area to unravel my problem. Maybe that’s you! Looking forward to peer you.
we use big wall calendars on our offices, big wall calendars are easier to read.
Good day. your writing style is great and i love it,
I’m impressed, I must say. Truly rarely do I encounter a blog that’s both educative and entertaining, and without a doubt, you might have hit the nail within the head. Your notion is outstanding; ab muscles something that insufficient persons are speaking intelligently about. We’re very happy that I found this in my seek out something with this.
Regards for this post, I am a big big fan of this site would like to go on updated.
Hi, Neat post. There’s a problem with your website in internet explorer, would test this… IE still is the market leader and a big portion of people will miss your fantastic writing due to this problem.
I used to be able to find good advice from your blog articles.
This sort of thing needs to happen! Simply letting the quota happen isn’t acceptable. This will help you stay above the curve.
you are really a good webmaster. The site loading speed is amazing. It seems that you’re doing any unique trick. Furthermore, The contents are masterpiece. you have performed a great activity in this topic!
I discovered your blog web site on google and check a few of your early posts. Proceed to keep up the excellent operate. I just additional up your RSS feed to my MSN News Reader. Looking for ahead to studying extra from you later on!…
You lost me, friend. Come on, man, I imagine I buy what youre saying. I’m sure what you’re saying, but you just appear to have forgotten that might be a few other folks inside world who view this matter for it is actually and will perhaps not agree with you. You may well be turning away alot of folks that could have been lovers of your respective website.
I am often to blogging and i really appreciate your site content. This content has really peaks my interest. I am going to bookmark your internet site and maintain checking for first time details.
Way cool! Some very valid points! I appreciate you writing this post and the rest of the website is really good.
Thanks for another great post. Where else could anybody get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.
Nicely… to be absolutely genuine, My partner and i had not been hoping to stumble upon this kind of data accidentally, as I did, because I recently came across your blog article whilst I used to be the truth is running looking throughout AOL, looking for some thing very close up however, not a similar… On the other hand at this time I will be over happy for being here and also I want to bring that the insight is extremely intriguing even though a little bit controversial to the recognized… I’d personally say it’s as much as discussion… but I’m frightened to cause you to an opponent, ha, ha, ha… However, for those who like to dicuss at length over it, you need to response to my remark and also I will always sign up so that I’ll be informed and are available back again for much more… Your current hopeful friend
It’s difficult to get knowledgeable individuals within this topic, but you appear to be guess what happens you’re discussing! Thanks
Hi” your blog is full of comments and it is very active”
Audio began playing anytime I opened this site, so annoying!
I can’t really help but admire your blog” your blog is so adorable and nice ,
We will design you a garden pool constructing that incorporates all these makes use of, or you can opt for two separate ones and have one of our small pool sheds put in for storage and then a totally lined and insulated backyard constructing for enjoyable and entertaining.
Perfectly written content material , thanks for entropy.
A blog like yours should be earning much money from adsense.::’;’
“I am shocked at the items I overlooked before I read this post.”
I am very happy to read this. This is the type of manual that needs to be given and not the random misinformation that’s at the other blogs. Appreciate your sharing this greatest doc.
A very informationrmative article and lots of really honest and forthright comments made! This certainly got me thinking about this issue, cheers all.
It’s actually a cool and helpful piece of info. I am satisfied that you shared this useful info with us. Please stay us informed like this. Thanks for sharing.
Will there always be a problem keeping a mattress protector on a memory foam mattress?
I am always thought about this, thankyou for putting up.
eye doctors are specially helpful whenever you have some eye problems**
You made some really good points there. I looked on the net for more info about the issue and found most people will go along with your views on this web site.
An fascinating discussion will be worth comment. I’m sure that you should write more about this topic, it might not be described as a taboo subject but usually everyone is too little to communicate on such topics. To another location. Cheers
oh i just hate the fat pads that i got, my fat pad is just genetics so i can’t do anything about it**
thank you for such a wonderful blog. Where else could anyone get that kind of info written in such a perfect way? I have a presentation that I am presently working on, and I have been on the look out for such info.
This is very interesting, You’re a very skilled blogger. I have joined your rss feed and look forward to seeking more of your fantastic post. Also, I have shared your web site in my social networks!
when i was younger, i always love the tune of alternative music compared to pop music;
of course above ground pools are easier to maintain and to clean..
It’s been a wild week or so watching individuals who I thought hated centralized social networks because of the harm they do giddily celebrating the entry into the fediverse of a vast, surveillance-centric social media conglomerate credibly accused of enabling focused persecution and mass murder.
Hey there, You have done an excellent job. I’ll certainly digg it and personally suggest to my friends. I am confident they will be benefited from this site.
It’s a shame you don’t have a donate button! I’d certainly donate to this outstanding blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will share this website with my Facebook group. Chat soon!
2024-08-10 Stray Youngsters feat.
Kotal joined Indian Tremendous League aspect Delhi Dynamos FC (present Odisha FC) for the 2017-18 season.
In 1731 he married the younger heiress Mary Ball, and they’d a household.
I’d need to consult with you here. Which isn’t some thing It’s my job to do! I like reading an article which will make people think. Also, many thanks permitting me to comment!
Hi there! I simply would like to give you a huge thumbs up for your excellent information you have got here on this post. I am coming back to your blog for more soon.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
For political and charitable companies in Scotland.
fitspresso reviews
Afteг attempting numeroᥙѕ fat burning supplements with ⅼittⅼe success, I lastly found FitSpresso,
and it has made a sіgnifіcant distinction. The mix of environment-friendly tea extract and Garcinia Cambogia has aided me lost stubborn pounds and keep a healthy weight.
I value that it’s made from natural active ingredients,
which straightens ԝith my commitment to a much healthier lifestyle.
FitSpresso has not only assisted mme drop weight yet likewise improved my overall health.
I feel more energеtic, concentгated, and prepared to
handle the dɑy. I extremely recommend FitSpresso to anyone trying to find a
reputable and reliable weight-loss remedy.
when i was a kid, i love to receive an assortment of birthday presents like teddy bears and mechanical toys..
Thanks, I’ve recently been searching for info approximately this topic for a while and yours is the best I have came upon till now. But, what about the bottom line? Are you certain about the source?
It’s perfect time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you few interesting things or tips. Maybe you could write next articles referring to this article. I want to read even more things about it!
If at all possible, when you gain knowledge, can you mind updating your site with more information? It is rather ideal for me.
It’s onerous to search out educated individuals on this subject, but you sound like you understand what you’re talking about! Thanks
Sometimes, blogging is a bit tiresome specially if you need to update more topics.“:”*
In 2014, June was nominated for a Blues Music Award within the ‘Greatest New Artist Debut’ class for Pushin’ In opposition to a Stone.
You have noted very useful details! PS. nice web site. “Disbelief in magic can force a poor soul into believing in government and business.” by Tom Robbins..
it does not take too long to learn good piano playing if you have a good piano lesson,.
You will find there’s obviously much to be informed on this. I reckon you made some very nice points in Features also. Keep working ,well done!
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Gaining muscle may also assist you to shed weight, which your joints will certainly admire — your physique continues burning increased rates of calories for hours after your workout.
If you have a site of your personal or a favorite you’d like to see included, let me know.
If you self-finance a business, all your income comes out of your clients, so they immediately become your primary precedence, not investors.
Army would first need to capture the city of Aachen in one of the toughest urban battles of World War II.
Stigma surrounding psychological health is a posh and multifaceted phenomenon that operates at both individual and societal ranges.
When this occurs, the bail agency often uses a bounty hunter to locate the defendant to have him or her taken back into custody.
Make sure he knows everything about home investors in Dallas tx and knows the wholesale investment property market of Dallas tx.
Thus you get to find most out of it.
The tournament pitted seven Swiss players against 9 internationals, together with six of the world’s leading players.
Presently, hundreds of farmers are abandoning the career every year.