wxPython Splitter窗口和面板 [英] wxPython Splitter windows and Panels

查看:277
本文介绍了wxPython Splitter窗口和面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用2 GenericDirCtrl构造一个文件选择器,该文件选择器在文件下方的所选目录中显示文件.我的问题是,最好将拆分器窗口作为框架的子级放置,然后将包含控件的面板添加到拆分器窗口中,或者将拆分器窗口嵌入具有框架的子面板的面板中?

I'm trying to construct a file selector using 2 GenericDirCtrl which display the files in the selected direcotry beneath them. My question is it better to place the splitter window as a child of the frame and add the Panel containing the control to the splitter window or embed the splitter window in a panel with the panel child of the frame?

推荐答案

当我使用SplitterWindow时,我将其放在框架上,并给每一侧都有自己的面板.但是您应该能够做到:框架,面板,SplitterWindow一样容易.

When I used a SplitterWindow, I put it on the frame and gave each side their own panel. But you should be able to do: Frame, Panel, SplitterWindow just as easily.

这是一个通用示例:

import wx
import wx.grid as gridlib

########################################################################
class LeftPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)

        grid = gridlib.Grid(self)
        grid.CreateGrid(25,12)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 0, wx.EXPAND)
        self.SetSizer(sizer)

########################################################################
class RightPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)
        txt = wx.TextCtrl(self)


class MyForm(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "Splitter Tutorial")

        splitter = wx.SplitterWindow(self)
        leftP = LeftPanel(splitter)
        rightP = RightPanel(splitter)

        # split the window
        splitter.SplitVertically(leftP, rightP)
        splitter.SetMinimumPaneSize(20)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.EXPAND)
        self.SetSizer(sizer)

# Run the program
if __name__ == "__main__":
    app = wx.App(False)
    frame = MyForm()
    frame.Show()
    app.MainLoop()

这篇关于wxPython Splitter窗口和面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