0

I'm trying to align the text to the top left (using tkinter only). Nothing I tried works so far (anchor, pack, grid with sticky 'w') and I can't understand why. I'm working with several classes, and the label is within a frame defined as its parent. The frame has no attributes so far, and the text on this label is being updated when the user picks a word through the board. When I add a lot of words (3-4 lines), it does go upwards.

        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

it looks like this: I want to align the 'a,a,a,a,a' under words found

lir0ni
  • 1
  • 1
  • Read [`compound=` - use TOP to draw the image above the text](http://effbot.org/tkinterbook/label.htm#Tkinter.Label.config-method). Relevant [labels-image-in-fixed-position](https://stackoverflow.com/questions/40997154/tkinter-labels-image-in-fixed-position) – stovfl Jan 18 '20 at 14:04
  • it'll present the text beside the the image as far as i understand, while I want the text to be on the image and left aligned – lir0ni Jan 18 '20 at 15:15
  • ***"want the text to be on the image and left aligned"***: `.Label(..., anchor='w')`. [Label.config-method - `anchor=`](http://effbot.org/tkinterbook/label.htm#Tkinter.Label.config-method) – stovfl Jan 18 '20 at 17:30
  • You need to use `Canvas` to hold the image and the text. – acw1668 Jan 20 '20 at 06:09

0 Answers0