Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Tkinter grid manager height/width nonconsistent

$
0
0

I have issue with tkinter grid manager consistency.I have specified columnconfigure so left part have 6, then one column is 1 as delimiter and then on right side (keyboard) the width is 3.As I understand left side should be twice size of right side. But on screen isn't. The haight have similar problem. All rows are set to rowconfigure=1, but on screen they are not same height.What I do wrong?Minimal part of my program to show problem:

#!/usr/bin/env python3# -*- coding: utf8 -*-from tkinter import *#***************************************************************************************************root = Tk()root.geometry("1024x600")tab3=Frame(root,relief=SUNKEN, bd=5 )tab3.pack(fill=BOTH, expand=True)#specify column widthsColwidths=[6,                       6,                      6,                      1,          3,          3,      3]gui1=[        [["Double\nline txt",1,1],      ["Double\nline txt",1,1],   ["Double\nline txt",1,1],   ["",1,1],   ["1",1,1],  ["2",1,1],  ["3",1,1]],        [["145.0",1,1],                 ["133.7",1,1],              ["133.1",1,1],              ["",1,1],   ["4",1,1],  ["5",1,1],  ["6",1,1]],        [["Double\nline txt",1,1],      ["TwoCel\ndblLine",1,2],    ["TwoCel\ndblLine",1,2],    ["",1,1],   ["7",1,1],  ["8",1,1],  ["9",1,1]],        [["20.5",1,1],                  ["",1,1],                   ["",1,1],                   ["",1,1],   ["X",1,1],  ["0",1,1],  ["OK️",1,1]]    ]for i,v in enumerate(Colwidths): tab3.columnconfigure(i, weight=v)for y,line in enumerate(gui1):    tab3.rowconfigure(y, weight=1)  #all rows are same height    for x, (txt,cs,rs) in enumerate(line):        if txt!="":            itm=Label(tab3,text=txt, bd=1, relief=SUNKEN, font=("Arial", 30, "bold"),bg='khaki')            itm.grid(row=y,column=x, columnspan=cs,rowspan=rs, sticky=NSEW)root.mainloop()

and the bad output:enter image description here

I was thinking that font is to big and can't fit into cell. So I remove sticky and try again and got this:enter image description here

so there are visible space around every item so size shouldn't be a problem.


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>