Changeset 4799 for trunk


Ignore:
Timestamp:
Feb 3, 2021 11:25:36 AM (9 months ago)
Author:
toby
Message:

work on docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4798 r4799  
    139139except ImportError:
    140140    print('ImportError for wx/mpl in GSASIIctrlGUI: ignore if docs build')
    141     # wx = Placeholder(vals)
    142     # wxscroll = Placeholder(['ScrolledPanel'])
    143     # if 'phoenix' in wx.version():
    144     #     wg = Placeholder('Grid GridTableBase GridCellEditor'.split())
    145     # else:
    146     #     wg = Placeholder('Grid PyGridTableBase PyGridCellEditor'.split())
    147 
    148 
    149 # avoid "duplicate base class _MockObject" error in class G2LstCtrl():
    150 # where listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin are same
    151 # in docs build
    152 try:
    153     class _(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin): pass
    154 except TypeError:
    155     print('docs build conflict in listmix classes')
    156     class Placeholder(object):
    157         def __init__(self, vals):
    158             for val in vals:
    159                 setattr(self, val, object)
    160         def __getattr__(self, value):
    161             if value[0].isupper():
    162                 return object
    163             return Placeholder([])
    164     listmix = Placeholder(['ListCtrlAutoWidthMixin','ColumnSorterMixin'])
    165     class _(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin): pass
    166141       
    167142import time
     
    60856060        else:
    60866061            print('Error in SetColWidth: use either auto or width')
    6087            
    6088 class G2LstCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
    6089     '''Creates a custom ListCtrl with support for images in column labels
    6090     '''
    6091     def __init__(self, parent, ID=wx.ID_ANY, pos=wx.DefaultPosition,
    6092                  size=wx.DefaultSize, style=0):
    6093         wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
    6094         listmix.ListCtrlAutoWidthMixin.__init__(self)
    6095         from wx.lib.embeddedimage import PyEmbeddedImage
    6096         # from demo/images.py
    6097         SmallUpArrow = PyEmbeddedImage(
    6098             b"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAADxJ"
    6099             b"REFUOI1jZGRiZqAEMFGke2gY8P/f3/9kGwDTjM8QnAaga8JlCG3CAJdt2MQxDCAUaOjyjKMp"
    6100             b"cRAYAABS2CPsss3BWQAAAABJRU5ErkJggg==")
    6101         SmallDnArrow = PyEmbeddedImage(
    6102             b"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAEhJ"
    6103             b"REFUOI1jZGRiZqAEMFGke9QABgYGBgYWdIH///7+J6SJkYmZEacLkCUJacZqAD5DsInTLhDR"
    6104             b"bcPlKrwugGnCFy6Mo3mBAQChDgRlP4RC7wAAAABJRU5ErkJggg==")
    6105         self.il = wx.ImageList(16, 16)
    6106         self.UpArrow = self.il.Add(SmallUpArrow.GetBitmap())
    6107         self.DownArrow = self.il.Add(SmallDnArrow.GetBitmap())
    6108         self.parent=parent
    6109         self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
    6110        
    6111     def GetListCtrl(self): # needed for sorting
    6112         return self
    6113     def GetSortImages(self):
    6114         #return (self.parent.DownArrow, self.parent.UpArrow)
    6115         return (self.DownArrow, self.UpArrow)
    6116 
     6062
     6063try:
     6064    class G2LstCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
     6065        '''Creates a custom ListCtrl with support for images in column labels
     6066        '''
     6067        def __init__(self, parent, ID=wx.ID_ANY, pos=wx.DefaultPosition,
     6068                     size=wx.DefaultSize, style=0):
     6069            wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
     6070            listmix.ListCtrlAutoWidthMixin.__init__(self)
     6071            from wx.lib.embeddedimage import PyEmbeddedImage
     6072            # from demo/images.py
     6073            SmallUpArrow = PyEmbeddedImage(
     6074                b"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAADxJ"
     6075                b"REFUOI1jZGRiZqAEMFGke2gY8P/f3/9kGwDTjM8QnAaga8JlCG3CAJdt2MQxDCAUaOjyjKMp"
     6076                b"cRAYAABS2CPsss3BWQAAAABJRU5ErkJggg==")
     6077            SmallDnArrow = PyEmbeddedImage(
     6078                b"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAEhJ"
     6079                b"REFUOI1jZGRiZqAEMFGke9QABgYGBgYWdIH///7+J6SJkYmZEacLkCUJacZqAD5DsInTLhDR"
     6080                b"bcPlKrwugGnCFy6Mo3mBAQChDgRlP4RC7wAAAABJRU5ErkJggg==")
     6081            self.il = wx.ImageList(16, 16)
     6082            self.UpArrow = self.il.Add(SmallUpArrow.GetBitmap())
     6083            self.DownArrow = self.il.Add(SmallDnArrow.GetBitmap())
     6084            self.parent=parent
     6085            self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
     6086
     6087        def GetListCtrl(self): # needed for sorting
     6088            return self
     6089        def GetSortImages(self):
     6090            #return (self.parent.DownArrow, self.parent.UpArrow)
     6091            return (self.DownArrow, self.UpArrow)
     6092except TypeError:
     6093    # avoid "duplicate base class _MockObject" error in class G2LstCtrl():
     6094    # where listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin are same
     6095    # in docs build
     6096    class G2LstCtrl(wx.ListCtrl):
     6097        '''Creates a custom ListCtrl with support for images in column labels
     6098        '''
     6099        pass
     6100    print('docs build kludge for G2LstCtrl')
     6101   
    61176102################################################################################
    61186103#### Display Help information
Note: See TracChangeset for help on using the changeset viewer.