def insert_radiobutton(self, what: str="", variable: tk.IntVar=None, value: int=0, fill_line: bool=True, index: int or str="end", command=None, *args):
"""Inserts a radiobutton into the game."""
tag = "Radio-{}-{}:{}".format(re.sub("[^0-9a-zA-Z]+", "", str(variable)), str(value), self.id_current_radio)
if variable.get() == value:
self.text.tag_configure(tag, foreground=self.colour_radio_on)
elif variable.get() != value:
self.text.tag_configure(tag, foreground=self.colour_radio_off)
self.text.insert(index, what + "\n" if fill_line else what, tag)
self.unbind_tag(tag, release=True, both=True)
self.text.tag_bind(tag, "<ButtonRelease-1>", command, "+")
self.text.tag_bind(tag, "<Button-1>", lambda *args: self.toggle_radio(variable, value, tag), "+")
self.bind_cursor(tag)
self.bind_background(tag)
self.id_current_radio += 1
评论列表
文章目录