【问题标题】:wxWidgets calculating incorrect frame sizewxWidgets 计算不正确的帧大小
【发布时间】:2011-08-20 08:12:29
【问题描述】:

我需要制作小的 wxWidgets (wxPython) 框架,它只包含工具栏和菜单栏,并且足够容纳它们。当我在下面运行代码时,它会创建一个框架,但它太大了。我应该怎么做才能使框架紧紧地围绕它包含的组件?

创建有问题的框架的代码:

类 ToolFrame(wx.Frame):

def __init__(self, editor):
    wx.Frame.__init__(self, None, title = "Tools")
    self.editor = editor

    self.menu = FileMenu(self, editor)

    self.menuBar = wx.MenuBar()
    self.menuBar.Append(self.menu, "File")
    self.SetMenuBar(self.menuBar)

    self.toolBar = Tools(self, editor)
    self.SetToolBar(self.toolBar)

    # frame size has to be constant
    self.Layout()
    size = self.GetSize()
    self.SetMaxSize(size)
    self.SetMinSize(size)

    # connect exit callback
    self.Bind(wx.EVT_CLOSE, self.onClose)


def addTool(self, tool):
    self.toolBar.addTool(tool)


def onClose(self, event):
    if self.editor:
        self.editor.postEvent(events.ExitRequestEvent())

def quit(self):
    self.Destroy()

【问题讨论】:

    标签: python user-interface wxpython wxwidgets


    【解决方案1】:

    尝试删除self.SetMaxSize(size)并说出发生了什么。

    【讨论】:

      猜你喜欢
      • 2023-03-11
      • 1970-01-01
      • 2022-08-12
      • 2014-05-27
      • 2019-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多