I am creating an app that tracks progress of tasks with progress bars. The idea is that I ask the user to input details about the task they have to complete( Client Name and Client Contact). Whenever you click the button to add a task, I should get the following.
The client name
The client contact
Progress bar
Increment button
However every time I run the code below I get the error
Traceback (most recent call last):
File "c:/Users/algor/OneDrive/Documents/Computer Science/Testgrid.py", line 44, in <module>
new = CNuser.get()
AttributeError: 'NoneType' object has no attribute 'get'
Can someone tell me what is wrong?
I tried looking at examples of dealing with user input in tkinter but had no success.
from tkinter import *
import tkinter as tk
from tkinter.scrolledtext import ScrolledText
from tkinter import ttk
from PIL import ImageTk, Image
import smtplib
import os
tasks = Tk()
tasks.geometry("1920x1080")
# These are the contents of the tasks tab
rows = 0
while rows < 50:
tasks.rowconfigure(rows, weight=20)
tasks.columnconfigure(rows, weight=20)
rows += 1
count = 1
count1 = 0
subtitle = Label(tasks, text="Task List:").grid(row=0, column=0)
CN = Label(tasks, text="Client Name*").grid(row=2, column=0, padx=3, pady=3)
CNuser = Entry(tasks, textvariable=CN).grid(row=3, column=0, padx=3, pady=3)
CC = Label(tasks, text="Client Contact*").grid(row=5, column=0, padx=3, pady=3)
CCuser = Entry(tasks, textvariable=CC).grid(row=6, column=0, padx=3, pady=3)
# progress bars
def addtask():
global count
global count1
global CNuser
global CCuser
new = CNuser.get()
def step():
my_progress["value"] += 20
Label(tasks, text=new, font=("Calibri")).grid(
column=1, row=count + 1)
Label(tasks, text=CCuser, font=("Calibri")).grid(
column=1, row=count + 2)
my_progress = ttk.Progressbar(
tasks, orient=HORIZONTAL, length=600, mode='determinate')
my_progress.grid(column=1, row=count + 3)
my_button = Button(tasks, text="New action complete",
command=step).grid(column=1, row=count + 4)
for i in range(1, 6):
count1 += 1
count = count + count1
Button(tasks, text="New task", command=addtask).grid(row=1, column=0)
tasks.mainloop()