Python 2.7 Thumbnailctrl大小(尝试使其全屏显示)

Python 2.7 Thumbnailctrl大小(尝试使其全屏显示),python-2.7,wxpython,thumbnails,splitter,Python 2.7,Wxpython,Thumbnails,Splitter,我一直在尝试在一个多裂片下插入两个Thubmnailctrl,我设法将它们放在那里,但我无法使它们占据整个空间。在thumbnailctrl.py上,我已经看到,在上,它的最大大小为350x280: def SetThumbSize(self, width, height, border=6): """ Sets the thumbnail size as width, height and border. :param `width`: the desired thumbnail width

我一直在尝试在一个多裂片下插入两个Thubmnailctrl,我设法将它们放在那里,但我无法使它们占据整个空间。在thumbnailctrl.py上,我已经看到,在上,它的最大大小为350x280:

def SetThumbSize(self, width, height, border=6):
"""
Sets the thumbnail size as width, height and border.

:param `width`: the desired thumbnail width;
:param `height`: the desired thumbnail height;
:param `border`: the spacing between thumbnails.
"""

if width > 350 or height > 280:
    return

self._tWidth = width 
self._tHeight = height
self._tBorder = border
self.SetScrollRate((self._tWidth + self._tBorder)/4,
                   (self._tHeight + self._tBorder)/4)
self.SetSizeHints(self._tWidth + self._tBorder*2 + 16,
                  self._tHeight + self._tBorder*2 + 8)
但另一方面,在ThumbnailCtrl下的演示中,它使用了一个拆分器来创建一个ThumbnailCtrl,大小如你所愿,所以我不知道我是否做错了什么(可能是使用了大小调整器),或者是拆分器的某个功能(完全不同于多拆分器)允许ThumbnailCtrl占据了它的全部空间

Thumbnailctrl+拆分器演示:

import wx
import os
import sys

try:
    dirName = os.path.dirname(os.path.abspath(__file__))
except:
    dirName = os.path.dirname(os.path.abspath(sys.argv[0]))

sys.path.append(os.path.split(dirName)[0])

try:
    from agw import thumbnailctrl as TC
except ImportError:  # if it's not there locally, try the wxPython lib.
import wx.lib.agw.thumbnailctrl as TC


class MainFrame(wx.Frame):
def __init__(self, redirect=False, filename=None):
    wx.Frame.__init__(self, None, title="Elephant")

    # self.SetMenuBar(self.CreateMenuBar())

    splitter = wx.SplitterWindow(self, -1, style=wx.CLIP_CHILDREN | wx.SP_3D | wx.WANTS_CHARS | wx.SP_LIVE_UPDATE)
    self.panel = wx.Panel(splitter, -1)

    sizer = wx.BoxSizer(wx.HORIZONTAL)
    scroll = TC.ThumbnailCtrl(splitter, -1, imagehandler=TC.NativeImageHandler)

    scroll.ShowFileNames()
    if os.path.isdir("../bitmaps"):
        scroll.ShowDir(os.path.normpath(os.getcwd() + "/../bitmaps"))
    else:
        scroll.ShowDir(os.getcwd())

    self.TC = scroll

    splitter.SplitVertically(scroll, self.panel, 180)

    splitter.SetMinimumPaneSize(140)
    self.SetMinSize((700, 590))
    self.CenterOnScreen()

if __name__ == "__main__":
    app = wx.App(False)
    frame = MainFrame()
    # import wx.lib.inspection
    # wx.lib.inspection.InspectionTool().Show()
    app.MainLoop()
我尝试使用两个缩略图制作多切分器(当第三个面板使用文本和内容时):

正如您所看到的,有两个缩略图,它们从左到右展开,但它们的上限为最大高度


非常感谢你的帮助

无法100%确定您试图通过此功能实现什么,但我怀疑您的问题在于
topmostSizer
比例属性。
尝试:

从手册中:

比例-尽管此参数的含义在中未定义 Sizer,它在wx.BoxSizer中用于指示是否是Sizer的子级 可以在wx.BoxSizer的主方向上更改其大小-其中 0表示不可更改,大于零的值为 相对于其他资产的价值(占总资产的比例)进行解释 同一wx.BoxSizer的子代

在本例中,您已将
topmostSizer
定义为垂直

import wx
import os
import cv2
import ctypes
from PIL import Image
from wx.lib.splitter import MultiSplitterWindow

try:
    from agw import thumbnailctrl as TC
except ImportError:  # if it's not there locally, try the wxPython lib.
    import wx.lib.agw.thumbnailctrl as TC


class SamplePane(wx.Panel):
def __init__(self, parent):
    wx.Panel.__init__(self, parent)

    self.thumbnail11 = TC.ThumbnailCtrl(self, imagehandler=TC.NativeImageHandler, thumboutline=4)
    self.thumbnail11.EnableDragging(True)
    # self.thumbnail11.SetThumbSize(350, screensize[0] / 15, 25)  # For images -> Max values 350,280

    # ################VID################ #

    topmostSizer = wx.BoxSizer(wx.VERTICAL)

    topmostSizer.Add(self.thumbnail11, proportion=0, flag=wx.EXPAND)

    self.SetSizer(topmostSizer)
    self.MaxSize
    # topmostSizer.Fit(self)


class MainFrame(wx.Frame):
""""""

    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="Elephant")

        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
        # t1Sizer = wx.BoxSizer(wx.VERTICAL)
        # self.thumbnail11 = TC.ThumbnailCtrl(splitter, imagehandler=TC.NativeImageHandler, thumboutline=4)
        panel = SamplePane(splitter)
        splitter.AppendWindow(panel)
        panel2 = SamplePane(splitter)
        splitter.AppendWindow(panel2)
        # t1Sizer.Add(panel, proportion=0, flag=wx.EXPAND)
        self.Show()

if __name__ == "__main__":
    app = wx.App(False)

    frame = MainFrame()
    # import wx.lib.inspection
    # wx.lib.inspection.InspectionTool().Show()
    app.MainLoop()
topmostSizer.Add(self.thumbnail11, proportion=1, flag=wx.EXPAND)