【问题标题】:Pythoncard item setsizePythoncard 项目设置大小
【发布时间】:2009-01-14 03:29:10
【问题描述】:

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

【问题讨论】:

    标签: python wxpython pythoncard


    【解决方案1】:

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

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

    【讨论】:

    • 我确信我已经告诉过你所有的一切,亲爱的先生,但我不记得太多了,因为我已经 9 个月没问这个问题了。无论如何,从问题中猜测,因为是我,我想我希望看到 (80, 21) (80, 21) 因为将大小设置为 (80,21) - 这是/是 GetBestSize( )- 上一行中的 item.SetSize(item.GetBestSize()) 。然后我遇到了 pythoncard 的另一个问题,如果我没记错的话,它与滚动条有关,这让我放弃并从头开始用 wxpython 重写应用程序。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 2022-09-27
    • 2013-03-08
    相关资源
    最近更新 更多