<commit_before>import wx
import os, sys
from wx.py import dispatcher
from Inspection.Inspector import Inspector
from Network.ObjectList import ObjectList
from Visible import Visible


class ArrangementInspector(Inspector):
    
    @classmethod
    def name(cls):
        return gettext('Arrangement')
    
    
    @classmethod
    def bitmap(cls):
        displayDir = os.path.abspath(os.path.dirname(sys.modules['Display'].__file__))
        image = wx.Image(displayDir + os.sep + 'ArrangementInspector.png')
        if image.IsOk():
            image.Rescale(16, 16)
            return image.ConvertToBitmap()
        else:
            return Inspector.bitmap(cls)
    
    
    @classmethod
    def canInspectDisplay(cls, display):
        return len(display.selection()) > 0


    def window(self, parentWindow=None):
        if not hasattr(self, '_window'):
            self._window = wx.Window(parentWindow, wx.ID_ANY)
            gridSizer = wx.FlexGridSizer(3, 2, 8, 8)
            
            # Add a slider for setting the arrangement weight within our parent.
            self._arrangedWeightSlider = wx.Slider(self._window, wx.ID_ANY, 50, 1, 100)
            self._arrangedWeightSlider.Bind(wx.EVT_SCROLL, self.onSetArrangedWeight)
            gridSizer.Add(wx.StaticText(self._window, wx.ID_ANY, gettext('Arranged weight:')), 0)
            gridSizer.Add(self._arrangedWeightSlider, 1)
            
            # Add a pop-up for choosing the child arrangement.
            self._arrangedAxisChoice = wx.Choice(self._window, wx.ID_ANY)
            self._arrangedAxisChoice.Append(gettext('None'), None)
            self._arrangedAxisChoice.Append(gettext('Largest'), 'largest')
            self._arrangedAxisChoice.Append(gettext('X'), 'X')
            self._arrangedAxisChoice.Append(gettext('Y'), 'Y')
            self._arrangedAxisChoice.Append(gettext('Z'), 'Z')<commit_msg>Now only showing inspector when it can be used.<commit_after>import wx
import os, sys
from wx.py import dispatcher
from Inspection.Inspector import Inspector
from Network.ObjectList import ObjectList
from Visible import Visible


class ArrangementInspector(Inspector):
    
    @classmethod
    def name(cls):
        return gettext('Arrangement')
    
    
    @classmethod
    def bitmap(cls):
        displayDir = os.path.abspath(os.path.dirname(sys.modules['Display'].__file__))
        image = wx.Image(displayDir + os.sep + 'ArrangementInspector.png')
        if image.IsOk():
            image.Rescale(16, 16)
            return image.ConvertToBitmap()
        else:
            return Inspector.bitmap(cls)
    
    
    @classmethod
    def canInspectDisplay(cls, display):
        for visible in display.selectedVisibles:
            if (len(visible.children) > 0 and visible.arrangedAxis is not None) or (visible.parent is not None and visible.parent.arrangedAxis is not None):
                return True
        return False


    def window(self, parentWindow=None):
        if not hasattr(self, '_window'):
            self._window = wx.Window(parentWindow, wx.ID_ANY)
            gridSizer = wx.FlexGridSizer(3, 2, 8, 8)
            
            # Add a slider for setting the arrangement weight within our parent.
            self._arrangedWeightSlider = wx.Slider(self._window, wx.ID_ANY, 50, 1, 100)
            self._arrangedWeightSlider.Bind(wx.EVT_SCROLL, self.onSetArrangedWeight)
            gridSizer.Add(wx.StaticText(self._window, wx.ID_ANY, gettext('Arranged weight:')), 0)
            gridSizer.Add(self._arrangedWeightSlider, 1)
            
            # Add a pop-up for choosing the child arrangement.
            self._arrangedAxisChoice = wx.Choice(self._window, wx.ID_ANY)
            self._arrangedAxisChoice.Append(gettext('None'), None)
            self._arrangedAxisChoice.Append(gettext('Largest'), 'largest')
            self._arrangedAxisChoice.Append(gettext('X'), 'X')
            self._arrangedAxisChoice.Append(gettext('Y'), 'Y')
            self._arrangedAxisChoice.Append(gettext('Z'), 'Z')
{'fraction_non_alphanumeric': 0.10314902058021325, 'fraction_numerical': 0.008430448797421275, 'mean_word_length': 2.621184919210054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7471495', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1168, 'n_words': 260}