示例#1
0
文件: viewer.py 项目: TaxIPP-Life/Til
def main(args):
    """The application launcher.

    First of all, translators are loaded. Then the GUI is shown and the events
    loop is started.
    """

    app = QtGui.QApplication(args)
    # These imports must be done after the QApplication has been instantiated
    from vitables.vtapp import VTApp
    from vitables.preferences import vtconfig

    # Specify the organization's Internet domain. When the Internet
    # domain is set, it is used on Mac OS X instead of the organization
    # name, since Mac OS X applications conventionally use Internet
    # domains to identify themselves
    app.setOrganizationDomain('vitables.org')
    app.setOrganizationName('ViTables')
    app.setApplicationName('ViTables')
    app.setApplicationVersion(vtconfig.getVersion())
    config = vtconfig.Config()

    # Localize the application using the system locale
    # numpy seems to have problems with decimal separator in some locales
    # (catalan, german...) so C locale is always used for numbers.
    locale.setlocale(locale.LC_ALL, '')
    locale.setlocale(locale.LC_NUMERIC, 'C')
    language = locale.getlocale()[0]
    # Future translations (if any) will use resource files
    # vt_translator = QTranslator()
    # vt_translator.load('vitables_%s' % language, config.translations_dir)
    # qt_translator = QTranslator()
    # qt_translator.load('qt_%s' % language, config.translations_dir)
    # app.installTranslator(vt_translator)
    # app.installTranslator(qt_translator)

    # Parse the command line
    parser = OptionParser(prog='vitables', version=vtconfig.getVersion(),
        usage='''%prog [options] [h5file]''')
    parser.add_option('-m', '--mode', dest='mode', choices=['r', 'a'],
        help='mode access for a database', metavar='MODE')
    parser.add_option('-d', '--dblist', dest='dblist',
        help='a file with the list of databases to be open', metavar='h5list')
    parser.set_defaults(mode='a', dblist='')
    (options, h5files) = parser.parse_args()
    if options.dblist:
        # Other options and positional arguments are silently ignored
        options.mode = ''
        h5files = []

    # Start the application
    del config
    vtapp = VTApp(mode=options.mode, dblist=options.dblist, h5files=h5files)
    vtapp.gui.show()
    app.exec_()
示例#2
0
def viewhdf(filepaths):
    app = QtWidgets.QApplication(filepaths)

    # These imports must be done after the QApplication has been instantiated
    with warnings.catch_warnings():
        # ignore deprecation warnings just for this import
        warnings.filterwarnings("ignore", category=DeprecationWarning)
        from vitables.vtapp import VTApp

    from vitables.preferences import vtconfig

    # Specify the organization's Internet domain. When the Internet
    # domain is set, it is used on Mac OS X instead of the organization
    # name, since Mac OS X applications conventionally use Internet
    # domains to identify themselves
    app.setOrganizationDomain('vitables.org')
    app.setOrganizationName('ViTables')
    app.setApplicationName('ViTables')
    app.setApplicationVersion(vtconfig.getVersion())

    # Localize the application using the system locale
    # numpy seems to have problems with decimal separator in some locales
    # (catalan, german...) so C locale is always used for numbers.
    locale.setlocale(locale.LC_ALL, '')
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Start the application
    vtapp = VTApp(mode='a', h5files=filepaths)
    vtapp.gui.show()
    app.exec_()
示例#3
0
def _parse_command_line():
    """Create parser and parse command line."""

    # Parse the command line optional arguments
    parser = argparse.ArgumentParser(usage='%(prog)s [option]... [h5file]...')
    h5files_group = parser.add_argument_group('h5files')
    logging_group = parser.add_argument_group('logging')
    # Options for the default group
    parser.add_argument(
        '--version', action='version',
        version='%(prog)s {}'.format(vtconfig.getVersion()))
    # Options for opening files
    h5files_group.add_argument(
        '-m', '--mode', choices=['r', 'a'], metavar='MODE',
        help='mode access for a database. Can be r(ead) or a(ppend)')
    h5files_group.add_argument('-d', '--dblist',
                               help=('a file with the list of HDF5 '
                                     'filepaths to be open'))
    # Logging options
    logging_group.add_argument('-l', '--log-file', help='log file path')
    logging_group.add_argument('-v', '--verbose', action='count', default=0,
                               help='log verbosity level')
    # Allow an optional list of input filepaths
    parser.add_argument('h5file', nargs='*')
    # Set sensible option defaults
    parser.set_defaults(mode='a', dblist='', h5file=[])
    # parse and process arguments
    args = parser.parse_args()
    if args.dblist:
        # Other options and positional arguments are silently ignored
        args.mode = ''
        args.h5file = []
    return args
