Skip to content

Commit 6182b30

Browse files
committed
cisstInteractive: fixed bitmaps
1 parent 6a85b17 commit 6182b30

File tree

3 files changed

+24
-28
lines changed

3 files changed

+24
-28
lines changed

cisstInteractive/code/irepy/ireImages.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@
3434
import wx
3535
import zlib
3636
if sys.version_info.major == 2:
37-
from cStringIO import StringIO
38-
BytesIO = StringIO
37+
from cStringIO import StringIO as BytesIO
3938
else:
40-
from io import StringIO, BytesIO
39+
from io import BytesIO
4140

4241
#----------------------------------------------------------------------
4342
def getSmallUpArrowData():
4443
return \
45-
"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
44+
b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
4645
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
4746
\x00\x00<IDAT8\x8dcddbf\xa0\x040Q\xa4{h\x18\xf0\xff\xdf\xdf\xffd\x1b\x00\xd3\
4847
\x8c\xcf\x10\x9c\x06\xa0k\xc2e\x08m\xc2\x00\x97m\xd8\xc41\x0c \x14h\xe8\xf2\
@@ -54,15 +53,15 @@ def getSmallUpArrowBitmap():
5453

5554
def getSmallUpArrowImage():
5655
try:
57-
stream = StringIO(getSmallUpArrowData())
56+
stream = BytesIO(getSmallUpArrowData())
5857
except TypeError as e:
5958
print('getSmallUpArrowImage: ', e)
6059
return wx.Image(stream)
6160

6261
#----------------------------------------------------------------------
6362
def getSmallDnArrowData():
6463
return \
65-
"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
64+
b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
6665
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
6766
\x00\x00HIDAT8\x8dcddbf\xa0\x040Q\xa4{\xd4\x00\x06\x06\x06\x06\x06\x16t\x81\
6867
\xff\xff\xfe\xfe'\xa4\x89\x91\x89\x99\x11\xa7\x0b\x90%\ti\xc6j\x00>C\xb0\x89\
@@ -74,7 +73,7 @@ def getSmallDnArrowBitmap():
7473

7574
def getSmallDnArrowImage():
7675
try:
77-
stream = StringIO(getSmallDnArrowData())
76+
stream = BytesIO(getSmallDnArrowData())
7877
except TypeError as e:
7978
print('getSmallDnArrowImage: ', e)
8079
return wx.Image(stream)

cisstInteractive/code/irepy/ireListCtrlPanel.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,10 @@ def __init__(self, parent, Label, ColumnTitles=[], Data=[]):
8888
# otherwise, every line in the list starts with a small up arrow
8989
# (this seems to be a wxWidgets bug on Windows).
9090
self.il = wx.ImageList(16, 16)
91-
if sys.version_info.major == 2:
92-
if sys.platform == 'win32':
93-
self.blank = self.il.Add(wx.Bitmap(16,16), wx.Bitmap(16,16))
94-
up_bitmap = ireImages.getSmallUpArrowBitmap()
95-
down_bitmap = ireImages.getSmallDnArrowBitmap()
96-
else:
97-
up_bitmap = wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (16,16))
98-
down_bitmap = wx.ArtProvider.GetBitmap(wx.ART_GO_DOWN, wx.ART_OTHER, (16,16))
91+
if sys.platform == 'win32':
92+
self.blank = self.il.Add(wx.Bitmap(16,16,1), wx.Bitmap(16,16,1))
93+
up_bitmap = ireImages.getSmallUpArrowBitmap()
94+
down_bitmap = ireImages.getSmallDnArrowBitmap()
9995
self.sm_up = self.il.Add(up_bitmap)
10096
self.sm_dn = self.il.Add(down_bitmap)
10197

cisstInteractive/code/irepy/ireMain.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,15 @@ def __init__(self, parent, id, title):
298298
#------------------------------------------------------
299299

300300
ToolBar = self.CreateToolBar( wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT )
301-
# Set up the toolbar, using bitmaps from ireImages.py or wx.ArtProvider.
302-
if sys.version_info.major == 2:
303-
new_bitmap = ireImages.getNewItemBitmap()
304-
open_bitmap = ireImages.getOpenItemBitmap()
305-
save_bitmap = ireImages.getSaveItemBitmap()
306-
else:
307-
tsize = (16,16)
308-
new_bitmap = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR, tsize)
309-
open_bitmap = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize)
310-
save_bitmap = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, tsize)
301+
# Set up the toolbar, using bitmaps from ireImages.py
302+
# Alternatively, could use wx.ArtProvider as follows:
303+
# tsize = (16,16)
304+
# new_bitmap = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR, tsize)
305+
# open_bitmap = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize)
306+
# save_bitmap = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, tsize)
307+
new_bitmap = ireImages.getNewItemBitmap()
308+
open_bitmap = ireImages.getOpenItemBitmap()
309+
save_bitmap = ireImages.getSaveItemBitmap()
311310
ToolBar.AddTool(wx.ID_NEW, "", new_bitmap, "New")
312311
ToolBar.SetToolLongHelp(wx.ID_NEW, "New file")
313312
ToolBar.AddTool(wx.ID_OPEN, "", open_bitmap, "Open")
@@ -600,9 +599,11 @@ def GetTypeString(self, obj):
600599
#-------------------------------------------------
601600

602601
def SaveHistoryToFile(self):
603-
cmdlist = self.CommandHistoryListCtrl.GetAllItems()
604-
f = open(self.HISTORY_FILENAME, 'w')
605-
pickle.dump(cmdlist, f)
602+
# PK TODO: pickle not yet working in Python3
603+
if sys.version_info.major == 2:
604+
cmdlist = self.CommandHistoryListCtrl.GetAllItems()
605+
f = open(self.HISTORY_FILENAME, 'w')
606+
pickle.dump(cmdlist, f)
606607

607608
def LoadHistoryFromFile(self, fn=HISTORY_FILENAME):
608609
Data = []

0 commit comments

Comments
 (0)