Brief description of the application:
I have created an application form that is attempting to capture a "X" quantity of serial numbers and the Serial Number itself. If user enter a valid quantity, I enable the "Save SN" button.
The problem:
The problem I have, is that form is able to capture up to 120 SN's. so capturing the SN and clicking "Save SN" each time is getting annoying.
The question:
How to either, click the button to execute the def
or Press "Return" (Enter) on the computer to execute the function?
** def enter(self)
-- > To get the user input, validate and Save a valid quantity
** def validatesn(self)
-- > To get the user input and validate the Serial Number format.
Please see below my code:
from tkinter import *
from tkinter import messagebox
sn_count = 0
class SerialForm ():
def enter(self):
global oven_qty
oven_qty = self.qty.get()
print(oven_qty)
def validatesn(self):
global sn_count, oven_qty
new_sn = self.serial.get()
print(new_sn)
print (sn_count)
def __init__(self, window):
self.window = window
window.geometry('390x320+400+200')
window.resizable(False,False)
window.title("App 1.30")
LabelFrame(window, text = " Serial Number Entry Form : ", font = ("Tahoma",14), height=250, width=360, bd=2, relief='groove' ).place(x=15,y=0)
Label(text='Quantity :',font=("Tahoma", 12)).place(x=20,y=40)
Label(text='Quantity Count :',font=("Tahoma", 12)).place(x=20,y=80)
LabelFrame(window, font = ("Tahoma",12), height=28, width = 145, bd=2, relief='ridge' ).place(x=160,y=80)
Label(text='Serial N. :',font=("Tahoma", 12)).place(x=20,y=120)
self.qty = Entry(window, font=("Arial Narrow", 12))
self.qty.place(x=160,y=40)
self.qty.config(state = NORMAL)
self.serial = Entry(window, font=("Arial Narrow", 12))
self.serial.place(x=160,y=120)
self.serial.config(state = DISABLED)
Label(text='Last Serial N. :',font=("Tahoma", 12)).place(x=20,y=160)
LabelFrame(window, font = ("Tahoma",12), height=28, width = 145, bd=2, relief='ridge' ).place(x=160,y=160)
self.window_btne = Button(window, text=" Enter Qty ", font=("Tahoma", 14), height=1, width=10, command=self.enter)
self.window_btne.place(x = 20, y = 200)
self.window_btne.config(state = NORMAL)
self.window_btns = Button(window, text=" Save SN ", font=("Tahoma", 14), height=1, width=10, command = self.validatesn)
self.window_btns.place(x = 140, y = 200)
self.window_btns.config(state = DISABLED)
root = Tk()
my_gui = SerialForm(root)
root.mainloop()