So I'm a newbie when it comes to creating GUI's in Python, and I was wondering how I can add values/integers in an Entry Field that has its state disabled in Python. I've actually done the same thing in Java, but I can't seem to figure out how to translate from Java to Python.
Java Version
C_ID.setText(String.valueOf(Integer.parseInt(C_ID.getText())+1));
Python Code
# Title for the Registration Form
label = Label(window, text="Customer Registration System", width=30, height=1, bg="yellow", anchor="center")
label.config(font=("Courier", 10))
label.grid(column=2, row=1)
# Customer ID Label (Left)
ID_Label = Label(window, text="Customer ID:", width=14, height=1, bg="yellow", anchor="w")
ID_Label.config(font=("Courier", 10))
ID_Label.grid(column=1, row=2)
# Customer ID Input Field
C_ID = StringVar()
C_ID = Entry(window, textvariable=C_ID, text="1")
C_ID.insert(0, "1")
C_ID.config(state=DISABLED)
C_ID.grid(column=2, row=2)
Extra Info:
My code needs to increment by 1 every time I press the save button.
def save():
if len(C_Name.get()) == 0 or len(C_Email.get()) == 0 or len(C_Birthday.get()) == 0 or len(
C_Address.get()) == 0 or len(C_Contact.get()) == 0:
msg_box("All Input Fields Must Be Complete", "Record")
elif not check_email:
msg_box("Please Input a Valid Email", "Record")
elif not check_dateValid:
msg_box("Please Input a Valid date", "Record")
elif not check_minor:
msg_box("Minors are Not Allowed to Register", "Record")
else:
msg_box("Save Record", "Record")
I tried using this code right here,
C_ID.config(text=str(int(C_ID.get())+1))1
But it doesn't seem to add no matter what I do.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…