示例#1
0
    def __init__(self, parent):
#         import config
        wx.Dialog.__init__(self, parent, -1,
                           title='Available styles')

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        treeSizer = wx.BoxSizer(wx.VERTICAL)
        # panel for the tree!
        treePanel = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
        self.tree = wx.TreeCtrl(treePanel, -1,
                           wx.DefaultPosition,
                           (-1,-1),
                           wx.TR_HIDE_ROOT |
                           wx.TR_HAS_BUTTONS |
                           wx.TR_MULTIPLE)
        root = self.tree.AddRoot('Style modules')
        # for each module, add styles found into it to the tree
        for moduleName in util.getPluginNames():
            module = __import__(moduleName)
            subItems = []
            for item in dir(module):
                thisOne = module.__getattribute__(item)
                if type(thisOne) is types.TypeType and \
                        issubclass(thisOne, style.Style) and \
                        not issubclass(style.Style, thisOne):
                    subItems.append(thisOne.__name__ +': '+ thisOne.description)
            if len(subItems) > 0:
                thisNode = self.tree.AppendItem(root, module.__name__)
                for item in subItems:
                    self.tree.AppendItem(thisNode, item)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onSelection)
        # now add the tree to the sizer in the panel...
        treeSizer.Add(self.tree, 1, wx.EXPAND)
        treePanel.SetSizer(treeSizer)

        # expand the tree by default
        self.tree.ExpandAll()
        
        mainSizer.Add(treePanel, 1, wx.EXPAND)
        mainSizer.Add((0,10), 0)

        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        # add standard buttons
        okButton = wx.Button(self, wx.ID_OK)
        cancelButton = wx.Button(self, wx.ID_CANCEL)
        buttonSizer.Add(okButton, 0)
        buttonSizer.Add((20,0), 1)
        buttonSizer.Add(cancelButton, 0)
        mainSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER)
        mainSizer.Add((0,10), 0)
        # now we're ready
        self.SetSizer(mainSizer)
        self.SetSize((500,500))
        
        self.CenterOnScreen()
示例#2
0
    def __init__(self, parent):
        #         import config
        wx.Dialog.__init__(self, parent, -1, title='Available styles')

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        treeSizer = wx.BoxSizer(wx.VERTICAL)
        # panel for the tree!
        treePanel = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
        self.tree = wx.TreeCtrl(
            treePanel, -1, wx.DefaultPosition, (-1, -1),
            wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS | wx.TR_MULTIPLE)
        root = self.tree.AddRoot('Style modules')
        # for each module, add styles found into it to the tree
        for moduleName in util.getPluginNames():
            module = __import__(moduleName)
            subItems = []
            for item in dir(module):
                thisOne = module.__getattribute__(item)
                if type(thisOne) is types.TypeType and \
                        issubclass(thisOne, style.Style) and \
                        not issubclass(style.Style, thisOne):
                    subItems.append(thisOne.__name__ + ': ' +
                                    thisOne.description)
            if len(subItems) > 0:
                thisNode = self.tree.AppendItem(root, module.__name__)
                for item in subItems:
                    self.tree.AppendItem(thisNode, item)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onSelection)
        # now add the tree to the sizer in the panel...
        treeSizer.Add(self.tree, 1, wx.EXPAND)
        treePanel.SetSizer(treeSizer)

        # expand the tree by default
        self.tree.ExpandAll()

        mainSizer.Add(treePanel, 1, wx.EXPAND)
        mainSizer.Add((0, 10), 0)

        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        # add standard buttons
        okButton = wx.Button(self, wx.ID_OK)
        cancelButton = wx.Button(self, wx.ID_CANCEL)
        buttonSizer.Add(okButton, 0)
        buttonSizer.Add((20, 0), 1)
        buttonSizer.Add(cancelButton, 0)
        mainSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER)
        mainSizer.Add((0, 10), 0)
        # now we're ready
        self.SetSizer(mainSizer)
        self.SetSize((500, 500))

        self.CenterOnScreen()
