Phoenix Logo

phoenix_title wx.lib.agw.thumbnailctrl.ScrolledThumbnail

This is the main class implementation of ThumbnailCtrl.


class_hierarchy Class Hierarchy

Inheritance diagram for class ScrolledThumbnail:

super_classes Known Superclasses

wx.ScrolledWindow


method_summary Methods Summary

__init__ Default class constructor.
CalculateBestCaption Calculates the best caption string to show based on the actual zoom factor.
Clear Clears ThumbnailCtrl.
DeleteFiles Deletes the selected thumbnails and their associated files.
DrawThumbnail Draws a visible thumbnail.
EnableDragging Enables/disables thumbnails drag and drop.
EnableToolTips Globally enables/disables thumbnail file information.
GetCaption Returns the thumbnail caption.
GetCaptionFont Returns the font for all the thumbnail captions.
GetCaptionHeight Returns the height for the file name caption.
GetDropShadow Returns whether to drop a shadow behind thumbnails or not.
GetGlobalPopupMenu Returns the global thumbnailss popup menu (no need of thumbnail selection).
GetHighlightPointed Returns whether the thumbnail pointed should be highlighted or not.
GetItem Returns the item at position index.
GetItemCount Returns the number of thumbnails.
GetItemIndex Returns the thumbnail index at position (x, y).
GetOriginalImage Returns the original image associated to a thumbnail.
GetPaintRect Returns the paint bounding rect for the OnPaint method.
GetPointed Returns the pointed thumbnail index.
GetPointedItem Returns the pointed thumbnail.
GetPopupMenu Returns the thumbnails popup menu when at least one thumbnail is selected.
GetSelectedItem Returns the selected thumbnail.
GetSelection Returns the selected thumbnail.
GetSelectionColour Returns the colour used to indicate a selected thumbnail.
GetShowDir Returns the working directory with images.
GetThumbBorder Returns the thumbnail border.
GetThumbHeight Returns the thumbnail height.
GetThumbInfo Returns the thumbnail information.
GetThumbOutline Returns the thumbnail outline style on selection.
GetThumbSize Returns the thumbnail size as width, height and border.
GetThumbWidth Returns the thumbnail width.
GetZoomFactor Returns the zoom factor.
InsertItem Inserts a thumbnail in the specified position.
IsAudio Returns True if a file contains audio data.
IsAudioVideo Returns True if a file contains either audio or video data.
IsSelected Returns whether a thumbnail is selected or not.
IsVideo Returns True if a file contains video data.
ListDirectory Returns list of file info objects for files of particular extensions.
LoadImages Threaded method to load images. Used internally.
OnChar Handles the wx.EVT_CHAR event for ThumbnailCtrl.
OnMouseDClick Handles the wx.EVT_LEFT_DCLICK event for ThumbnailCtrl.
OnMouseDown Handles the wx.EVT_LEFT_DOWN and wx.EVT_RIGHT_DOWN events for ThumbnailCtrl.
OnMouseLeave Handles the wx.EVT_LEAVE_WINDOW event for ThumbnailCtrl.
OnMouseMove Handles the wx.EVT_MOTION event for ThumbnailCtrl.
OnMouseUp Handles the wx.EVT_LEFT_UP and wx.EVT_RIGHT_UP events for ThumbnailCtrl.
OnMouseWheel Handles the wx.EVT_MOUSEWHEEL event for ThumbnailCtrl.
OnPaint Handles the wx.EVT_PAINT event for ThumbnailCtrl.
OnResize Handles the wx.EVT_SIZE event for ThumbnailCtrl.
OnThumbChanged Handles the EVT_THUMBNAILS_THUMB_CHANGED event for ThumbnailCtrl.
RemoveItemAt Removes a thumbnail at the specified position.
Rotate Rotates the selected thumbnails by the angle specified by angle.
ScrollToSelected Scrolls the ScrolledWindow to the selected thumbnail.
SetCaption Sets the current caption string.
SetCaptionFont Sets the font for all the thumbnail captions.
SetDropShadow Sets whether to drop a shadow behind thumbnails or not.
SetGlobalPopupMenu Sets the global thumbnails popup menu (no need of thumbnail selection).
SetHighlightPointed Sets whether the thumbnail pointed should be highlighted or not.
SetLabelControl Sets the thumbnail label as StaticText.
SetOrientation Set the ThumbnailCtrl orientation (partially implemented).
SetPopupMenu Sets the thumbnails popup menu when at least one thumbnail is selected.
SetSelection Sets thumbnail selection.
SetSelectionColour Sets the colour used to indicate a selected thumbnail.
SetThumbOutline Sets the thumbnail outline style on selection.
SetThumbSize Sets the thumbnail size as width, height and border.
SetZoomFactor Sets the zoom factor.
ShowDir Shows thumbnails for a particular folder.
ShowFileNames Sets whether the user wants to show file names under the thumbnails or not.
ShowThumbs Shows all the thumbnails.
SortItems Sorts the items accordingly to the CmpThumb function.
ThreadImage Threaded method to load images. Used internally.
UpdateItems Updates thumbnail items.
UpdateProp Updates ThumbnailCtrl and its visible thumbnails.
UpdateShow Updates thumbnail items.
ZoomIn Zooms the thumbnails in.
ZoomOut Zooms the thumbnails out.

