Обработка многократного вхождения в tkinter python - PullRequest
0 голосов
/ 27 сентября 2019

В tkinter (код прилагается) всякий раз, когда я нажимаю кнопку «+», которая создаст новое текстовое поле, но получит текстовое значение как пустое. Попробуйте несколько способов, но я не могу получить результат. Пожалуйста, помогите получитьвходное значение из множественного ввода. Пожалуйста, обратитесь к указанному коду

import tkinter
from tkinter import *

window = Tk()
window.geometry("700x650")
window.configure(background='#7dd4ca')
window.title('vinoj')
i = 50
j = -1


def campaign_text_box_value():
    print(campaign_text_box.get())


def line_item_text_box_value():  # use for multiple text box by press +
    global i, j
    j = j + 1
    i = i + 50
    print(j)
    input_text = 'alttext' + str(i)
    input_text = Entry(window, textvariable=input_text)
    input_text.place(x=220, y=i)
    print(input_text.get())


def submit_all_lines():
    print(str(line_item_text_box.get()))


campaign_text_name = tkinter.Label(window, text='campaign name', height=2, width=25, bg='#c9d1ce', fg='white')
campaign_text_name.place(x=2, y=20)
campaign_text_box = Entry(window, textvariable='campaign_text_name')
campaign_text_box.place(x=220, y=20)
campaign_text_box_button = tkinter.Button(window, text='submit', bg='green', fg='white', height=2, width=10,
                                          command=lambda: campaign_text_box_value())  # button creation
campaign_text_box_button.place(x=580, y=15)
line_item_text_name = tkinter.Label(window, text='Line Item Name', height=2, width=25, bg='#c9d1ce', fg='white')
line_item_text_name.place(x=2, y=100)
line_item_text_box_button = tkinter.Button(window, text='+', bg='green', fg='white', height=2, width=10,
                                           command=lambda: line_item_text_box_value())  # button creation
line_item_text_box_button.place(x=580, y=100)
line_item_text_box_submit_all_button = tkinter.Button(window, text='submit_all', bg='green', fg='white', height=2,
                                                      width=10, command=lambda: submit_all_lines())  # button creation
line_item_text_box_submit_all_button.place(x=580, y=185)
window.mainloop()
...