def insert_trigger(self, what: str="", fill_line: bool=False, index: int or str="end", command=None, *args):
"""Inserts a trigger into the game."""
tag = "Trigger-{}:{}".format(re.sub("[^0-9a-zA-Z]+", "", what), self.id_current_trigger)
self.text.tag_configure(tag, foreground=self.colour_trigger_on)
self.text.insert(index, what + "\n" if fill_line else what, tag)
self.unbind_tag(tag)
self.text.tag_bind(tag, "<Button-1>", command, "+")
self.text.tag_bind(tag, "<Button-1>", lambda *args: self.toggle_trigger(tag), "+")
self.bind_cursor(tag)
self.bind_background(tag)
self.id_current_trigger += 1
return tag
评论列表
文章目录