api Class API



class ScrolledThumbnail(wx.ScrolledWindow)

This is the main class implementation of ThumbnailCtrl.


Methods



__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, thumboutline=THUMB_OUTLINE_IMAGE, thumbfilter=THUMB_FILTER_IMAGES, imagehandler=PILImageHandler)

Default class constructor.

Parameters:
  • parent – parent window. Must not be None;
  • id – window identifier. A value of -1 indicates a default value;
  • pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
  • size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;
  • thumboutline – outline style for ScrolledThumbnail, which may be:
    Outline Flag Value Description
    THUMB_OUTLINE_NONE 0 No outline is drawn on selection
    THUMB_OUTLINE_FULL 1 Full outline (image+caption) is drawn on selection
    THUMB_OUTLINE_RECT 2 Only thumbnail bounding rectangle is drawn on selection (default)
    THUMB_OUTLINE_IMAGE 4 Only image bounding rectangle is drawn.
  • thumbfilter – filter for image/video/audio files. Actually only THUMB_FILTER_IMAGES is implemented;
  • imagehandler – can be PILImageHandler if PIL is installed (faster), or NativeImageHandler which only uses wxPython image methods.


CalculateBestCaption(self, dc, caption, sw, width)

Calculates the best caption string to show based on the actual zoom factor.

Parameters:
  • dc – an instance of wx.DC;
  • caption – the original caption string;
  • sw – the maximum width allowed for the caption string, in pixels;
  • width – the caption string width, in pixels.


Clear(self)

Clears ThumbnailCtrl.



DeleteFiles(self)

Deletes the selected thumbnails and their associated files.

Warning

This method deletes the original files too.



DrawThumbnail(self, bmp, thumb, index)

Draws a visible thumbnail.

Parameters:
  • bmp – the thumbnail version of the original image;
  • thumb – an instance of Thumb;
  • index – the index of the thumbnail to draw.


EnableDragging(self, enable=True)

Enables/disables thumbnails drag and drop.

Parameters:enableTrue to enable drag and drop, False to disable it.


EnableToolTips(self, enable=True)

Globally enables/disables thumbnail file information.

Parameters:enableTrue to enable thumbnail file information, False to disable it.


GetCaption(self)

Returns the thumbnail caption.



GetCaptionFont(self)

Returns the font for all the thumbnail captions.



GetCaptionHeight(self, begRow, count=1)

Returns the height for the file name caption.

Parameters:
  • begRow – the caption line at which we start measuring the height;
  • count – the number of lines to measure.


GetDropShadow(self)

Returns whether to drop a shadow behind thumbnails or not.



GetGlobalPopupMenu(self)

Returns the global thumbnailss popup menu (no need of thumbnail selection).



GetHighlightPointed(self)

Returns whether the thumbnail pointed should be highlighted or not.

Note

Please be aware that this functionality may be slow on slower computers.



GetItem(self, index)

Returns the item at position index.

Parameters:index – the thumbnail index position.


GetItemCount(self)

Returns the number of thumbnails.



GetItemIndex(self, x, y)

Returns the thumbnail index at position (x, y).

Parameters:
  • x – the mouse x position;
  • y – the mouse y position.


GetOriginalImage(self, index=None)

Returns the original image associated to a thumbnail.

Parameters:index – the index of the thumbnail. If defaulted to None, the current selection is used.


GetPaintRect(self)

Returns the paint bounding rect for the OnPaint method.



GetPointed(self)

Returns the pointed thumbnail index.



GetPointedItem(self)

Returns the pointed thumbnail.



GetPopupMenu(self)

Returns the thumbnails popup menu when at least one thumbnail is selected.



