FAQ
Hi all,
when i type the following code under python3, version 3.2 using osx 10.6.8:

##############################################################
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

from tkinter import *
from tkinter.ttk import *
from tkinter.font import Font

root = Tk()
tv = Treeview(root, columns=['ad1', 'ad2'])
tv.pack()
tv.heading('#0', text='tree label', anchor=E)
tv.column('#0', anchor=E)
tv.heading('ad1', text='additional info 1', anchor=E)
tv.column('ad1', anchor=E)
tv.heading('ad2', text='additional info 2', anchor=E)
tv.column('ad2', anchor=E)

nd = tv.insert('', 'end', text='left aligned', values=['right aligned',
'right aligned'])
tv.column('#0', width=Font().measure('left aligned'))

for l in ['#0', '#1', '#2']:
print('column %s \nheading options: %s \ncolumn options %s' %
(l, tv.heading(l, option=None), tv.column(l, option=None)))

root.mainloop()
##############################################################

i get the following output:

column #0
heading options: {'tate': '', 'text': 'tree label', 'image': '',
'command': '', 'anchor': 'e'}
column options {'minwidth': 20, 'width': 200, 'id': '', 'anchor': 'e',
'stretch': 1}
column #1
heading options: {'tate': '', 'text': 'additional info 1', 'image': '',
'command': '', 'anchor': 'e'}
column options {'minwidth': 20, 'width': 200, 'id': 'ad1', 'anchor':
'e', 'stretch': 1}
column #2
heading options: {'tate': '', 'text': 'additional info 2', 'image': '',
'command': '', 'anchor': 'e'}
column options {'minwidth': 20, 'width': 200, 'id': 'ad2', 'anchor':
'e', 'stretch': 1}

showing that all elements should be right aligned (anchor:'e').
Nevertheless, all headings are centered, the tree label is left aligned
while the rest is right aligned. This is not what i would expect.

Additional, the column width of the tree label is to small, one
charakter is missing. Can someone explain to me, how to do this the
right way?

Thank you for any hints
Wolfgang

Search Discussions

  • Ned Deily at Jul 1, 2011 at 6:20 am
    In article <4e0cad83$0$6583$9b4e6d93 at newsspool3.arcor-online.net>,
    Wolfgang Meiners wrote:
    when i type the following code under python3, version 3.2 using osx 10.6.8:
    [...]

    You might want to ask your question on the Tkinter list and/or possibly
    the Tcl Mac list.

    http://mail.python.org/mailman/listinfo/tkinter-discuss
    https://lists.sourceforge.net/lists/listinfo/tcl-mac

    --
    Ned Deily,
    nad at acm.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 30, '11 at 5:08p
activeJul 1, '11 at 6:20a
posts2
users2
websitepython.org

2 users in discussion

Ned Deily: 1 post Wolfgang Meiners: 1 post

People

Translate

site design / logo © 2022 Grokbase