Iain,
Good to hear that things are coming together.
Here is a little help on the start time sort.
The data manager sort is based on the program requirements and is usually the name, station distance or stop sequence.
The following change sorts the train list by start time:
# for train in trains:
for train in sorted(trains, key = lambda t: t.getStartTime()):
The ¡°sorted¡± method takes a list and creates a new list that has been sorted. In this example, the new list is transient and feeds the ¡°for train in¡± phrase. The ¡°key=¡° provides an alternate key. Since a ¡°train¡± is a Java object, Python does not know how to get a value for the key. The ¡°lamda¡± keyword indicates that an anonymous function will provide the value with the function being "t: t.getStartTime()".
Dave Sand
toggle quoted message
Show quoted text
On Dec 18, 2018, at 10:42 AM, Iain <iain@...> wrote:
Dave,
I have spent some time with your program and have come to understand it.
It's about 20 years since I last wrote programs and the facilities of the languages have changed dramatically. I would never have worked out how to get input via rolling selection lists.
I have made a couple of changes in order to get raw times and times in Excel format (that is where the time is a fraction of 1 or 1*(time in mins/1440). I am now looking at getting trains sorted by start times (ultimately by a specified station departure time) in order to produce "printed" timetable data.
It's all very interesting, and I am glad I have a decent editor which keeps me clear on required indentations!
Thanks for getting me started.