GetSelectedItem(self, index)

Returns the selected thumbnail.

Parameters:index – the thumbnail index (i.e., the selection).


GetSelection(self, selIndex=-1)

Returns the selected thumbnail.

Parameters:selIndex – if not equal to -1, the index of the selected thumbnail.


GetSelectionColour(self)

Returns the colour used to indicate a selected thumbnail.



GetShowDir(self)

Returns the working directory with images.



GetThumbBorder(self)

Returns the thumbnail border.



GetThumbHeight(self)

Returns the thumbnail height.



GetThumbInfo(self, thumb=-1)

Returns the thumbnail information.

Parameters:thumb – the index of the thumbnail for which we are collecting information.


GetThumbOutline(self)

Returns the thumbnail outline style on selection.

See also

SetThumbOutline for a list of possible return values.



GetThumbSize(self)

Returns the thumbnail size as width, height and border.



GetThumbWidth(self)

Returns the thumbnail width.



GetZoomFactor(self)

Returns the zoom factor.



InsertItem(self, thumb, pos)

Inserts a thumbnail in the specified position.

Parameters:pos – the index at which we wish to insert the new thumbnail.


IsAudio(self, fname)

Returns True if a file contains audio data. Currently unused as ThumbnailCtrl recognizes only image files.

Parameters:fname – a file name.

Todo

Find a way to create thumbnails of video, audio and other formats.



IsAudioVideo(self, fname)

Returns True if a file contains either audio or video data. Currently unused as ThumbnailCtrl recognizes only image files.

Parameters:fname – a file name.

Todo

Find a way to create thumbnails of video, audio and other formats.



IsSelected(self, indx)

Returns whether a thumbnail is selected or not.

Parameters:indx – the index of the thumbnail to check for selection.


IsVideo(self, fname)

Returns True if a file contains video data. Currently unused as ThumbnailCtrl recognizes only image files.

Parameters:fname – a file name.

Todo

Find a way to create thumbnails of video, audio and other formats.



ListDirectory(self, directory, fileExtList)

Returns list of file info objects for files of particular extensions.

Parameters:
  • directory – the folder containing the images to thumbnail;
  • fileExtList – a Python list of file extensions to consider.


LoadImages(self, newfile, imagecount)

Threaded method to load images. Used internally.

Parameters:
  • newfile – a file name containing an image to thumbnail;
  • imagecount – the number of images loaded until now.


OnChar(self, event)

Handles the wx.EVT_CHAR event for ThumbnailCtrl.

Parameters:event – a KeyEvent event to be processed.

Note

You have these choices:

  1. d key rotates 90 degrees clockwise the selected thumbnails;
  2. s key rotates 90 degrees counter-clockwise the selected thumbnails;
  3. a key rotates 180 degrees the selected thumbnails;
  4. Del key deletes the selected thumbnails;
  5. + key zooms in;
  6. - key zooms out.


OnMouseDClick(self, event)

Handles the wx.EVT_LEFT_DCLICK event for ThumbnailCtrl.

Parameters:event – a MouseEvent event to be processed.


OnMouseDown(self, event)

Handles the wx.EVT_LEFT_DOWN and wx.EVT_RIGHT_DOWN events for ThumbnailCtrl.

Parameters:event – a MouseEvent event to be processed.


OnMouseLeave(self, event)

Handles the wx.EVT_LEAVE_WINDOW event for ThumbnailCtrl.

Parameters:event – a MouseEvent event to be processed.


OnMouseMove(self, event)

Handles the wx.EVT_MOTION event for ThumbnailCtrl.

Parameters:event – a MouseEvent event to be processed.


OnMouseUp(self, event)

Handles the wx.EVT_LEFT_UP and wx.EVT_RIGHT_UP events for ThumbnailCtrl.

Parameters:event – a MouseEvent event to be processed.


OnMouseWheel(self, event)

Handles the wx.EVT_MOUSEWHEEL event for ThumbnailCtrl.

Parameters:event – a MouseEvent event to be processed.

Note

If you hold down the Ctrl key, you can zoom in/out with the mouse wheel.



OnPaint(self, event)

Handles the wx.EVT_PAINT event for ThumbnailCtrl.

Parameters:event – a PaintEvent event to be processed.


OnResize(self, event)

Handles the wx.EVT_SIZE event for ThumbnailCtrl.

Parameters:event – a wx.SizeEvent event to be processed.


OnThumbChanged(self, event)

Handles the EVT_THUMBNAILS_THUMB_CHANGED event for ThumbnailCtrl.

