示例#1
0
def main():
    is_windows = sys.platform.startswith('win')

    # Create the application-wide logger (root)
    logger = logging.getLogger()

    # Set this to logging.WARN or logging.ERROR for production
    logger.setLevel(logging.DEBUG)

    # Create console handler for all log messages
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)

    # Create formatter and add it to the handlers
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    ch.setFormatter(formatter)

    # Add the handler to the logger
    logger.addHandler(ch)

    #if is_windows:
    # Create file handler which logs warning messages and up
    #logging_path = os.path.join(expanduser("~"), 'cscibox', 'log')
    #try:
    #    os.makedirs(logging_path)
    #except OSError:
    #    None

    #fh = logging.FileHandler(os.path.join(expanduser("~"), "cscibox.log"))
    #fh.setLevel(logging.WARN)
    #fh.setFormatter(formatter)
    #logger.addHandler(fh)

    if getattr(sys, 'frozen', False):
        # We are running in a |PyInstaller| bundle
        # Setup the database
        datastore.Datastore().setup_database()

    app = BrowserApp()
    app.MainLoop()
示例#2
0
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

import wx

from cscience import datastore
from cscience.framework import Template
from cscience.GUI import dialogs, events
from cscience.GUI.Editors import MemoryFrame

datastore = datastore.Datastore()

EditTemplateField = dialogs.field_dialog('Template Field', 'Key', ('int', 'float', 'string'))

class TemplateListCtrl(wx.ListCtrl):
    cols = ['name', 'field_type', 'iskey']
    labels = ['Name', 'Type', 'Is Key?']

    def __init__(self, *args, **kwargs):
        self._template = None
        if 'style' in kwargs:
            style = kwargs['style']
        else:
            style = 0
        kwargs['style'] = style | wx.LC_REPORT | wx.LC_VIRTUAL | \
                                wx.LC_SINGLE_SEL