Я пытаюсь сделать постраничную систему на tkinter, однако текст, начинающийся справа налево, выглядит немного странным, и я бы предпочел, чтобы текст распределялся равномерно от центра этикетки.
Пример
This is some really cool text
<< Prev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . >> Next
Чтобы затем стать
. . . . . . . . . . . . .. This is some really cool text
<< Prev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . >> Next
Точки есть, потому что Stackoverflow не позволяетболее одного пробела, так что просто игнорируйте их.Это должно выглядеть точно так же, как в центре внимания Microsoft Word
Вот базовый код, который я имею, я пытался использовать anchor = CENTER
, но он не работал как задумано.Извините, если это основной, я новичок в Tkinter
from tkinter import *
introText = ["Some say","That it is","very important","to clean","your hands","Yababababa doooooooo"]
currentPage = 1
def forceSize(main, width, height):
main.minsize(width, height)
main.maxsize(width, height)
def storyGUI(textList):
global currentPage
textListLength = len(textList)
def prevPage(main, textLabel):
global currentPage
if currentPage != 1:
textLabel.config(text = introText[currentPage-2])
main.title("Page "+str(currentPage-1))
currentPage -= 1
def nextPage(main, textLabel):
global currentPage
if currentPage != textListLength:
textLabel.config(text = introText[currentPage])
main.title("Page "+str(currentPage+1))
currentPage += 1
storyTK = Tk()
forceSize(storyTK, 400, 100)
storyTK.title("Page 1")
textLabel = Label(storyTK, text = introText[0], font = ("Calibri", 13), anchor = CENTER)
prevButton = Button(storyTK, text = "<< Prev", command = lambda: prevPage(storyTK, textLabel))
nextButton = Button(storyTK, text = "Next >>", command = lambda: nextPage(storyTK, textLabel))
textLabel.place(x = 160, y = 15)
prevButton.place(x = 30, y = 60)
nextButton.place(x = 310, y = 60)
storyTK.mainloop()
#def intro():
storyGUI(introText)