--- title: Widgets keywords: fastai sidebar: home_sidebar summary: "This module contains widgets to perform selected tasks such as viewing/modifying plots interactively. Use Jupyterlab>=3, Notebook or VS Code, Google Colab may not work! For troubleshooting plotly's FigureWidget see Plotly's help" description: "This module contains widgets to perform selected tasks such as viewing/modifying plots interactively. Use Jupyterlab>=3, Notebook or VS Code, Google Colab may not work! For troubleshooting plotly's FigureWidget see Plotly's help" nb_path: "Widgets.ipynb" ---
{% raw %}
{% endraw %} {% raw %}

  Index 
  XmlElementTree 
  StaticPlots 
  InteractivePlots 
  Utilities 
  StructureIO 
  Widgets● 

{% endraw %} {% raw %}
{% endraw %}
{% raw %}

css_style[source]

css_style(colors_dict, _class='main_wrapper')

Return style based on colors_dict available as pp.light_colors, pp.dark_colors etc

{% endraw %} {% raw %}
{% endraw %} {% raw %}

get_files_gui[source]

get_files_gui(auto_fill='vasprun.xml', theme_colors=None, height=320)

  • Creates a GUI interface for files/folders filtering.
  • Parmeters
    • auto_fill : Default is vasprun.xml, any file/folder.
    • theme_colors : None,Any of pivotpy.[dark,light,simple]_colors.
    • height : Height of Grid box.
  • Returns
    • Tuple(GUI_gridbox,Files_Dropdown). Access second one by item itself.
{% endraw %} {% raw %}
{% endraw %} {% raw %}
full_box,files_w = get_files_gui(theme_colors=light_colors,height=400)
{% endraw %} {% raw %}

class InputGui[source]

InputGui(sys_info=None, theme_colors=None, height=400)

{% endraw %} {% raw %}
{% endraw %} {% raw %}
{% endraw %} {% raw %}
{% endraw %} {% raw %}

generate_summary[source]

generate_summary(paths_list=None)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

class VasprunApp[source]

VasprunApp(height=580)

Display a GUI for vasp output analysis. self.theme_colors can be used to edit custom theme.

  • Usage Example
import pivotpy as pp
va = pp.VasprunApp()
va.cache_data = False #Turn off cache globally.
va.evr_kws['elim'] = [-2,2] #Only Bands in this range will be included. Global accross project, can change anytime.
va.evr_kws['try_pwsh'] = False #Defult is True. Tries to load Powershell exported data.
va.ibands_kws['mode'] = 'bands' #Change graph mode from 'markers' to 'bands'. Setting it to 'lines' is not recommended in live graph, it could hang all UI.
va.show() #Displays App and do work!
va.theme_colors = pp.dark_colors #Set theme to dark externally and edit dictionary values to make your own theme
va.splot(**kwargs) #Get matplotlib plot of current data.
va.df #After you do some analysis and hit `Project Summary` button, get DataFrame.
va.fig #Get current fig in Notebook cell.
{% endraw %} {% raw %}
{% endraw %} {% raw %}
va = VasprunApp()
# va.cache_data = False  
# va.evr_kws['try_pwsh'] = False
# va.evr_kws['elim'] = [-2,2]
# va.show()
{% endraw %} {% raw %}
va.set_theme_colors({'next_bg': 'whitesmoke',
 'hover_bg': 'skyblue',
 'accent': 'black',
 'main_bg': 'white',
 'main_fg': 'black'})
{% endraw %}

App Attributes

Note: If you used pivotpy.sio.get_kpath for generating KPOINTS file, your kticks will be automatically filled. If not, you can still add this example string at end of first line of first KPOINTS file with your own values, (not required in all KPOINST files, one time fill is enough if whole project is based on same kpath) [Do not modify names of variables!].
HSK-INDS = [0, 29, -1], LABELS = ['M', 'Γ|M', 'L'], SEG-INDS = [21, 29]

Let's va = VasprunApp(), then:

  • va.input is dictionary which is unpacked in plot arguments.
  • va.idos_kws and va.ibands_kws can be modified for other arguments not present in self.input.
  • va.cache_data is boolean to turn caching ON and OFF. Caching helps in faster load in subsequent requests.
  • va.result is what you see in table.
  • va.data is output of export_vasprun. You can tweak va.evr_kws that are passed to export_vasprun.
  • va.fig is current figure.
  • va.set_theme_colors could be used to change theme, e.g va.set_theme_colors(pp.dark_colors) will change theme to Dark. This is useful to create new themes, you can edit color values in dark_colors/light_colors and apply back. Do not modify keys, just values!.
  • va.InGui is instance of InputGui class and va.InGui.out is used as va.input. va.html is used to observe self.__updata_input internally.
  • va.iplot and va.splot give current figure(detached) and its matplotlib figure respectively. Their kwargs correspond to current figure's command e.g if Bands figure is there, kwargs are passed to iplot_rgb_lines for va.iplot and to splot_rgb_lines for va.splot.

Almost every other attribute is a gui or collection of widgets. E.g. va.dds is dictionary that contains all dropdowns in app. Make sure to not change any key in any dictionary, if done by mistake use, dictionary.pop(key,None).

Edit Custom Theme

You can set va.set_theme_colors(<va.theme_colors after edit>) and then apply Custom from theme dropdown to display theme of your choice. Used CSS-compatible color values only.

Extend Functionality (Example: Save Matplotlib's figure on clicking Load Graph)

You can extend app as you choose, see how it saves a figure on button(within app) click.

import pivotpy as pp
import ipywidgets as ipw, os

va = pp.VasprunApp()
va.show() 

#Create Additional Functionality 
out = ipw.Output()

@out.capture(clear_output=True, wait=True)
def update_mpl(change): 
    if change:
        va.splot(colorbar=False)
        path = os.path.join(os.path.dirname(va.files_dd.value),'mpl_plot.png')
        pp.savefig(path,transparent=True,dpi=600) #Prevents overwiting existing files
        pp._show()
        print(va.data.sys_info.incar)
va.buttons['load_graph'].on_click(update_mpl)   
out
{% raw %}

class KPathApp[source]

KPathApp(path='POSCAR')

View and trace path on BZ.

  • Usage

    ka = KPathApp() ka.show() #Display app ka.splot() #get matplotlib figure

{% endraw %} {% raw %}
{% endraw %} {% raw %}
#ka.show()
{% endraw %}

Interactive Rich Slides in Jupyter Notebook

Navigate to ipyslides or do pip install ipyslides to create beautiful data driven presentation in Jupyter Notebook.

{% raw %}

  Index 
  XmlElementTree 
  StaticPlots 
  InteractivePlots 
  Utilities 
  StructureIO 
  Widgets● 

{% endraw %}