Pythoncard 项目集大小
下面是我的 pythoncard 应用程序的基类:
class MyBackground(model.Background):
def on_initialize(self, event):
# if you have any initialization
# including sizer setup, do it here
self.setLayout()
def setLayout(self):
sizer1 = wx.BoxSizer(wx.VERTICAL) # main sizer
for item in self.components.itervalues():
item.SetSize(item.GetBestSize())
print item.GetBestSize(),item.GetSize() # here
sizer1.Add(item, 0, wx.ALL, 10)
sizer1.Fit(self)
self.panel.SetSizer(sizer1)
self.panel.Layout()
self.visible = 1
它使用包含以下内容的资源文件:
{'application':{'type':'Application',
'name':'Template',
'backgrounds': [
{'type':'Background',
'name':'bgTemplate',
'title':u'Standard Template with no menus',
'size': (800, 600),
'statusBar':1,
'style':['wx.MINIMIZE_BOX', 'wx.CLOSE_BOX', 'wx.MAXIMIZE_BOX', 'wx.FRAME_SHAPED', 'wx.CAPTION',
'wx.DEFAULT_FRAME_STYLE', 'wx.FULL_REPAINT_ON_RESIZE', 'wx.HW_SCROLLBAR_AUTO'],
'components': [
{'backgroundColor': '&H00FFFFFF&',
'name': 'MinMax0',
'position': (1080, 9900),
'size': (732, 220),
'text': '10000',
'type': 'TextField'}]}]}
在我用注释标记“此处”的行上打印 (80, 21) (732, 220)
,我希望是 (80, 21) (80, 21)
。 如何设置 pythoncard 应用程序中组件的大小?
Below is the base class of my pythoncard application:
class MyBackground(model.Background):
def on_initialize(self, event):
# if you have any initialization
# including sizer setup, do it here
self.setLayout()
def setLayout(self):
sizer1 = wx.BoxSizer(wx.VERTICAL) # main sizer
for item in self.components.itervalues():
item.SetSize(item.GetBestSize())
print item.GetBestSize(),item.GetSize() # here
sizer1.Add(item, 0, wx.ALL, 10)
sizer1.Fit(self)
self.panel.SetSizer(sizer1)
self.panel.Layout()
self.visible = 1
Which uses the resource file with content below:
{'application':{'type':'Application',
'name':'Template',
'backgrounds': [
{'type':'Background',
'name':'bgTemplate',
'title':u'Standard Template with no menus',
'size': (800, 600),
'statusBar':1,
'style':['wx.MINIMIZE_BOX', 'wx.CLOSE_BOX', 'wx.MAXIMIZE_BOX', 'wx.FRAME_SHAPED', 'wx.CAPTION',
'wx.DEFAULT_FRAME_STYLE', 'wx.FULL_REPAINT_ON_RESIZE', 'wx.HW_SCROLLBAR_AUTO'],
'components': [
{'backgroundColor': '&H00FFFFFF&',
'name': 'MinMax0',
'position': (1080, 9900),
'size': (732, 220),
'text': '10000',
'type': 'TextField'}]}]}
On the line that I have marked with a comment saying 'here' prints (80, 21) (732, 220)
, which i expected to be (80, 21) (80, 21)
. How can i set the size of the components in a pythoncard application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么是80,21?
你告诉它把项目变成 732,220,它就这么做了。
还是还有什么你没有告诉我们的?
Why 80,21?
You told it to make the item 732,220 and that's what it did.
Or is there something else that you didn't tell us?