Hi Michael, I was just trying to reply to my self with the solution I've found, while I received your email :) I was using the Canvas in the begging, but it was complicating quite my code, so I tried to avoid it. However I found a solution maybe not the most elegant, but it works. According to the documentation of tk label the "height" option is in text units unless if an image is associated with the label, then it is in screen units. So I've created a dummy image of 1x1 pixels as transparent gif and added it as image/text compound in the label see the code below.
import tkFont from Tkinter import * ONEPIXEL=r"R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" def function(event=None): print time.winfo_geometry() print time.winfo_geometry() print date.winfo_geometry() if __name__ == "__main__": tk=Tk() onepixel=PhotoImage(data=ONEPIXEL) timefont = tkFont.Font(family="Helvetica",size=-96) ascent = timefont.metrics()['ascent'] print "ascent=",ascent time = Label(tk, text="10:21:46", image=onepixel, compound=LEFT, font=timefont, background="Yellow", height=ascent ) time.grid(row=0, column=0, sticky=N+EW) time.bind("<1>", function) date = Label(tk, text="Sat 04 Feb 2017", font="Helevetica -25", background="Cyan") date.grid(row=1, column=0, sticky=NSEW) tk.grid_rowconfigure(0, minsize=10) tk.mainloop() ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of Michael Lange [klappn...@web.de] Sent: Saturday, February 04, 2017 01:36 To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] Define height in a row of a grid manager Hi, On Fri, 3 Feb 2017 16:35:53 +0000 Vasilis Vlachoudis <vasilis.vlachou...@cern.ch> wrote: > Dear all, > > I am trying to optimize the screen space use in a small screen QVGA > mounted on a RPi > > On the first row (using the grid manager) I display the time with big > fonts. The space allocated for the row includes, correctly includes the > descent of the font however in the case of numbers its an empty space. > So its loosing a lot of useful screen space there. > > Is there a way to force the height of a single row in the grid manager > to be equal to the font ascent only? I am not entirely sure about this, but if I understand you correctly I think that it might actually not be grid who consumes the "excess" space, but the Label (or whichever) widget that you use to display the digits. If this assumption is true, a workaround might be to use a Canvas of pre-defined height instead and place the time-string with a pixel-sized font into properly calculated coordinates. I did not test this though, just a random thought :-) Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. The more complex the mind, the greater the need for the simplicity of play. -- Kirk, "Shore Leave", stardate 3025.8 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss