[Python]Auto-dependency for selected tasks

A place to post your ideas and solutions for how best to make use of the software

Moderators: abstr, Niko

Post Reply
Niko
Posts: 239
Joined: Wed Sep 18, 2019 6:48 am

[Python]Auto-dependency for selected tasks

Post by Niko » Mon Jan 13, 2020 2:06 pm

Maybe you remember my prior script which allows you to convert the content of a folder into tasks and the chapters of a book into tasks.
After that is done, usually I have I have to make each task dependent to the higher one manually, that takes much time, especially when you have more than 10 elements.
This script allows you to make each task below dependent on the task above it. All you need to do is to input in the console the ID of the first and the last tasks.
TESTING
1.gif
1.gif (144.15 KiB) Viewed 4701 times
ADD NEW TASKS using loops
2.gif
2.gif (370.5 KiB) Viewed 4701 times
THE WORKING SOLUTION
3.gif
3.gif (493.42 KiB) Viewed 4701 times

Code: Select all

import os
from time import sleep
# %% markdown
# # Input Values (Task Numbers 110-120)
InptStartID = int(input("Input ID of the first task"))
InptEndID = int(input("Input ID of the last task"))
listnewStart = []
listendFinish = []
# %% markdown
# # Make Lists
for z in range (InptStartID,InptEndID+1):
    (listendFinish.append(z))
print (listendFinish)
for x in range (InptStartID+1,InptEndID+1):
    (listnewStart.append(x))
print (listnewStart)
# %% markdown
# # Input Values (Task Numbers 110-120)
for i, j in zip(listnewStart, listendFinish):
    #print (i,j)

    pathtotdl = "C:/{ThePathToTDL}/ToDoList.exe /$(seltid)"
    variables1 = " -tid "
    variables2 = " -dp "
    cmd = pathtotdl+variables1+str(i)+variables2+str(j)
    sendcommand = os.system(cmd)
    sleep(1)
        
Next version of the script will be "all-in-one solution", where you wouldn't need use the first script at the beginning.

User avatar
abstr
Site Admin
Posts: 370
Joined: Sun Jul 28, 2019 12:22 pm

Re: [Python]Auto-dependency for selected tasks

Post by abstr » Mon Jan 13, 2020 11:42 pm

Rather than entering the first/last task IDs manually, you could simply select a range of tasks in the tree and use '$(seltid)' in your UDT.

TDL will then pass the IDs on the commandline as '<first>|<second>|...|<last>' eg.In your example you would select all tasks between 10 and 20 and TDL will pass '10|11|12|13|14|15|16|17|18|19|20' on the commandline.

Presumably your python script could easily parse that string...

ps. Currently the task IDs are ordered exactly as they appear in the Task Tree. ie. the order is affected by sorting

Niko
Posts: 239
Joined: Wed Sep 18, 2019 6:48 am

Re: [Python]Auto-dependency for selected tasks

Post by Niko » Tue Jan 14, 2020 5:20 pm

Thank you, Daniel. I definitely have to learn more about UDT scripts.
I will try to make a new version of the script, taking into account the information you provided (the simpler the better)

Post Reply