Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
write to csv file problem
#12
if, if and should. I can't imagine why that might not return something.

That is some ugly code. A lot of the ugly is from using Entry. Entry is a terrible choice for entering information. For entering an integer I would think about using a spinbox. For entering departure or destination I would look at using a checkbox or option menu

If you want to use Entry I suggest subclassing Entry to make an IntEntry and an ListEntry that force users to enter valid information. These would have validation built into the control, so you don't have to write extra code to validate each entry object's value. The beauty of writing an Entry sublcass that does the validation is you only feel the pain once, when you write the sublcass. Currently you are feeling the pain each time you use an Entry widget to enter a number.

After you get the entry part fixed, you should change how your code uses the information. Your code should not allow the user to check a flight if there are errors in any of the entries. If your form has a submit button, I would disable the button if the form is not valid. Another choice is the submit button first checks the form, and only executes the submit callback if all the entries are valid. The more you can separate the data entry part of the program from the doing work part of the program, the cleaner and more robust your code will be.
Reply


Messages In This Thread
write to csv file problem - by jacksfrustration - Nov-03-2023, 03:55 PM
RE: write to csv file problem - by noisefloor - Nov-03-2023, 05:05 PM
RE: write to csv file problem - by deanhystad - Nov-03-2023, 05:54 PM
RE: write to csv file problem - by deanhystad - Nov-03-2023, 10:22 PM
RE: write to csv file problem - by jacksfrustration - Nov-03-2023, 10:47 PM
RE: write to csv file problem - by deanhystad - Nov-04-2023, 05:43 AM
RE: write to csv file problem - by jacksfrustration - Nov-07-2023, 02:31 PM
RE: write to csv file problem - by deanhystad - Nov-07-2023, 03:55 PM
RE: write to csv file problem - by jacksfrustration - Nov-07-2023, 04:32 PM
RE: write to csv file problem - by deanhystad - Nov-07-2023, 06:30 PM
RE: write to csv file problem - by jacksfrustration - Nov-07-2023, 08:58 PM
RE: write to csv file problem - by deanhystad - Nov-09-2023, 01:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What does .flush do? How can I change this to write to the file? Pedroski55 3 288 Apr-22-2024, 01:15 PM
Last Post: snippsat
  Last record in file doesn't write to newline gonksoup 3 485 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,563 Nov-09-2023, 10:56 AM
Last Post: mg24
  How do I read and write a binary file in Python? blackears 6 7,074 Jun-06-2023, 06:37 PM
Last Post: rajeshgk
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,151 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Read text file, modify it then write back Pavel_47 5 1,689 Feb-18-2023, 02:49 PM
Last Post: deanhystad
  how to read txt file, and write into excel with multiply sheet jacklee26 14 10,322 Jan-21-2023, 06:57 AM
Last Post: jacklee26
  How to write in text file - indented block Joni_Engr 4 6,534 Jul-18-2022, 09:09 AM
Last Post: Hathemand
  Upgrading from 2 to 3 and having file write problems KenHorse 2 1,526 May-08-2022, 09:47 PM
Last Post: KenHorse
  Cursor write 3rd file empty paulo79 3 1,924 Mar-10-2022, 02:51 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020