示例#4
0
def viewhdf(filepaths):
    app = QtGui.QApplication(filepaths)

    # These imports must be done after the QApplication has been instantiated
    with warnings.catch_warnings():
        # ignore deprecation warnings just for this import
        warnings.filterwarnings("ignore", category=DeprecationWarning)
        from vitables.vtapp import VTApp

    from vitables.preferences import vtconfig

    # Specify the organization's Internet domain. When the Internet
    # domain is set, it is used on Mac OS X instead of the organization
    # name, since Mac OS X applications conventionally use Internet
    # domains to identify themselves
    app.setOrganizationDomain('vitables.org')
    app.setOrganizationName('ViTables')
    app.setApplicationName('ViTables')
    app.setApplicationVersion(vtconfig.getVersion())

    # Localize the application using the system locale
    # numpy seems to have problems with decimal separator in some locales
    # (catalan, german...) so C locale is always used for numbers.
    locale.setlocale(locale.LC_ALL, '')
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Start the application
    vtapp = VTApp(mode='a', h5files=filepaths)
    vtapp.show()
    app.exec_()
示例#5
0
def _parse_command_line():
    """Create parser and parse command line."""
     # Parse the command line optional arguments
    parser = argparse.ArgumentParser(usage='%(prog)s [option]... [h5file]...')
    h5files_group = parser.add_argument_group('h5files')
    logging_group = parser.add_argument_group('logging')
    # Options for the default group
    parser.add_argument(
        '--version', action='version',
        version='%(prog)s {}'.format(vtconfig.getVersion()))
    # Options for opening files
    h5files_group.add_argument(
        '-m', '--mode', choices=['r', 'a'], metavar='MODE',
        help='mode access for a database. Can be r(ead) or a(ppend)')
    h5files_group.add_argument('-d', '--dblist',
                               help=('a file with the list of HDF5 '
                                     'filepaths to be open'))
    # Logging options
    logging_group.add_argument('-l', '--log-file', help='log file path')
    logging_group.add_argument('-v', '--verbose', action='count', default=0,
                               help='log verbosity level')
    # Allow an optional list of input filepaths
    parser.add_argument('h5file', nargs='*')
    # Set sensible option defaults
    parser.set_defaults(mode='a', dblist='', h5file=[])
    # parse and process arguments
    args = parser.parse_args()
    if args.dblist:
        # Other options and positional arguments are silently ignored
        args.mode = ''
        args.h5file = []
    return args
示例#6
0
 def __init__(self):
     self.app = QtWidgets.QApplication(sys.argv)
     self.app.setOrganizationDomain('vitables.org')
     self.app.setOrganizationName('ViTables')
     self.app.setApplicationName('ViTables')
     self.app.setApplicationVersion(vtconfig.getVersion())
     self.vtapp_object = vitables.vtapp.VTApp(keep_splash=False)
     self.gui = self.vtapp_object.gui
示例#7
0
文件: conftest.py 项目: rth/ViTables
 def __init__(self):
     self.app = QtWidgets.QApplication(sys.argv)
     self.app.setOrganizationDomain('vitables.org')
     self.app.setOrganizationName('ViTables')
     self.app.setApplicationName('ViTables')
     self.app.setApplicationVersion(vtconfig.getVersion())
     self.vtapp_object = vitables.vtapp.VTApp(keep_splash=False)
     self.gui = self.vtapp_object.gui
