You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
prerequisite:
you have more than one tkinter listbox
behavior in py 2.7.13 and py 3.5.3:
if you leave a listbox and goes to another, then the abandoned listbox create not a ListboxSelect Event
behavior in py 3.6.0 and 3.6.1:
if you leave a listbox and goes to another, then the abandoned listbox create a ListboxSelect Event and this gives a error-message
I dont know if my program is false, but it works in 2.7 and 3.5 good, however not with 3.6
Bug examples should be the bare minimum of code needed to reproduce the problem, not a dump of (failing) application code. See, for instance, https://stackoverflow.com/help/mcve.
http://www.tcl.tk/man/tcl8.6/TkCmd/listbox.htm says "Any time the set of selected item(s) in the listbox is updated by the user through the keyboard or mouse, the virtual event <<ListboxSelect>> will be generated." It was the same for 8.5.
What precise actions are *needed* to produce what you consider buggy behavior? Please copy the complete traceback for the exception. What system (OS) are you using. If *nix, are you using the same tcl/tk for 3.6 as for 3.5?
sorry for the "Long" code, but sometime is an longer example better than many words (and the most code is for layout, please fold with PyCharm)
i use "original" Python with tcl/tk as it is in the installer
in my gif-pictures you can see my sytem and the pyton versions
please run my example in 3.5.3 and in 3.6.1
call Font-Menue
choose size 11 and than choose style Standard
you will see what i mean
Thank you
mlouielu commented on Apr 29, 2017
mlouielumannequin
Mannequin
More actions
I can reproduce the problem at 2.7.13 on Linux.
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1542, in __call__returnself.func(*args)
File "tests.py", line 174, in get_style
lb_sty_get = listbox_style.get(lb_sty_cur)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2629, in getreturnself.tk.call(self._w, 'get', first)
TclError: bad listbox index "": must be active, anchor, end, @x,y, or a number
FrankPae commented on Apr 29, 2017
FrankPaemannequin
MannequinAuthor
More actions
i have added my picture for 2.7.13
i mean there is no problem
mlouielu commented on Apr 29, 2017
mlouielumannequin
Mannequin
More actions
The problem cause by listbox.curselection(). When crossing from a listbox to another listbox, it will trigger twice event.
The first time get a valid select tuple from curselection() (which will return (index, label)), and the second time will generate empty tuple.
You should check curselection()'s tuple before passing into listbox.get(). The easiest is to add a if stmt for lb_*_cur, for example:
you need the workaround also for get_style and get_font
mlouielu commented on Apr 29, 2017
mlouielumannequin
Mannequin
More actions
I think this is only a normal behavior now.
Generate two events make sense, they are generate by different widget:
.!editor.!font_dialog.!frame.!frame.!listbox (0,) # Select Font
.!editor.!font_dialog.!frame2.!frame.!listbox (0,) # Select Style
.!editor.!font_dialog.!frame.!frame.!listbox () # Deselect Font
When you select one list and trying to select another listbox,
you will trigger two event, first is the select, and second the de-select.
So you will need to handle the de-select part.
mlouielu commented on Apr 29, 2017
mlouielumannequin
Mannequin
More actions
This behavior is as same as on my Linux Python 2.7.13:
(<Tkinter.Listbox instance at 0x7f4b2b0c08c0>, (2,)) # Select Font
(<Tkinter.Listbox instance at 0x7f4b29caf248>, (3,)) # Select Style
(<Tkinter.Listbox instance at 0x7f4b2b0c08c0>, ()) # Deselect Font
And also, you don't need a try expect to handle this situation. You can see that when de-select the listbox, curselection() will return an empty tuple, you only need an if statement to handle this:
Frank, bigger is not better for demonstrating a problem. The only thing needed for this issue is a tk window with two list boxes. Having to click twice to get a window with more than just the two Listboxes is just noise.
Anyway, I downloaded the file as tem.py into a directory on the path and ran "py -x.y -m tem" with the 3 x,y pairs. For 3.6 I see the traceback Louie Lu posted -- **for 2.7**.
Since clicking in box 2 after clicking in box 1 changes the selection set in *both* boxes, on all 3 versions, there should a <<ListboxSelect>> event for both, on all 3 versions, as specified in the tcl/tk doc that I quoted. I believe it was a bug when the deselect event did not happen.
On Windows, 2.7.13 uses tk 8.5.15, 3.5.z uses tk 8.6.4, and 3.6.z uses tk 8.6.6. My hypothesis is that the bug of not raising an event for the deselect, at least on Windows, was fixed in tk in 8.6.5/6. If so, this should be closed as 'not a bug'.
Louie, what tk x.y.z do you have on your linux?
Serhiy, did you change anything in tkinter for 8.6 that could have affected <<ListboxSelect>> events?
FrankPae commented on Apr 30, 2017
FrankPaemannequin
MannequinAuthor
More actions
I am not a profi, just a normal user, i do what i can so good i can
I would like to thank all python developers
(AND: I think your last question ist the right question)
Activity
FrankPae commentedon Apr 28, 2017
prerequisite:
you have more than one tkinter listbox
behavior in py 2.7.13 and py 3.5.3:
if you leave a listbox and goes to another, then the abandoned listbox create not a ListboxSelect Event
behavior in py 3.6.0 and 3.6.1:
if you leave a listbox and goes to another, then the abandoned listbox create a ListboxSelect Event and this gives a error-message
I dont know if my program is false, but it works in 2.7 and 3.5 good, however not with 3.6
Thank you
terryjreedy commentedon Apr 29, 2017
Bug examples should be the bare minimum of code needed to reproduce the problem, not a dump of (failing) application code. See, for instance, https://stackoverflow.com/help/mcve.
http://www.tcl.tk/man/tcl8.6/TkCmd/listbox.htm says "Any time the set of selected item(s) in the listbox is updated by the user through the keyboard or mouse, the virtual event <<ListboxSelect>> will be generated." It was the same for 8.5.
What precise actions are *needed* to produce what you consider buggy behavior? Please copy the complete traceback for the exception. What system (OS) are you using. If *nix, are you using the same tcl/tk for 3.6 as for 3.5?
FrankPae commentedon Apr 29, 2017
thank you for your answer
sorry for the "Long" code, but sometime is an longer example better than many words (and the most code is for layout, please fold with PyCharm)
i use "original" Python with tcl/tk as it is in the installer
in my gif-pictures you can see my sytem and the pyton versions
please run my example in 3.5.3 and in 3.6.1
call Font-Menue
choose size 11 and than choose style Standard
you will see what i mean
Thank you
mlouielu commentedon Apr 29, 2017
I can reproduce the problem at 2.7.13 on Linux.
FrankPae commentedon Apr 29, 2017
i have added my picture for 2.7.13
i mean there is no problem
mlouielu commentedon Apr 29, 2017
The problem cause by listbox.curselection(). When crossing from a listbox to another listbox, it will trigger twice event.
The first time get a valid select tuple from curselection() (which will return (index, label)), and the second time will generate empty tuple.
You should check curselection()'s tuple before passing into listbox.get(). The easiest is to add a if stmt for lb_*_cur, for example:
mlouielu commentedon Apr 29, 2017
But I'm not sure if this is a behavior error or something else, I'm still trying to find the root cause.
FrankPae commentedon Apr 29, 2017
it works in py 2.7 and 3.5 normal
there must be a change in 3.6, intended or unintentional
this is my Workaround:
you need the workaround also for get_style and get_font
mlouielu commentedon Apr 29, 2017
I think this is only a normal behavior now.
Generate two events make sense, they are generate by different widget:
.!editor.!font_dialog.!frame.!frame.!listbox (0,) # Select Font
.!editor.!font_dialog.!frame2.!frame.!listbox (0,) # Select Style
.!editor.!font_dialog.!frame.!frame.!listbox () # Deselect Font
When you select one list and trying to select another listbox,
you will trigger two event, first is the select, and second the de-select.
So you will need to handle the de-select part.
mlouielu commentedon Apr 29, 2017
This behavior is as same as on my Linux Python 2.7.13:
(<Tkinter.Listbox instance at 0x7f4b2b0c08c0>, (2,)) # Select Font
(<Tkinter.Listbox instance at 0x7f4b29caf248>, (3,)) # Select Style
(<Tkinter.Listbox instance at 0x7f4b2b0c08c0>, ()) # Deselect Font
And also, you don't need a try expect to handle this situation. You can see that when de-select the listbox, curselection() will return an empty tuple, you only need an if statement to handle this:
FrankPae commentedon Apr 29, 2017
Thanks for the answers
Can you please explain why python 3.6 requires another treatment?
In 2.7 und 3.5 I do not need that
Thank you
terryjreedy commentedon Apr 30, 2017
Frank, bigger is not better for demonstrating a problem. The only thing needed for this issue is a tk window with two list boxes. Having to click twice to get a window with more than just the two Listboxes is just noise.
Anyway, I downloaded the file as tem.py into a directory on the path and ran "py -x.y -m tem" with the 3 x,y pairs. For 3.6 I see the traceback Louie Lu posted -- **for 2.7**.
Since clicking in box 2 after clicking in box 1 changes the selection set in *both* boxes, on all 3 versions, there should a <<ListboxSelect>> event for both, on all 3 versions, as specified in the tcl/tk doc that I quoted. I believe it was a bug when the deselect event did not happen.
On Windows, 2.7.13 uses tk 8.5.15, 3.5.z uses tk 8.6.4, and 3.6.z uses tk 8.6.6. My hypothesis is that the bug of not raising an event for the deselect, at least on Windows, was fixed in tk in 8.6.5/6. If so, this should be closed as 'not a bug'.
Louie, what tk x.y.z do you have on your linux?
Serhiy, did you change anything in tkinter for 8.6 that could have affected <<ListboxSelect>> events?
FrankPae commentedon Apr 30, 2017
I am not a profi, just a normal user, i do what i can so good i can
I would like to thank all python developers
(AND: I think your last question ist the right question)
mlouielu commentedon May 1, 2017
ah, I think Terry point out the problem behind why my 2.7 and Frank's 2.7 have different behavior.
I'm using tk 8.6.6-1 on Linux, and it may be the problem from tk version.
FrankPae commentedon May 1, 2017
Here some detailed information about Tcl / Tk versions:
platform Windows-10-10.0.14393 AMD64
python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)]
tkinter Tcl/Tk 8.6.6 / 8.6.6
python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]
tkinter Tcl/Tk 8.6.4 / 8.6.4
python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]
tkinter Tcl/Tk 8.5.15 / 8.5.15