The attachment shows what I'm trying to achieve.
a) The program reads in a csv file containing names of songs (song1 - song5 etc).
b) the exact names from the csv file display in a text widget i.e. the widget shows song1, song2, song 3 etc
c) a user clicks one of those names and the program looks in a directory that contains those exact names but with a mp3 suffix i.e. song1.mp3, song2.mp3 etc and loads vlc media player.
d) The song names obviously differ in real life, but I wanted to show that the CSV, text widget and windows explorer names are all common.
I need to understand how to make this happen.
1) I understand loading the csv and tagging the text, so the user knows where to click
2) I dont understand the procedure when a user clicks the text, i.e. how to work out the area in the text widget the user clicked and from that how to create some sort of binding to load the file, a mp3 suffix would need to be automatically attached also.
EDIT Working Code added
def viewFile(event):
path = "c:\\pdf"
suffix= ".pdf"
self.outputbox.tag_remove("dwg", "1.0", "end")
self.outputbox.tag_configure("dwg", background="red")
self.outputbox.tag_add("dwg", "insert linestart", "insert lineend")
getdwg=self.outputbox.get("insert linestart", "insert linestart+10c")
getdwg=getdwg.strip()
linkname = (getdwg + suffix)
self.outputbox.tag_bind("dwg", "<ButtonRelease-1>", lambda event, filename=path + '/' + linkname: subprocess.run(filename, shell=True))
There is a couple of fixed items that are used to generate the final filename and path which may not be relevant to others namely 'path', 'suffix' but it appears to work as required :)