Skip to content

Commit

Permalink
add custom width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
dou-du committed Apr 9, 2021
1 parent cba054b commit b519de5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/css/brillouin.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.BZ-widget {
width: 100%;
width: 450px;
height: 450px;
align-items: center;
}
8 changes: 6 additions & 2 deletions js/lib/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ var BrillouinZoneView = widgets.DOMWidgetView.extend({
this.model.on('change:path_vectors', this.vectors_changed, this);
this.model.on('change:update_structure', this.reloadBZ, this);

this.el.innerHTML = '<div class="BZ-widget" id="' + this.canvasID + '"></div>'
+ '<div id="' + this.infoID + '"></div>';
this.width = this.model.get('width');
this.height = this.model.get('height');

this.el.innerHTML = '<div class="BZ-widget" id="' + this.canvasID
+ '" style="width:' + this.width + '; height:' + this.height +';"'
+ '></div><div id="' + this.infoID + '"></div>';

var jsondata = this.model.get('jsondata');
var faceColor = this.model.get('face_color');
Expand Down
2 changes: 1 addition & 1 deletion widget_bzvisualizer/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Module version
version_info = (0, 1, 0, 'alpha', 3)
version_info = (0, 1, 0, 'alpha', 4)

# Module version stage suffix map
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
Expand Down
8 changes: 6 additions & 2 deletions widget_bzvisualizer/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class BZVisualizer(widgets.DOMWidget):
# Singal to update the structure
update_structure = Int().tag(sync=True)

def __init__(self, cell, positions, numbers, face_color=True):
# Set the width and height of the widget
width = Unicode('450px').tag(sync=True)
height = Unicode('450px').tag(sync=True)

def __init__(self, cell, positions, numbers, face_color=True, width='450px', height='450px'):
if type(cell) == np.ndarray:
cell = cell.tolist()

Expand All @@ -62,7 +66,7 @@ def __init__(self, cell, positions, numbers, face_color=True):
if type(numbers) == np.ndarray:
numbers = numbers.tolist()

super().__init__(cell = cell, positions=positions, numbers=numbers, face_color=face_color)
super().__init__(cell = cell, positions=positions, numbers=numbers, face_color=face_color, width=width, height=height)

system = (np.array(cell), np.array(positions), np.array(numbers))
res = seekpath.getpaths.get_path(system, with_time_reversal=False)
Expand Down

0 comments on commit b519de5

Please sign in to comment.