Возникла проблема с моей программой tkinter на Python. В одиннадцатой строке я поместил \n
, так как весь текст не соответствовал моему заданному размеру окна. Я хотел бы, чтобы новая строка начиналась справа (ie как нажатие клавиши ввода в редакторе текста). Появляется, когда вызывается новая строка, это основывает текст из центра. Я новичок в tkitner и поэтому не знаю всех команд / функций, поэтому помощь будет оценена. Iv'e добавил фото проблемы.
def password_basic_check():#Function that gets called when enter button is pressed. function check password matches. its lengh and if it has both upper and lower case letters
if password_enter_txt.get() != password_reenter_txt.get():#checks if both passwords matches
password_fault_report.configure(text='Passwords do not match, try again.')#prints this text out into the blank string
elif len(password_reenter_txt.get()) < 8:#checks if password lengh is below 8 characters
password_fault_report.configure(text='Password needs to be at least 8 characters long')
elif password_reenter_txt.get().islower() == True or password_reenter_txt.get().isupper() == True:#if password returns true if string has lower and upper case letters are used
password_fault_report.configure(text='Password needs have both upper\n and lower case lettes')
else:
password_fault_report.configure(text='Password correct')#if all of the password checks fail
window = Tk()
window.geometry('480x320') #setting size of window (pixles)
window.title('Password Checker')
window.iconbitmap('/Users/andypaling/Desktop/index.ico')#sets icon for window
welcome_lbl = Label(window, text='Welcome', font=('Arial', 26), fg='#71C2FE') #Label with text saying 'welcome' in light blue
welcome_lbl.place(x=15, y=10) #placing welcome label in top left of window
under_line_lbl = Label(window, text='__________________', font=('Arial', 35), fg='#FFB56B') #orange line under blue for looks
under_line_lbl.place(x=0, y=40)
intro_lbl = Label(window, text='Please enter your password: ', font=('Arial', 14, 'bold italic'))#lable with text underlined and italics
intro_lbl.place(x=10, y=90)
password_enter_lbl = Label(window, text='Password: ', font=('Candara', 10))
password_enter_lbl.place(x=10, y=120)
password_enter_txt = Entry(window, width=20, relief='raised')#entry box for user to enter their password
password_enter_txt.place(x=10, y=135)
password_reenter_lbl = Label(window, text='Re-enter password', font=('Candara', 10))#same as above for password reenter lbl and entry
password_reenter_lbl.place(x=10, y=160)
password_reenter_txt = Entry(window, width=20, relief='raised')
password_reenter_txt.place(x=10, y=175)
password_fault_report = Label(window, text='', font=('Arial', 14))#Empty label to be filled later to report password errors
password_fault_report.place(x=225, y=140)
password_enter_btn = Button(window, text='Enter.', relief='raised', width=6, bg='orange', command=password_basic_check)#button to enter password, when pressed, password_basic_check is called
password_enter_btn.place(x=10, y=210)
window.mainloop()
[photo of problem][1]
[1]: https://i.stack.imgur.com/GdQ1Y.png