0
텍스트를 가운데 맞춤 텍스트 또는 ScrolledText 위젯에 배치하려고합니다. 어떻게 이뤄지나요? 이Tkinter와 스크롤 된 텍스트를 사용하여 파이썬에서 텍스트 정렬을 설정하려고 시도했습니다.
#Gui
import tkinter as tk
import tkinter.scrolledtext as tkst
from tkinter import *
def center_window(width=300, height=200):
# get screen width and height
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
# calculate position x and y coordinates
x = (screen_width/2) - (width/2)
y = (screen_height/2) - (height/2)
root.geometry('%dx%d+%d+%d' % (width, height, x, y))
root=Tk()
root.title("Writing is hard!")
center_window(1200,600)
heading = Label(root, text="Welcome to the app which checks your content for you!", font=("arial",30,"bold"), fg="steelblue")
label1=Label(root, text="Please type in your article: ", font=("arial",20,"bold"), fg="lightgreen")
ArticleTextBox = tkst.ScrolledText(width=100, height=20, justify='CENTER')
def do_it():
article=ArticleTextBox.get(0.0,tk.END)
print("Hello "+name.get())
print(article)
work= Button(root, text="work", width=30,height=5,bg="lightblue",command=do_it)
#Puts everything on screen
heading.pack()
label1.pack()
ArticleTextBox.pack()
work.pack()
root.mainloop()
텍스트 상자에 아무 것도 추가하지 않는 코드는 어디에도 없습니다. –
Bryan에게 감사 드려요.하지만 그건 사실입니다. 이것은 프로그램의 사용자가 워드 프로세서와 같은 ScrolledText에 타이핑하기 때문입니다. –