I want to create a frame, which width = primary display width。
so I create get display width via wx.Display
class MainDisplay:
"""
主显示器
"""
def __init__(self):
"""
初始化,获取主显示器的相关参数
"""
for i in range(wx.Display.GetCount()):
display = wx.Display(index=i)
if display.IsPrimary():
self.width = display.GetClientArea()[2] # 主显示器宽度
self.height = display.GetClientArea()[3] # 主显示器高度
self.ppi = display.GetStdPPIValue() # 获得显示器的ppi
self.scale = display.GetScaleFactor() # 获取放大
and then, I pass the width and height to my frame, via self.SetClientSize
class IntroFrame(wx.Frame):
"""
简介窗口
"""
def __init__(self, parent=None, width=None, height=None, title='答得喵'):
wx.Frame.__init__(self, parent, wx.ID_ANY, pos=wx.DefaultPosition, title=title)
# self.SetClientSize(width, int(min(width, height)/2))
print(width, int(height/2))
self.SetClientSize(width, int(height/2))
print(self.GetSize())
When I run the program, I get two different size:
2560 700
(2576, 739)
It seems GetSize is bigger than SetClientSize, I want to how can I fix it.