I'm having some trouble understanding how to get tags to work on my particular application, what I have is a text widget called 'dwgoutputbox' that displays a number of fields after reading a CSV file
In this instance, the dwgoutputbox
text widget displays a number of string variables descDwg1,descDwg2,descDwg3
which are the items in the first column, followed by the 'issue' number which are other variables
I'm trying to get the items in the first column to highlight so eventually I can make them clickable as they will link to files.
As the items in the first column will change, depending on the CSV search (but remain in the below general format) I'm unsure of how to get the tag_config to work
self.outputQty.insert(INSERT,descQty)
self.outputDesc.insert(INSERT,descPN, END," ", END, descInfo)
self.dwgoutputbox.insert(INSERT, descDwg1, END, " ", END, " Issue: ",END,descIss1,END, "\n")
self.dwgoutputbox.insert(INSERT, descDwg2, END, " ", END, " Issue: ",END,descIss2,END, "\n")
self.dwgoutputbox.insert(INSERT, descDwg3, END, " ", END, " Issue: ",END,descIss3,END, "\n")
format_link()
def format_link(dwgoutputbox,tag,apply_tag):
self.dwgoutputbox.tag_config(tagName="19",foreground="blue",underline=1)
dwgoutputbox.tag_bind(tag,"<Button-1>",apply_tag)
Ok, managed to get it to work as expected, largely due to the help and patience of Bryan Oakley - thank you its greatly appreciated.
self.dwgoutputbox = Text(root, borderwidth=0, width=50, height=15, foreground="#ffffff",background="#3F3F3F", font="system_font 10")
self.dwgoutputbox.grid(row=3, column=2, columnspan=5, padx=2, pady=3)
self.dwgoutputbox.tag_config("dwg",foreground="lightblue")
self.dwgoutputbox.insert(1.0, descDwg3, "dwg", " Issue: ", "", descIss3, "", "\n")
self.dwgoutputbox.insert(1.0, descDwg2, "dwg", " Issue: ", "", descIss2, "", "\n")
self.dwgoutputbox.insert(1.0, descDwg1, "dwg", " Issue: ", "", descIss1, "", "\n")
half my problem is there doesnt appear to be many / any good 'basic' explanations of the more advanced stuff, which presents a newbie of a month of playing with python a good challenge. Enjoying it though :)