def __init__(self, system): super(QtMolecularViewer, self).__init__() self.actions = {} self.system = system self.widget.clicked.connect(self.on_click) # Let's add some dock self.controls = QtGui.QDockWidget() # Eliminate the dock titlebar title_widget = QtGui.QWidget(self) self.controls.setTitleBarWidget(title_widget) hb = QtGui.QHBoxLayout() # For controls self.keys = {} self.actions['action1'] = QtGui.QPushButton('action1') self.actions['action2'] = QtGui.QPushButton('action2') # Sidebar definition dock1 = QtGui.QDockWidget() bt1 = IconButton(os.path.join(resources_dir, 'select_atoms.svg'), 'Select all atoms') bt2 = IconButton(os.path.join(resources_dir, 'select_molecules.svg'), 'Select all molecules') bt3 = IconButton(os.path.join(resources_dir, 'hide_icon.svg'), 'Hide selected') bt4 = IconButton(os.path.join(resources_dir, 'show_icon.svg'), 'Show selected') self.actions['select_all_atoms'] = bt1 self.actions['select_all_molecules'] = bt2 self.actions['hide'] = bt3 self.actions['show'] = bt4 layout = QtGui.QGridLayout() layout.addWidget(bt1, 0, 0, Qt.AlignLeft) layout.addWidget(bt2, 0, 1, Qt.AlignLeft) layout.addWidget(bt3, 1, 0, Qt.AlignLeft) layout.addWidget(bt4, 1, 1, Qt.AlignLeft) layout.setColumnStretch(3, 1) layout.setRowStretch(2, 1) wrapper = QtGui.QWidget() wrapper.setLayout(layout) dock1.setWidget(wrapper) wrapper.setFixedSize(150, 100) self.addDockWidget(Qt.DockWidgetArea(Qt.RightDockWidgetArea), dock1) self._repr_controls = QtGui.QDockWidget() self.addDockWidget(Qt.RightDockWidgetArea, self._repr_controls) #self.add_representation(VdWRepresentation) self.add_representation(BallAndStickRepresentation)
def __init__(self): super(QtTrajectoryViewer, self).__init__() self.controls = QDockWidget() # Eliminate the dock titlebar title_widget = QtGui.QWidget(self) self.controls.setTitleBarWidget(title_widget) traj_controls = TrajectoryControls(self) self.controls.setWidget(traj_controls) # Molecular viewer self.widget = QChemlabWidget(self) self.setCentralWidget(self.widget) self.addDockWidget(Qt.DockWidgetArea(Qt.BottomDockWidgetArea), self.controls) self.show() # Replace in this way traj_controls.frame_changed.connect(self.on_frame_changed) self.traj_controls = traj_controls
def __init__(self): super(QtMolecularViewer, self).__init__() self.actions = {} self.widget.background_color = colors.black ##################################### # This is all UI stuff ##################################### self.widget.clicked.connect(self.on_click) # Let's add some dock self.controls = QtGui.QDockWidget() # Eliminate the dock titlebar title_widget = QtGui.QWidget(self) self.controls.setTitleBarWidget(title_widget) hb = QtGui.QHBoxLayout() # For controls self.keys = {} self.actions['action1'] = QtGui.QPushButton('action1') self.actions['action2'] = QtGui.QPushButton('action2') # Sidebar definition dock1 = QtGui.QDockWidget() dock2 = QtGui.QDockWidget() bt1 = IconButton(os.path.join(resources_dir, 'select_atoms.svg'), 'Select all atoms') bt2 = IconButton(os.path.join(resources_dir, 'select_molecules.svg'), 'Select all molecules') bt3 = IconButton(os.path.join(resources_dir, 'hide_icon.svg'), 'Hide selected') bt4 = IconButton(os.path.join(resources_dir, 'show_icon.svg'), 'Show selected') self.actions['select_all_atoms'] = bt1 self.actions['select_all_molecules'] = bt2 self.actions['hide'] = bt3 self.actions['show'] = bt4 layout = QtGui.QGridLayout() layout.addWidget(bt1, 0, 0, Qt.AlignLeft) layout.addWidget(bt2, 0, 1, Qt.AlignLeft) layout.addWidget(bt3, 1, 0, Qt.AlignLeft) layout.addWidget(bt4, 1, 1, Qt.AlignLeft) layout.setColumnStretch(3, 1) layout.setRowStretch(2, 1) wrapper = QtGui.QWidget() wrapper.setLayout(layout) dock1.setWidget(wrapper) self.ipython = QIPythonWidget() self.ipython.initialize() wrapper2 = QtGui.QWidget(self) vb = QtGui.QVBoxLayout(self) vb.setSizeConstraint(QtGui.QLayout.SetMaximumSize) self.traj_controls = TrajectoryControls() vb.addWidget(self.traj_controls, 1) vb.addWidget(self.ipython, 2) wrapper2.setLayout(vb) dock2.setWidget(wrapper2) wrapper.setFixedSize(150, 100) self.addDockWidget(Qt.DockWidgetArea(Qt.RightDockWidgetArea), dock1) self.addDockWidget(Qt.DockWidgetArea(Qt.BottomDockWidgetArea), dock2) self._repr_controls = QtGui.QDockWidget() self.addDockWidget(Qt.RightDockWidgetArea, self._repr_controls) ############################################ # Initialization code ############################################ self.namespace = self.ipython.get_user_namespace() self.namespace['__builtins__'].viewer = self #self.ipython.app.shell.ex('import sys') #self.ipython.app.shell.ex('''sys.path.append('/home/gabriele/workspace/chemlab/toolboxes/')''') self.ipython.app.shell.ex( 'from chemlab.mviewer.toolboxes.init import *')
def __init__(self): super(QtTrajectoryViewer, self).__init__() self.controls = QDockWidget() self._timer = QtCore.QTimer(self) self._timer.timeout.connect(self.do_update) # Eliminate the dock titlebar title_widget = QtGui.QWidget(self) self.controls.setTitleBarWidget(title_widget) vb = QtGui.QVBoxLayout() hb = QtGui.QHBoxLayout() # For controls containerhb2 = QtGui.QWidget(self) hb2 = QtGui.QHBoxLayout() # For settings containerhb2.setLayout(hb2) containerhb2.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) vb.addWidget(containerhb2) vb.addLayout(hb) self.vb = vb # Settings buttons hb2.addWidget(QtGui.QLabel('Speed')) self._speed_slider = QtGui.QSlider(Qt.Horizontal) self._speed_slider.resize(100, self._speed_slider.height()) self._speed_slider.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) self.speeds = np.linspace(15, 250, 11).astype(int) self.speeds = self.speeds.tolist() self.speeds.reverse() self._speed_slider.setMaximum(10) self._speed_slider.setValue(7) self._speed_slider.valueChanged.connect(self.on_speed_changed) hb2.addWidget(self._speed_slider) hb2.addStretch(1) wrapper = QtGui.QWidget() wrapper.setLayout(vb) # Molecular viewer self.widget = QChemlabWidget(self) self.setCentralWidget(self.widget) # Control buttons self.play_stop = PlayStopButton() hb.addWidget(self.play_stop) self.slider = AnimationSlider() hb.addWidget(self.slider, 2) self._label_tmp = '<b><FONT SIZE=30>{}</b>' self.timelabel = QtGui.QLabel(self._label_tmp.format('0.0')) hb.addWidget(self.timelabel) self._settings_button = QtGui.QPushButton() self._settings_button.setStyleSheet(''' QPushButton { width: 30px; height: 30px; }''') icon = QtGui.QIcon(os.path.join(resources_dir, 'settings_icon.svg')) self._settings_button.setIcon(icon) self._settings_button.clicked.connect(self._toggle_settings) hb.addWidget(self._settings_button) self.controls.setWidget(wrapper) self.addDockWidget(Qt.DockWidgetArea(Qt.BottomDockWidgetArea), self.controls) self._settings_pan = containerhb2 self.show() self.speed = self.speeds[self._speed_slider.value()] # Connecting all the signals self.play_stop.play.connect(self.on_play) self.play_stop.pause.connect(self.on_pause) self.slider.valueChanged.connect(self.on_slider_change) self.slider.sliderPressed.connect(self.on_slider_down) self.play_stop.setFocus() vb.setSizeConstraint(QtGui.QLayout.SetMaximumSize) containerhb2.setVisible(False)