Hi I am fairly new to programming. Anyway, I am trying to create a code where I make my program input new boxes after they press ok. Right now its just opening into a new window. How do I make this so that it’s in one window, and a new input box just shows up instead?
Here is my code:
import yfinance as yf
from tkinter import *
import customtkinter
customtkinter.set_default_color_theme("dark-blue")
root = customtkinter.CTk()
root.title('tkinter.com-CustomTkinter Input Window')
root.geometry = ('400x200')
def input():
dialog = customtkinter.CTkInputDialog(text=' Stock Ticker' , title='Stock Name')
dateInput = customtkinter.CTkInputDialog(text = 'Please Enter Start Date Here: YYYY-MM-DD', title= 'Start Date')
end_date = customtkinter.CTkInputDialog(text = 'Please Enter End Date Here: YYYY-MM-DD', title = 'End Date')
global thing
thing = dialog.get_input()
if thing:
my_label.configure(text=f"Hello: {thing}")
else:
my_label.configure(text=f'You forgot to write')
global date1
date1 = dateInput.get_input()
if date1:
my_label.configure(text=f"Hello: {date1}")
else:
my_label.configure(text=f'You forgot to write')
global date_end
date_end = end_date.get_input()
if date_end:
my_label.configure(text=f"Hello: {date_end}")
else:
my_label.configure(text=f'You forgot to write')
my_button = customtkinter.CTkButton(root, text = "Click Me", command = input)
my_button.pack(pady = 40)
my_label = customtkinter.CTkLabel(root, text='')
my_label.pack(pady=10)
root.mainloop()
New contributor
ben Stiller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.