Question

In: Computer Science

This is in Python, I am trying to create a new window to print the data...

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:]))

Solutions

Expert Solution

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.


Related Solutions

this is my code in python I am trying to open a file and then print...
this is my code in python I am trying to open a file and then print the contents on my console but when i run it nothing prints in the console def file_to_dictionary(rosterFile): myDictionary={}    with open(rosterFile,'r') as f: for line in f: myDictionary.append(line.strip()) print(myDictionary)             return myDictionary    file_to_dictionary((f"../data/Roster.txt"))      
I am trying to write a python code to create a function that returns all possible...
I am trying to write a python code to create a function that returns all possible dimensions (reshaping) for an input matrix, can someone explains the math and write a python code with explaining all the steps and give me a test cases, and please explain if there is more than one approach. so if we have 1*8 matrix we should return 1*8, 2*4,4*2,8*1 def reshaping(M) should return a n ORDERED list AND the all possible reshaped matrices
I am trying to create bit masks to create a new binary number with the original...
I am trying to create bit masks to create a new binary number with the original bits' orders turned around, and concataneted. For example, int test=0b01100010001010001001(20 bits) now, I need bit masking to make it: int result = 20th bit, 10-1 bits, 11th bit, 19-12 bits, in this order. So in this case, answer would be: 0(20th bit)10100010(10-1 bits)0(11th bit)1011000100(19-12 bits). Im trying to do something like int res |= test & 0x7F800; res |= test& 0x400; Can't seem to...
I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
Hi I am having the following problem. At the moment I am trying to create a...
Hi I am having the following problem. At the moment I am trying to create a bode plot for the following function. G(s)=(Ks+3)/((s+2)(s+3)) Note: Not K(s+2)! I then want to plot multiple bode plots for various values of K. Eg. 1,2,3, etc. I am having two separate issues. 1. How do I define the TF with a constant K in the location required (a multiple of s in the numerator) 2. How do I create multiple bode plots for values...
I am trying to create new empty dataset with a shape (40, 30) in phyton with...
I am trying to create new empty dataset with a shape (40, 30) in phyton with using pandas. How can I create it?
I am trying to create a classified balance sheet and I am unsure what is involved...
I am trying to create a classified balance sheet and I am unsure what is involved when reporting the current assets, liabilities and owners equity?
I am working on a project for my Computer Science course. I am trying to create...
I am working on a project for my Computer Science course. I am trying to create a Battleship game where a user names two coordinates on a grid and is then told whether this results in a "Hit" or a "Miss". Once the ship has been hit a certain number of times (based on the size of the ship) the ship is sunk. I have written all the code but it now fails to execute when I try to run...
In trying to apply my knowledge in the real world, I am trying to create a...
In trying to apply my knowledge in the real world, I am trying to create a realistic retirement schedule. However, I am running into difficulties using both a financial calculator as well as our equations from class in doing this. I am trying to do the following: plan a retirement schedule between the ages of 25 and 70, in which I would deposit 20% of my income each year. The income starts at 80,000 with an annual growth rate of...
This is my code for python. I am trying to do the fourth command in the...
This is my code for python. I am trying to do the fourth command in the menu which is to add an employee to directory with a new phone number. but I keep getting error saying , "TypeError: unsupported operand type(s) for +: 'dict' and 'dict". Below is my code. What am I doing wrong? from Lab_6.Employee import * def file_to_directory(File): myDirectory={}       with open(File,'r') as f: data=f.read().split('\n')    x=(len(data)) myDirectory = {} for line in range(0,199):      ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT