Thumbnailctrl size (trying to get it to fullscreen)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Thumbnailctrl size (trying to get it to fullscreen)

Marcos del Amo


I've been trying to insert two Thubmnailctrl under a Multisplitter, I have managed to put them in there, but I can't manage to make them ocuppy the full space. On thumbnailctrl.py I've seen that on the the maximum size it can be is 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)

But on the other hand on the demo under ThumbnailCtrl, it uses an Splitter to create a Thumbnailctrl as big as you want, so I don't know if I'm doing something wrong (maybe with Sizers) or is some feature from Splitter (totally diferent than multisplitter) that allows the Thumbnailctrl to occupy it's full space.

Thumbnailctrl + Splitter Demo:

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

self.thumbsizer_staticbox = wx.StaticBox(self.panel, -1, "Thumb Style")
self.customsizer_staticbox = wx.StaticBox(self.panel, -1, "Thumb Customization")
self.optionsizer_staticbox = wx.StaticBox(self.panel, -1, "More Options")
self.dirsizer_staticbox = wx.StaticBox(self.panel, -1, "Directory Selection")
self.dirbutton = wx.Button(self.panel, -1, "Change Directory")
self.radiostyle1 = wx.RadioButton(self.panel, -1, "THUMB_OUTLINE_NONE", style=wx.RB_GROUP)
self.radiostyle2 = wx.RadioButton(self.panel, -1, "THUMB_OUTLINE_FULL")
self.radiostyle3 = wx.RadioButton(self.panel, -1, "THUMB_OUTLINE_RECT")
self.radiostyle4 = wx.RadioButton(self.panel, -1, "THUMB_OUTLINE_IMAGE")
self.highlight = wx.CheckBox(self.panel, -1, "Highlight on pointing")
self.showfiles = wx.CheckBox(self.panel, -1, "Show file names")
self.enabledragging = wx.CheckBox(self.panel, -1, "Enable drag and drop")
self.setpopup = wx.CheckBox(self.panel, -1, "Set popup menu on thumbs")
self.setgpopup = wx.CheckBox(self.panel, -1, "Set global popup menu")
self.showcombo = wx.CheckBox(self.panel, -1, "Show folder combobox")

self.radios = [self.radiostyle1, self.radiostyle2, self.radiostyle3,
self.radiostyle4]
self.thumbstyles = ["THUMB_OUTLINE_NONE", "THUMB_OUTLINE_FULL", "THUMB_OUTLINE_RECT",
"THUMB_OUTLINE_IMAGE"]

self.SetProperties()
self.DoLayout()

self.panel.SetSizer(sizer)
sizer.Layout()

self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeOutline, self.radiostyle1)
self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeOutline, self.radiostyle2)
self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeOutline, self.radiostyle3)
self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeOutline, self.radiostyle4)
self.Bind(wx.EVT_CHECKBOX, self.OnHighlight, self.highlight)
self.Bind(wx.EVT_CHECKBOX, self.OnShowFiles, self.showfiles)
self.Bind(wx.EVT_CHECKBOX, self.OnEnableDragging, self.enabledragging)
self.Bind(wx.EVT_CHECKBOX, self.OnSetPopup, self.setpopup)
self.Bind(wx.EVT_CHECKBOX, self.OnSetGlobalPopup, self.setgpopup)
self.Bind(wx.EVT_CHECKBOX, self.OnShowComboBox, self.showcombo)

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

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

def SetProperties(self):

self.radiostyle4.SetValue(1)
self.showfiles.SetValue(1)
boldFont = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")
self.dirbutton.SetFont(boldFont)

def DoLayout(self):

