내장 바인딩 후 Tkinter 텍스트 위젯의 사용자 정의 이벤트 바인딩
문제 이해
Tkinter의 텍스트 위젯에서는 위젯의 내장 바인딩보다 먼저 사용자 정의 이벤트 바인딩이 실행되어 텍스트 업데이트에 불일치가 발생하는 상황이 발생할 수 있습니다.
해결책
이 문제를 해결하려면 이벤트가 처리되는 순서를 변경할 수 있습니다. Tkinter 위젯에는 바인딩 실행 순서를 결정하는 "bindtags" 계층이 할당됩니다.
1. 바인딩태그 재정렬
바인드태그의 기본 순서는 위젯, 클래스, 최상위, 모두입니다. 클래스 바인딩태그 뒤에 위젯 바인딩태그를 배치하여 순서를 변경할 수 있습니다. 이렇게 하면 클래스 바인딩이 위젯 바인딩보다 먼저 실행됩니다.
<code class="python"># Modify the bindtags to rearrange the order entry.bindtags(('Entry', '.entry', '.', 'all'))</code>
2. 추가 바인딩 태그 소개
또는 클래스 바인딩 태그 뒤에 새 바인딩 태그를 만들고 사용자 정의 이벤트를 이 새 태그에 바인딩할 수 있습니다.
<code class="python"># Create a new bindtag "post-class-bindings" after the class bindtag entry.bindtags(('.entry','Entry','post-class-bindings', '.', 'all')) # Bind your custom events to "post-class-bindings" entry.bind_class("post-class-bindings", "<keypress>", OnKeyPress)</keypress></code>
두 접근 방식의 이점
- 바인드태그 재정렬: 위젯의 모든 바인딩에 영향을 줍니다.
- 새 바인딩태그 소개: 기반으로 이벤트를 선택적으로 바인딩할 수 있습니다.
예제 코드
다음 코드는 두 가지 접근 방식을 모두 보여줍니다.
<code class="python">import Tkinter def OnKeyPress(event): value = event.widget.get() string="value of %s is '%s'" % (event.widget._name, value) status.configure(text=string) root = Tkinter.Tk() entry1 = Tkinter.Entry(root, name="entry1") entry2 = Tkinter.Entry(root, name="entry2") entry3 = Tkinter.Entry(root, name="entry3") # Three different bindtags entry1.bindtags(('.entry1', 'Entry', '.', 'all')) entry2.bindtags(('Entry', '.entry2', '.', 'all')) entry3.bindtags(('.entry3','Entry','post-class-bindings', '.', 'all')) # Bind the first two entries to the default bind tags entry1.bind("<keypress>", OnKeyPress) entry2.bind("<keypress>", OnKeyPress) # Bind the third entry to the "post-class-bindings" bind tag entry3.bind_class("post-class-bindings", "<keypress>", OnKeyPress) # ... Continue with your GUI code </keypress></keypress></keypress></code>
위 내용은 내장 바인딩 후에 내 사용자 정의 Tkinter 텍스트 위젯 바인딩이 실행되는지 어떻게 확인할 수 있나요?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Python 스크립트가 UNIX 시스템에서 실행할 수없는 이유는 다음과 같습니다. 1) CHMOD XYOUR_SCRIPT.PY를 사용하여 실행 권한을 부여하는 권한이 불충분합니다. 2) 잘못되거나 누락 된 Shebang 라인은 #!/usr/bin/envpython을 사용해야합니다. 3) 잘못된 환경 변수 설정, os.environ 디버깅을 인쇄 할 수 있습니다. 4) 잘못된 Python 버전을 사용하여 Shebang 행 또는 명령 줄에 버전을 지정할 수 있습니다. 5) 가상 환경을 사용하여 종속성을 분리하는 의존성 문제; 6) 구문 오류, python-mpy_compileyour_script.py를 사용하여 감지하십시오.

파이썬 어레이를 사용하는 것은 목록보다 많은 양의 숫자 데이터를 처리하는 데 더 적합합니다. 1) 배열 더 많은 메모리를 저장, 2) 배열은 숫자 값으로 작동하는 것이 더 빠르며, 3) 배열 힘 유형 일관성, 4) 배열은 C 배열과 호환되지만 목록만큼 유연하고 편리하지 않습니다.

더 나은 orfelexibility 및 mixdatatatatytys, 탁월한 정비 계산 모래 데이터 세트.

numpymanagesmemoryforlargearraysefficiedviews, 사본 및 메모리-맵핑 파일

ListSinpythondonoTrequireimportingAmodule, whilearraysfromtheArrayModuledOneedAnimport.1) ListSareBuilt-in, Versatile, andCanholdixedDatatypes.2) arraysarraysaremorememorememeMorememeMorememeMorememeMorememeMorememeMorememeMoremeMoremeTeverTopeTeveTeTeTeTeTeTeTeTeTeTeTeTeTeTeTeTeveTeTeTeTeTeTeTeTete가 필요합니다.

PythonlistsCanstoreAnyDatAtype, ArrayModuLearRaysStoreOneType 및 NUMPYARRAYSAREFORNUMERICALPUTATION.1) LISTSAREVERSATILEBUTLESSMEMORY-EFFICENT.2) ARRAYMODUERRAYRAYRAYSARRYSARESARESARESARESARESARESAREDOREDORY-UNFICEDONOUNEOUSDATA.3) NumpyArraysUraysOrcepperperperperperperperperperperperperperperperferperferperferferpercient

whenyouattempttoreavalueofthewrongdatatypeinapythonaphonarray, thisiSdueTotheArrayModule의 stricttyPeenforcement, theAllElementStobeofthesAmetypecified bythetypecode.forperformancersassion, arraysaremoreficats the thraysaremoreficats thetheperfication the thraysaremorefications는

Pythonlistsarepartoftsandardlardlibrary, whileraysarenot.listsarebuilt-in, 다재다능하고, 수집 할 수있는 반면, arraysarreprovidedByTearRaymoduledlesscommonlyusedDuetolimitedFunctionality.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

드림위버 CS6
시각적 웹 개발 도구
