AGW Logo

agw_title ScrolledThumbnail

This is the main class implementation of ThumbnailCtrl.

hierarchy Inheritance Diagram

Inheritance diagram for: ScrolledThumbnail

Inheritance diagram of ScrolledThumbnail


method_summary Methods Summary

__init__Default class constructor.
CalculateBestCaptionCalculates the best caption string to show based on the actual zoom factor.
ClearClears ThumbnailCtrl.
DeleteFilesDeletes the selected thumbnails and their associated files.
DrawThumbnailDraws a visible thumbnail.
EnableDraggingEnables/disables thumbnails drag and drop.
EnableToolTipsGlobally enables/disables thumbnail file information.
GetCaptionReturns the thumbnail caption.
GetCaptionFontReturns the font for all the thumbnail captions.
GetCaptionHeightReturns the height for the file name caption.
GetDropShadowReturns whether to drop a shadow behind thumbnails or not.
GetGlobalPopupMenuReturns the global thumbnailss popup menu (no need of thumbnail selection).
GetHighlightPointedReturns whether the thumbnail pointed should be highlighted or not.
GetItemReturns the item at position index.
GetItemCountReturns the number of thumbnails.
GetItemIndexReturns the thumbnail index at position (x, y).
GetOriginalImageReturns the original image associated to a thumbnail.
GetPaintRectReturns the paint bounding rect for the OnPaint method.
GetPointedReturns the pointed thumbnail index.
GetPointedItemReturns the pointed thumbnail.
GetPopupMenuReturns the thumbnails popup menu when at least one thumbnail is selected.
GetSelectedItemReturns the selected thumbnail.
GetSelectionReturns the selected thumbnail.
GetSelectionColourReturns the colour used to indicate a selected thumbnail.
GetShowDirReturns the working directory with images.
GetThumbBorderReturns the thumbnail border.
GetThumbHeightReturns the thumbnail height.
GetThumbInfoReturns the thumbnail information.
GetThumbOutlineReturns the thumbnail outline style on selection.
GetThumbSizeReturns the thumbnail size as width, height and border.
GetThumbWidthReturns the thumbnail width.
GetZoomFactorReturns the zoom factor.
InsertItemInserts a thumbnail in the specified position.
IsAudioReturns True if a file contains audio data.
IsAudioVideoReturns True if a file contains either audio or video data.
IsSelectedReturns whether a thumbnail is selected or not.
IsVideoReturns True if a file contains video data.
ListDirectoryReturns list of file info objects for files of particular extensions.
LoadImagesThreaded method to load images.
OnCharHandles the wx.EVT_CHAR event for ThumbnailCtrl.
OnMouseDClickHandles the wx.EVT_LEFT_DCLICK event for ThumbnailCtrl.
OnMouseDownHandles the wx.EVT_LEFT_DOWN and wx.EVT_RIGHT_DOWN events for ThumbnailCtrl.
OnMouseLeaveHandles the wx.EVT_LEAVE_WINDOW event for ThumbnailCtrl.
OnMouseMoveHandles the wx.EVT_MOTION event for ThumbnailCtrl.
OnMouseUpHandles the wx.EVT_LEFT_UP and wx.EVT_RIGHT_UP events for ThumbnailCtrl.
OnMouseWheelHandles the wx.EVT_MOUSEWHEEL event for ThumbnailCtrl.
OnPaintHandles the wx.EVT_PAINT event for ThumbnailCtrl.
OnResizeHandles the wx.EVT_SIZE event for ThumbnailCtrl.
OnThumbChangedHandles the EVT_THUMBNAILS_THUMB_CHANGED event for ThumbnailCtrl.
RemoveItemAtRemoves a thumbnail at the specified position.
RotateRotates the selected thumbnails by the angle specified by angle.
ScrollToSelectedScrolls the wx.ScrolledWindow to the selected thumbnail.
SetCaptionSets the current caption string.
SetCaptionFontSets the font for all the thumbnail captions.
SetDropShadowSets whether to drop a shadow behind thumbnails or not.
SetGlobalPopupMenuSets the global thumbnails popup menu (no need of thumbnail selection).
SetHighlightPointedSets whether the thumbnail pointed should be highlighted or not.
SetLabelControlSets the thumbnail label as wx.StaticText.
SetOrientationSet the ThumbnailCtrl orientation (partially implemented).
SetPopupMenuSets the thumbnails popup menu when at least one thumbnail is selected.
SetSelectionSets thumbnail selection.
SetSelectionColourSets the colour used to indicate a selected thumbnail.
SetThumbOutlineSets the thumbnail outline style on selection.
SetThumbSizeSets the thumbnail size as width, height and border.
SetZoomFactorSets the zoom factor.
ShowDirShows thumbnails for a particular folder.
ShowFileNamesSets whether the user wants to show file names under the thumbnails or not.
ShowThumbsShows all the thumbnails.
SortItemsSorts the items accordingly to the CmpThumb function.
ThreadImageThreaded method to load images.
UpdateItemsUpdates thumbnail items.
UpdatePropUpdates ThumbnailCtrl and its visible thumbnails.
UpdateShowUpdates thumbnail items.
ZoomInZooms the thumbnails in.
ZoomOutZooms the thumbnails out.

API Class API

class ScrolledThumbnail(wx.ScrolledWindow)[source]

This is the main class implementation of ThumbnailCtrl.



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

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(dc, caption, sw, width)[source]

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()[source]

Clears ThumbnailCtrl.



DeleteFiles()[source]

Deletes the selected thumbnails and their associated files.

Warning

This method deletes the original files too.



