[issue33289] askcolor is returning floats for r, g, b values instead of ints
New submission from Bryan Oakley : Even though the underlying tcl/tk interpreter is returning ints, askcolor is converting the values to floats. My guess is this is an oversight related to the change in functionality of the / operator in python3. this: return (r/256, g/256, b/256), str(result) should probably be this: return (r//256, g//256, b//256), str(result) -- components: Tkinter messages: 315367 nosy: Bryan.Oakley priority: normal severity: normal status: open title: askcolor is returning floats for r,g,b values instead of ints versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue33289> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33289] tkinter askcolor returning floats for r, g, b values instead of ints
Bryan Oakley added the comment: yes, this is a well known backwards incompatibility. In python 2, the division operator returns an integer if both operands are integers. In python 3 it returns a float. https://www.python.org/dev/peps/pep-0238/ On Thu, Jul 12, 2018 at 8:48 AM STINNER Victor wrote: > > STINNER Victor added the comment: > > Is this issue a regression of Python 3? red/256 gave an integer on Python > 2? > > -- > nosy: +vstinner > > ___ > Python tracker > <https://bugs.python.org/issue33289> > ___ > -- title: tkinter askcolor returning floats for r,g,b values instead of ints -> tkinter askcolor returning floats for r, g, b values instead of ints ___ Python tracker <https://bugs.python.org/issue33289> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15861] ttk.Treeview "unmatched open brace in list"
New submission from Bryan Oakley: If you try to insert an item into the treeview, give it a tuple of values for the "values" attribute, and one of those values has unbalanced braces, you'll get an error "unmatched open brace in list" To reproduce: import Tkinter as tk import ttk root = tk.Tk() tree = ttk.Treeview(root) tree.insert("","end",values=("one","two","bam! {")) root.mainloop() -- components: Tkinter messages: 169839 nosy: Bryan.Oakley priority: normal severity: normal status: open title: ttk.Treeview "unmatched open brace in list" type: behavior versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue15861> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15861] ttk.Treeview "unmatched open brace in list"
Bryan Oakley added the comment: What behavior do I expect? I expect it to not throw an error. I expect whatever string I give to be inserted into the widget unadulterated (ie: if I give the string "foo {" I expect to see "foo {" in the widget). Tkinter is effectively telling me "you have a Tcl syntax error". Since I'm programming in python I should be insulated from that, particularly since the error comes internally after Tkinter transforms my data. How Tkinter does it under the hood, I don't care. Tkinter should make sure that the data it passes to the Tcl interpreter is well-formed. -- ___ Python tracker <http://bugs.python.org/issue15861> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15861] ttk.Treeview "unmatched open brace in list"
Bryan Oakley added the comment: I gave myself an hour or so to play around with this, and the crux of the matter seems to be in the function `_format_optdict()` which converts a dictionary of options and values into something suitable to pass to `tk.call()`. However, I think the same bug is in other `_format*` functions as well, it's just that their nature is such that they have much less of a chance to be passed weird data. `_format_optdict` has some code that does a half-hearted attempt at handling values that are tuples, such as the case with the "values" attribute of the ttk.Treeview widget. However, all it does is protect values that have a space, by surrounding the value with curly braces. Hence, when the value itself has a curly brace, tcl throws the "unmatched open brace" error. What is needed is to create a bona fide tcl list element according to the rules of Tcl. I tried a hack where I simply escaped all problem characters, so instead of returning `{foo bar}` the function returns `foo\ bar`. This seemed to work, at least for the tiny bit of testing that I did. Another solution might be to do something like tk.call("list",*the_tuple), though sadly, `_format_optdict` is a function rather than a method so it doesn't have access to the tcl interpreter. What I think ttk needs (and may already exist somewhere in the Tkinter world; I haven't looked...) is a function that takes a tuple and converts it to a canonical list. Then, the places that do something ad hoc can all call this one function. For more information on the gory details of the string representation of a list see http://www.tcl.tk/cgi-bin/tct/tip/407.html -- ___ Python tracker <http://bugs.python.org/issue15861> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25684] ttk.OptionMenu radiobuttons aren't unique between two instances of OptionMenu
New submission from Bryan Oakley: Original issue was brought to my attention by this SO question: http://stackoverflow.com/questions/33831289/ttk-optionmenu-displaying-check-mark-on-all-menus The ttk.OptionMenu uses radiobuttons for the dropdown menu. However, because it doesn't set the `variable` attribute, they all get the default. If you have two or more OptionMenu instances, all of the radiobuttons are tied together. If you select the first item in the first OptionMenu, and the second item in the second OptionMenu, the dropdown menu for both will show the second item checked. The solution is to add `variable=self._variable` when creating the menu radiobutton items. -- components: Tkinter messages: 255001 nosy: Bryan.Oakley priority: normal severity: normal status: open title: ttk.OptionMenu radiobuttons aren't unique between two instances of OptionMenu versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 ___ Python tracker <http://bugs.python.org/issue25684> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25684] ttk.OptionMenu radiobuttons aren't unique between two instances of OptionMenu
Changes by Bryan Oakley : -- type: -> behavior ___ Python tracker <http://bugs.python.org/issue25684> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com