그래픽 사용자 인터페이스 FAQ¶
일반적인 GUI 질문¶
What GUI toolkits exist for Python?¶
Standard builds of Python include an object-oriented interface to the Tcl/Tk widget set, called tkinter. This is probably the easiest to install (since it comes included with most binary distributions of Python) and use. For more info about Tk, including pointers to the source, see the Tcl/Tk home page. Tcl/Tk is fully portable to the macOS, Windows, and Unix platforms.
Depending on what platform(s) you are aiming at, there are also several alternatives. A list of cross-platform and platform-specific GUI frameworks can be found on the python wiki.
Tkinter 질문¶
Tkinter 응용 프로그램을 어떻게 고정(freeze)합니까?¶
Freeze는 독립 실행형 응용 프로그램을 만드는 도구입니다. Tkinter 응용 프로그램을 고정할 때, 응용 프로그램은 여전히 Tcl과 Tk 라이브러리가 필요하므로 진정한 독립 실행형이 아닙니다.
One solution is to ship the application with the Tcl and Tk libraries, and point
to them at run-time using the TCL_LIBRARY
and TK_LIBRARY
environment variables.
Various third-party freeze libraries such as py2exe and cx_Freeze have handling for Tkinter applications built-in.
I/O를 기다리는 동안 Tk 이벤트를 처리하도록 할 수 있습니까?¶
On platforms other than Windows, yes, and you don’t even
need threads! But you’ll have to restructure your I/O
code a bit. Tk has the equivalent of Xt’s XtAddInput()
call, which allows you
to register a callback function which will be called from the Tk mainloop when
I/O is possible on a file descriptor. See 파일 처리기.
Tkinter에서 키 바인딩이 동작하지 않습니다: 이유가 무엇입니까?¶
An often-heard complaint is that event handlers bound
to events with the bind()
method
don’t get handled even when the appropriate key is pressed.
가장 흔한 원인은 바인딩이 적용되는 위젯에 “키보드 포커스”가 없는 것입니다. focus 명령에 대한 Tk 설명서를 확인하십시오. 보통 위젯은 그것을 클릭할 때 키보드 포커스를 받습니다 (레이블은 그렇지 않습니다; takefocus 옵션을 보십시오).