示例#8
0
def _set_credentials(app):
    """Specify the organization's Internet domain.

    When the Internet domain is set, it is used on Mac OS X instead of
    the organization name, since Mac OS X applications conventionally
    use Internet domains to identify themselves

    """
    app.setOrganizationDomain('vitables.org')
    app.setOrganizationName('ViTables')
    app.setApplicationName('ViTables')
    app.setApplicationVersion(vtconfig.getVersion())
示例#9
0
def _set_credentials(app):
    """Specify the organization's Internet domain.

    When the Internet domain is set, it is used on Mac OS X instead of
    the organization name, since Mac OS X applications conventionally
    use Internet domains to identify themselves

    """
    app.setOrganizationDomain('vitables.org')
    app.setOrganizationName('ViTables')
    app.setApplicationName('ViTables')
    app.setApplicationVersion(vtconfig.getVersion())
示例#10
0
    def helpVersions(self):
        """
        Message box with info about versions of libraries used by
        ``ViTables``.
        """

        # The libraries versions dictionary
        libs_versions = {
            'title': translate('VTApp', 'Version Numbers',
                'Caption of the Versions dialog'),
            'Python': reduce(lambda x,y: '.'.join([unicode(x), unicode(y)]),
                sys.version_info[:3]),
            'PyTables': tables.__version__ ,
            'NumPy': tables.numpy.__version__,
            'Qt': QtCore.qVersion(),
            'PyQt': QtCore.PYQT_VERSION_STR,
            'ViTables': vtconfig.getVersion()
        }

        # Add new items to the dictionary
        libraries = ('HDF5', 'Zlib', 'LZO', 'BZIP2')
        for lib in libraries:
            lversion = tables.whichLibVersion(lib.lower())
            if lversion:
                libs_versions[lib] = lversion[1]
            else:
                libs_versions[lib] = translate('VTApp', 'not available',
                    'Part of the library not found text')

        # Construct the dialog
        versions_dlg = QtGui.QDialog(self.gui)
        versions_dlg.setWindowTitle(translate('VTApp', 'Version Numbers',
                                             'Caption of the Versions dialog'))
        layout = QtGui.QVBoxLayout(versions_dlg)
        versions_edit = QtGui.QTextEdit(versions_dlg)
        buttons_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        layout.addWidget(versions_edit)
        layout.addWidget(buttons_box)

        buttons_box.accepted.connect(versions_dlg.accept)

        versions_edit.setReadOnly(1)
        versions_edit.setText(\
            u"""
            <qt>
            <h3>{title}</h3>
            <table>
            <tr><td><b>Python</b></td><td>{Python}</td></tr>
            <tr><td><b>PyTables</b></td><td>{PyTables}</td></tr>
            <tr><td><b>NumPy</b></td><td>{NumPy}</td></tr>
            <tr><td><b>HDF5</b></td><td>{HDF5}</td></tr>
            <tr><td><b>Zlib</b></td><td>{Zlib}</td></tr>
            <tr><td><b>LZO</b></td><td>{LZO}</td></tr>
            <tr><td><b>BZIP2</b></td><td>{BZIP2}</td></tr>
            <tr><td><b>Qt</b></td><td>{Qt}</td></tr>
            <tr><td><b>PyQt</b></td><td>{PyQt}</td></tr>
            <tr><td><b>ViTables</b></td><td>{ViTables}</td></tr>
            </table>
            </qt>""".format(
                title=libs_versions['title'],
                Python=libs_versions['Python'],
                PyTables=libs_versions['PyTables'],
                NumPy=libs_versions['NumPy'],
                Qt=libs_versions['Qt'],
                PyQt=libs_versions['PyQt'],
                ViTables=libs_versions['ViTables'],
                HDF5=libs_versions['HDF5'],
                Zlib=libs_versions['Zlib'],
                LZO=libs_versions['LZO'],
                BZIP2=libs_versions['BZIP2'],
                ))

        # Show the dialog
        versions_dlg.exec_()