Parameters:event – a ThumbnailEvent event to be processed.


RemoveItemAt(self, pos)

Removes a thumbnail at the specified position.

Parameters:pos – the index at which we wish to remove the thumbnail.


Rotate(self, angle=90)

Rotates the selected thumbnails by the angle specified by angle.

Parameters:angle – the rotation angle for the thumbnail, in degrees.


ScrollToSelected(self)

Scrolls the ScrolledWindow to the selected thumbnail.



SetCaption(self, caption="")

Sets the current caption string.

Parameters:caption – the current caption string.


SetCaptionFont(self, font=None)

Sets the font for all the thumbnail captions.

Parameters:font – a valid wx.Font object. If defaulted to None, a standard font will be generated.


SetDropShadow(self, drop)

Sets whether to drop a shadow behind thumbnails or not.

Parameters:dropTrue to drop a shadow behind each thumbnail, False otheriwise.


SetGlobalPopupMenu(self, gpmenu)

Sets the global thumbnails popup menu (no need of thumbnail selection).

Parameters:gpmenu – an instance of wx.Menu.


SetHighlightPointed(self, highlight=True)

Sets whether the thumbnail pointed should be highlighted or not.

Parameters:highlightTrue to enable highlight-on-point with the mouse, False otherwise.

Note

Please be aware that this functionality may be slow on slower computers.



SetLabelControl(self, statictext)

Sets the thumbnail label as StaticText.

Parameters:statictext – an instance of StaticText.


SetOrientation(self, orient=THUMB_VERTICAL)

Set the ThumbnailCtrl orientation (partially implemented).

Parameters:orient – one of THUMB_VERTICAL, THUMB_HORIZONTAL.

Todo

Correctly implement the THUMB_HORIZONTAL orientation.



SetPopupMenu(self, menu)

Sets the thumbnails popup menu when at least one thumbnail is selected.

Parameters:menu – an instance of wx.Menu.


SetSelection(self, value=-1)

Sets thumbnail selection.

Parameters:value – the thumbnail index to select.


SetSelectionColour(self, colour=None)

Sets the colour used to indicate a selected thumbnail.

Parameters:colour – a valid wx.Colour object. If defaulted to None, it will be taken from the system settings.


SetThumbOutline(self, outline)

Sets the thumbnail outline style on selection.

Parameters:outline – the outline to use on selection. This can be one of the following bits:
Outline Flag Value Description
THUMB_OUTLINE_NONE 0 No outline is drawn on selection
THUMB_OUTLINE_FULL 1 Full outline (image+caption) is drawn on selection
THUMB_OUTLINE_RECT 2 Only thumbnail bounding rectangle is drawn on selection (default)
THUMB_OUTLINE_IMAGE 4 Only image bounding rectangle is drawn.


SetThumbSize(self, width, height, border=6)

Sets the thumbnail size as width, height and border.

Parameters:
  • width – the desired thumbnail width;
  • height – the desired thumbnail height;
  • border – the spacing between thumbnails.


SetZoomFactor(self, zoom=1.4)

Sets the zoom factor.

Parameters:zoom – a floating point number representing the zoom factor. Must be greater than or equal to 1.0.


ShowDir(self, folder, filter=THUMB_FILTER_IMAGES)

Shows thumbnails for a particular folder.

Parameters:
  • folder – a directory containing the images to thumbnail;
  • filter – filter images, video audio (currently implemented only for images).

Todo

Find a way to create thumbnails of video, audio and other formats.



ShowFileNames(self, show=True)

Sets whether the user wants to show file names under the thumbnails or not.

Parameters:showTrue to show file names under the thumbnails, False otherwise.


ShowThumbs(self, thumbs, caption)

Shows all the thumbnails.

Parameters:
  • thumbs – should be a sequence with instances of Thumb;
  • caption – the caption text for the current selected thumbnail.


SortItems(self)

Sorts the items accordingly to the CmpThumb function.



ThreadImage(self, filenames)

Threaded method to load images. Used internally.

Parameters:filenames – a Python list of file names containing images.


UpdateItems(self)

Updates thumbnail items.



UpdateProp(self, checkSize=True)

Updates ThumbnailCtrl and its visible thumbnails.

Parameters:checkSizeTrue to update the items visibility if the window size has changed.


UpdateShow(self)

Updates thumbnail items.



ZoomIn(self)

Zooms the thumbnails in.



ZoomOut(self)

Zooms the thumbnails out.