[英]How do I make my wxPython scrolledPanel scroll to the bottom of the window?
[英]How do I make my wxpython top frame show in the middle of my desktop?
我想让我的GUI程序顶部框架垂直和水平对齐。
wx.Frame.__init__(self, parent=None, id= -1, title="Test Frame", pos=(-1, -1), size=(1280, 770), style=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX)
我应该做什么(除了计算找到绝对位置)到pos=(-1, -1)
使它显示在中间(无论800 * 600或1280 * 800等),还是其他一些属性设置也需要?
简单地使用
self.Center()
在类__init__()
而不是pos=(-1,-1)
。
w = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
h = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
pos=(w/2, h/2)
这使您成为屏幕的中心。
现在,假设您有一个800x600大小的应用程序:
APPWIDTH = 800
APPHEIGHT = 600
w = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
h = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
# Centre of the screen
x = w / 2
y = h / 2
# Minus application offset
x -= (APPWIDTH / 2)
y -= (APPHEIGHT / 2)
pos=(x, y)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.