Debugging RadioButtons program in Python

2024/10/8 2:27:34
from Tkinter import *class Application (Frame):def __init__(self, master):Frame.__init__(self, master)self.grid()self.create_widgets()def create_widgets(self):Label(self, text = "Select the last book you read.").grid (row = 0, column = 0, sticky = W)self.choice = StringVar() Radiobutton (self,text = "Nausea by Jean-Paul Sartre",variable = self.choice,value = "Wake up. This is a dream. This is all only a test of the emergency broadcasting system.",command = self.update_text).grid (row = 2, column = 1, sticky = W)Radiobutton (self,text = "Infinite Jest by David Foster Wallace",variable = self.choice,value = "Because an adult borne without the volition to choose the thoughts that he thinks, is going to get hosed ;)",command = self.update_text).grid (row = 3, column = 1, sticky = W)Radiobutton (self,text = "Cat's Cradle by Kurt Vonnegut",variable = self.choice,value = " \"Here we are, trapped in the amber of the moment. There is no why!\" ",command = self.update_text.grid (row = 4, column = 1, sticky = W)self.txt_display = Text (self, width = 40, height = 5, wrap = WORD)self.txt_display.grid (row = 6, column = 0, sticky = W)#There is only one choice value - self.choice. That can be "printed."def update_text(self):message = self.choice.get()self.txt_display.delete (0.0, END)self.txt_display.insert (0.0, message)# The Main
root = Tk()
root.title ("The Book Critic One")
root.geometry ("400x400")app = Application (root)
root.mainloop()

I keep getting a Syntax Error in the self.text_display_delete line which I can't seem to lose.

Any input would be greatly appreciated.

Answer

Take a look at the previous line - I only count one closing parenthesis, while you should have two:

 Radiobutton (self,text = "Cat's Cradle by Kurt Vonnegut",variable = self.choice,value = " \"Here we are, trapped in the amber of the moment. There is no why!\" ",command = self.update_text.grid (row = 4, column = 1, sticky = W)) #<-- Missing that second paren

Usually if one line looks clean, the syntax error is on the previous line(s), and 99% of the time it's a missing paren.

https://en.xdnf.cn/q/118750.html

Related Q&A

Why am I getting an Internal Server error

My python script runs just fine on the Apache server locally set up on my computer, however, on importing the json2html library I am getting an internal server errorThe moment I comment the import stat…

Save pixel data in txt format in PIL

My program is to extract the pixel from an image and to save the pixel data in the text file for analysis. My picture is a binary image that gives only 255 and 0 sHere is the program:from PIL import Im…

ValueError: view limit minimum 0.0 is less than 1 and is an invalid Matplotlib date value

Ive been given the python script where matplotlib is used , when running the script it opens the window and display graph. its working perfectly on my laptop. But this error occurs when I upload the fi…

Python win32com Outlook Stores not iterable

Trying to list all Outllook stores (and finally all e-mails in those stores):import win32com.clientoutlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") sto…

Using a users input to search dictionary keys and print that keys matching value

I am working with tkinter, as I have my gui set up with and entry, label, and button. Im trying to search my dictionarys keys with the users input from the entry, and print the value of the key that wa…

How to write CSV into the next column

I have output that I can write into a CSV. However, because of how i setup my XML to text, the output iterates itself incorrectly. Ive tried a lot to fix my XML output, but I dont see any way to fix it…

Comparing date from pandas dataframe to current date

Im currently trying to write a script that does a specific action on a certain day. So for example, if today is the 6/30/2019 and in my dataframe there is a 6/30/2019 entry, xyz proceeds to happen. How…

How to divide a binary file to 6-byte blocks in C++ or Python with fast speed? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 5…

Selenium, python dynamic table

Im creating a robot with selenium that get all info from agencies in Brasil, ive alredy done the permutation click between all States and counties, all i have to do nows click in all agencies and get i…

How to split string into column

I got a csv file with some data, and I want to split this data.My column one contains a title, my column 2 contains some dates, and my column 3 contains some text linked to the dates.I want to tran…