Subpixel positioning on Tk canvas
Christian Gollwitzer
auriocus at gmx.de
Sat Jun 19 00:42:14 EDT 2021
Am 19.06.21 um 06:26 schrieb George Furbish:
> On Saturday, June 19, 2021 at 12:22:31 AM UTC-4, Christian Gollwitzer wrote:
>> Am 19.06.21 um 02:03 schrieb George Furbish:
>>> Does Tk support interpolation/subpixel positioning of canvas elements? (e.g. images, text.) I have moving elements on my canvas, but the movement isn't very smooth and it's especially obvious when I have text moving alongside an image, since the two elements tend to jump to the next pixel at different times, creating a little judder between the two.
>> There is an "improved canvas" available, tkpath, which supports
>> antialiasing on all platforms. It is part of, e.g. undroidwish, if you
>> want to experiment with it. Last time I tested it had problems on macOS
>> though.
>
> How can I enable or access the improved canvas via Tkinter?
>
Probably by writing the wrapper for it ;)
Sorry for that answer, but Tkinter does not support many of the most
useful extensions for Tcl/Tk, because someone has to write the wrappers.
It only supports what is provided by base Tk. Among those I consider
useful and use in almost any application are:
* TkDnD for native drag'n'drop support (there is an inferior python
package of the same name which implements local DnD only)
* tablelist - complete widget for displaying trees and tables like
ttk::treeview, but with almost every feature one could imagine
* pdf4tcl - create a PDF from a canvas content, e.g. for printing
....
Basically you call Tcl via the eval() method of tkinter; in principle
you could do
========================
import tkinter as tk
root=tk()
root.eval('package require tkpath')
root.eval('...here comes your tkpath code...')
root.call('.tkp', 'create', 'oval', ....)
============================
tkpath is described here: https://wiki.tcl-lang.org/page/tkpath
For the wrapping, look at the implementation files of Tkinter, for say,
the original canvas, and modify accordingly.
Christian
More information about the Python-list
mailing list