how would you write this function in non oop

def highlight(self, seq):
         if "highlight" in self.textWidget.tag_names():
            self.textWidget.tag_delete("highlight")
            i = len(seq)
            idx = "1.0"
         while True:
            idx = self.textWidget.search(seq, idx, nocase=1, stopindex='end')
            if idx:
                idx2 = self.textWidget.index("%s+%dc" % (idx, i))
                self.textWidget.tag_add("highlight", idx, idx2)
                self.textWidget.tag_config("highlight", background="yellow")
                idx = idx2
            else: return

Maybe I am misunderstanding, but you'd simply take the self.textWidget (which seems to be the only class/instance variable in this problem) and make it either a global variable, or pass it to your method as an argument.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.