繁体   English   中英

如何将wx.ScrolledWindow放在wx.SplitterWindow中?

[英]How can I put a wx.ScrolledWindow inside a wx.SplitterWindow?

我不会以为这会那么棘手。 我试图得到这样的东西:

X | X

两个X均为ScrolledWindows,最终将包含大量文本和'|' 是将两者分开的“分割器”。 我想要一些与大多数视觉差异一样的东西。 不过,我似乎无法使它正常工作。 我现在的大问题是我违反了一些主张。 当我直接在python中运行它时,它实际上大致绘制了我的期望值,尽管有约束违例,但减去了适当大小的一些细化。 我的项目使用pybliographer,但是在违反约束时退出。 我做错了吗? 有没有更简单的方法可以做到这一点?

我已经包括了对splitterwindow示例代码的简单修改,以使用scrolledwindows。 我首先将面板安装在scrolledwindows内,然后使用它来设置滚动条,如wxpython Wiki(http://wiki.wxpython.org/ScrolledWindows中的第二个示例)所示,抱歉,新用户不能创建两个超链接。

import wx

class Splitterwindow(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(350, 300))
        quote = '''Whether you think that you can, or that you can't, you are usually right'''
        splitter = wx.SplitterWindow(self, -1)
        scroll1 = wx.ScrolledWindow(splitter,-1)
        panel1 = wx.Panel(scroll1, -1)
        wx.StaticText(panel1, -1, quote, (100, 100), style=wx.ALIGN_CENTRE)
        panel1.SetBackgroundColour(wx.LIGHT_GREY)
        panel1.SetAutoLayout(True)
        panel1.Layout()
        panel1.Fit()
        scroll_unit = 50
        width,height = panel1.GetSizeTuple()
        scroll1.SetScrollbars(scroll_unit,scroll_unit,width/scroll_unit,height/scroll_unit)
        scroll2 = wx.ScrolledWindow(splitter,-1)
        panel2 = wx.Panel(scroll2, -1)
        wx.StaticText(panel2, -1, quote, (100, 100), style=wx.ALIGN_CENTRE)
        panel2.SetBackgroundColour(wx.WHITE)
        panel2.SetAutoLayout(True)
        panel2.Layout()
        panel2.Fit()
        scroll_unit = 50
        width,height = panel2.GetSizeTuple()
        scroll2.SetScrollbars(scroll_unit,scroll_unit,width/scroll_unit,height/scroll_unit)
        splitter.SplitVertically(scroll1, scroll2)
        self.Centre()
        self.Show(True)

app = wx.App()
tmp = Splitterwindow(None, -1, 'splitterwindow.py')
app.MainLoop()

这个例子怎么了? 对我来说,它按预期工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM