【问题标题】:wxPython : How do I shrink the size of Button to the width of the label text?wxPython:如何将 Button 的大小缩小到标签文本的宽度?
【发布时间】:2014-05-09 05:26:51
【问题描述】:

我有一个 FlexGridSizer,我添加了一堆 TextCtrl,其中一些是供用户输入路径的,所以我在这些 TextCtrl 框右侧的相邻列中有一个 Button。标签文本是......我只在其中包含 TextCtrl 的列上调用 AddGrowableCol......这是我在 for 循环中添加按钮的方式(我不使用 addmany):

widgetItem = wx.Button(parent, -1, "...")
widgetItem.row=rowNum
widgetItem.col=colNum
widgetItem.target = lastTextBox
self.Bind(wx.EVT_BUTTON, self.getFile, widgetItem)
currentSizer.AddF(widgetItem, wx.SizerFlags(0).Border(wx.ALL, 5))

【问题讨论】:

    标签: wxpython wxwidgets


    【解决方案1】:

    啊,我在想什么叫做shrink-wrapped或shrink-to-fit,被wxPython称为exactfit: wxPython docs on Button class, style section

    wx.BU_EXACTFIT
    

    这是我必须实例化 Button 的方法:

    widgetItem = wx.Button(parent, -1, "...", style=wx.BU_EXACTFIT)
    

    【讨论】:

      猜你喜欢
      • 2017-10-09
      • 1970-01-01
      • 2021-05-27
      • 2021-11-10
      • 1970-01-01
      • 2011-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多