示例#11
0
    def helpAbout(self):
        """
        Show a tabbed dialog with the application About and License info.
        """

        # Text to be displayed
        about_text = translate('VTApp',
            """<qt>
            <h3>ViTables {0}</h3>
            ViTables is a graphical tool for displaying datasets
            stored in PyTables and HDF5 files. It is written using PyQt
            , the Python bindings for the Qt GUI toolkit.<p>
            For more information see
            <b>http://www.vitables.org</b>.<p>
            Please send bug reports or feature requests to the
            <em>ViTables Users Group</em>.<p>
            ViTables uses third party software which is copyrighted by
            its respective copyright holder. For details see the
            copyright notice of the individual packages.
            </qt>""",
            'Text of the About ViTables dialog').format(vtconfig.getVersion())
        thanks_text = translate('VTApp',
            """<qt>
            Alexey Naydenov for his contributions to the plugins system and for
            providing logging support to the application.<p>
            Kamil Kisiel and Max Bohnet for fixing bugs.<p>
            Dmitrijs Ledkovs for contributing the new and greatly enhanced
            build system and for making Debian packages.<p>
            Oxygen team for a wonderful icons set.<p>
            All the people who reported bugs and made suggestions.
            </qt>""",
            'Text of the About ViTables dialog (Thanks to page)')
        license_text = vitables.utils.getLicense()

        # Construct the dialog
        about_dlg = QtGui.QDialog(self.gui)
        about_dlg.setWindowTitle(
            translate('VTApp', 'About ViTables {0}',
                'Caption of the About ViTables dialog').\
                format(vtconfig.getVersion()))
        layout = QtGui.QVBoxLayout(about_dlg)
        tab_widget = QtGui.QTabWidget(about_dlg)
        buttons_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        layout.addWidget(tab_widget)
        layout.addWidget(buttons_box)

        buttons_box.accepted.connect(about_dlg.accept)

        # Make About page
        content = [about_text, thanks_text, license_text]
        tabs = [translate('VTApp', '&About',
            'Title of the first tab of the About dialog'),
            translate('VTApp', '&Thanks To',
            'Title of the second tab of the About dialog'),
            translate('VTApp', '&License',
            'Title of the third tab of the About dialog')]

        for index in range(0, 3):
            widget = makePage(content[index])
            tab_widget.addTab(widget, tabs[index])


        # Show the dialog
        about_dlg.exec_()
示例#12
0
    def __init__(self, mode='', dblist='', h5files=None, keep_splash=True):
        """
        Initialize the application.

        This method starts the application: makes the GUI, configure the
        app, instantiates managers needed to control the app. and connect
        signals to slots.
        """

        super(VTApp, self).__init__()

        # Make the main window easily accessible for external modules
        self.setObjectName('VTApp')

        self.is_first_opening = True  # for Open file dialogs

        # Show a splash screen
        logo = QtGui.QPixmap(os.path.join(ICONDIR, "vitables_logo.png"))
        splash = vitables.vtsplash.VTSplash(logo)
        splash.show()
        t_i = time.time()

        # Instantiate a configurator object for the application
        self.config = vtconfig.Config()

        # Create the GUI. This is done in 3 steps:
        # - create the main window
        # - create the model/view for the tree of databases
        # - setup the main window
        splash.drawMessage(translate('VTApp', 'Creating the GUI...',
            'A splash screen message'))
        self.gui = vtgui.VTGUI(self, vtconfig.getVersion())
        dbs_tmodel = dbstreemodel.DBsTreeModel(self)
        dbstreeview.DBsTreeView(self, dbs_tmodel)

        # Apply the configuration stored on disk
        splash.drawMessage(translate('VTApp', 'Configuration setup...',
            'A splash screen message'))

        # Reset the configuration object. I don't know why this is necessary
        # but it is
        del self.config
        self.config = vtconfig.Config()
        self.config.loadConfiguration(self.config.readConfiguration())

        # Load plugins.
        # Some plugins modify existing menus so plugins must be loaded after
        # creating the user interface.
        # Some plugins modify the tree of databases or datasets displaying so
        # plugins must be loaded before opening any file.
        self.plugins_mgr = \
            pluginsloader.PluginsLoader(self.config.enabled_plugins)
        self.plugins_mgr.loadAll()
        self.pluginsLoaded.emit()
        self.dbtree_model_created.emit()

        # The queries manager
        self.queries_mgr = qmgr.QueriesManager()

        # Print the welcome message
        print(translate('VTApp',
            """ViTables {0}\nCopyright (c) 2008-2013 Vicent Mas."""
            """\nAll rights reserved.""",
            'Application startup message').format(vtconfig.getVersion()))

        # The list of most recently open DBs
        self.number_of_recent_files = 10
        while len(self.config.recent_files) > self.number_of_recent_files:
            del self.config.recent_files[-1]

        # The File Selector History
        self.file_selector_history = []
        if self.config.startup_working_directory != u'last':
            self.config.last_working_directory = os.getcwdu()
        self.file_selector_history.append(self.config.last_working_directory)

        # List of HelpBrowser instances in memory
        self.doc_browser = None

        # Restore last session
        if self.config.restore_last_session:
            splash.drawMessage(translate('VTApp', 'Recovering last session...',
                'A splash screen message'))
            self.recoverLastSession()

        # Process the command line
        if h5files:
            splash.drawMessage(translate('VTApp', 'Opening files...',
                'A splash screen message'))
            self.processCommandLineArgs(mode=mode, h5files=h5files)
        elif dblist:
            splash.drawMessage(translate('VTApp',
                'Opening the list of files...',
                'A splash screen message'))
            self.processCommandLineArgs(dblist=dblist)

        # Make sure that the splash screen is shown at least for two seconds
        if keep_splash:
            t_f = time.time()
            while t_f - t_i < 2:
                t_f = time.time()
        splash.finish(self.gui)
        del splash

        # Ensure that QActions have a consistent state
        self.gui.updateActions()

        self.gui.dbs_tree_model.rowsRemoved.connect(self.gui.updateActions)
        self.gui.dbs_tree_model.rowsInserted.connect(self.gui.updateActions)

        self.gui.updateWindowMenu()
