File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 font_size: ' 18sp'
1010 height: ' 24sp'
1111 text: ' Exception details: '
12- CodeInput:
13- id : catched_exception_code_input_here
14- size_hint: 1 , 1
15- text: root.message
16- size_hint: 1 , 1
12+ ScrollView:
13+ CodeInput:
14+ id : catched_exception_code_input_here
15+ text: root.message
16+ size_hint: 1 , None
17+ height: self .minimum_height
1718 Button:
1819 size_hint_y: None
1920 height: ' 40sp'
Original file line number Diff line number Diff line change 22
33import asyncio
44import traceback
5+ from pathlib import Path
56
67from kivy .base import (
78 ExceptionHandler ,
1617
1718def load_exception_popup_style ():
1819 """Load KV rules for `UnhandledExceptionPopupHere`."""
19- Builder .load_string (
20- """<-UnhandledExceptionPopupHere>:
21- title: "Unhandled Exception catched"
22- BoxLayout:
23- orientation: 'vertical'
24- padding: 10
25- spacing: 20
26- Label:
27- size_hint_y: None
28- font_size: '18sp'
29- height: '24sp'
30- text: 'Exception details: '
31- ScrollView:
32- CodeInput:
33- id: catched_exception_code_input_here
34- text: root.message
35- size_hint: 1, None
36- height: self.minimum_height
37- Button:
38- size_hint_y: None
39- height: '40sp'
40- text: 'OK, continue'
41- on_press: root.dismiss()
42- """
43- )
20+ kv_path = str (Path (__file__ ).with_suffix (".kv" ))
21+
22+ if kv_path not in Builder .files :
23+ Builder .load_file (kv_path )
4424
4525
4626class ErrorMessageOnException (ExceptionHandler ):
@@ -63,7 +43,11 @@ class UnhandledExceptionPopupHere(Popup):
6343
6444def install_exception_handler ():
6545 """Install `ErrorMessageOnException` exception handler."""
66- ExceptionManager .add_handler (ErrorMessageOnException ())
46+ if not any (
47+ isinstance (handler , ErrorMessageOnException )
48+ for handler in ExceptionManager .handlers
49+ ):
50+ ExceptionManager .add_handler (ErrorMessageOnException ())
6751
6852
6953def show_exception_popup (exc : Exception | None = None ):
You can’t perform that action at this time.
0 commit comments