Home > Enterprise >  How can i set full page size textbox ( like notepad ) with tkinter python?
How can i set full page size textbox ( like notepad ) with tkinter python?

Time:07-04

I want to set a full page size textbox with tkinter in python. I want to do this because if the program run with full page textbox, i can write value from rfid automatically. Otherwise i have to click the page if i want to write value with rfid reader.

def onReturn(event):

            rfIDtext=entry1.get()
            cur.execute("INSERT INTO RFIDDATA(customer_ID,rf_ID) VALUES (?,?)",(custID,rfIDtext,))


            entry1.delete(0,'end')
            root.destroy()
            con.commit()   
            
        root = tk.Tk()
        root.title("RFID")
        
        entry1 =tk.Entry(root)
        entry1.bind("<Return>",onReturn)
        entry1.pack(pady=20)
        root.attributes('-fullscreen', True) # that is program size not textbox
        
        root.mainloop()
                
        con.close()

CodePudding user response:

You should use tk.Text. It has -height and -width options. You can use root.width() for the window's width and root.height() for the window's height.

text = tk.Text(root, width = root.width(), height = root.height())
text.pack(pady=20)

EDIT: To focus the entry/text you should use entry1.focus().

  • Related