In: Computer Science
This is in Python, I am trying to create a new window to print the data to screen, it prints fine in the terminal. I know this is a small segment of my code and its the only portion I am having a problem with. I was wondering if anyone can see what my problem may be. The current issue is
NameError: name 'fltVal' is not defined and AttributeError: 'PressureGUI' object has no attribute 'r_count'
Any help would be appreciated Based on the comment I made some changes which got me past the error above
The updated code is now with a new error of
File "/Volumes/NO NAME/CSE-222/Data Analysis
Program/pressure_data.py", line 175, in
print_data_range_console
text= str(format(float,
'10.2f'))).grid(row=self.r_count,column=self.c_count)
TypeError: unsupported format string passed to type.__format__
I know it has to do with line 12 below but I am confused at this point
My output should be barometric pressue in the format of 1028.95 in one column and temp in the second column
def print_data_range_console(self):
new_win = tkinter.Toplevel(self.window)
label = tkinter.Label(new_win, text="Data Print")
#display_data_win = tkinter.Tk
#self.DisplayDataWin = display_data_win()
#self.display_win_open = True
"""Prints the given data selction to the console"""
print(" ".join(self.window.radio_var.get().split()))
for i in self.get_data_range():
self.DisplayWin.dd_win.data_lbl =
tk.Label(self.get_data_range,\
font=('Helvetica',10), bg='white',\
text= str(format(float,
'10.2f'))).grid(row=self.r_count,column=self.c_count)
self.col_count = self.c_count + 1
if self.col_count == 6:
self.col_count = 1
self.row_count = self.r_count + 1
print(" ".join(str(x) for x in i[1:]))
def print_data_range_console(self): new_win = tkinter.Toplevel(self.window) label = tkinter.Label(new_win, text="Data Print") #display_data_win = tkinter.Tk #self.DisplayDataWin = display_data_win() #self.display_win_open = True """Prints the given data selction to the console""" print(" ".join(self.window.radio_var.get().split())) for i in self.get_data_range(): self.DisplayWin.dd_win.data_lbl = tk.Label(self.get_data_range,\ font=('Helvetica',10), bg='white',\ text= '%10.2f'.format(i)).grid(row=self.r_count, column=self.c_count) self.col_count = self.c_count + 1 if self.col_count == 6: self.col_count = 1 self.row_count = self.r_count + 1 print(" ".join(str(x) for x in i[1:]))
************************************************** You can format the string as '%10.2f'.format(i), where i is the number which you want to print with 2 decimal digits.. I am sorry, but your question is not very clear on what you want to print.. however the error exists because there is no format method.. Format method is found in string class, hence '%10.2f'.format is called. Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.