Tkinter bind Shift-MouseWheel to horizontal scroll
You need to have the binding call your own function, and then have that function call the xview_scroll method of the widget:
self.bind('<Shift-MouseWheel>', self.scrollHorizontally)
...
def scrollHorizontally(self, event):
self.log.xview_scroll((event.delta/120), "units")
You may need to adjust the number of units (or "pages") you want to scroll with each click of the wheel.
This answer has more information about platform differences with respect to the delta
attribute of the event.
Checkbuttons within a scrolling Text spill over the top border
Set the borderwidth of the Text widget to zero. If you still want the "sunken"
look, you can configure the outer frame.
How to identify non-printable KeyPress events in Tkinter
Question 1 and 2 :
I believe your method works, but it seems simpler to just use the str.isprintable
method, it returns a boolean indicating whether or not the argument string isprintable:
>>> "aéûβß\\".isprintable() #Works with various accents, special characters
True
>>> "\x16".isprintable()
False
>>> "\n".isprintable() #Excludes all other characters
False
the method using len(repr(event.char) == 3
could work, but it would for instance, also exclude \, which has a repr of 4 chars ('\\').
Question 3 :
Like you said, there are a bunch of gotcha (eg: tab's event char is "\t", returns is "\r"... I don't know where/if you can find an exhaustive list of these particularities, the only solution I ever had was try out the most common (eg pretty much every key and combinason Ctrl+key on my keyboard, using a program of course:
chars = dict()
def LogKey(event, chars = chars): #dict is mutable
global char #get the actual value of char
dict[char] = event.char #
root = Tk()
root.bind("<KeyPress>", LogKey)
for character in "abcde...123456...²&é\"'(-è_...)": #and so on
char = character
root.event_generate("<KeyPress-{}>".format(character))
char = "<Control-{}>".format(character)
root.event_generate(char)
char = "<Control-Shift-{}>".format(character)
...
#Inspect the dictonary chars in the end
It's probably not the best method, but it should cover most cases, you can also expande to test multiple keys (eg Control-c-v)...
Related Topics
What Does --Enable-Optimizations Do While Compiling Python
Cannot "Pip Install Cryptography" in Docker Alpine Linux 3.3 with Openssl 1.0.2G and Python 2.7
Ctypes Loading a C Shared Library That Has Dependencies
How to Find the Target File's Full(Absolute Path) of the Symbolic Link or Soft Link in Python
How to Rewrite Output in Terminal
What Is the Return Value of Subprocess.Call()
Package Libffi Was Not Found in the Pkg-Config Search Path Redhat6.5
What Is My Current Desktop Environment
Django Form Dropdown List of Numbers
How to Run Python Script on Terminal (Ubuntu)
Multiprocessing.Pool Spawning New Childern After Terminate() on Linux/Python2.7
Pairing Bluetooth Devices with Passkey/Password in Python - Rfcomm (Linux)
Python Requests, How to Specify Port for Outgoing Traffic
Install Scipy with Mkl Through Pip