2013-12-07 3 views
7

마우스가 필요없는 전체 화면 Tkinter Python 응용 프로그램이 있습니다. 아래에 단순화 된 버전이 있습니다. F1을 누르면 전체 화면이 열리고 텍스트 위젯이 활성화됩니다.Tkinter에서 마우스 포인터를 숨기거나 비활성화하는 방법은 무엇입니까?

import Tkinter as tk 

class App(): 
    def __init__(self): 
     self.root = tk.Tk() 
     self.root.attributes('-fullscreen', True) 
     self.root.configure(background='red') 
     self.root.bind('<F1>', self.opennote) 
     self.root.bind('<F2>', self.closenote) 
     self.root.bind('<F3>', self.quit) 
     l = tk.Label(text="some text here") 
     l.pack() 
     self.root.mainloop() 

    def opennote(self, event): 
     self.n = tk.Text(self.root, background='blue') 
     self.n.pack() 

    def closenote(self, event): 
     self.n.destroy() 

    def quit(self, event): 
     self.root.destroy() 

App() 

시작되면 마우스 포인터가 표시되지 않습니다. 텍스트 위젯을 시작한 후 표시되고 텍스트 위젯과 나머지 화면 사이의 모양이 변경됩니다.

(매개 변수로 cursor=''을 사용하여) 마우스 커서를 숨기는 방법에 대한 여러 기사를 찾았지만 위젯에서 마우스 포인터로 작동하는 항목을 찾지 못했습니다.

Tkinter에서 마우스 포인터를 완전히 숨길 수 있습니까?

(a question on how to set the mouse positionself.root.event_generate('<Motion>', warp=True, x=self.root.winfo_screenwidth(), y=self.root.winfo_screenheight())을 실행하여 멀리이 커서를 이동 도와주었습니다.이 솔루션은 아니지만 적어도 포인터가 화면의 중간에서 하나의 얼굴에 점프하지 않습니다)

답변

4

내가 올 수있는 가장 가까운 Frame을 만들고 커서를 'none'으로 설정하는 것입니다.하지만 적어도 내 컴퓨터 (Mac OS X Mavericks)에는 커서를두고 앱 창을 다시 입력해야하는 문제가 있습니다. 어쩌면 다른 사람이 응용 프로그램이로드 사라 커서를 트리거하는 방법을 알아낼 수 있지만, 여기에 내가 지금까지 가지고있는 코드입니다 :

import Tkinter as tk 


class App(): 
    def __init__(self): 
     self.root = tk.Tk() 
     self.root.attributes('-fullscreen', True) 
     self.main_frame = tk.Frame(self.root) 
     self.main_frame.config(background='red', cursor='none') 
     self.main_frame.pack(fill=tk.BOTH, expand=tk.TRUE) 
     self.root.bind('<F1>', self.opennote) 
     self.root.bind('<F2>', self.closenote) 
     self.root.bind('<F3>', self.quit) 
     l = tk.Label(self.main_frame, text="some text here") 
     l.pack() 
     self.root.mainloop() 

    def opennote(self, event): 
     self.n = tk.Text(self.main_frame, background='blue') 
     self.n.pack() 

    def closenote(self, event): 
     self.n.destroy() 

    def quit(self, event): 
     self.root.destroy() 

App() 
16

것 같아요,

root.config(cursor="none")

작동합니다은.

+0

Windows 10 및 Ubuntu 16에서 모두 나를 위해 일했습니다. – ChewToy

관련 문제