
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Hide or Disable Mouse Pointer in Tkinter
There are several ways to disable and enable a particular widget in a Tkinter application. However, if we want to control the Tkinter window components such as mouse cursor, control icons, toolbars, then Tkinter provides several built-in functions which can be used to configure the Tkinter window objects.
To hide or disable the mouse pointer for a particular Tkinter application, then we can configure the mouse property using config(mouse= "none") method. It can be invoked for the master or root window.
Example
#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame or window win= Tk() #Set the geometry of tkinter frame win.geometry("750x250") def callback(event): win.destroy() #Create a Label and a Button widget label=ttk.Label(win, text="Press Enter to Close the Window", font=('Century 17 bold')) label.pack(ipadx=10) win.bind('<Return>',callback) #Disable the Mouse Pointer win.config(cursor="none") win.mainloop()
Output
Running the above code will hide or disable the Mouse Pointer for the window.
Now, while residing in the window, press Enter that will force the window to close.
Advertisements