wxpython滑动面板_wxPython Splitter窗口和面板

1586010002-jmsa.png

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?

解决方案

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.

Here's a generic example:

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值