Aug-08-2021, 07:26 PM
(This post was last modified: Aug-08-2021, 07:30 PM by Yoriz.
Edit Reason: Added prefix
)
Hello
At the beginning I want show you what I want achieve.
I using tkinter: 2 text field and 1 button:
in the first text field I enter:
one
two
three
I press the button
The second field should show:
a:one
a:two
a:three
but unfortunately it appears:
a:one
two
three
it is my code:
Thank you for help, I beginning my adventure with Python so maybe my question is tryvial...
At the beginning I want show you what I want achieve.
I using tkinter: 2 text field and 1 button:
in the first text field I enter:
one
two
three
I press the button
The second field should show:
a:one
a:two
a:three
but unfortunately it appears:
a:one
two
three
it is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import tkinter as tk from tkinter import * def OpenWindow(): root = tk.Tk() root.geometry( '400x250' ) return root root = OpenWindow() text1 = Text(root, width = '12' , height = '10' ) text1.place(x = 20 ,y = 20 ) text2 = Text(root, width = "12" , height = "10" ) text2.place(x = 240 ,y = 20 ) def click(): text_input = text1.get( "1.0" , END) text2.delete( 1.0 , END) for i in text_input: row_word = ( 'a:' + text_input) text2.insert( 1.0 , row_word) button_click = Button(root, text = 'add' , command = click) button_click.pack() root.mainloop() |