I've increased the custon AddPrivateFont
pointsize to
self.label_font.SetPointSize(27)
of the Title bar of the sample_one.py
script from this shared project:
https://wiki.wxpython.org/How%20to%20add%20a%20menu%20bar%20in%20the%20title%20bar%20%28Phoenix%29
From the script of my previous question here:
https://web.archive.org/web/20221202192613/https://paste.c-net.org/HondoPrairie
AddPrivateFont to App Title / Title bar in WxPython?
My problem is I can't figure out how to make the Title bar's height larger so the Title text displays its top part correctly. Currently the top of the Title text is truncated.
I tried adjusting the height
and textHeight
values from this statement:
textWidth, textHeight = gcdc.GetTextExtent(self.label)
tposx, tposy = ((width / 2) - (textWidth / 2), (height / 1) - (textHeight / 1))
from previous ones (in the sample_one.py
script):
textWidth, textHeight = gcdc.GetTextExtent(self.label)
tposx, tposy = ((width / 2) - (textWidth / 2), (height / 3) - (textHeight / 3))
Because it truncated the bottom (now the bottom shows up correctly but not the top of the Title text).
There is also this method I'm not sure how to handle:
def DoGetBestSize(self):
"""
...
"""
dc = wx.ClientDC(self)
dc.SetFont(self.GetFont())
textWidth, textHeight = dc.GetTextExtent(self.label)
spacing = 10
totalWidth = textWidth + (spacing)
totalHeight = textHeight + (spacing)
best = wx.Size(totalWidth, totalHeight)
self.CacheBestSize(best)
return best
I tried tweaking it and printing results but to no avail.
Here's a preview of the Truncated Title text:
What would be the correct approach to finding out what controls the height of the title bar object to fix the truncated title text?
1条答案
按热度按时间dxxyhpgq1#
感谢@Rolf of萨克森的headsup,我想明白了!
它采取了以下3个步骤:
第一步:
顶部标题文本显示自:
第二步:
标题文本下方的垂直间距(不显示文本):
第三步:
带文本显示的标题文本下方的垂直间距:
编辑:
第四步:
状态栏显示: