Exception protection to tk calls
Vasilis Vlachoudis <[email protected]> Wed, 31 Mar 2021 06:53:26 +0000
| Newsgroups | gmane.comp.python.tkinter |
|---|---|
| Message-ID | <[email protected]> |
--===============6015779584109556568==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_0BC70B5D93E054469872FFD0FE07220E0332B9C7FBCERNXCHG54cer_"
--_000_0BC70B5D93E054469872FFD0FE07220E0332B9C7FBCERNXCHG54cer_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Is there any recommendation which tkinter calls have to be protected with a=
n exception handling
I occasionally receive traceback errors from my users on various calls
like: grab_current, grab_release, focus_get
most of the times I protect them with with a TclError handler catching exce=
ptions
like_tkinter.TclError: bad window path name
Also which type of exception has to be protected, this is the first time I'=
ve got a KeyError
from a tkinter call, which normally should be innocent focus_get()"
Traceback:
Traceback (most recent call last):
File "/usr/local/flair/tkFlair.py", line 1304, in __call__
return self.func(*args)
File "/usr/local/flair/InputExtra.py", line 1026, in focusOut
self._focus =3D self.focus_get()
File "/usr/lib/python3.8/tkinter/__init__.py", line 748, in focus_get
return self._nametowidget(name)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1498, in nametowidget
w =3D w.children[n]
KeyError: '__tk__messagebox'
--_000_0BC70B5D93E054469872FFD0FE07220E0332B9C7FBCERNXCHG54cer_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html dir=3D"ltr">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style id=3D"css_styles">=0A=
<!--=0A=
blockquote.cite=0A=
{margin-left:5px;=0A=
margin-right:0px;=0A=
padding-left:10px;=0A=
padding-right:0px;=0A=
border-left:1px solid #cccccc}=0A=
blockquote.cite2=0A=
{margin-left:5px;=0A=
margin-right:0px;=0A=
padding-left:10px;=0A=
padding-right:0px;=0A=
border-left:1px solid #cccccc;=0A=
margin-top:3px;=0A=
padding-top:0px}=0A=
a img=0A=
{border:0px}=0A=
li[style=3D'text-align: center;'], li[style=3D'text-align: center; '], li[s=
tyle=3D'text-align: right;'], li[style=3D'text-align: right; ']=0A=
{list-style-position:inside}=0A=
body=0A=
{font-family:Segoe UI;=0A=
font-size:12pt}=0A=
.quote=0A=
{margin-left:1em;=0A=
margin-right:1em;=0A=
border-left:5px #ebebeb solid;=0A=
padding-left:0.3em}=0A=
-->=0A=
</style><style type=3D"text/css" id=3D"owaParaStyle"></style>
</head>
<body fpstyle=3D"1" ocsi=3D"0">
<div style=3D"direction: ltr;font-family: Tahoma;color: #000000;font-size: =
10pt;">
<div style=3D"">
<div style=3D"">
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;">Is there any recommendation which tki=
nter calls have to be protected with an exception handling</span></font></d=
iv>
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;">I occasionally receive traceback erro=
rs from my users on various calls</span></font></div>
<div style=3D"color: rgb(0, 0, 0); font-family: "Times New Roman"=
; font-size: 16px;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;">like: grab_current, grab_release, focus_get</sp=
an></div>
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;">most of the times I protect them with with=
a TclError handler catching exceptions</span></font></div>
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;">like_tkinter.TclError: bad window path nam=
e</span></font></div>
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;"><br>
</span></font></div>
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;">Also which type of exception has to be pro=
tected, this is the first time I've got a KeyError</span></font></div>
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;">from a tkinter call, which normally should=
be innocent focus_get()"</span></font></div>
<div style=3D""><font face=3D"Segoe UI, Helvetica, Arial, sans-serif"><span=
style=3D"font-size: 13.3333px;"><br>
</span></font></div>
<div style=3D"color: rgb(0, 0, 0); font-family: "Times New Roman"=
; font-size: 16px;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"><br>
</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: "Times New Roman"=
; font-size: 16px;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;">Traceback:</span><br style=3D"font-size: 13.333=
3px; font-family: "Segoe UI", Helvetica, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;">Traceback (most recent call last):</span><br st=
yle=3D"font-size: 13.3333px; font-family: "Segoe UI", Helvetica, =
Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> File "/usr/local/flair/tkFlair.py&q=
uot;, line 1304, in __call__</span><br style=3D"font-size: 13.3333px; font-=
family: "Segoe UI", Helvetica, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> return self.func(*args)</spa=
n><br style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> File "/usr/local/flair/InputExtra.p=
y", line 1026, in focusOut</span><br style=3D"font-size: 13.3333px; fo=
nt-family: "Segoe UI", Helvetica, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> self._focus =3D self.focus_g=
et()</span><br style=3D"font-size: 13.3333px; font-family: "Segoe UI&q=
uot;, Helvetica, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> File "/usr/lib/python3.8/tkinter/__=
init__.py", line 748, in focus_get</span><br style=3D"font-size: 13.33=
33px; font-family: "Segoe UI", Helvetica, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> return self._nametowidget(na=
me)</span><br style=3D"font-size: 13.3333px; font-family: "Segoe UI&qu=
ot;, Helvetica, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> File "/usr/lib/python3.8/tkinter/__=
init__.py", line 1498, in nametowidget</span><br style=3D"font-size: 1=
3.3333px; font-family: "Segoe UI", Helvetica, Arial, sans-serif;"=
>
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;"> w =3D w.children[n]</span><b=
r style=3D"font-size: 13.3333px; font-family: "Segoe UI", Helveti=
ca, Arial, sans-serif;">
<span style=3D"font-size: 13.3333px; font-family: "Segoe UI", Hel=
vetica, Arial, sans-serif;">KeyError: '__tk__messagebox'</span>
</div>
</div>
</div>
</div>
</body>
</html>
--_000_0BC70B5D93E054469872FFD0FE07220E0332B9C7FBCERNXCHG54cer_--
--===============6015779584109556568==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss
--===============6015779584109556568==--