splitsizer = wx.BoxSizer(wx.VERTICAL)
optionsizer = wx.StaticBoxSizer(self.optionsizer_staticbox, wx.VERTICAL)
zoomsizer = wx.BoxSizer(wx.HORIZONTAL)
customsizer = wx.StaticBoxSizer(self.customsizer_staticbox, wx.VERTICAL)
thumbsizer = wx.StaticBoxSizer(self.thumbsizer_staticbox, wx.VERTICAL)
radiosizer = wx.BoxSizer(wx.VERTICAL)
dirsizer = wx.StaticBoxSizer(self.dirsizer_staticbox, wx.HORIZONTAL)
dirsizer.Add(self.dirbutton, 0, wx.LEFT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL | wx.ADJUST_MINSIZE, 3)
splitsizer.Add(dirsizer, 0, wx.EXPAND | wx.TOP | wx.LEFT, 5)
radiosizer.Add(self.radiostyle1, 0, wx.LEFT | wx.TOP | wx.ADJUST_MINSIZE, 3)
radiosizer.Add(self.radiostyle2, 0, wx.LEFT | wx.TOP | wx.ADJUST_MINSIZE, 3)
radiosizer.Add(self.radiostyle3, 0, wx.LEFT | wx.TOP | wx.ADJUST_MINSIZE, 3)
radiosizer.Add(self.radiostyle4, 0, wx.LEFT | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, 3)
thumbsizer.Add(radiosizer, 1, wx.EXPAND, 0)
splitsizer.Add(thumbsizer, 0, wx.TOP | wx.EXPAND | wx.LEFT, 5)
customsizer.Add(self.highlight, 0, wx.LEFT | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, 3)
customsizer.Add(self.showfiles, 0, wx.LEFT | wx.BOTTOM | wx.ADJUST_MINSIZE, 3)
customsizer.Add(self.enabledragging, 0, wx.LEFT | wx.BOTTOM | wx.ADJUST_MINSIZE, 3)
customsizer.Add(self.setpopup, 0, wx.LEFT | wx.BOTTOM | wx.ADJUST_MINSIZE, 3)
customsizer.Add(self.setgpopup, 0, wx.LEFT | wx.BOTTOM | wx.ADJUST_MINSIZE, 3)
customsizer.Add(self.showcombo, 0, wx.LEFT | wx.BOTTOM | wx.ADJUST_MINSIZE, 3)
splitsizer.Add(customsizer, 0, wx.TOP | wx.EXPAND | wx.LEFT, 5)
optionsizer.Add(zoomsizer, 1, wx.EXPAND, 0)
splitsizer.Add(optionsizer, 0, wx.EXPAND | wx.TOP | wx.LEFT, 5)
self.panel.SetAutoLayout(True)
self.panel.SetSizer(splitsizer)
splitsizer.Fit(self.panel)

def CreateMenuBar(self):

file_menu = wx.Menu()

AS_EXIT = wx.NewId()
file_menu.Append(AS_EXIT, "&Exit")
self.Bind(wx.EVT_MENU, self.OnClose, id=AS_EXIT)

help_menu = wx.Menu()

AS_ABOUT = wx.NewId()
help_menu.Append(AS_ABOUT, "&About...")
self.Bind(wx.EVT_MENU, self.OnAbout, id=AS_ABOUT)

menu_bar = wx.MenuBar()

menu_bar.Append(file_menu, "&File")
menu_bar.Append(help_menu, "&Help")

return menu_bar

def OnClose(self, event):

self.Destroy()

def OnAbout(self, event):

msg = "This Is The About Dialog Of The ThumbnailCtrl Demo.\n\n" + \
"Author: Andrea Gavana @ 10 Dec 2005\n\n" + \
"Please Report Any Bug/Requests Of Improvements\n" + \
"To Me At The Following Adresses:\n\n" + \
"[hidden email]\n" + "[hidden email]\n\n" + \
"Welcome To wxPython " + wx.VERSION_STRING + "!!"

dlg = wx.MessageDialog(self, msg, "ThumbnailCtrl Demo",
wx.OK | wx.ICON_INFORMATION)

dlg.SetFont(wx.Font(8, wx.NORMAL, wx.NORMAL, wx.NORMAL, False))
dlg.ShowModal()
dlg.Destroy()

def OnSetDirectory(self, event):

dlg = wx.DirDialog(self, "Choose a directory with images:",
defaultPath=os.getcwd(),
style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)

