Skip to main content
 首页 » 编程设计

Pythoncard 项目集大小

2025年05月04日752php

下面是我的 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 应用程序中组件的大小?

请您参考如下方法:

为什么是 80,21? 您告诉它使项目成为 732,220,它就是这样做的。

或者还有什么您没有告诉我们的?