hi, pls i have written a set of codes for a program and i want to deselect the radiobutton and also clear the contents of the entry widgets,the entry widgets get cleared tho. thank you

def adduser():
    name = "Name: " + entry_box1.get()
    reference_number ="Reference_number:  " + entry_box2.get()
    room_number = "Room_number: " + entry_box3.get()
    dan = "Daniel:  " + str(ticked_daniel.get())
    samp = "Sampson : " + str(ticked_sampson.get())
    morgan = "Morgan : " + str(ticked_morgan.get())

    timestamp = str(now)

    contact = [name + reference_number + room_number + dan + samp + morgan + timestamp]


    temp1 = open("VOTINGDATAF.txt", "a")
    temp1.write( name +'     '+ reference_number + '              ' + room_number +'                 '+ dan+'   ' + samp +'        '+ morgan + '      '+ timestamp)
    temp1.write("\n")
    entry_box1.delete(0, END)
    entry_box2.delete(0, END)
    entry_box3.delete(0, END)
    daniel.deselect()

and this is what i get as error

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python34\lib\idlelib\run.py", line 121, in main
    seq, request = rpc.request_queue.get(block=True, timeout=0.05)
  File "C:\Python34\lib\queue.py", line 175, in get
    raise Empty
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1487, in __call__
    return self.func(*args)
  File "C:/Python34/ec2.py", line 120, in adduser
    daniel.deselect()
AttributeError: 'Radiobutton' object has no attribute 'deselect'

Variable daniel will have to an instance of class Radiobutton.

check with
print(type(daniel))

You can also just select another radio button. It will deselect the others.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.