0

次のコードで少し問題があります。タグのタプルを使用すると、何を試しても、coords 関数は空のリストを返します。

def drop_line(self, event):
    """
    Function to call when the mouse is released. Creates a permanent bond between people.
    """
    self.delete_temporary()
    person = self.canvas.find_enclosed(event.x - self.people_size_var.get(),
                                       event.y - self.people_size_var.get(),
                                       event.x + self.people_size_var.get(),
                                       event.y + self.people_size_var.get())

    # Writing friendships to dictionary.
    try:
        Link.person_name = self.canvas.gettags(person)
        Link.friends_dictionary[Link.person_name[0]] = (Link.friend_name[0] + "," +
                                                        Link.friends_dictionary[Link.person_name[0]])
        Link.friends_dictionary[Link.friend_name[0]] = (Link.person_name[0] + "," +
                                                        Link.friends_dictionary[Link.friend_name[0]])
        line = self.canvas.create_line(self.pos_x, self.pos_y, event.x, event.y, activefill="red", smooth=True,
                                       fill="black",width=self.edge_width_var.get(),
                                       tags=("permanent", Link.person_name[0], Link.friend_name[0]))


        # My problem is here :( Can't get the last 2 prints to work

        print(self.canvas.gettags(line))
        print(("permanent", Link.person_name[0], Link.friend_name[0]))
        print(self.canvas.coords(("permanent", Link.person_name[0], Link.friend_name[0])))
        print(self.canvas.coords(self.canvas.gettags(line)))

アイデアやリンクであっても、どんな助けでも大歓迎です!

ありがとうございました。

4

1 に答える 1