Tkinter text widget settings tab

I need to set the tab size for my text widget to 4 characters. When I do textwidget.config(tabs = ("4c","8c"))

I am not getting the required results. It contains many characters which are now 4 characters. Am I doing something wrong by setting the tabs property? Also, when I show the row and column number, I do it by getting the insertion index, but here the tab is marked as one character and not four, which I would like it to be perfect. Is there a better way to get the column number without having to deal with this tabs issue?

+3


source to share


1 answer


the documentation for the tt text option of the Tk text widget specifies that the 2c distance will be 2 centimeters. The documentation doesn't seem to say, but uses the Tk_GetPixels function to convert parameter values ​​to distances and here it contains the following types:

<none>
  The number specifies a distance in pixels.
c
  The number specifies a distance in centimeters on the screen.
i
  The number specifies a distance in inches on the screen.
m
  The number specifies a distance in millimeters on the screen.
p
  The number specifies a distance in printer points (1/72 inch) on the screen.

      



If you want to use character spacing, you must use the font size using the font specific to your text widget and the appropriate character, for example, m

or n

given that for proportional fonts, characters have different widths. An example of this is given in the Tk -tabs text widget.

+3


source







All Articles