Skip to content
Snippets Groups Projects
Commit 733b620e authored by Paul McCarthy's avatar Paul McCarthy
Browse files

The beginnings of my iconifying of all the interface things.

parent 6f8f6882
No related branches found
No related tags found
No related merge requests found
Showing
with 92 additions and 15 deletions
......@@ -19,3 +19,6 @@ Dependencies:
- ARB_fragment_program
- OpenGL 2.1
Some of the icons are derived from the Freeline icon set, by Enes Dal,
available at https://www.iconfinder.com/Enesdal, and released under the
Creative Commons (Attribution 3.0 Unported) license.
......@@ -9,6 +9,7 @@
import props
import fsl.fslview.toolbar as fsltoolbar
import fsl.fslview.icons as icons
import fsl.fslview.actions as actions
......@@ -27,12 +28,17 @@ class OrthoToolBar(fsltoolbar.FSLViewToolBar):
toolSpecs = [
actions.ActionButton(ortho, 'screenshot'),
props .Widget( 'zoom', spin=False, showLimits=False),
props .Widget( 'layout'),
props .Widget( 'showXCanvas'),
props .Widget( 'showYCanvas'),
props .Widget( 'showZCanvas'),
actions.ActionButton(self, 'more')]
props .Widget('zoom', spin=False, showLimits=False),
props .Widget('layout'),
props .Widget('showXCanvas',
icon=icons.findImageFile('showxcanvas', 32)[0]),
props .Widget('showYCanvas',
icon=icons.findImageFile('showycanvas', 32)[0]),
props .Widget('showZCanvas',
icon=icons.findImageFile('showzcanvas', 32)[0]),
actions.ActionButton(self,
'more',
icon=icons.findImageFile('gear', 32)[0])]
targets = {'screenshot' : ortho,
'zoom' : orthoOpts,
......
......@@ -18,6 +18,7 @@ import props
import pwidgets.elistbox as elistbox
import fsl.fslview.panel as fslpanel
import fsl.fslview.icons as icons
import fsl.data.image as fslimage
......@@ -38,15 +39,21 @@ class ListItemWidget(wx.Panel):
self.listBox = listBox
self.name = '{}_{}'.format(self.__class__.__name__, id(self))
self.saveButton = wx.Button( self,
label='S',
style=wx.BU_EXACTFIT)
self.lockButton = wx.ToggleButton( self,
label='L',
style=wx.BU_EXACTFIT)
self.visibility = props.makeWidget(self,
display,
'enabled')
# BU_NOTEXT causes a segmentation fault under OSX
if wx.Platform == '__WXMAC__': btnStyle = wx.BU_EXACTFIT
else: btnStyle = wx.BU_EXACTFIT | wx.BU_NOTEXT
self.saveButton = wx.Button( self, style=btnStyle)
self.lockButton = wx.ToggleButton(self, style=btnStyle)
self.saveButton.SetBitmap(icons.loadBitmap('floppydisk', 20))
self.lockButton.SetBitmap(icons.loadBitmap('chainlink', 20))
self.visibility = props.makeWidget(
self,
display,
'enabled',
icon=icons.findImageFile('eye', 20)[0])
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
......
#!/usr/bin/env python
#
# icons.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import os.path as op
import glob
import wx
# _bitmapPath = '/Users/paulmc/Projects/fslpy/fsl/fslview/icons/'
_bitmapPath = op.join(op.dirname(__file__), 'icons')
print _bitmapPath
def findImageFile(iconId, size):
path = op.join(_bitmapPath, '{}_*png'.format(iconId))
files = glob.glob(path)
fileNames = map(op.basename, files)
filePrefs = [op.splitext(f)[0] for f in fileNames]
sizes = map(int, [fp.split('_')[1] for fp in filePrefs])
if len(sizes) == 0:
raise ValueError('Invalid icon ID: {}'.format(iconId))
sizeDiffs = map(abs, [s - size for s in sizes])
idx = sizeDiffs.index(min(sizeDiffs))
return files[idx], sizes[idx]
def _resizeImage(image, size):
w, h = image.GetSize().Get()
if w >= h:
h = size * h / float(w)
w = size
else:
w = size * (w / float(h))
h = size
image.Rescale(w, h, wx.IMAGE_QUALITY_BICUBIC)
return image
def loadImage(iconId, size=None):
filename, fSize = findImageFile(iconId, size)
img = wx.Image(filename)
if fSize != size: return _resizeImage(img, size)
else: return img
def loadBitmap(iconId, size=None):
return wx.BitmapFromImage(loadImage(iconId, size))
fsl/fslview/icons/chainlink_16.png

338 B

fsl/fslview/icons/chainlink_20.png

384 B

fsl/fslview/icons/eye_16.png

353 B

fsl/fslview/icons/eye_20.png

365 B

fsl/fslview/icons/floppydisk_16.png

391 B

fsl/fslview/icons/floppydisk_20.png

500 B

fsl/fslview/icons/gear_32.png

640 B

fsl/fslview/icons/showxcanvas_32.png

893 B

fsl/fslview/icons/showycanvas_32.png

1.06 KiB

fsl/fslview/icons/showzcanvas_32.png

1.11 KiB

File added
fsl/fslview/icons/sources/eye.png

10.2 KiB

File added
fsl/fslview/icons/sources/gear.png

13.8 KiB

File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment