forked from cool-RR/python_toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneric_bitmaps.py
More file actions
48 lines (37 loc) · 1.25 KB
/
generic_bitmaps.py
File metadata and controls
48 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright 2009-2017 Ram Rachum.
# This program is distributed under the MIT license.
'''Defines functions for getting generic bitmaps, sometimes from the OS.'''
import wx
from python_toolbox import caching
is_mac = (wx.Platform == '__WXMAC__')
is_gtk = (wx.Platform == '__WXGTK__')
is_win = (wx.Platform == '__WXMSW__')
@caching.cache()
def _get_icon_bitmap_from_shell32_dll(index_number, size):
assert isinstance(index_number, int)
assert is_win
import win32api
width, height = size
shell32_dll = win32api.GetModuleFileName(
win32api.GetModuleHandle('shell32.dll')
)
return wx.BitmapFromIcon(
wx.Icon(
'%s;%s' % (shell32_dll, index_number),
wx.BITMAP_TYPE_ICO,
desiredWidth=width,
desiredHeight=height
)
)
@caching.cache()
def get_closed_folder_bitmap(size=(16, 16)):
if is_win:
return _get_icon_bitmap_from_shell32_dll(3, size=size)
else:
return wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, size)
@caching.cache()
def get_open_folder_bitmap(size=(16, 16)):
if is_win:
return _get_icon_bitmap_from_shell32_dll(4, size=size)
else:
return wx.ArtProvider_GetBitmap(wx.ART_FOLDER_OPEN, wx.ART_OTHER, size)