开发者

wxWidgets calculating incorrect frame size

开发者 https://www.devze.com 2023-03-29 16:58 出处:网络
I need to make small wxWidgets (wxPyt开发者_StackOverflow社区hon) frame, which contains only toolbar and menubar and is just enough big to contain them. When I run code below, it creates a frame but i

I need to make small wxWidgets (wxPyt开发者_StackOverflow社区hon) frame, which contains only toolbar and menubar and is just enough big to contain them. When I run code below, it creates a frame but it`s way too big. What should I do to make frame fit tightly around components it contains?

Code that creates problematic frame:

class 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()


Try to delete self.SetMaxSize(size) and say what happened.

0

精彩评论

暂无评论...
验证码 换一张
取 消