示例#3
0
 def __init__(self):
     # local storage for what can load what
     # key = problem type, value = class
     # problem type should be in fact a tuple (type, subtype)
     self.vrpInputClasses = {}
     self.vrpSolutionClasses = {}
     self.styleSheetClasses = {}
     # get available plugins
     pluginNames = util.getPluginNames()
     # for each of these we can store what they allow to load
     for name in pluginNames:
         module = __import__(name)
         for item in dir(module):
             if item[:1] == '_': continue
             thisOne = module.__getattribute__(item)
             # interesting case: classes
             if type(thisOne) is types.TypeType:
                 # case 1: input data class
                 if issubclass(thisOne, vrpdata.VrpInputData):
                     key = (unicode(thisOne.problemType),
                            unicode(thisOne.instanceType))
                     self.vrpInputClasses[key] = thisOne
                     if not (key[0], u'default') in self.vrpInputClasses:
                         # add this class as default in case there isn't one
                         self.vrpInputClasses[(key[0],
                                               u'default')] = thisOne
                 # case 2: solution data class
                 elif issubclass(thisOne, vrpdata.VrpSolutionData):
                     key = (unicode(thisOne.problemType),
                            unicode(thisOne.solutionType))
                     self.vrpSolutionClasses[key] = thisOne
                     if not (key[0], u'default') in self.vrpSolutionClasses:
                         # add this class as default in case there isn't one
                         self.vrpSolutionClasses[(key[0], u'default')] = \
                             thisOne
                 # case 3: style sheet
                 elif issubclass(thisOne, stylesheet.StyleSheet):
                     for key in thisOne.defaultFor:
                         self.styleSheetClasses[unicode(key)] = thisOne
                 else:
                     # non-appropriate class for this context (e.g. Style)
                     pass
示例#4
0
 def __init__(self):
     # local storage for what can load what
     # key = problem type, value = class
     # problem type should be in fact a tuple (type, subtype)
     self.vrpInputClasses = {}
     self.vrpSolutionClasses = {}
     self.styleSheetClasses = {}
     # get available plugins
     pluginNames = util.getPluginNames()
     # for each of these we can store what they allow to load
     for name in pluginNames:
         module = __import__(name)
         for item in dir(module):
             if item[:1] == '_': continue
             thisOne = module.__getattribute__(item)
             # interesting case: classes
             if type(thisOne) is types.TypeType:
                 # case 1: input data class
                 if issubclass(thisOne, vrpdata.VrpInputData):
                     key = (unicode(thisOne.problemType),
                            unicode(thisOne.instanceType))
                     self.vrpInputClasses[key] = thisOne
                     if not (key[0], u'default') in self.vrpInputClasses:
                         # add this class as default in case there isn't one
                         self.vrpInputClasses[(key[0], u'default')] = thisOne
                 # case 2: solution data class
                 elif issubclass(thisOne, vrpdata.VrpSolutionData):
                     key = (unicode(thisOne.problemType),
                            unicode(thisOne.solutionType))
                     self.vrpSolutionClasses[key] = thisOne
                     if not (key[0], u'default') in self.vrpSolutionClasses:
                         # add this class as default in case there isn't one
                         self.vrpSolutionClasses[(key[0], u'default')] = \
                             thisOne
                 # case 3: style sheet
                 elif issubclass(thisOne, stylesheet.StyleSheet):
                     for key in thisOne.defaultFor:
                         self.styleSheetClasses[unicode(key)] = thisOne
                 else:
                     # non-appropriate class for this context (e.g. Style)
                     pass
示例#5
0
# [email protected]
# Last modified: July 29th 2011 by Fabien Tricoire
#
# -*- coding: utf-8 -*-
# this class uses unicode by default, i.e. every identifier string that can be
# used as a key in a dict will be coverted to unicode
import os
import string
import types

import vrpdata
import stylesheet
import util

# load available plugins
pluginNames = util.getPluginNames()
for name in pluginNames:
    exec 'import ' + name


# an instance of data loader handles various procedures
class DataLoader:
    def __init__(self):
        # local storage for what can load what
        # key = problem type, value = class
        # problem type should be in fact a tuple (type, subtype)
        self.vrpInputClasses = {}
        self.vrpSolutionClasses = {}
        self.styleSheetClasses = {}
        # get available plugins
        pluginNames = util.getPluginNames()
示例#6
0
# [email protected]
# Last modified: July 29th 2011 by Fabien Tricoire
#
# -*- coding: utf-8 -*-
# this class uses unicode by default, i.e. every identifier string that can be
# used as a key in a dict will be coverted to unicode
import os
import string
import types

import vrpdata
import stylesheet
import util

# load available plugins
pluginNames = util.getPluginNames()
for name in pluginNames:
    exec 'import ' + name
    
# an instance of data loader handles various procedures
class DataLoader:
    def __init__(self):
        # local storage for what can load what
        # key = problem type, value = class
        # problem type should be in fact a tuple (type, subtype)
        self.vrpInputClasses = {}
        self.vrpSolutionClasses = {}
        self.styleSheetClasses = {}
        # get available plugins
        pluginNames = util.getPluginNames()
        # for each of these we can store what they allow to load