Tkinter Treeview: set column widths











up vote
-1
down vote

favorite












I have a treeview with lots of columns and data, some numbers with fixed #commas, some warning symbols, some text that can be cut, some text that shouldn't be cut etc.
In short: I need and want to manually specify widths column by column.
My current approach is this one:



DEF_TreeHeaders = ['id','pos','time', ...]
DEF_TreeAlign = [L, L, R, ...]
DEF_TreeWidth = [0, 5, 10, ...]

for i in [..]:
treeView.column(i, width= DEF_TreeWidth[i], ...)


Seems width is not really absolute and also depends from the overall width of treeView. Trying everything through is time consuming and doesn't lead to the optimal solution.



So my idea is to let the python script run, adjust the columns manually and then print out the current widths, freeze them and store them in a config file.



Good idea? I am sure I am not the only one having had this problem. How have you handled it? How to set absolute width no matter what?










share|improve this question
























  • Possible duplicate of How to change ttk.Treeview column width and weight in Python 3.3
    – stovfl
    Nov 9 at 14:49










  • Thanks, part (1) "hard wire width" is done by now and I like my approach for setting width = 100 more: treeView.column("Column 1", minwidth= 100, width= 100) Also very useful is to specify font and row height: style = ttk.Style() style.configure("Treeview", rowheight= 18, font= ('Helvetica', 9))
    – VengaVenga
    Nov 9 at 15:18















up vote
-1
down vote

favorite












I have a treeview with lots of columns and data, some numbers with fixed #commas, some warning symbols, some text that can be cut, some text that shouldn't be cut etc.
In short: I need and want to manually specify widths column by column.
My current approach is this one:



DEF_TreeHeaders = ['id','pos','time', ...]
DEF_TreeAlign = [L, L, R, ...]
DEF_TreeWidth = [0, 5, 10, ...]

for i in [..]:
treeView.column(i, width= DEF_TreeWidth[i], ...)


Seems width is not really absolute and also depends from the overall width of treeView. Trying everything through is time consuming and doesn't lead to the optimal solution.



So my idea is to let the python script run, adjust the columns manually and then print out the current widths, freeze them and store them in a config file.



Good idea? I am sure I am not the only one having had this problem. How have you handled it? How to set absolute width no matter what?










share|improve this question
























  • Possible duplicate of How to change ttk.Treeview column width and weight in Python 3.3
    – stovfl
    Nov 9 at 14:49










  • Thanks, part (1) "hard wire width" is done by now and I like my approach for setting width = 100 more: treeView.column("Column 1", minwidth= 100, width= 100) Also very useful is to specify font and row height: style = ttk.Style() style.configure("Treeview", rowheight= 18, font= ('Helvetica', 9))
    – VengaVenga
    Nov 9 at 15:18













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a treeview with lots of columns and data, some numbers with fixed #commas, some warning symbols, some text that can be cut, some text that shouldn't be cut etc.
In short: I need and want to manually specify widths column by column.
My current approach is this one:



DEF_TreeHeaders = ['id','pos','time', ...]
DEF_TreeAlign = [L, L, R, ...]
DEF_TreeWidth = [0, 5, 10, ...]

for i in [..]:
treeView.column(i, width= DEF_TreeWidth[i], ...)


Seems width is not really absolute and also depends from the overall width of treeView. Trying everything through is time consuming and doesn't lead to the optimal solution.



So my idea is to let the python script run, adjust the columns manually and then print out the current widths, freeze them and store them in a config file.



Good idea? I am sure I am not the only one having had this problem. How have you handled it? How to set absolute width no matter what?










share|improve this question















I have a treeview with lots of columns and data, some numbers with fixed #commas, some warning symbols, some text that can be cut, some text that shouldn't be cut etc.
In short: I need and want to manually specify widths column by column.
My current approach is this one:



DEF_TreeHeaders = ['id','pos','time', ...]
DEF_TreeAlign = [L, L, R, ...]
DEF_TreeWidth = [0, 5, 10, ...]

for i in [..]:
treeView.column(i, width= DEF_TreeWidth[i], ...)


Seems width is not really absolute and also depends from the overall width of treeView. Trying everything through is time consuming and doesn't lead to the optimal solution.



So my idea is to let the python script run, adjust the columns manually and then print out the current widths, freeze them and store them in a config file.



Good idea? I am sure I am not the only one having had this problem. How have you handled it? How to set absolute width no matter what?







python tkinter treeview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 11:03









martineau

64.7k887173




64.7k887173










asked Nov 9 at 10:50









VengaVenga

2515




2515












  • Possible duplicate of How to change ttk.Treeview column width and weight in Python 3.3
    – stovfl
    Nov 9 at 14:49










  • Thanks, part (1) "hard wire width" is done by now and I like my approach for setting width = 100 more: treeView.column("Column 1", minwidth= 100, width= 100) Also very useful is to specify font and row height: style = ttk.Style() style.configure("Treeview", rowheight= 18, font= ('Helvetica', 9))
    – VengaVenga
    Nov 9 at 15:18


















  • Possible duplicate of How to change ttk.Treeview column width and weight in Python 3.3
    – stovfl
    Nov 9 at 14:49










  • Thanks, part (1) "hard wire width" is done by now and I like my approach for setting width = 100 more: treeView.column("Column 1", minwidth= 100, width= 100) Also very useful is to specify font and row height: style = ttk.Style() style.configure("Treeview", rowheight= 18, font= ('Helvetica', 9))
    – VengaVenga
    Nov 9 at 15:18
















Possible duplicate of How to change ttk.Treeview column width and weight in Python 3.3
– stovfl
Nov 9 at 14:49




Possible duplicate of How to change ttk.Treeview column width and weight in Python 3.3
– stovfl
Nov 9 at 14:49












Thanks, part (1) "hard wire width" is done by now and I like my approach for setting width = 100 more: treeView.column("Column 1", minwidth= 100, width= 100) Also very useful is to specify font and row height: style = ttk.Style() style.configure("Treeview", rowheight= 18, font= ('Helvetica', 9))
– VengaVenga
Nov 9 at 15:18




Thanks, part (1) "hard wire width" is done by now and I like my approach for setting width = 100 more: treeView.column("Column 1", minwidth= 100, width= 100) Also very useful is to specify font and row height: style = ttk.Style() style.configure("Treeview", rowheight= 18, font= ('Helvetica', 9))
– VengaVenga
Nov 9 at 15:18

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224278%2ftkinter-treeview-set-column-widths%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224278%2ftkinter-treeview-set-column-widths%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff