Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
layout = QtGui.QVBoxLayout(self)
layout.setContentsMargins(0,0,0,0)
layout.setSpacing(0)
self.visualization = MayaviVisualization()
self.ui = self.visualization.edit_traits(parent=self,kind='subpanel').control
layout.addWidget(self.ui)
self.ui.setParent(self)
def init(self, parent):
""" Finishes initializing the editor by creating the underlying toolkit
widget.
"""
factory = self.factory
self.control = QtGui.QWidget()
lay = QtGui.QVBoxLayout(self.control)
lay.setContentsMargins(0, 0, 0, 0)
assert self.value.scene_editor is None, \
"The SceneModel may only have one active editor!"
self._create_scene()
self.value.activated = True
def init(self, parent):
global local_canvas
# create a layout for the tab widget and the main view
layout = QtGui.QVBoxLayout()
self.control = QtGui.QWidget()
self.control.setLayout(layout)
# add the tab widget
self.tab_widget = tab_widget = QtGui.QTabBar()
QtCore.QObject.connect(tab_widget,
QtCore.SIGNAL('currentChanged(int)'),
self._tab_activated )
tab_widget.setDocumentMode(True)
layout.addWidget(tab_widget)
# add the main plot
if not local_canvas:
local_canvas = FigureCanvasQTAggLocal(Figure())
local_canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
def __init__(self, parent=None):
super(BrillouinWindow, self).__init__(parent)
self.k_path = None
self.resize(900, 600)
layout = QtGui.QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
self.mayavi_widget = BrillouinVisualization(self)
self.ui = self.mayavi_widget.edit_traits(parent=self,
kind='subpanel').control
layout.addWidget(self.ui)
self.ui.setParent(self)
table_widget = QtGui.QWidget(parent=self)
layout.addWidget(table_widget)
table_layout = QtGui.QVBoxLayout(table_widget)
self.table = QtGui.QTableWidget(table_widget)
copy_action = CopySelectedCellsAction(self.table)
self.table.addAction(copy_action)
paste_action = PasteIntoTable(self.table, self)
self.table.addAction(paste_action)
self.table.setColumnCount(4)
self.table.setRowCount(0)
table_layout.addWidget(self.table)
for i, label in enumerate(['x', 'y', 'z', 'Label']):
if code:
# TODO do this!
code_string = """
import numpy as np
import matplotlib.pyplot as plt
self.first_plot_bool = True
self.figure = plt.figure(1)
plt.close(plt.figure(1))
self.ax = None
self.last_bandstructure = None"""
class DosVisualization(QtGui.QWidget):
def __init__(self, parent=None):
super(DosVisualization, self).__init__()
self.first_plot_bool = True
# a figure instance to plot on
self.figure = plt.figure(1)
plt.close(plt.figure(1))
self.ax = None
self.last_dos = None
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
color = self.palette().color(QtGui.QPalette.Base)
self.figure.patch.set_facecolor([color.red() / 255, color.green() / 255, color.blue() / 255])
if sum([color.red(), color.blue(), color.green()]) / 3 < 100:
def create_control(self, parent):
"""
Creates the underlying Qt window used for the notebook.
"""
self.layout = QtGui.QVBoxLayout()
self.control = QtGui.QWidget()
self.control.setLayout(self.layout)
return self.control
panel = None
if nr_groups == 1:
panel = _GroupPanel(content[0], ui).control
elif nr_groups > 1:
panel = QtGui.QTabWidget()
# Identify ourselves as being a Tabbed group so we can later
# distinguish this from other QTabWidgets.
panel.setProperty("traits_tabbed_group", True)
_fill_panel(panel, content, ui)
panel.ui = ui
# If the UI is scrollable then wrap the panel in a scroll area.
if ui.scrollable and panel is not None:
# Make sure the panel is a widget.
if isinstance(panel, QtGui.QLayout):
w = QtGui.QWidget()
w.setLayout(panel)
panel = w
size_policy = panel.sizePolicy()
sa = QtGui.QScrollArea()
sa.setWidget(panel)
sa.setWidgetResizable(True)
sa.setSizePolicy(size_policy)
panel = sa
return panel
def create(self, parent):
""" Create and set the toolkit-specific control that represents the
pane.
"""
self.control = QtGui.QWidget(parent)
continue
else:
E_plot, epsilon_plot = self.broaden_spectrum(energy, epsilon, width=gamma, mode=broaden_mode)
data[:, i] = epsilon_plot
i += 1
full_header = ['epsilon1', 'epsilon1_11', 'epsilon1_22', 'epsilon1_33', 'epsilon2', 'epsilon2_11',
'epsilon2_22', 'epsilon2_33']
from itertools import compress
header = 'Energy [eV] ' + ' '.join(list(compress(full_header, spectrum_exists)))
np.savetxt(filename, data, header=header)
class BandStructureVisualization(QtGui.QWidget):
def __init__(self, parent=None):
super(BandStructureVisualization, self).__init__()
self.first_plot_bool = True
# a figure instance to plot on
self.figure = plt.figure(1)
plt.close(plt.figure(1))
self.ax = None
self.last_bandstructure = None
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
color = self.palette().color(QtGui.QPalette.Base)
self.figure.patch.set_facecolor([color.red() / 255, color.green() / 255, color.blue() / 255])
if sum([color.red(), color.blue(), color.green()]) / 3 < 100:
# Allow multiple open pages at once?
multiple_open = Bool(False)
# can the editor delete list items?
delete = Bool(False)
# The pages contained in the notebook:
pages = List(VerticalNotebookPage)
# The traits UI editor this notebook is associated with (if any):
editor = Instance(Editor)
#-- Private Traits -------------------------------------------------------
# The Qt control used to represent the notebook:
control = Instance(QtGui.QWidget)
# The Qt layout containing the child widgets & layouts
layout = Instance(QtGui.QVBoxLayout)
#-- Public Methods -------------------------------------------------------
def create_control(self, parent):
"""
Creates the underlying Qt window used for the notebook.
"""
self.layout = QtGui.QVBoxLayout()
self.control = QtGui.QWidget()
self.control.setLayout(self.layout)