Delete Radiobuttons from running Tkinter GUI
up vote
0
down vote
favorite
I'm trying to delete the radiobuttons from my GUI using a Clear button. I found this example: enter link description here I know that I have to create a reference list for the Radionbutttons when creating them with a loop. And I can remove a button with grid_remove(). The point where I'm failing is to create the reference list. I'm getting a IndentationError: unexpected indent when i enter master.buttons.grid(column=val, row=2) into the Loop. This is my reduced code example:
import Tkinter as tk
master = tk.Tk()
var_step = IntVar()
step_mgl=session.odbs[path].steps.keys() #Imports the names of the steps from a file
i=0
steps=
while i < len(step_mgl):
steps.append((step_mgl[i], i+1))
i+=1
def clear():
for button in master.buttons:
button.grid_remove()
del master.buttons
master.buttons=
for txt, val in steps:
master.buttons.append(Radiobutton(master,
text=txt,
variable=var_step,
command=update,
value=val))
master.buttons.grid(column=val, row=2)
Button(master,text='Clear',command=clear).grid(row=3)
mainloop()
I tried so many things but i can't get this fixed, it's always the same Error. Thank you guys.
enter image description here
python tkinter
add a comment |
up vote
0
down vote
favorite
I'm trying to delete the radiobuttons from my GUI using a Clear button. I found this example: enter link description here I know that I have to create a reference list for the Radionbutttons when creating them with a loop. And I can remove a button with grid_remove(). The point where I'm failing is to create the reference list. I'm getting a IndentationError: unexpected indent when i enter master.buttons.grid(column=val, row=2) into the Loop. This is my reduced code example:
import Tkinter as tk
master = tk.Tk()
var_step = IntVar()
step_mgl=session.odbs[path].steps.keys() #Imports the names of the steps from a file
i=0
steps=
while i < len(step_mgl):
steps.append((step_mgl[i], i+1))
i+=1
def clear():
for button in master.buttons:
button.grid_remove()
del master.buttons
master.buttons=
for txt, val in steps:
master.buttons.append(Radiobutton(master,
text=txt,
variable=var_step,
command=update,
value=val))
master.buttons.grid(column=val, row=2)
Button(master,text='Clear',command=clear).grid(row=3)
mainloop()
I tried so many things but i can't get this fixed, it's always the same Error. Thank you guys.
enter image description here
python tkinter
Your code givesAttributeError: 'list' object has no attribute 'grid'. Replace withmaster.buttons[-1].grid(column=val, row=2)
– stovfl
yesterday
I tried your option but i still gives me the same error. I added a screenshot of the error at the end of my post.
– TimWo
15 hours ago
Read Lines and Indentation
– stovfl
14 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to delete the radiobuttons from my GUI using a Clear button. I found this example: enter link description here I know that I have to create a reference list for the Radionbutttons when creating them with a loop. And I can remove a button with grid_remove(). The point where I'm failing is to create the reference list. I'm getting a IndentationError: unexpected indent when i enter master.buttons.grid(column=val, row=2) into the Loop. This is my reduced code example:
import Tkinter as tk
master = tk.Tk()
var_step = IntVar()
step_mgl=session.odbs[path].steps.keys() #Imports the names of the steps from a file
i=0
steps=
while i < len(step_mgl):
steps.append((step_mgl[i], i+1))
i+=1
def clear():
for button in master.buttons:
button.grid_remove()
del master.buttons
master.buttons=
for txt, val in steps:
master.buttons.append(Radiobutton(master,
text=txt,
variable=var_step,
command=update,
value=val))
master.buttons.grid(column=val, row=2)
Button(master,text='Clear',command=clear).grid(row=3)
mainloop()
I tried so many things but i can't get this fixed, it's always the same Error. Thank you guys.
enter image description here
python tkinter
I'm trying to delete the radiobuttons from my GUI using a Clear button. I found this example: enter link description here I know that I have to create a reference list for the Radionbutttons when creating them with a loop. And I can remove a button with grid_remove(). The point where I'm failing is to create the reference list. I'm getting a IndentationError: unexpected indent when i enter master.buttons.grid(column=val, row=2) into the Loop. This is my reduced code example:
import Tkinter as tk
master = tk.Tk()
var_step = IntVar()
step_mgl=session.odbs[path].steps.keys() #Imports the names of the steps from a file
i=0
steps=
while i < len(step_mgl):
steps.append((step_mgl[i], i+1))
i+=1
def clear():
for button in master.buttons:
button.grid_remove()
del master.buttons
master.buttons=
for txt, val in steps:
master.buttons.append(Radiobutton(master,
text=txt,
variable=var_step,
command=update,
value=val))
master.buttons.grid(column=val, row=2)
Button(master,text='Clear',command=clear).grid(row=3)
mainloop()
I tried so many things but i can't get this fixed, it's always the same Error. Thank you guys.
enter image description here
python tkinter
python tkinter
edited 15 hours ago
asked yesterday
TimWo
83
83
Your code givesAttributeError: 'list' object has no attribute 'grid'. Replace withmaster.buttons[-1].grid(column=val, row=2)
– stovfl
yesterday
I tried your option but i still gives me the same error. I added a screenshot of the error at the end of my post.
– TimWo
15 hours ago
Read Lines and Indentation
– stovfl
14 hours ago
add a comment |
Your code givesAttributeError: 'list' object has no attribute 'grid'. Replace withmaster.buttons[-1].grid(column=val, row=2)
– stovfl
yesterday
I tried your option but i still gives me the same error. I added a screenshot of the error at the end of my post.
– TimWo
15 hours ago
Read Lines and Indentation
– stovfl
14 hours ago
Your code gives
AttributeError: 'list' object has no attribute 'grid'. Replace with master.buttons[-1].grid(column=val, row=2)– stovfl
yesterday
Your code gives
AttributeError: 'list' object has no attribute 'grid'. Replace with master.buttons[-1].grid(column=val, row=2)– stovfl
yesterday
I tried your option but i still gives me the same error. I added a screenshot of the error at the end of my post.
– TimWo
15 hours ago
I tried your option but i still gives me the same error. I added a screenshot of the error at the end of my post.
– TimWo
15 hours ago
Read Lines and Indentation
– stovfl
14 hours ago
Read Lines and Indentation
– stovfl
14 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371682%2fdelete-radiobuttons-from-running-tkinter-gui%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your code gives
AttributeError: 'list' object has no attribute 'grid'. Replace withmaster.buttons[-1].grid(column=val, row=2)– stovfl
yesterday
I tried your option but i still gives me the same error. I added a screenshot of the error at the end of my post.
– TimWo
15 hours ago
Read Lines and Indentation
– stovfl
14 hours ago