示例#13
0
def main(args):
    """The application launcher.

    First of all, translators are loaded. Then the GUI is shown and the events
    loop is started.
    """

    app = QtGui.QApplication(args)
    # These imports must be done after the QApplication has been instantiated
    from vitables.vtapp import VTApp
    from vitables.preferences import vtconfig

    # Specify the organization's Internet domain. When the Internet
    # domain is set, it is used on Mac OS X instead of the organization
    # name, since Mac OS X applications conventionally use Internet
    # domains to identify themselves
    app.setOrganizationDomain('vitables.org')
    app.setOrganizationName('ViTables')
    app.setApplicationName('ViTables')
    app.setApplicationVersion(vtconfig.getVersion())
    config = vtconfig.Config()

    # Localize the application using the system locale
    # numpy seems to have problems with decimal separator in some locales
    # (catalan, german...) so C locale is always used for numbers.
    locale.setlocale(locale.LC_ALL, '')
    locale.setlocale(locale.LC_NUMERIC, 'C')
    language = locale.getlocale()[0]
    # Future translations (if any) will use resource files
    # vt_translator = QTranslator()
    # vt_translator.load('vitables_%s' % language, config.translations_dir)
    # qt_translator = QTranslator()
    # qt_translator.load('qt_%s' % language, config.translations_dir)
    # app.installTranslator(vt_translator)
    # app.installTranslator(qt_translator)

    # Parse the command line
    parser = OptionParser(prog='vitables',
                          version=vtconfig.getVersion(),
                          usage='''%prog [options] [h5file]''')
    parser.add_option('-m',
                      '--mode',
                      dest='mode',
                      choices=['r', 'a'],
                      help='mode access for a database',
                      metavar='MODE')
    parser.add_option('-d',
                      '--dblist',
                      dest='dblist',
                      help='a file with the list of databases to be open',
                      metavar='h5list')
    parser.set_defaults(mode='a', dblist='')
    (options, h5files) = parser.parse_args()
    if options.dblist:
        # Other options and positional arguments are silently ignored
        options.mode = ''
        h5files = []

    # Start the application
    del config
    vtapp = VTApp(mode=options.mode, dblist=options.dblist, h5files=h5files)
    vtapp.gui.show()
    app.exec_()