How Do I Disable Keyboard Input Into An Entry Widget, Disable Resizing Of Tkinter Window And Hide The Console Window?
I am making a calculator using tkinter and I wish to do the following: Disable keyboard input for the Entry widget so that the user can only input through the buttons. Even aft
Solution 1:
To be able to disable keyboard input in Entry(args)
Set the state to disabled:
display = Entry(root, state=DISABLED)
To be able to disable the feature of resizing the tkinter window (so that you can't drag and stretch it.
root.resizable(0,0)
To be able to make the command prompt window disappear. (I just want the tkinter window.
Rename the file with a .pyw extension (assuming you are using windows)
Solution 2:
Don't use from tkinter import *
it's really not recommended because it pollutes the main namespace with every public name in the module. At best this makes code less explicit, at worst, it can (and it will) cause name collisions.
Have the right reflexes, use import tkinter
or import tkinter as tk
instead
this should work, you have to use the disabledbackground
option :
import tkinter as tkroot= tk.Tk()
display = tk.Entry(root,font=('Arial', 20, 'bold'), disabledbackground='lightblue', state='disabled')
display.pack()
root.resizable(0,0)
root.mainloop()
Post a Comment for "How Do I Disable Keyboard Input Into An Entry Widget, Disable Resizing Of Tkinter Window And Hide The Console Window?"