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
I thought it might be helpful to share my learnings about getting unicode characters to appear (or not) on buttons. It might be good to include an example in the documentation. (Or maybe just have this ticket to refer people to).
I also have got a noise and mute button on my GUI. I found some suitable unicode which works in Python.
For example:
~ $ python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> u'\U0001F508'
'🔈'
>>> u'\U0001F507'
'🔇'
However this doesn't work in the tkinter as it appear tcl doesn't supprt UTF-16 so I get the following error:
$ python3 python/guizero/examples/bitbot_example.py
scanning...
Traceback (most recent call last):
File "python/guizero/examples/bitbot_example.py", line 97, in <module>
_build_horn_section(buz_btns)
File "python/guizero/examples/bitbot_example.py", line 77, in _build_horn_section
buzz_on = PushButton(box_obj, bitbot.buzzer_on, text=u'\U0001F508', grid=[0, 0])
File "/home/pi/python/guizero/guizero/PushButton.py", line 38, in __init__
self.config(text=text, command=command, pady=pady, padx=padx)
File "/usr/lib/python3.4/tkinter/__init__.py", line 1322, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python3.4/tkinter/__init__.py", line 1313, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: character U+1f508 is above the range (U+0000-U+FFFF) allowed by Tcl
The text was updated successfully, but these errors were encountered:
Coincidentally I was looking into this type of thing the other day. As you've mentioned, and as far as I understand, tcl does not support UTF-16, but you can still use UTF-8, so you'd have to convert your characters to that format:
The documentation left a lot to be desired in this area. On first impressions it sounded like it should be able to support 16-bit Unicode by default: https://www.tcl.tk/man/tcl/TclCmd/encoding.htm#M10
However it seems like their 16 bit implementation is UCS-16: https://en.wikibooks.org/wiki/Tcl_Programming/Internationalization#Unicode_implementations:_UTF-8.2C_UCS-16
Which I personally don't know much about. Technically speaking UTF-16 derived from UCS-2, but I honestly don't know where this "UCS-16" comes into play.
Funnily enough internally it is declared as "unicode" so trying root.tk.call('encoding', 'system', 'ucs-16') won't work and you'll have to use root.tk.call('encoding', 'system', 'unicode') instead.
I thought it might be helpful to share my learnings about getting unicode characters to appear (or not) on buttons. It might be good to include an example in the documentation. (Or maybe just have this ticket to refer people to).
I wanted to have arrows on my buttons so sourced the unicodes from:
http://www.w3schools.com/charsets/ref_utf_arrows.asp
To get this to appear on a button you do the following:
I also have got a noise and mute button on my GUI. I found some suitable unicode which works in Python.
For example:
However this doesn't work in the tkinter as it appear tcl doesn't supprt UTF-16 so I get the following error:
The text was updated successfully, but these errors were encountered: