Giter Site home page Giter Site logo

Comments (3)

mkhorton avatar mkhorton commented on June 18, 2024

@mattmcdermott

As discussed earlier, with the new project layout, an XRayDiffractionComponent could be in crystal_tookit/components/xrd.py, and it'd look something like:

import dash
import dash_core_components as dcc
import dash_html_components as html

from crystal_toolkit.helpers.layouts import *  # layout helpers like `Columns` etc. (most subclass html.Div)

from crystal_toolkit.components.core import MPComponent

class XRayDiffractionComponent(MPComponent):

    @property
    def all_layouts():
        returns {'graph': ..., 'controls': ..., etc.}

    @property
    def standard_layout():
        returns html.Div([self.all_layouts['graph'], self.all_layouts['controls'])

    def _generate_callbacks(self, app, cache):

        @app.callback(...)
        def callback_here():
            ...

To use, you can test in a sample usage.py, where it would look something like:

import crystal_toolkit as ct

...define app...

ct.register_app(app)
ct.register_cache(cache)

xrd_component = XRayDiffractionComponent(my_struct)

app.layout = xrd_component.standard_layout

Finally, to name ids, use MPComponent's id method, so html.Div(id=self.id("my-div")). This ensures that multiple instances of the same MPComponent can be used (eg displaying multiple XRD spectra on the same page).

from crystaltoolkit.

mkhorton avatar mkhorton commented on June 18, 2024

Also, there may still be changes necessary for the base class / this may not be suitable for your needs as-is and you should feel welcome to modify it, but this should at least work as a starting point.

from crystaltoolkit.

mattmcdermott avatar mattmcdermott commented on June 18, 2024

Closing with addition of XRD and XAS components. #70

from crystaltoolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.