DrawThumbnail(bmp, thumb, index)[source]

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(enable=True)[source]

Enables/disables thumbnails drag and drop.

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


EnableToolTips(enable=True)[source]

Globally enables/disables thumbnail file information.

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


GetCaption()[source]

Returns the thumbnail caption.



GetCaptionFont()[source]

Returns the font for all the thumbnail captions.



GetCaptionHeight(begRow, count=1)[source]

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()[source]

Returns whether to drop a shadow behind thumbnails or not.



GetGlobalPopupMenu()[source]

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



GetHighlightPointed()[source]

Returns whether the thumbnail pointed should be highlighted or not.

Note

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



GetItem(index)[source]

Returns the item at position index.

Parameters:index – the thumbnail index position.


GetItemCount()[source]

Returns the number of thumbnails.



GetItemIndex(x, y)[source]

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

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


GetOriginalImage(index=None)[source]

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()[source]

Returns the paint bounding rect for the OnPaint method.



GetPointed()[source]

Returns the pointed thumbnail index.



GetPointedItem()[source]

Returns the pointed thumbnail.



GetPopupMenu()[source]

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



GetSelectedItem(index)[source]

Returns the selected thumbnail.

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


GetSelection(selIndex=-1)[source]

Returns the selected thumbnail.

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


GetSelectionColour()[source]

Returns the colour used to indicate a selected thumbnail.



GetShowDir()[source]

Returns the working directory with images.



GetThumbBorder()[source]

Returns the thumbnail border.



GetThumbHeight()[source]

Returns the thumbnail height.



GetThumbInfo(thumb=-1)[source]

Returns the thumbnail information.

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


GetThumbOutline()[source]

Returns the thumbnail outline style on selection.

See also

SetThumbOutline for a list of possible return values.



GetThumbSize()[source]

Returns the thumbnail size as width, height and border.



GetThumbWidth()[source]

Returns the thumbnail width.



GetZoomFactor()[source]

Returns the zoom factor.



InsertItem(thumb, pos)[source]

Inserts a thumbnail in the specified position.

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


IsAudio(fname)[source]

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(fname)[source]

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(indx)[source]

Returns whether a thumbnail is selected or not.

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


IsVideo(fname)[source]

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(directory, fileExtList)[source]

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(newfile, imagecount)[source]

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(event)[source]

Handles the wx.EVT_CHAR event for ThumbnailCtrl.

Parameters:event – a wx.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(event)[source]

Handles the wx.EVT_LEFT_DCLICK event for ThumbnailCtrl.

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


OnMouseDown(event)[source]

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

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



OnMouseLeave(event)[source]

Handles the wx.EVT_LEAVE_WINDOW event for ThumbnailCtrl.

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



OnMouseMove(event)[source]

Handles the wx.EVT_MOTION event for ThumbnailCtrl.

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



OnMouseUp(event)[source]

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

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



OnMouseWheel(event)[source]

Handles the wx.EVT_MOUSEWHEEL event for ThumbnailCtrl.

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

Note

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



OnPaint(event)[source]

Handles the wx.EVT_PAINT event for ThumbnailCtrl.

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


OnResize(event)[source]

Handles the wx.EVT_SIZE event for ThumbnailCtrl.

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


OnThumbChanged(event)[source]

Handles the EVT_THUMBNAILS_THUMB_CHANGED event for ThumbnailCtrl.

Parameters:event – a ThumbnailEvent event to be processed.


RemoveItemAt(pos)[source]

Removes a thumbnail at the specified position.

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


Rotate(angle=90)[source]

Rotates the selected thumbnails by the angle specified by angle.

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


ScrollToSelected()[source]

Scrolls the wx.ScrolledWindow to the selected thumbnail.



SetCaption(caption='')[source]

Sets the current caption string.

Parameters:caption – the current caption string.


SetCaptionFont(font=None)[source]

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(drop)[source]

Sets whether to drop a shadow behind thumbnails or not.

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


SetGlobalPopupMenu(gpmenu)[source]

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

Parameters:gpmenu – an instance of wx.Menu.


SetHighlightPointed(highlight=True)[source]

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(statictext)[source]

Sets the thumbnail label as wx.StaticText.

Parameters:statictext – an instance of wx.StaticText.



SetOrientation(orient=THUMB_VERTICAL)[source]

Set the ThumbnailCtrl orientation (partially implemented).

Parameters:orient – one of THUMB_VERTICAL, THUMB_HORIZONTAL.

Todo

Correctly implement the THUMB_HORIZONTAL orientation.



SetPopupMenu(menu)[source]

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

Parameters:menu – an instance of wx.Menu.



SetSelection(value=-1)[source]

Sets thumbnail selection.

Parameters:value – the thumbnail index to select.


SetSelectionColour(colour=None)[source]

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(outline)[source]

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(width, height, border=6)[source]

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(zoom=1.4)[source]

Sets the zoom factor.

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


ShowDir(folder, filter=THUMB_FILTER_IMAGES)[source]

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(show=True)[source]

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(thumbs, caption)[source]

Shows all the thumbnails.

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


SortItems()[source]

Sorts the items accordingly to the CmpThumb function.



ThreadImage(filenames)[source]

Threaded method to load images. Used internally.

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


UpdateItems()[source]

Updates thumbnail items.



UpdateProp(checkSize=True)[source]

Updates ThumbnailCtrl and its visible thumbnails.

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


UpdateShow()[source]

Updates thumbnail items.



ZoomIn()[source]

Zooms the thumbnails in.



ZoomOut()[source]

Zooms the thumbnails out.

Tree

Table Of Contents

Previous topic

PILImageHandler

Next topic

Thumb