wx.lib.agw.scrolledthumbnail.ScrolledThumbnail¶
This is the main class implementation of ThumbnailCtrl
.
Class Hierarchy¶
Known Superclasses¶
Methods Summary¶
Default class constructor. |
|
Calculates the best caption string to show based on the actual zoom factor. |
|
Clears |
|
Draws a visible thumbnail. |
|
Enables/disables thumbnails drag and drop. |
|
Globally enables/disables thumbnail file information. |
|
Returns the font for all the thumbnail captions. |
|
Returns the height for the file name caption. |
|
Returns whether to drop a shadow behind thumbnails or not. |
|
Returns the global thumbnailss popup menu (no need of thumbnail selection). |
|
Returns whether the thumbnail pointed should be highlighted or not. |
|
Return thumbnail at specified position. |
|
Returns the number of thumbnails. |
|
Returns the thumbnail index at position (x, y). |
|
Returns the paint bounding rect for the |
|
Returns the pointed thumbnail index. |
|
Returns the pointed thumbnail. |
|
Returns the thumbnails popup menu when at least one thumbnail is selected. |
|
Returns the selected thumbnail. |
|
Returns the selected thumbnail. |
|
Returns the colour used to indicate a selected thumbnail. |
|
Returns the thumbnail border. |
|
Returns the thumbnail height. |
|
Returns the thumbnail information. |
|
Returns the thumbnail outline style on selection. |
|
Returns the thumbnail size as width, height and border. |
|
Returns the thumbnail width. |
|
Returns the zoom factor. |
|
Inserts a thumbnail in the specified position. |
|
Returns whether a thumbnail is selected or not. |
|
Threaded method to load images. Used internally. |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Removes a thumbnail at the specified position. |
|
Rotates the selected thumbnails by the angle specified by angle. |
|
Scrolls the |
|
Sets the font for all the thumbnail captions. |
|
Sets whether to drop a shadow behind thumbnails or not. |
|
Sets the global thumbnails popup menu (no need of thumbnail selection). |
|
Sets whether the thumbnail pointed should be highlighted or not. |
|
Sets the thumbnails popup menu when at least one thumbnail is selected. |
|
Sets thumbnail selection. |
|
Sets the colour used to indicate a selected thumbnail. |
|
Sets the thumbnail outline style on selection. |
|
Sets the thumbnail size as width, height and border. |
|
Sets the zoom factor. |
|
Sets whether the user wants to show file names under the thumbnails or not. |
|
Shows all the thumbnails. |
|
Threaded method to load images. Used internally. |
|
Updates thumbnail items. |
|
Updates |
|
Updates thumbnail items. |
|
Zooms the thumbnails in. |
|
Zooms the thumbnails out. |
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, imagehandler=None)¶
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.
imagehandler – can be
PILImageHandler
if PIL is installed (faster), orNativeImageHandler
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
.
- 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:
enable –
True
to enable drag and drop,False
to disable it.
- EnableToolTips(self, enable=True)¶
Globally enables/disables thumbnail file information.
- Parameters:
enable –
True
to enable thumbnail file information,False
to disable it.
- 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, pos)¶
Return thumbnail at specified position.
- Parameters:
pos – the index of the thumbnail
- Returns:
the Thumb
- 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.
- 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.
- 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.
- IsSelected(self, indx)¶
Returns whether a thumbnail is selected or not.
- Parameters:
indx – the index of the thumbnail to check for selection.
- 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 forThumbnailCtrl
.- Parameters:
event – a
KeyEvent
event to be processed.
Note
You have these choices:
d
key rotates 90 degrees clockwise the selected thumbnails;s
key rotates 90 degrees counter-clockwise the selected thumbnails;a
key rotates 180 degrees the selected thumbnails;+
key zooms in;
(5)
-
key zooms out. All other keys cause an EVT_THUMBNAILS_CHAR event to be thrown.
- OnMouseDClick(self, event)¶
Handles the
wx.EVT_LEFT_DCLICK
event forThumbnailCtrl
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseDown(self, event)¶
Handles the
wx.EVT_LEFT_DOWN
andwx.EVT_RIGHT_DOWN
events forThumbnailCtrl
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseLeave(self, event)¶
Handles the
wx.EVT_LEAVE_WINDOW
event forThumbnailCtrl
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseMove(self, event)¶
Handles the
wx.EVT_MOTION
event forThumbnailCtrl
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseUp(self, event)¶
Handles the
wx.EVT_LEFT_UP
andwx.EVT_RIGHT_UP
events forThumbnailCtrl
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseWheel(self, event)¶
Handles the
wx.EVT_MOUSEWHEEL
event forThumbnailCtrl
.- 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 forThumbnailCtrl
.- Parameters:
event – a
PaintEvent
event to be processed.
- OnResize(self, event)¶
Handles the
wx.EVT_SIZE
event forThumbnailCtrl
.- Parameters:
event – a
wx.SizeEvent
event to be processed.
- OnThumbChanged(self, event)¶
Handles the
EVT_THUMBNAILS_THUMB_CHANGED
event forThumbnailCtrl
.- 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.
- SetCaptionFont(self, font=None)¶
Sets the font for all the thumbnail captions.
- Parameters:
font – a valid
wx.Font
object. If defaulted toNone
, a standard font will be generated.
- SetDropShadow(self, drop)¶
Sets whether to drop a shadow behind thumbnails or not.
- Parameters:
drop –
True
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:
highlight –
True
to enable highlight-on-point with the mouse,False
otherwise.
Note
Please be aware that this functionality may be slow on slower computers.
- 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 toNone
, 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.
- ShowFileNames(self, show=True)¶
Sets whether the user wants to show file names under the thumbnails or not.
- Parameters:
show –
True
to show file names under the thumbnails,False
otherwise.
- ShowThumbs(self, thumbs)¶
Shows all the thumbnails.
- Parameters:
thumbs – should be a sequence with instances of
Thumb
;
- 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:
checkSize –
True
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.