# If the user selects OK, then we process the dialog's data.
# This is done by getting the path data from the dialog - BEFORE
# we destroy it.
if dlg.ShowModal() == wx.ID_OK:
self.TC.ShowDir(dlg.GetPath())

# Only destroy a dialog after you're done with it.
dlg.Destroy()

def OnChangeOutline(self, event): # wxGlade: MyFrame.<event_handler>

radio = event.GetEventObject()
pos = self.radios.index(radio)

if pos == 0:
self.TC.SetThumbOutline(TC.THUMB_OUTLINE_NONE)
elif pos == 1:
self.TC.SetThumbOutline(TC.THUMB_OUTLINE_FULL)
elif pos == 2:
self.TC.SetThumbOutline(TC.THUMB_OUTLINE_RECT)
elif pos == 3:
self.TC.SetThumbOutline(TC.THUMB_OUTLINE_IMAGE)

self.TC.Refresh()

event.Skip()

def OnHighlight(self, event): # wxGlade: MyFrame.<event_handler>

if self.highlight.GetValue() == 1:
self.TC.SetHighlightPointed(True)
else:
self.TC.SetHighlightPointed(False)

event.Skip()

def OnShowFiles(self, event): # wxGlade: MyFrame.<event_handler>

if self.showfiles.GetValue() == 1:
self.TC.ShowFileNames(True)
else:
self.TC.ShowFileNames(False)

self.TC.Refresh()

event.Skip()

def OnEnableDragging(self, event):

if self.enabledragging.GetValue() == 1:
self.TC.EnableDragging(True)
else:
self.TC.EnableDragging(False)

self.TC.Refresh()

event.Skip()

def OnSetPopup(self, event): # wxGlade: MyFrame.<event_handler>

if self.setpopup.GetValue() == 1:
menu = self.CreatePopups()
self.TC.SetPopupMenu(menu)
else:
self.TC.SetPopupMenu(None)

event.Skip()

def OnSetGlobalPopup(self, event):

if self.setgpopup.GetValue() == 1:
menu = self.CreateGlobalPopups()
self.TC.SetGlobalPopupMenu(menu)
else:
self.TC.SetGlobalPopupMenu(None)

event.Skip()

def OnShowComboBox(self, event):

if self.showcombo.GetValue() == 1:
self.TC.ShowComboBox(True)
else:
self.TC.ShowComboBox(False)

event.Skip()

val = self.textzoom.GetValue().strip()

try:
val = float(val)
except:
errstr = "Error: a float value is required."
dlg = wx.MessageDialog(self, errstr, "ThumbnailCtrlDemo Error",
wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
self.textzoom.SetValue("1.4")
return

if val < 1.0:
errstr = "Error: zoom factor must be grater than 1.0."
dlg = wx.MessageDialog(self, errstr, "ThumbnailCtrlDemo Error",
wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
self.textzoom.SetValue("1.4")
return

self.TC.SetZoomFactor(val)

event.Skip()

dlg = wx.ColourDialog(self)

# Ensure the full colour dialog is displayed,
# not the abbreviated version.
dlg.GetColourData().SetChooseFull(True)

if dlg.ShowModal() == wx.ID_OK:
# If the user selected OK, then the dialog's wx.ColourData will
# contain valid information. Fetch the data ...
data = dlg.GetColourData()

# ... then do something with it. The actual colour data will be
# returned as a three-tuple (r, g, b) in this particular case.
colour = data.GetColour().Get()
colour = wx.Colour(colour[0], colour[1], colour[2])
self.TC.SetSelectionColour(colour)
self.TC.Refresh()

# Once the dialog is destroyed, Mr. wx.ColourData is no longer your
# friend. Don't use it again!
dlg.Destroy()

# ----------------------------------------------------------------------


if __name__ == '__main__':
app = wx.App()
MainFrame().Show()
app.MainLoop()

My attempt at a Multisplitter with two thumbnails (and when that works a third panel with text and stuff):

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

As you can si there are two thumbnails and they expand left to right, but they are capped at a maximum height.

Thanks a lot for the help!


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...