0

我正在尝试将文本与左上角对齐(仅使用 tkinter)。到目前为止,我没有尝试过任何工作(锚点、打包、带有粘性“w”的网格),我不明白为什么。我正在使用几个类,并且标签位于定义为其父级的框架内。到目前为止,该框架没有任何属性,并且当用户通过板子选择一个单词时,此标签上的文本正在更新。当我添加很多单词(3-4 行)时,它确实会向上。

        self.__words_found = ""
        WordsContainer.IMAGE = tki.PhotoImage(file="words_container2.png")
        self.__words_found_label = tki.Label(self.__parent,
                                             text=self.__words_found,
                                             font=("David", 18),
                                             image=WordsContainer.IMAGE,
                                             compound='center',
                                             justify='left',
                                             relief=tki.FLAT, height=105,
                                             width=500)
        self.__words_found_label.grid(row=0, column=0,
                                      sticky='w')

    def add_word(self, word):
        if self.__current_index == 0:
            self.__words_found = word
        else:
            self.__words_found = self.__words_found + ", " + word
        if self.__current_index > 0 and self.__current_index % 20 == 0:
            self.__words_found = self.__words_found + '\n' + word
        self.__words_found_label.config(text=self.__words_found)
        self.__current_index += 1

它看起来像这样: 我想在找到的单词下对齐 'a,a,a,a,a'

4

0 回答 0