From e574645e94d1a87fc7441c62ad768b1dce5c86d2 Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Wed, 31 May 2017 10:25:51 -0300 Subject: [PATCH] Removed the local colorselect --- invesalius/gui/default_viewers.py | 2 +- invesalius/gui/task_navigator.py | 2 +- invesalius/gui/task_slice.py | 4 ++-- invesalius/gui/task_surface.py | 4 ++-- invesalius/gui/widgets/colourselect.py | 176 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 5 files changed, 6 insertions(+), 182 deletions(-) delete mode 100644 invesalius/gui/widgets/colourselect.py diff --git a/invesalius/gui/default_viewers.py b/invesalius/gui/default_viewers.py index a8b509e..8c0a037 100644 --- a/invesalius/gui/default_viewers.py +++ b/invesalius/gui/default_viewers.py @@ -302,9 +302,9 @@ class VolumeInteraction(wx.Panel): import wx.lib.platebtn as pbtn import wx.lib.buttons as btn import wx.lib.pubsub as ps +import wx.lib.colourselect as csel import invesalius.constants as const -import invesalius.gui.widgets.colourselect as csel [BUTTON_RAYCASTING, BUTTON_VIEW, BUTTON_SLICE_PLANE, BUTTON_3D_STEREO] = [wx.NewId() for num in xrange(4)] RAYCASTING_TOOLS = wx.NewId() diff --git a/invesalius/gui/task_navigator.py b/invesalius/gui/task_navigator.py index f1eb418..e8e2057 100644 --- a/invesalius/gui/task_navigator.py +++ b/invesalius/gui/task_navigator.py @@ -26,6 +26,7 @@ import wx.lib.hyperlink as hl import wx.lib.masked.numctrl import wx.lib.foldpanelbar as fpb from wx.lib.pubsub import pub as Publisher +import wx.lib.colourselect as csel import invesalius.constants as const import invesalius.data.bases as db @@ -34,7 +35,6 @@ import invesalius.data.coregistration as dcr import invesalius.data.trackers as dt import invesalius.data.trigger as trig import invesalius.gui.dialogs as dlg -import invesalius.gui.widgets.colourselect as csel class TaskPanel(wx.Panel): def __init__(self, parent): diff --git a/invesalius/gui/task_slice.py b/invesalius/gui/task_slice.py index 20cb893..04fe288 100644 --- a/invesalius/gui/task_slice.py +++ b/invesalius/gui/task_slice.py @@ -24,6 +24,7 @@ import wx import wx.lib.hyperlink as hl import wx.lib.platebtn as pbtn import wx.lib.foldpanelbar as fpb +import wx.lib.colourselect as csel from wx.lib.pubsub import pub as Publisher import invesalius.data.mask as mask @@ -31,7 +32,6 @@ import invesalius.data.slice_ as slice_ import invesalius.constants as const import invesalius.gui.dialogs as dlg import invesalius.gui.widgets.gradient as grad -import invesalius.gui.widgets.colourselect as csel from invesalius.project import Project import invesalius.session as ses @@ -421,7 +421,7 @@ class MaskProperties(wx.Panel): self.combo_mask_name = combo_mask_name # Mask colour - button_colour= csel.ColourSelect(self, 111,colour=(0,255,0),size=(-1,22)) + button_colour= csel.ColourSelect(self, 111,colour=(0,255,0),size=(22,-1)) self.button_colour = button_colour # Sizer which represents the first line diff --git a/invesalius/gui/task_surface.py b/invesalius/gui/task_surface.py index 026e5ab..ebea08a 100644 --- a/invesalius/gui/task_surface.py +++ b/invesalius/gui/task_surface.py @@ -23,11 +23,11 @@ import wx import wx.lib.hyperlink as hl from wx.lib.pubsub import pub as Publisher import wx.lib.foldpanelbar as fpb +import wx.lib.colourselect as csel import invesalius.constants as const import invesalius.data.slice_ as slice_ import invesalius.gui.dialogs as dlg -import invesalius.gui.widgets.colourselect as csel import wx.lib.platebtn as pbtn import invesalius.project as prj import invesalius.utils as utl @@ -415,7 +415,7 @@ class SurfaceProperties(wx.Panel): self.combo_surface_name = combo_surface_name # Mask colour - button_colour= csel.ColourSelect(self, -1,colour=(0,0,255),size=(-1,22)) + button_colour= csel.ColourSelect(self, -1,colour=(0,0,255),size=(22, -1)) button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) self.button_colour = button_colour diff --git a/invesalius/gui/widgets/colourselect.py b/invesalius/gui/widgets/colourselect.py deleted file mode 100644 index 8b5eff5..0000000 --- a/invesalius/gui/widgets/colourselect.py +++ /dev/null @@ -1,176 +0,0 @@ -#---------------------------------------------------------------------------- -# Name: ColourSelect.py -# Purpose: Colour Box Selection Control -# -# Author: Lorne White, Lorne.White@telusplanet.net -# -# Created: Feb 25, 2001 -# Licence: wxWindows license -#---------------------------------------------------------------------------- - -# creates a colour wxButton with selectable color -# button click provides a colour selection box -# button colour will change to new colour -# GetColour method to get the selected colour - -# Updates: -# call back to function if changes made - -# Cliff Wells, logiplexsoftware@earthlink.net: -# - Made ColourSelect into "is a button" rather than "has a button" -# - Added label parameter and logic to adjust the label colour according to the background -# colour -# - Added id argument -# - Rearranged arguments to more closely follow wx conventions -# - Simplified some of the code - -# Cliff Wells, 2002/02/07 -# - Added ColourSelect Event - -# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for 2.5 compatability. -# - -""" -Provides a `ColourSelect` button that, when clicked, will display a -colour selection dialog. The selected colour is displayed on the -button itself. -""" - -#---------------------------------------------------------------------------- - -import wx - -#---------------------------------------------------------------------------- - -wxEVT_COMMAND_COLOURSELECT = wx.NewEventType() - -class ColourSelectEvent(wx.PyCommandEvent): - def __init__(self, id, value): - wx.PyCommandEvent.__init__(self, id = id) - self.SetEventType(wxEVT_COMMAND_COLOURSELECT) - self.value = value - - def GetValue(self): - return self.value - -EVT_COLOURSELECT = wx.PyEventBinder(wxEVT_COMMAND_COLOURSELECT, 1) - -#---------------------------------------------------------------------------- - -class ColourSelect(wx.BitmapButton): - def __init__(self, parent, id=wx.ID_ANY, label="", colour=wx.BLACK, - pos=wx.DefaultPosition, size=wx.DefaultSize, - callback=None, style=0): - if label: - w, h = parent.GetTextExtent(label) - w += 6 - h += 6 - else: - w, h = 20, 20 - wx.BitmapButton.__init__(self, parent, id, wx.EmptyBitmap(w,h), - pos=pos, size=size, style=style|wx.BU_AUTODRAW) - - if type(colour) == type( () ): - colour = wx.Colour(*colour) - self.colour = colour - self.SetLabel(label) - self.callback = callback - bmp = self.MakeBitmap() - self.SetBitmap(bmp) - parent.Bind(wx.EVT_BUTTON, self.OnClick, self) - - - def GetColour(self): - return self.colour - - def GetValue(self): - return self.colour - - def SetValue(self, colour): - self.SetColour(colour) - - def SetColour(self, colour): - if type(colour) == tuple: - colour = wx.Colour(*colour) - if type(colour) == str: - colour = wx.NamedColour(colour) - - self.colour = colour - bmp = self.MakeBitmap() - self.SetBitmap(bmp) - - - def SetLabel(self, label): - self.label = label - - def GetLabel(self): - return self.label - - - def MakeBitmap(self): - bdr = 8 - width, height = self.GetSize() - - # yes, this is weird, but it appears to work around a bug in wxMac - if "wxMac" in wx.PlatformInfo and width == height: - height -= 1 - - bmp = wx.EmptyBitmap(width-bdr, height-bdr) - dc = wx.MemoryDC() - dc.SelectObject(bmp) - dc.SetFont(self.GetFont()) - label = self.GetLabel() - # Just make a little colored bitmap - dc.SetBackground(wx.Brush(self.colour)) - dc.Clear() - - if label: - # Add a label to it - avg = reduce(lambda a, b: a + b, self.colour.Get()) / 3 - fcolour = avg > 128 and wx.BLACK or wx.WHITE - dc.SetTextForeground(fcolour) - dc.DrawLabel(label, (0,0, width-bdr, height-bdr), - wx.ALIGN_CENTER) - - dc.SelectObject(wx.NullBitmap) - return bmp - - - def SetBitmap(self, bmp): - self.SetBitmapLabel(bmp) - #self.SetBitmapSelected(bmp) - #self.SetBitmapDisabled(bmp) - #self.SetBitmapFocus(bmp) - #self.SetBitmapSelected(bmp) - self.Refresh() - - - def OnChange(self): - evt = ColourSelectEvent(self.GetId(), self.GetValue()) - evt.SetEventObject(self) - wx.PostEvent(self, evt) - if self.callback is not None: - self.callback() - - def OnClick(self, event): - data = wx.ColourData() - data.SetChooseFull(True) - data.SetColour(self.colour) - dlg = wx.ColourDialog(wx.GetTopLevelParent(self), data) - - try: - changed = dlg.ShowModal() == wx.ID_OK - except(wx._core.PyAssertionError): - changed = True - - if changed: - data = dlg.GetColourData() - self.SetColour(data.GetColour()) - dlg.Destroy() - - # moved after dlg.Destroy, since who knows what the callback will do... - if changed: - self.OnChange() - -- libgit2 0.21.2