class SphairaApp(QApplication): def __init__(self, args): super(SphairaApp, self).__init__(args) name = 'Sphaira Viewer' self.setApplicationName(name) self.layer_widget = QDockWidget('Layers') self.layer_widget.setFeatures( QDockWidget.DockWidgetMovable | QDockWidget.DockWidgetFloatable ) self.layer_list = LayerListWithToolBar() self.layer_widget.setWidget(self.layer_list) self.gl_widget = SphairaView(self.layer_list) self.mainWindow = QMainWindow() self.mainWindow.setWindowTitle(name) self.mainWindow.setCentralWidget(self.gl_widget) self.mainWindow.addDockWidget( QtCore.Qt.DockWidgetArea.BottomDockWidgetArea, self.layer_widget, ) self.mainWindow.resize(800, 600) self.mainWindow.showMaximized() def load_file(self, file_name, in_format): return self.gl_widget.load_file(file_name, in_format)
def closeEvent(self, event): """ OVERRIDE... Insures proper garbage collection of UI """ self.deleteLater() QDockWidget.closeEvent(self, event)
def __init__(self, canvas, parent, coordinates=True): """ coordinates: should we show the coordinates on the right? """ self.canvas = canvas self.coordinates = coordinates QDockWidget.__init__(self, parent) self.setFloating(True) NavigationToolbar2.__init__(self, canvas)
def __init__(self, opc=None): super(MainWindow, self).__init__() self.opc = opc self.setWindowTitle('OPC DA Datalogger') self.layout = QHBoxLayout(self) self.configuration = Configuration(self, opc) self.configuration_dock = QDockWidget("Configuration", self) self.configuration_dock.setWidget(self.configuration) self.configuration_dock.setFeatures(QDockWidget.NoDockWidgetFeatures) self.addDockWidget(Qt.LeftDockWidgetArea, self.configuration_dock) self.logging_area = LoggingArea(self) self.logging_dock = QDockWidget("Logging", self) self.logging_dock.setWidget(self.logging_area) self.logging_dock.setFeatures(QDockWidget.NoDockWidgetFeatures) self.addDockWidget(Qt.RightDockWidgetArea, self.logging_dock) self.setLayout(self.layout) self.resize(900, 600) self.logging_timer = QTimer(self) self.logging_timer.timeout.connect(self._loogging_callback)
def initList(self): self.leftDock = QDockWidget() self.leftDock.setFeatures( QDockWidget.DockWidgetFeature.NoDockWidgetFeatures) QApplication.instance().doclist = QListWidget() QApplication.instance().doclist.itemDoubleClicked.connect( openDocumentAction) self.leftDock.setWidget(QApplication.instance().doclist) self.leftDock.setAllowedAreas(Qt.LeftDockWidgetArea) self.addDockWidget(Qt.LeftDockWidgetArea, self.leftDock)
def __init__(self): """ Initialize a new QMayaDockWidget instance **RETURNS** *None* >>> doc_widget = QMayaDockWidget() >>> doc_widget.show() """ self._maya_win = QMayaMain.getMainWindow() QDockWidget.__init__(self, self._maya_win) self.setWindowTitle(self.TITLE) self.setFloating(self.DEFAULT_FLOATING)
def setup_sidebar(self): self.sidebar = sidebar = QDockWidget() sidebar.setAllowedAreas(Qt.LeftDockWidgetArea) sidebar.setFeatures(QDockWidget.NoDockWidgetFeatures) sidebar.setFixedWidth(240) widget = QWidget(sidebar) # add stuff here # provide a callback? sidebar.setWidget(widget) print(sidebar.size()) self.main.addDockWidget(Qt.LeftDockWidgetArea, sidebar)
class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("Query") self.setWindowIcon(QIcon("res/SplashScreen.png")) self.initCentral() self.initStatusBar() self.initToolbar() self.initList() self.showMaximized() self.leftDock.hide() def initCentral(self): QApplication.instance().webview = DocumentView( os.getcwd() + "\\res\\ProjectGreeter.html") self.setCentralWidget(QApplication.instance().webview) def initToolbar(self): self.addToolBar(Qt.TopToolBarArea, SearchBar(self)) def initStatusBar(self): self.statusBar().addWidget(QLabel( QApplication.instance().indexer.root)) def initList(self): self.leftDock = QDockWidget() self.leftDock.setFeatures( QDockWidget.DockWidgetFeature.NoDockWidgetFeatures) QApplication.instance().doclist = QListWidget() QApplication.instance().doclist.itemDoubleClicked.connect( openDocumentAction) self.leftDock.setWidget(QApplication.instance().doclist) self.leftDock.setAllowedAreas(Qt.LeftDockWidgetArea) self.addDockWidget(Qt.LeftDockWidgetArea, self.leftDock)
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
class MainWindow(QMainWindow): def __init__(self, opc=None): super(MainWindow, self).__init__() self.opc = opc self.setWindowTitle('OPC DA Datalogger') self.layout = QHBoxLayout(self) self.configuration = Configuration(self, opc) self.configuration_dock = QDockWidget("Configuration", self) self.configuration_dock.setWidget(self.configuration) self.configuration_dock.setFeatures(QDockWidget.NoDockWidgetFeatures) self.addDockWidget(Qt.LeftDockWidgetArea, self.configuration_dock) self.logging_area = LoggingArea(self) self.logging_dock = QDockWidget("Logging", self) self.logging_dock.setWidget(self.logging_area) self.logging_dock.setFeatures(QDockWidget.NoDockWidgetFeatures) self.addDockWidget(Qt.RightDockWidgetArea, self.logging_dock) self.setLayout(self.layout) self.resize(900, 600) self.logging_timer = QTimer(self) self.logging_timer.timeout.connect(self._loogging_callback) def _start_logging(self): self.tags = self.configuration.tag_selection.selected_tags() header, line = opcda.read(self.opc, self.tags) self.logging_area.te_logging.clear() self.logging_area.te_logging.append(header) self.logging_timer.start(500) def _loogging_callback(self): header, line = opcda.read(self.opc, self.tags) self.logging_area.te_logging.append(line) def _stop_logging(self): self.logging_timer.stop()
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)
class QtTrajectoryViewer(QMainWindow): """Bases: `PySide.QtGui.QMainWindow` Interface for viewing trajectory. It provides interface elements to play/pause and set the speed of the animation. **Example** To set up a QtTrajectoryViewer you have to add renderers to the scene, set the number of frames present in the animation by calling ;py:meth:`~chemlab.graphics.QtTrajectoryViewer.set_ticks` and define an update function. Below is an example taken from the function :py:func:`chemlab.graphics.display_trajectory`:: from chemlab.graphics import QtTrajectoryViewer # sys = some System # coords_list = some list of atomic coordinates v = QtTrajectoryViewer() sr = v.add_renderer(AtomRenderer, sys.r_array, sys.type_array, backend='impostors') br = v.add_renderer(BoxRenderer, sys.box_vectors) v.set_ticks(len(coords_list)) @v.update_function def on_update(index): sr.update_positions(coords_list[index]) br.update(sys.box_vectors) v.set_text(format_time(times[index])) v.widget.repaint() v.run() .. warning:: Use with caution, the API for this element is not fully stabilized and may be subject to change. """ 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) def set_ticks(self, number): '''Set the number of frames to animate. ''' self.max_index = number self.current_index = 0 self.slider.setMaximum(self.max_index-1) self.slider.setMinimum(0) self.slider.setPageStep(1) def set_text(self, text): '''Update the time indicator in the interface.''' self.timelabel.setText(self._label_tmp.format(text)) def on_play(self): if self.current_index == self.max_index - 1: # Restart self.current_index = 0 self._timer.start(self.speed) def do_update(self): if self.current_index >= self.max_index: self.current_index = self.max_index - 1 self._timer.stop() self.play_stop.set_pause() else: self.current_index += 1 self.slider.setSliderPosition(self.current_index) def on_pause(self): self._timer.stop() def on_slider_change(self, value): #print 'Slider moved', value self.current_index = value self._update_function(self.current_index) def on_slider_down(self): self._timer.stop() self.play_stop.set_pause() def on_speed_changed(self, index): self.speed = self.speeds[index] if self._timer.isActive(): self._timer.stop() self._timer.start(self.speed) def add_renderer(self, klass, *args, **kwargs): '''The behaviour of this function is the same as :py:meth:`chemlab.graphics.QtViewer.add_renderer`. ''' renderer = klass(self.widget, *args, **kwargs) self.widget.renderers.append(renderer) return renderer def add_ui(self, klass, *args, **kwargs): '''Add an UI element for the current scene. The approach is the same as renderers. .. warning:: The UI api is not yet finalized ''' ui = klass(self.widget, *args, **kwargs) self.widget.uis.append(ui) return ui def add_post_processing(self, klass, *args, **kwargs): pp = klass(self.widget, *args, **kwargs) self.widget.post_processing.append(pp) return pp def run(self): app.exec_() def update_function(self, func): '''Set the function to be called when it's time to display a frame. *func* should be a function that takes one integer argument that represents the frame that has to be played:: def func(index): # Update the renderers to match the # current animation index ''' self._update_function = func def _toggle_settings(self): self._settings_pan.setVisible(not self._settings_pan.isVisible())
def initDock (self ): dock =QDockWidget ("foboard",self ) dock .setAllowedAreas (Qt .TopDockWidgetArea |Qt .BottomDockWidgetArea ) dock .setWidget (self .foboard ) self .addDockWidget (Qt .BottomDockWidgetArea ,dock )
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.dirty = False # Models # - Filesystem Model self.fileSystemModel = QFileSystemModel() # rootPath = QDesktopServices.storageLocation( # QDesktopServices.HomeLocation) # fileSystemRoot = self.fileSystemModel.setRootPath(rootPath) fileSystemRoot = self.fileSystemModel.setRootPath( "/home/ryan/Programming/Python/projects/r3tagger/r3tagger/tests" ) # Views # - Filesystem View self.fileSystemView = QTreeView() self.fileSystemView.setModel(self.fileSystemModel) self.fileSystemView.setRootIndex(fileSystemRoot) self.fileSystemView.doubleClicked.connect(self.updateAlbumModel) self.fileSystemView.expanded.connect(self.fixFileSystemColumns) self.fileSystemView.collapsed.connect(self.fixFileSystemColumns) # - Album View self.albumView = albumcollection.MusicCollectionView() self.albumView.setSelectionMode(QAbstractItemView.MultiSelection) self.albumView.clicked.connect(self.updateEditing) self.albumView.expanded.connect(self.fixAlbumViewColumns) self.albumView.collapsed.connect(self.fixAlbumViewColumns) self.albumView.model().dataChanged.connect(self.fixAlbumViewColumns) self.albumView.model().dataChanged.connect(self._setDirty) model = self.albumView.model() model.dataChanged.connect(self.updateEditing) # Editing Group self.editingGroup = QFormLayout() self.lineArtist = QLineEdit() self.lineAlbum = QLineEdit() self.lineTitle = QLineEdit() self.lineTrack = QLineEdit() self.lineDate = QLineEdit() self.lineGenre = QLineEdit() self.editingGroup.addRow("Artist:", self.lineArtist) self.editingGroup.addRow("Album:", self.lineAlbum) self.editingGroup.addRow("Title:", self.lineTitle) self.editingGroup.addRow("Track:", self.lineTrack) self.editingGroup.addRow("Date:", self.lineDate) self.editingGroup.addRow("Genre:", self.lineGenre) self.tagsToAttribs = { "artist": self.lineArtist, "album": self.lineAlbum, "title": self.lineTitle, "tracknumber": self.lineTrack, "date": self.lineDate, "genre": self.lineGenre, } # Confirm / Cancel / Clear Group self.buttonGroup = QHBoxLayout() self.buttonGroup.addStretch() confirm = QPushButton("Confirm") confirm.clicked.connect(self.confirmChanges) self.buttonGroup.addWidget(confirm) cancel = QPushButton("Cancel") cancel.clicked.connect(self.cancelChanges) self.buttonGroup.addWidget(cancel) clear = QPushButton("Clear") clear.clicked.connect(self.clearAlbumView) self.buttonGroup.addWidget(clear) self.buttonGroup.addStretch() # Statusbar # status = self.statusBar() # status.setSizeGripEnabled(False) # status.showMessage("Ready", 5000) # Docks dockAllowed = Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea # - Filesystem Dock fileSystemDock = QDockWidget("Navigate", self) fileSystemDock.setObjectName("fileSystemDock") fileSystemDock.setAllowedAreas(dockAllowed) fileSystemDock.setWidget(self.fileSystemView) self.addDockWidget(Qt.LeftDockWidgetArea, fileSystemDock) # - Editing Dock editingWidget = QWidget() editingWidget.setLayout(self.editingGroup) editingDock = QDockWidget("Editing", self) editingDock.setObjectName("editingDock") editingDock.setAllowedAreas(dockAllowed) editingDock.setWidget(editingWidget) self.addDockWidget(Qt.RightDockWidgetArea, editingDock) # Actions fileAddSongAction = self._createAction( text="Add &Songs", slot=self.fileAddSong, shortcut=QKeySequence.Open, icon="fileOpen", tip="Add files (songs)", ) fileAddAlbumAction = self._createAction( text="Add &Album", slot=self.fileAddAlbum, shortcut=QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_O), icon="fileOpen", tip="Add directory (album)", ) fileSaveAction = self._createAction( text="&Save Changes", slot=self.confirmChanges, shortcut=QKeySequence.Save, icon="fileSave", tip="Save Changes", ) fileQuitAction = self._createAction( text="&Quit", slot=self.close, shortcut=QKeySequence.Quit, icon="fileQuit", tip="Quit Program" ) editRecognizeAction = self._createAction( text="&Recognize", slot=self.editRecognize, shortcut=QKeySequence(Qt.CTRL + Qt.Key_R), icon="editRecognize", tip="Recognize music", ) editReorganizeAction = self._createAction( text="Reorganize", slot=self.editReorganize, shortcut=QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_R), icon="editReorganize", tip="Reorganize music", ) editSettingsAction = self._createAction( text="Settings", slot=self.editSettings, shortcut=QKeySequence.Preferences, icon="editSettings", tip="Edit settings", ) helpDocsAction = self._createAction( text="Documentation", slot=self.helpDocs, shortcut=QKeySequence.HelpContents, icon="helpDocs", tip="Documentation", ) helpAboutAction = self._createAction( text="About", slot=self.helpAbout, shortcut=QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_F1), icon="helpAbout", tip="About", ) toggleEditing = editingDock.toggleViewAction() toggleEditing.setIcon(QIcon(":/toggleEditing.png")) toggleFileNav = fileSystemDock.toggleViewAction() toggleFileNav.setIcon(QIcon(":/toggleFileNav.png")) # Menus fileMenu = self.menuBar().addMenu("&File") self._addActions(fileMenu, (fileAddSongAction, fileAddAlbumAction, fileSaveAction, fileQuitAction)) editMenu = self.menuBar().addMenu("&Edit") self._addActions(editMenu, (editReorganizeAction, editRecognizeAction, editSettingsAction)) helpMenu = self.menuBar().addMenu("&Help") self._addActions(helpMenu, (helpDocsAction, helpAboutAction)) # Toolbars editToolbar = self.addToolBar("EditToolbar") editToolbar.setObjectName("editToolbar") self._addActions(editToolbar, (editRecognizeAction, editReorganizeAction)) toggleToolbar = self.addToolBar("ToggleToolbar") toggleToolbar.setObjectName("toggleToolbar") self._addActions(toggleToolbar, (toggleFileNav, toggleEditing)) # Settings settings = QSettings() if settings.contains("MainWindow/Geometry"): self.restoreGeometry(settings.value("MainWindow/Geometry")) if settings.contains("MainWindow/State"): self.restoreState(settings.value("MainWindow/State")) self.setWindowTitle("r3tagger") # Final Layout centralWidget = QWidget() centralLayout = QVBoxLayout() centralLayout.addWidget(self.albumView) centralLayout.addLayout(self.buttonGroup) centralWidget.setLayout(centralLayout) self.setCentralWidget(centralWidget)
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--qt_from', default='pyqt', choices=['pyqt', 'pyqt5', 'pyside', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument('--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyside() elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt() elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt5_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt5_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt5() elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_qtpy_ui import Ui_DockWidget as ui_widgets from ui.dw_views_qtpy_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_qtpy_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_qtpy_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment() elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt.QtGui import QApplication, QMainWindow, QDockWidget from pyqtgraph.Qt.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize #from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_menus_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqtgraph_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqtgraph_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if args.no_dark: style = '' def write_settings(window): """Get window settings and write it into a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') settings.setValue('pos', window.pos()) settings.setValue('size', window.size()) settings.setValue('state', window.saveState()) def read_settings(window): """Read and set window settings from a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') if args.qt_from == 'pyside': pos = settings.value('pos', window.pos()) size = settings.value('size', window.size()) state = settings.value('state', window.saveState()) else: pos = settings.value('pos', window.pos(), type='QPoint') size = settings.value('size', window.size(), type='QSize') state = settings.value('state', window.saveState(), type='QByteArray') window.restoreState(state) window.resize(size) window.move(pos) # create the application app = QApplication(sys.argv) app.setOrganizationName('QDarkStyle') app.setApplicationName('QDarkStyle Example') # setup stylesheet app.setStyleSheet(style) # create main window window = QMainWindow() window.setObjectName('mainwindow') ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__ + " - Example - Using " + args.qt_from) # create docks for buttons dw_buttons = QDockWidget() dw_buttons.setObjectName('buttons') ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() dw_displays.setObjectName('displays') ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - fields dw_inputs_fields = QDockWidget() dw_inputs_fields.setObjectName('_fields') ui_inputs_fields = ui_inputs_fields() ui_inputs_fields.setupUi(dw_inputs_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_fields) # create docks for inputs - no fields dw_inputs_no_fields = QDockWidget() dw_inputs_no_fields.setObjectName('inputs_no_fields') ui_inputs_no_fields = ui_inputs_no_fields() ui_inputs_no_fields.setupUi(dw_inputs_no_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_fields) # create docks for widgets dw_widgets = QDockWidget() dw_widgets.setObjectName('widgets') ui_widgets = ui_widgets() ui_widgets.setupUi(dw_widgets) window.addDockWidget(Qt.LeftDockWidgetArea, dw_widgets) # create docks for views dw_views = QDockWidget() dw_views.setObjectName('views') ui_views = ui_views() ui_views.setupUi(dw_views) window.addDockWidget(Qt.LeftDockWidgetArea, dw_views) # create docks for containters - tabs dw_containers_tabs = QDockWidget() dw_containers_tabs.setObjectName('containers') ui_containers_tabs = ui_containers_tabs() ui_containers_tabs.setupUi(dw_containers_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_tabs) # create docks for containers - no tabs dw_containers_no_tabs = QDockWidget() dw_containers_no_tabs.setObjectName('containers_no_tabs') ui_containers_no_tabs = ui_containers_no_tabs() ui_containers_no_tabs.setupUi(dw_containers_no_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_no_tabs) # tabify right docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs_fields) window.tabifyDockWidget(dw_inputs_fields, dw_inputs_no_fields) # auto quit after 2s when testing on travis-ci if "--test" in sys.argv: QTimer.singleShot(2000, app.exit) # run read_settings(window) window.showMaximized() app.exec_() write_settings(window)
def add_dock_widget(self, title, widget, alignment): dock = QDockWidget(title, self) dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) dock.setWidget(widget) self.addDockWidget(alignment, dock)
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '--qt_from', default='pyqt', choices=['pyqt', 'pyqt5', 'pyside', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument( '--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget from PySide.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_pyside() elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget from PyQt4.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_pyqt() elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget from PyQt5.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_pyqt5() elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget from qtpy.QtCore import QTimer, Qt # import examples UI according to wrapper from ui.mw_views_widgets_containers_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_from_environment() elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_views_widgets_containers_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.mw_dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.mw_dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.mw_dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs from ui.mw_dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields # getting style style = qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if args.no_dark: style = '' # create the application app = QApplication(sys.argv) # setup stylesheet app.setStyleSheet(style) # create main window window = QMainWindow() ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__ + " - Example - Using " + args.qt_from) # create docks for buttons dw_buttons = QDockWidget() ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - fields dw_inputs = QDockWidget() ui_inputs = ui_inputs() ui_inputs.setupUi(dw_inputs) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs) # create docks for inputs - no fields dw_inputs_no_field = QDockWidget() ui_inputs_no_field = ui_inputs_no_fields() ui_inputs_no_field.setupUi(dw_inputs_no_field) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_field) # tabify docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs) window.tabifyDockWidget(dw_inputs, dw_inputs_no_field) # connect some actions, signals and functions # auto quit after 2s when testing on travis-ci if "--test" in sys.argv: QTimer.singleShot(2000, app.exit) # run window.showMaximized() app.exec_()
def __init__(self): super(ConsoleWidget, self).__init__() self.setWindowTitle('1c query') self._connection = None self._home = os.path.expanduser('~/%s' % QApplication.applicationName()) if not os.path.isdir(self._home): os.mkdir(self._home) self.queryToolBar = self.addToolBar('Query') self.queryAction = self.queryToolBar.addAction('Run', self.executeQuery) self.queryAction.setDisabled(True) uri_history = list() path = os.path.join(self._home, 'uri_history.txt') if os.path.isfile(path): uri_history = open(path, 'r').read().split('\n') self.connectionToolBar = self.addToolBar('Connection') self.connectionUriCombo = QComboBox(self) self.connectionUriCombo.setEditable(True) if not uri_history: self.connectionUriCombo.addItem('File="";usr="";pwd="";') self.connectionUriCombo.addItem('Srvr="{host}";Ref="{ref}";Usr="******";Pwd="{password}";') else: self.connectionUriCombo.addItems(uri_history) self.connectionUriCombo.setCurrentIndex(len(uri_history) - 1) self.connectionUriCombo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) self.connectionToolBar.addWidget(self.connectionUriCombo) self.onesVersionCombo = QComboBox(self) self.onesVersionCombo.addItems(['8.3', '8.2', '8.1', '8.0']) self.onesVersionCombo.setCurrentIndex(0) self.connectionToolBar.addWidget(self.onesVersionCombo) self.connectAction = self.connectionToolBar.addAction('Connect', self.connectOneS) self.disconnectAction = self.connectionToolBar.addAction('Disconnect', self.disconnectOneS) self.disconnectAction.setDisabled(True) self.logEdit = QPlainTextEdit(self) self.logDock = QDockWidget('Log', self) self.logDock.setWidget(self.logEdit) self.addDockWidget(Qt.BottomDockWidgetArea, self.logDock, Qt.Horizontal) self.splitter = QSplitter(Qt.Vertical, self) self.setCentralWidget(self.splitter) self.sqlEdit = QTextEdit(self) self.sqlEdit.setLineWrapMode(QTextEdit.NoWrap) path = os.path.join(self._home, 'last-sql.txt') if os.path.isfile(path): sql = open(path, 'r').read() self.sqlEdit.setText(sql) self.model = QStandardItemModel(self) self.tableView = QTableView(self) self.tableView.setModel(self.model) self.splitter.addWidget(self.sqlEdit) self.splitter.addWidget(self.tableView) self.splitter.setStretchFactor(0, 3) self.splitter.setStretchFactor(1, 2)
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '--qt_from', default='qtpy', choices=['pyqt', 'pyqt5', 'pyside', 'pyside2', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument( '--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") parser.add_argument('--reset', action='store_true', help="Reset GUI settings (position, size).") parser.add_argument('--screenshots', action='store_true', help="Generate screenshots.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) # to avoid problems when testing without screen if args.test: os.environ['QT_QPA_PLATFORM'] = 'offscreen' if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyside elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyqt elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt5_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt5_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyqt5 elif args.qt_from == 'pyside2': # using PyQt5 wrapper from PySide2.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PySide2.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside2_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside2_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside2_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside2_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside2_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside2_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside2_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside2_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside2_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyside2 elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_qtpy_ui import Ui_DockWidget as ui_widgets from ui.dw_views_qtpy_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_qtpy_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_qtpy_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_from_environment elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from pyqtgraph.Qt.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize #from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_menus_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqtgraph_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqtgraph_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = lambda: qdarkstyle.load_stylesheet_from_environment( is_pyqtgraph=True) def write_settings(window): """Get window settings and write it into a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') settings.setValue('pos', window.pos()) settings.setValue('size', window.size()) settings.setValue('state', window.saveState()) def read_settings(window, reset=False): """Read and set window settings from a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') try: pos = settings.value('pos', window.pos()) size = settings.value('size', window.size()) state = settings.value('state', window.saveState()) except Exception: pos = settings.value('pos', window.pos(), type='QPoint') size = settings.value('size', window.size(), type='QSize') state = settings.value('state', window.saveState(), type='QByteArray') if not reset: window.restoreState(state) window.resize(size) window.move(pos) # create the application app = QApplication(sys.argv) app.setOrganizationName('QDarkStyle') app.setApplicationName('QDarkStyle Example') # setup stylesheet style = '' if args.no_dark is False: style = style_method() app.setStyleSheet(style) # create main window window = QMainWindow() window.setObjectName('mainwindow') ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__) # create docks for buttons dw_buttons = QDockWidget() dw_buttons.setObjectName('buttons') ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() dw_displays.setObjectName('displays') ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - no fields dw_inputs_no_fields = QDockWidget() dw_inputs_no_fields.setObjectName('inputs_no_fields') ui_inputs_no_fields = ui_inputs_no_fields() ui_inputs_no_fields.setupUi(dw_inputs_no_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_fields) # create docks for inputs - fields dw_inputs_fields = QDockWidget() dw_inputs_fields.setObjectName('_fields') ui_inputs_fields = ui_inputs_fields() ui_inputs_fields.setupUi(dw_inputs_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_fields) # create docks for widgets dw_widgets = QDockWidget() dw_widgets.setObjectName('widgets') ui_widgets = ui_widgets() ui_widgets.setupUi(dw_widgets) window.addDockWidget(Qt.LeftDockWidgetArea, dw_widgets) # create docks for views dw_views = QDockWidget() dw_views.setObjectName('views') ui_views = ui_views() ui_views.setupUi(dw_views) window.addDockWidget(Qt.LeftDockWidgetArea, dw_views) # create docks for containers - no tabs dw_containers_no_tabs = QDockWidget() dw_containers_no_tabs.setObjectName('containers_no_tabs') ui_containers_no_tabs = ui_containers_no_tabs() ui_containers_no_tabs.setupUi(dw_containers_no_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_no_tabs) # create docks for containters - tabs dw_containers_tabs = QDockWidget() dw_containers_tabs.setObjectName('containers') ui_containers_tabs = ui_containers_tabs() ui_containers_tabs.setupUi(dw_containers_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_tabs) # tabify right docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs_fields) window.tabifyDockWidget(dw_inputs_fields, dw_inputs_no_fields) # tabify right docks window.tabifyDockWidget(dw_containers_no_tabs, dw_containers_tabs) window.tabifyDockWidget(dw_containers_tabs, dw_widgets) window.tabifyDockWidget(dw_widgets, dw_views) # issues #9120, #9121 on Spyder qstatusbar = QStatusBar() qstatusbar.addWidget( QLabel('Issue Spyder #9120, #9121 - background not matching.')) qstatusbar.addWidget(QPushButton('OK')) window.setStatusBar(qstatusbar) # auto quit after 2s when testing on travis-ci if args.test: QTimer.singleShot(2000, app.exit) # run read_settings(window, args.reset) window.showMaximized() # Save screenshots for differents displays and quit if args.screenshots: window.showFullScreen() QTimer.singleShot( 1000, lambda: create_screenshots(app, window, not args.no_dark)) app.exec_() write_settings(window)
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--qt_from', default='qtpy', choices=['pyqt', 'pyqt5', 'pyside','pyside2', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument('--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") parser.add_argument('--reset', action='store_true', help="Reset GUI settings (position, size).") parser.add_argument('--screenshots', action='store_true', help="Generate screenshots.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) # to avoid problems when testing without screen if args.test: os.environ['QT_QPA_PLATFORM']='offscreen' if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyside elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyqt elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt5_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt5_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyqt5 elif args.qt_from == 'pyside2': # using PyQt5 wrapper from PySide2.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from PySide2.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside2_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside2_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside2_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside2_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside2_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside2_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside2_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside2_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside2_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_pyside2 elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_qtpy_ui import Ui_DockWidget as ui_widgets from ui.dw_views_qtpy_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_qtpy_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_qtpy_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = qdarkstyle.load_stylesheet_from_environment elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt.QtGui import QApplication, QMainWindow, QDockWidget, QStatusBar, QLabel, QPushButton from pyqtgraph.Qt.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize #from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_menus_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqtgraph_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqtgraph_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_no_tabs # Getting style style_method = lambda: qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if args.no_dark: style = '' def write_settings(window): """Get window settings and write it into a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') settings.setValue('pos', window.pos()) settings.setValue('size', window.size()) settings.setValue('state', window.saveState()) def read_settings(window, reset=False): """Read and set window settings from a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') if args.qt_from == 'pyside' or args.qt_from == 'pyside2': pos = settings.value('pos', window.pos()) size = settings.value('size', window.size()) state = settings.value('state', window.saveState()) else: pos = settings.value('pos', window.pos(), type='QPoint') size = settings.value('size', window.size(), type='QSize') state = settings.value('state', window.saveState(), type='QByteArray') if not reset: window.restoreState(state) window.resize(size) window.move(pos) # create the application app = QApplication(sys.argv) app.setOrganizationName('QDarkStyle') app.setApplicationName('QDarkStyle Example') # setup stylesheet style = style_method() app.setStyleSheet(style) # create main window window = QMainWindow() window.setObjectName('mainwindow') ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__) # create docks for buttons dw_buttons = QDockWidget() dw_buttons.setObjectName('buttons') ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() dw_displays.setObjectName('displays') ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - no fields dw_inputs_no_fields = QDockWidget() dw_inputs_no_fields.setObjectName('inputs_no_fields') ui_inputs_no_fields = ui_inputs_no_fields() ui_inputs_no_fields.setupUi(dw_inputs_no_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_fields) # create docks for inputs - fields dw_inputs_fields = QDockWidget() dw_inputs_fields.setObjectName('_fields') ui_inputs_fields = ui_inputs_fields() ui_inputs_fields.setupUi(dw_inputs_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_fields) # create docks for widgets dw_widgets = QDockWidget() dw_widgets.setObjectName('widgets') ui_widgets = ui_widgets() ui_widgets.setupUi(dw_widgets) window.addDockWidget(Qt.LeftDockWidgetArea, dw_widgets) # create docks for views dw_views = QDockWidget() dw_views.setObjectName('views') ui_views = ui_views() ui_views.setupUi(dw_views) window.addDockWidget(Qt.LeftDockWidgetArea, dw_views) # create docks for containers - no tabs dw_containers_no_tabs = QDockWidget() dw_containers_no_tabs.setObjectName('containers_no_tabs') ui_containers_no_tabs = ui_containers_no_tabs() ui_containers_no_tabs.setupUi(dw_containers_no_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_no_tabs) # create docks for containters - tabs dw_containers_tabs = QDockWidget() dw_containers_tabs.setObjectName('containers') ui_containers_tabs = ui_containers_tabs() ui_containers_tabs.setupUi(dw_containers_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_tabs) # tabify right docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs_fields) window.tabifyDockWidget(dw_inputs_fields, dw_inputs_no_fields) # tabify right docks window.tabifyDockWidget(dw_containers_no_tabs, dw_containers_tabs) window.tabifyDockWidget(dw_containers_tabs, dw_widgets) window.tabifyDockWidget(dw_widgets, dw_views) # issues #9120, #9121 on Spyder qstatusbar = QStatusBar() qstatusbar.addWidget(QLabel('Issue Spyder #9120, #9121 - background not matching.')) qstatusbar.addWidget(QPushButton('OK')) window.setStatusBar(qstatusbar) # auto quit after 2s when testing on travis-ci if args.test: QTimer.singleShot(2000, app.exit) # run read_settings(window, args.reset) window.showMaximized() # Save screenshots for differents displays and quit if args.screenshots: window.showFullScreen() QTimer.singleShot(1000, lambda: create_screenshots(app, window, not args.no_dark)) app.exec_() write_settings(window)
def _init_widgets(self): main = QMainWindow() main.setWindowFlags(Qt.Widget) # main.setCorner(Qt.TopLeftCorner, Qt.TopDockWidgetArea) # main.setCorner(Qt.TopRightCorner, Qt.RightDockWidgetArea) pathtree = QPathTree(self, main) pathtree_dock = QDockWidget('PathTree', pathtree) main.setCentralWidget(pathtree_dock) # main.addDockWidget(Qt.BottomDockWidgetArea, pathtree_dock) pathtree_dock.setWidget(pathtree) pathgroups_logic = self.workspace.instance.path_groups if self.workspace.instance is not None else None pathgroups = QPathGroups(pathgroups_logic, main) pathgroups_dock = QDockWidget('PathGroups', pathgroups) main.addDockWidget(Qt.RightDockWidgetArea, pathgroups_dock) pathgroups_dock.setWidget(pathgroups) reg_viewer = QRegisterViewer(self) reg_viewer_dock = QDockWidget('Register Viewer', reg_viewer) main.addDockWidget(Qt.RightDockWidgetArea, reg_viewer_dock) reg_viewer_dock.setWidget(reg_viewer) mem_viewer = QMemoryViewer(self) mem_viewer_dock = QDockWidget('Memory Viewer', mem_viewer) main.addDockWidget(Qt.RightDockWidgetArea, mem_viewer_dock) mem_viewer_dock.setWidget(mem_viewer) main.tabifyDockWidget(reg_viewer_dock, mem_viewer_dock) self._pathtree = pathtree self._pathgroups = pathgroups self._register_viewer = reg_viewer self._memory_viewer = mem_viewer main_layout = QHBoxLayout() main_layout.addWidget(main) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout)
def __init__(self, parent=None): super(mainwin, self).__init__(parent) self.setWindowTitle("Nigandu English to Tamil Dictionary") self.setGeometry(200, 50, 650, 600) self.setMinimumHeight(620) self.setMinimumWidth(650) self.setMaximumHeight(660) self.setMaximumWidth(800) #Setting up status bar self.myStatusBar = QStatusBar() self.myStatusBar.showMessage('Ready', 7000) self.setStatusBar(self.myStatusBar) #Setting up application icon appIcon = QIcon(":/icons/njnlogo.png") self.setWindowIcon(appIcon) # defining the central widget self.central = QWidget(self) #combobox plus search button self.whole = QVBoxLayout(self.central) self.gridlayout = QGridLayout() self.comboBox = QLineEdit(self) #self.comboBox.setEditable(True) self.comboBox.setObjectName("comboBox") self.completer = QCompleter(self.comboBox) self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setMaxVisibleItems(10) self.comboBox.setCompleter(self.completer) #self.comboBox.setCompleter() self.gridlayout.addWidget(self.comboBox, 1, 1, 1, 2) self.searchbtn = QPushButton() self.searchbtn.setObjectName("searchbtn") self.searchbtn.setText("&Search") self.gridlayout.addWidget(self.searchbtn, 1, 3) vbox = QVBoxLayout() self.tamtext = QTextBrowser() self.listview = QListWidget(self) #self.listview.setEditTriggers(QAbstractItemView.NoEditTriggers) self.listview.setWindowTitle("Suggested words") self.tamtext.setMinimumHeight(100) self.tamtext.setMaximumHeight(150) vbox.addWidget(self.tamtext) self.suglbl = QLabel(self) self.suglbl.setText("Suggested Words:") vbox.addWidget(self.suglbl) vbox.addWidget(self.listview) self.whole.addLayout(self.gridlayout) self.whole.addLayout(vbox) self.setCentralWidget(self.central) #setting docks self.histdockwidg = QDockWidget("History", self) self.bkmdockwidg = QDockWidget("Book Marks", self) self.histdockwidg.setObjectName("self.histdockwidg") self.bkmdockwidg.setObjectName("self.bkmdockwidg") #self.histdockwidg.setMaximumWidth(histwidth) self.histdockwidg.setAllowedAreas(Qt.RightDockWidgetArea) self.bkmdockwidg.setAllowedAreas(Qt.RightDockWidgetArea) self.histdockwidg.setMaximumWidth(250) self.bkmdockwidg.setMaximumWidth(250) self.histdockwidg.setMinimumWidth(200) self.bkmdockwidg.setMinimumWidth(200) #self.bkmdockwidg.setMaximumWidth(histwidth) self.histli = QListWidget() self.bkmli = QListWidget() self.histlis = [0] self.bkmlistfromfile = [] self.histdockwidg.setWidget(self.histli) self.bkmdockwidg.setWidget(self.bkmli) self.addDockWidget(Qt.RightDockWidgetArea, self.histdockwidg) self.addDockWidget(Qt.RightDockWidgetArea, self.bkmdockwidg) #file menu fi_addwrd = self.createactions("&Add a word...", self.addwrdf, "Alt+A", ":/icons/add.png", "Add a word to the dictionary. . .") fi_options = self.createactions("&Options", self.optionsf, "None", ":/icons/options.png", "Change the default settings. . .") fi_help = self.createactions("&Help", self.helpf, QKeySequence.HelpContents, ":/icons/help.png", "Help contents. . .") fi_quit = self.createactions("&Quit", self.close, QKeySequence.Close, ":/icons/quit.png", "Close the application. . .") fplus = self.createactions("FontPlus", self.fplusf, "None", ":/icons/fplus.png", "Increase the font size") fminus = self.createactions("FontMinus", self.fminusf, "None", ":/icons/fminus.png", "Decrease the font size") #list of file actions fi_menu = (fi_addwrd, fi_options, fi_help, None, fi_quit) #go menu self.go_prev = self.createactions("&Previous Word", self.prevf, "Alt+Z", ":/icons/prev.png", "Previous Word") self.go_next = self.createactions("&Next Word", self.nextf, "Alt+X", ":/icons/next.png", "Next Word") self.go_rand = self.createactions("&Random Word", self.randf, "Ctrl+R", ":/icons/rand.png", "Select a random word") #list of go actions go_menu = (self.go_prev, self.go_next, self.go_rand ) self.go_next.setEnabled(False) self.go_prev.setEnabled(False) #book mark menu self.bkm_addfav = self.createactions("&Bookmark", self.addfavf, "Ctrl+B", ":/icons/bookmark.png", "Book mark this word") self.bkm_viewbkm = self.createactions("&View Bookmarks", self.viewbkmf, "Alt+V", ":/icons/viewbkm.png", "View bookmarked words") #list of book mark items bkm_menu = (self.bkm_addfav, self.bkm_viewbkm) #help menu hlp_about = self.createactions("Abo&ut", self.aboutf, "Ctrl+U", ":/icons/about.png", "About") hlp_visitblog = self.createactions("&Visit Blog", self.visitblogf, "None", ":/icons/visitblog.png", "Visit our blog") hlp_help = self.createactions("&Help", self.helpf, "Ctrl+H", ":/icons/help.png", "Help Contents") #list of help menu items hlp_menu = (hlp_about, hlp_visitblog, hlp_help) #Setting up the menubar filemenu = self.menuBar().addMenu("&File") self.addmenu(filemenu, fi_menu) gomenu = self.menuBar().addMenu("&Go") self.addmenu(gomenu, go_menu) bkmmenu = self.menuBar().addMenu("&Book Mark") self.addmenu(bkmmenu, bkm_menu) helpmenu = self.menuBar().addMenu("&Help") self.addmenu(helpmenu, hlp_menu) intn = QSize(40, 40) self.setIconSize(intn) #Setting up the tool bar filetools = self.addToolBar("File") filetools.setObjectName("filetools") self.addmenu(filetools, (fi_addwrd, fplus, fminus)) gotools = self.addToolBar("Go") gotools.setObjectName("gotools") self.addmenu(gotools, go_menu) bkmtools = self.addToolBar("Bkm") bkmtools.setObjectName("bkmtools") self.addmenu(bkmtools, bkm_menu) hlptools = self.addToolBar("Help") hlptools.setObjectName("helptools") self.addmenu(hlptools, hlp_menu) self.loadfiles() self.returncount = 0 self.bkm_addfav.setEnabled(False) #clipboard function if self.clipauto: clip = QApplication.clipboard() cliptxt = clip.text() self.comboBox.setText(cliptxt) self.setevent() #connections self.connect(self.comboBox, SIGNAL("textChanged(QString)"), self.search) self.connect(self.comboBox, SIGNAL("returnPressed()"), self.returnpressedevent) self.connect(self.searchbtn, SIGNAL("clicked()"), self.onenter) self.connect(self.listview, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.listwidcall) self.connect(self.histli, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.listwidcall) self.connect(self.bkmli, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.listwidcall)
class mainwin(QMainWindow): def __init__(self, parent=None): super(mainwin, self).__init__(parent) self.setWindowTitle("Nigandu English to Tamil Dictionary") self.setGeometry(200, 50, 650, 600) self.setMinimumHeight(620) self.setMinimumWidth(650) self.setMaximumHeight(660) self.setMaximumWidth(800) #Setting up status bar self.myStatusBar = QStatusBar() self.myStatusBar.showMessage('Ready', 7000) self.setStatusBar(self.myStatusBar) #Setting up application icon appIcon = QIcon(":/icons/njnlogo.png") self.setWindowIcon(appIcon) # defining the central widget self.central = QWidget(self) #combobox plus search button self.whole = QVBoxLayout(self.central) self.gridlayout = QGridLayout() self.comboBox = QLineEdit(self) #self.comboBox.setEditable(True) self.comboBox.setObjectName("comboBox") self.completer = QCompleter(self.comboBox) self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setMaxVisibleItems(10) self.comboBox.setCompleter(self.completer) #self.comboBox.setCompleter() self.gridlayout.addWidget(self.comboBox, 1, 1, 1, 2) self.searchbtn = QPushButton() self.searchbtn.setObjectName("searchbtn") self.searchbtn.setText("&Search") self.gridlayout.addWidget(self.searchbtn, 1, 3) vbox = QVBoxLayout() self.tamtext = QTextBrowser() self.listview = QListWidget(self) #self.listview.setEditTriggers(QAbstractItemView.NoEditTriggers) self.listview.setWindowTitle("Suggested words") self.tamtext.setMinimumHeight(100) self.tamtext.setMaximumHeight(150) vbox.addWidget(self.tamtext) self.suglbl = QLabel(self) self.suglbl.setText("Suggested Words:") vbox.addWidget(self.suglbl) vbox.addWidget(self.listview) self.whole.addLayout(self.gridlayout) self.whole.addLayout(vbox) self.setCentralWidget(self.central) #setting docks self.histdockwidg = QDockWidget("History", self) self.bkmdockwidg = QDockWidget("Book Marks", self) self.histdockwidg.setObjectName("self.histdockwidg") self.bkmdockwidg.setObjectName("self.bkmdockwidg") #self.histdockwidg.setMaximumWidth(histwidth) self.histdockwidg.setAllowedAreas(Qt.RightDockWidgetArea) self.bkmdockwidg.setAllowedAreas(Qt.RightDockWidgetArea) self.histdockwidg.setMaximumWidth(250) self.bkmdockwidg.setMaximumWidth(250) self.histdockwidg.setMinimumWidth(200) self.bkmdockwidg.setMinimumWidth(200) #self.bkmdockwidg.setMaximumWidth(histwidth) self.histli = QListWidget() self.bkmli = QListWidget() self.histlis = [0] self.bkmlistfromfile = [] self.histdockwidg.setWidget(self.histli) self.bkmdockwidg.setWidget(self.bkmli) self.addDockWidget(Qt.RightDockWidgetArea, self.histdockwidg) self.addDockWidget(Qt.RightDockWidgetArea, self.bkmdockwidg) #file menu fi_addwrd = self.createactions("&Add a word...", self.addwrdf, "Alt+A", ":/icons/add.png", "Add a word to the dictionary. . .") fi_options = self.createactions("&Options", self.optionsf, "None", ":/icons/options.png", "Change the default settings. . .") fi_help = self.createactions("&Help", self.helpf, QKeySequence.HelpContents, ":/icons/help.png", "Help contents. . .") fi_quit = self.createactions("&Quit", self.close, QKeySequence.Close, ":/icons/quit.png", "Close the application. . .") fplus = self.createactions("FontPlus", self.fplusf, "None", ":/icons/fplus.png", "Increase the font size") fminus = self.createactions("FontMinus", self.fminusf, "None", ":/icons/fminus.png", "Decrease the font size") #list of file actions fi_menu = (fi_addwrd, fi_options, fi_help, None, fi_quit) #go menu self.go_prev = self.createactions("&Previous Word", self.prevf, "Alt+Z", ":/icons/prev.png", "Previous Word") self.go_next = self.createactions("&Next Word", self.nextf, "Alt+X", ":/icons/next.png", "Next Word") self.go_rand = self.createactions("&Random Word", self.randf, "Ctrl+R", ":/icons/rand.png", "Select a random word") #list of go actions go_menu = (self.go_prev, self.go_next, self.go_rand ) self.go_next.setEnabled(False) self.go_prev.setEnabled(False) #book mark menu self.bkm_addfav = self.createactions("&Bookmark", self.addfavf, "Ctrl+B", ":/icons/bookmark.png", "Book mark this word") self.bkm_viewbkm = self.createactions("&View Bookmarks", self.viewbkmf, "Alt+V", ":/icons/viewbkm.png", "View bookmarked words") #list of book mark items bkm_menu = (self.bkm_addfav, self.bkm_viewbkm) #help menu hlp_about = self.createactions("Abo&ut", self.aboutf, "Ctrl+U", ":/icons/about.png", "About") hlp_visitblog = self.createactions("&Visit Blog", self.visitblogf, "None", ":/icons/visitblog.png", "Visit our blog") hlp_help = self.createactions("&Help", self.helpf, "Ctrl+H", ":/icons/help.png", "Help Contents") #list of help menu items hlp_menu = (hlp_about, hlp_visitblog, hlp_help) #Setting up the menubar filemenu = self.menuBar().addMenu("&File") self.addmenu(filemenu, fi_menu) gomenu = self.menuBar().addMenu("&Go") self.addmenu(gomenu, go_menu) bkmmenu = self.menuBar().addMenu("&Book Mark") self.addmenu(bkmmenu, bkm_menu) helpmenu = self.menuBar().addMenu("&Help") self.addmenu(helpmenu, hlp_menu) intn = QSize(40, 40) self.setIconSize(intn) #Setting up the tool bar filetools = self.addToolBar("File") filetools.setObjectName("filetools") self.addmenu(filetools, (fi_addwrd, fplus, fminus)) gotools = self.addToolBar("Go") gotools.setObjectName("gotools") self.addmenu(gotools, go_menu) bkmtools = self.addToolBar("Bkm") bkmtools.setObjectName("bkmtools") self.addmenu(bkmtools, bkm_menu) hlptools = self.addToolBar("Help") hlptools.setObjectName("helptools") self.addmenu(hlptools, hlp_menu) self.loadfiles() self.returncount = 0 self.bkm_addfav.setEnabled(False) #clipboard function if self.clipauto: clip = QApplication.clipboard() cliptxt = clip.text() self.comboBox.setText(cliptxt) self.setevent() #connections self.connect(self.comboBox, SIGNAL("textChanged(QString)"), self.search) self.connect(self.comboBox, SIGNAL("returnPressed()"), self.returnpressedevent) self.connect(self.searchbtn, SIGNAL("clicked()"), self.onenter) self.connect(self.listview, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.listwidcall) self.connect(self.histli, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.listwidcall) self.connect(self.bkmli, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.listwidcall) def writehistlis(self, lis): if len(lis) >= 2: for i in range(1, len(lis)): cur.execute("insert into HISTORY values(?)", (lis[i], )) def writebkmlis(self, lis): cur.execute("delete from BOOKMARKS") if len(lis) > 0: for i in range(len(lis)): cur.execute("insert into BOOKMARKS values(?)", (lis[i], )) def listwidcall(self, item): self.comboBox.setText(item.text()) self.setevent() def search(self, text, *args): li = [] tplus = text + "%" cur.execute("select ENGW from ENGTAM where ENGW like ? limit 20", (tplus, )) cuf = cur.fetchall() model = QStringListModel() for i in range(len(cuf)): k = cuf[i][0] li.append(k) model.setStringList(li) self.completer.setModel(model) def returnpressedevent(self, *args): self.comboBox.selectAll() self.returncount += 1 if self.returncount % 2 == 0: self.setevent() else: self.comboBox.selectAll() def setevent(self): self.comboBox.selectAll() self.bkm_addfav.setEnabled(True) lis = [] eng = self.comboBox.text() cur.execute("SELECT rowid, TAMW FROM ENGTAM WHERE ENGW like ? limit 1", (eng,)) cuf = cur.fetchall() if len(cuf) == 0: self.tamtext.setText("No words found. . . ") self.listview.addItem("No Suggestions. . .") else: for i in range(len(cuf)): tam = cuf[0][1] rowid = cuf[0][0] self.tamtext.setText(tam) if rowid <= 25: start = 0 end = 50 elif rowid >= 190513: start = rowid - 190487 end = rowid + 190537 else: start = rowid - 25 end = rowid + 25 cur.execute("SELECT ENGW FROM ENGTAM WHERE rowid>=? and rowid<=?", (start, end, )) cuff = cur.fetchall() for i in range(len(cuff)): engw = cuff[i][0] lis.append(engw) if self.listview.count() is not None: self.listview.clear() self.listview.addItems(lis) self.addtoli(eng, self.histlis) if self.histlis[0] >= 2: self.go_prev.setEnabled(True) self.comboBox.setFocus() if self.histdock: self.histli.addItem(eng) def addtoli(self, addw, lis, c=1): if len(lis) > 0: if type(lis[0]) == int: if len(lis) >= 2: for i in range(1, len(lis)): if lis[i] == addw: c = 0 pass if c == 1: lis.append(addw) else: lis.append(addw) lis[0] = len(lis) - 1 def addtobkmli(self, addw, lis, nc=1): for i in range(len(lis)): if lis[i] == addw: nc = 0 pass if nc == 1: lis.append(addw) def onenter(self, *args): self.comboBox.selectAll() self.setevent() def loadfiles(self): self.loadsettings() self.loadhistlis() self.loadbkm() self.setfontsize(int(self.fontsize)) self.setdocks() def setdocks(self): ist = str(self.histdock) jst = str(self.bkmdock) if ist == "False": self.removedock(self.histdockwidg) else: self.adddock(self.histdockwidg) if jst == "False": self.removedock(self.bkmdockwidg) else: self.adddock(self.bkmdockwidg) def loadsettings(self): cur.execute("select * from SETTINGS") cuffun = cur.fetchall() fn = int(cuffun[0][1]) self.fontsize = fn self.clipauto = cuffun[1][1] self.histdock = cuffun[2][1] self.savehist = cuffun[3][1] self.bkmdock = cuffun[4][1] self.delhist = cuffun[5][1] self.delbkm = cuffun[6][1] def loadhistlis(self): histtodockli = [] cur.execute("select * from HISTORY") historyfetch = cur.fetchall() for i in range(len(historyfetch)): self.addtobkmli(historyfetch[i][0], histtodockli) for i in histtodockli: self.histli.addItem(i) def loadbkm(self): cur.execute("select * from BOOKMARKS") bkmfetch = cur.fetchall() for i in range(len(bkmfetch)): self.addtobkmli(bkmfetch[i][0], self.bkmlistfromfile) for i in self.bkmlistfromfile: self.bkmli.addItem(i) def createactions(self, text, slot=None, shortcut="None", icon=None, tip=None, checkable=False, signal="triggered()"): action = QAction(text, self) if icon is not None: action.setIcon(QIcon(icon)) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if slot is not None: self.connect(action, SIGNAL(signal), slot) if checkable: action.setCheckable(True) return action def addmenu(self, target, actions): for action in actions: if action is None: target.addSeparator() else: target.addAction(action) #Actions def addwrdf(self): self.dlg = addawrd() self.dlg.show() self.connect(self.dlg.buttonBox, SIGNAL("rejected()"), self.dlg.close) self.connect(self.dlg.buttonBox, SIGNAL("accepted()"), self.addawordtodb) def addawordtodb(self): eng = self.dlg.lineEdit.text() tam = self.dlg.lineEdit_2.text() if len(eng) != 0 and len(tam) != 0: cur.execute("INSERT INTO ENGTAM(ENGW, TAMW) VALUES(?, ?)", (eng, tam, )) self.dlg.close() QMessageBox.information(self, "Nigandu Eng -> Tam Dictionary", "Added Successfully. . .") else: self.dlg.lineEdit.setFocus() self.dlg.close() QMessageBox.warning(self, "Nigandu Eng -> Tam Dictionary", "Invalid Entry. . .") def optionsf(self): self.opt = optdlg(self) self.opt.spinBox.setProperty("value", int(self.fontsize)) font = QFont() font.setPixelSize(int(self.fontsize)) self.opt.sampletxt.setFont(font) if str(self.clipauto) == "True": self.opt.checkclip.setChecked(True) elif str(self.clipauto) == "False": self.opt.checkclip.setChecked(False) if str(self.histdock) == "True": self.opt.checkshowhistdock.setChecked(True) elif str(self.histdock) == "False": self.opt.checkshowhistdock.setChecked(False) if str(self.bkmdock) == "True": self.opt.checkshowbkmdock.setChecked(True) elif str(self.bkmdock) == "False": self.opt.checkshowbkmdock.setChecked(False) self.opt.show() self.connect(self.opt.buttonBox, SIGNAL("accepted()"), self.optok) self.connect(self.opt.buttonBox.button(QDialogButtonBox.Apply), SIGNAL("clicked()"), self.optapply) self.connect(self.opt.checkdelhist, SIGNAL("stateChanged(int)"), self.deleteallhist) self.connect(self.opt.checkshowhistdock, SIGNAL("stateChanged(int)"), self.shownexttime) self.connect(self.opt.checkshowbkmdock, SIGNAL("stateChanged(int)"), self.shownexttime) def shownexttime(self, i): if i == 0: pass if i == 2: QMessageBox.information(self, self.windowTitle(), "Click Apply or Ok \n The Dock window will be added, \n the next time you start the application. . .") def optok(self): self.optapply() self.opt.close() def optapply(self): self.updatesettings() self.applyopt() def updatesettings(self): self.fontsize = self.opt.spinBox.value() self.clipauto = self.opt.checkclip.isChecked() self.histdock = self.opt.checkshowhistdock.isChecked() self.bkmdock = self.opt.checkshowbkmdock.isChecked() self.delhist = self.opt.checkdelhist.isChecked() for i, j in [("fontsize", self.fontsize),("clipauto", str(self.clipauto)),("histdock", str(self.histdock)), ("bkmdock", str(self.bkmdock)),("delhist", str(self.delhist))]: cur.execute("UPDATE SETTINGS SET setting=? WHERE field=?", (j, i, )) def applyopt(self): self.loadsettings() self.setfontsize(int(self.fontsize)) if str(self.bkmdock) == "False" or str(self.histdock) == "False": self.setdocks() def removedock(self, dock): self.removeDockWidget(dock) def adddock(self, dock): self.addDockWidget(Qt.RightDockWidgetArea, dock) def deleteallhist(self, i): if i == 0: pass elif i == 2: self.histli.clear() self.histlis = [0] cur.execute("delete from HISTORY") QMessageBox.information(self, self.windowTitle(), "All the History Records are deleted. . .") def setfontsize(self, i): if i >= 8 or i <= 24: font = QFont() font.setPixelSize(i) self.comboBox.setFont(font) self.searchbtn.setFont(font) self.bkmli.setFont(font) self.histli.setFont(font) self.listview.setFont(font) self.tamtext.setFont(font) def helpf(self): form = helpform.HelpForm("index.html", self) form.show() def closeEvent(self, *args, **kwargs): self.writehistlis(self.histlis) self.writebkmlis(self.bkmlistfromfile) for i, j in [("fontsize", int(self.fontsize)),("clipauto", str(self.clipauto)),("histdock", str(self.histdock)), ("bkmdock", str(self.bkmdock)),("delhist", str(self.delhist))]: cur.execute("UPDATE SETTINGS SET setting=? WHERE field=?", (j, i, )) con.commit() con.close() def fplusf(self): self.fontsize += 1 if self.fontsize <= 24: self.setfontsize(self.fontsize) def fminusf(self): self.fontsize -= 1 if self.fontsize >= 10: self.setfontsize(self.fontsize) def prevf(self): pr = self.histlis[0] - 1 if pr > 1: self.comboBox.setText(self.histlis[pr]) self.setevent() self.histlis[0] = pr self.go_next.setEnabled(True) elif pr == 1: self.comboBox.setText(self.histlis[pr]) self.setevent() self.histlis[0] = pr self.go_next.setEnabled(True) self.go_prev.setEnabled(False) else: pass def nextf(self): pr = self.histlis[0] + 1 if pr < len(self.histlis) - 1: self.comboBox.setText(self.histlis[pr]) self.setevent() self.histlis[0] = pr self.go_prev.setEnabled(True) elif pr == len(self.histlis) - 1: self.comboBox.setText(self.histlis[pr]) self.setevent() self.histlis[0] = pr self.go_prev.setEnabled(True) self.go_next.setEnabled(False) else: pass def randf(self): import random n = random.randrange(190538) cur.execute("select ENGW from ENGTAM where rowid = ?", (n, )) cuf = cur.fetchone() self.comboBox.setText(cuf[0]) self.setevent() def addfavf(self): txt = self.comboBox.text() if len(txt) != 0: self.addtobkmli(txt, self.bkmlistfromfile) self.writetolistwidget(self.bkmlistfromfile, self.bkmli) def sortit(self): self.bkmlistfromfile.sort() self.writetolistwidget(self.bkmlistfromfile, self.form.listWidget) self.writetolistwidget(self.bkmlistfromfile, self.bkmli) cur.execute("delete from BOOKMARKS") def writetolistwidget(self, lis, liswid): liswid.clear() for i in lis: liswid.addItem(i) def deletecurrentbkm(self): ct = self.form.listWidget.currentItem().text() self.bkmlistfromfile.remove(ct) self.writetolistwidget(self.bkmlistfromfile, self.bkmli) self.writetolistwidget(self.bkmlistfromfile, self.form.listWidget) cur.execute("delete from BOOKMARKS") def deleteallbkm(self): self.form.listWidget.clear() self.bkmli.clear() self.bkmlistfromfile = [] cur.execute("delete from BOOKMARKS") def viewbkmf(self): self.form = managebkm(self) self.writetolistwidget(self.bkmlistfromfile, self.form.listWidget) self.form.show() self.connect(self.form.closebtn, SIGNAL("clicked()"), self.form.close) self.connect(self.form.sortbtn, SIGNAL("clicked()"), self.sortit) self.connect(self.form.deletebtn, SIGNAL("clicked()"), self.deletecurrentbkm) self.connect(self.form.deleteallbtn, SIGNAL("clicked()"), self.deleteallbkm) def aboutf(self): QMessageBox.about(self, "About Nigandu English to Tamil Dictionary", """<b>Nigandu English to Tamil Dictionary</b> v %s <p>This is the first corss-platform English to Tamil bilingual dictionary; Free to use.</p> <p>Copyright © 2014 NJN Private Ltd. All rights reserved.</p> <p>Thanks to Python and PySide Project.</p> <p>Using Python 3.3, Qt 4.8 and PySide 1.2.1</p>""" % (__version__)) def visitblogf(self): webbrowser.open("http://www.e-nool.blogspot.com")
def __init__(self, p_size): QDockWidget.__init__(self) self.__size = p_size
class QtTrajectoryViewer(QMainWindow): """Bases: `PySide.QtGui.QMainWindow` Interface for viewing trajectory. It provides interface elements to play/pause and set the speed of the animation. **Example** To set up a QtTrajectoryViewer you have to add renderers to the scene, set the number of frames present in the animation by calling ;py:meth:`~chemlab.graphics.QtTrajectoryViewer.set_ticks` and define an update function. Below is an example taken from the function :py:func:`chemlab.graphics.display_trajectory`:: from chemlab.graphics import QtTrajectoryViewer # sys = some System # coords_list = some list of atomic coordinates v = QtTrajectoryViewer() sr = v.add_renderer(AtomRenderer, sys.r_array, sys.type_array, backend='impostors') br = v.add_renderer(BoxRenderer, sys.box_vectors) v.set_ticks(len(coords_list)) @v.update_function def on_update(index): sr.update_positions(coords_list[index]) br.update(sys.box_vectors) v.set_text(format_time(times[index])) v.widget.repaint() v.run() .. warning:: Use with caution, the API for this element is not fully stabilized and may be subject to change. """ 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) def set_ticks(self, number): '''Set the number of frames to animate. ''' self.max_index = number self.current_index = 0 self.slider.setMaximum(self.max_index - 1) self.slider.setMinimum(0) self.slider.setPageStep(1) def set_text(self, text): '''Update the time indicator in the interface.''' self.timelabel.setText(self._label_tmp.format(text)) def on_play(self): if self.current_index == self.max_index - 1: # Restart self.current_index = 0 self._timer.start(self.speed) def do_update(self): if self.current_index >= self.max_index: self.current_index = self.max_index - 1 self._timer.stop() self.play_stop.set_pause() else: self.current_index += 1 self.slider.setSliderPosition(self.current_index) def on_pause(self): self._timer.stop() def on_slider_change(self, value): #print 'Slider moved', value self.current_index = value self._update_function(self.current_index) def on_slider_down(self): self._timer.stop() self.play_stop.set_pause() def on_speed_changed(self, index): self.speed = self.speeds[index] if self._timer.isActive(): self._timer.stop() self._timer.start(self.speed) def add_renderer(self, klass, *args, **kwargs): '''The behaviour of this function is the same as :py:meth:`chemlab.graphics.QtViewer.add_renderer`. ''' renderer = klass(self.widget, *args, **kwargs) self.widget.renderers.append(renderer) return renderer def add_ui(self, klass, *args, **kwargs): '''Add an UI element for the current scene. The approach is the same as renderers. .. warning:: The UI api is not yet finalized ''' ui = klass(self.widget, *args, **kwargs) self.widget.uis.append(ui) return ui def add_post_processing(self, klass, *args, **kwargs): pp = klass(self.widget, *args, **kwargs) self.widget.post_processing.append(pp) return pp def run(self): app.exec_() def update_function(self, func): '''Set the function to be called when it's time to display a frame. *func* should be a function that takes one integer argument that represents the frame that has to be played:: def func(index): # Update the renderers to match the # current animation index ''' self._update_function = func def _toggle_settings(self): self._settings_pan.setVisible(not self._settings_pan.isVisible())
class QtTrajectoryViewer(QMainWindow): """Bases: `PySide.QtGui.QMainWindow` Interface for viewing trajectory. It provides interface elements to play/pause and set the speed of the animation. **Example** To set up a QtTrajectoryViewer you have to add renderers to the scene, set the number of frames present in the animation by calling ;py:meth:`~chemlab.graphics.QtTrajectoryViewer.set_ticks` and define an update function. Below is an example taken from the function :py:func:`chemlab.graphics.display_trajectory`:: from chemlab.graphics import QtTrajectoryViewer # sys = some System # coords_list = some list of atomic coordinates v = QtTrajectoryViewer() sr = v.add_renderer(AtomRenderer, sys.r_array, sys.type_array, backend='impostors') br = v.add_renderer(BoxRenderer, sys.box_vectors) v.set_ticks(len(coords_list)) @v.update_function def on_update(index): sr.update_positions(coords_list[index]) br.update(sys.box_vectors) v.set_text(format_time(times[index])) v.widget.repaint() v.run() .. warning:: Use with caution, the API for this element is not fully stabilized and may be subject to change. """ 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 set_ticks(self, number): self.traj_controls.set_ticks(number) def set_text(self, text): '''Update the time indicator in the interface. ''' self.traj_controls.timelabel.setText(self.traj_controls._label_tmp.format(text)) def on_frame_changed(self, index): self._update_function(index) def on_pause(self): self._timer.stop() def on_slider_change(self, value): self.current_index = value self._update_function(self.current_index) def on_slider_down(self): self._timer.stop() self.play_stop.set_pause() def on_speed_changed(self, index): self.speed = self.speeds[index] if self._timer.isActive(): self._timer.stop() self._timer.start(self.speed) def add_renderer(self, klass, *args, **kwargs): '''The behaviour of this function is the same as :py:meth:`chemlab.graphics.QtViewer.add_renderer`. ''' renderer = klass(self.widget, *args, **kwargs) self.widget.renderers.append(renderer) return renderer def add_ui(self, klass, *args, **kwargs): '''Add an UI element for the current scene. The approach is the same as renderers. .. warning:: The UI api is not yet finalized ''' ui = klass(self.widget, *args, **kwargs) self.widget.uis.append(ui) return ui def add_post_processing(self, klass, *args, **kwargs): pp = klass(self.widget, *args, **kwargs) self.widget.post_processing.append(pp) return pp def run(self): app.exec_() def update_function(self, func, frames=None): '''Set the function to be called when it's time to display a frame. *func* should be a function that takes one integer argument that represents the frame that has to be played:: def func(index): # Update the renderers to match the # current animation index ''' # Back-compatibility if frames is not None: self.traj_controls.set_ticks(frames) self._update_function = func def _toggle_settings(self): self._settings_pan.setVisible(not self._settings_pan.isVisible())
def _init_widgets(self): main = QMainWindow() main.setWindowFlags(Qt.Widget) # main.setCorner(Qt.TopLeftCorner, Qt.TopDockWidgetArea) # main.setCorner(Qt.TopRightCorner, Qt.RightDockWidgetArea) pathtree = QPathTree(self, self.workspace, parent=main) pathtree_dock = QDockWidget('PathTree', pathtree) main.setCentralWidget(pathtree_dock) # main.addDockWidget(Qt.BottomDockWidgetArea, pathtree_dock) pathtree_dock.setWidget(pathtree) simgrs_logic = self.workspace.instance.simgrs if self.workspace.instance is not None else None simgrs = QSimulationManagers(simgrs_logic, main) pathgroups_dock = QDockWidget('SimulationManagers', simgrs) main.addDockWidget(Qt.RightDockWidgetArea, pathgroups_dock) pathgroups_dock.setWidget(simgrs) reg_viewer = QRegisterViewer(self) reg_viewer_dock = QDockWidget('Register Viewer', reg_viewer) main.addDockWidget(Qt.RightDockWidgetArea, reg_viewer_dock) reg_viewer_dock.setWidget(reg_viewer) mem_viewer = QMemoryViewer(self) mem_viewer_dock = QDockWidget('Memory Viewer', mem_viewer) main.addDockWidget(Qt.RightDockWidgetArea, mem_viewer_dock) mem_viewer_dock.setWidget(mem_viewer) vextemps_viewer = QVEXTempsViewer(self) vextemps_viewer_dock = QDockWidget('VEX Temps Viewer', vextemps_viewer) main.addDockWidget(Qt.RightDockWidgetArea, vextemps_viewer_dock) vextemps_viewer_dock.setWidget(vextemps_viewer) main.tabifyDockWidget(reg_viewer_dock, mem_viewer_dock) main.tabifyDockWidget(mem_viewer_dock, vextemps_viewer_dock) reg_viewer_dock.raise_() self._pathtree = pathtree self._simgrs = simgrs self._register_viewer = reg_viewer self._memory_viewer = mem_viewer self._vextemps_viewer = vextemps_viewer main_layout = QHBoxLayout() main_layout.addWidget(main) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout)
class ConsoleWidget(QMainWindow): def __init__(self): super(ConsoleWidget, self).__init__() self.setWindowTitle('1c query') self._connection = None self._home = os.path.expanduser('~/%s' % QApplication.applicationName()) if not os.path.isdir(self._home): os.mkdir(self._home) self.queryToolBar = self.addToolBar('Query') self.queryAction = self.queryToolBar.addAction('Run', self.executeQuery) self.queryAction.setDisabled(True) uri_history = list() path = os.path.join(self._home, 'uri_history.txt') if os.path.isfile(path): uri_history = open(path, 'r').read().split('\n') self.connectionToolBar = self.addToolBar('Connection') self.connectionUriCombo = QComboBox(self) self.connectionUriCombo.setEditable(True) if not uri_history: self.connectionUriCombo.addItem('File="";usr="";pwd="";') self.connectionUriCombo.addItem('Srvr="{host}";Ref="{ref}";Usr="******";Pwd="{password}";') else: self.connectionUriCombo.addItems(uri_history) self.connectionUriCombo.setCurrentIndex(len(uri_history) - 1) self.connectionUriCombo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) self.connectionToolBar.addWidget(self.connectionUriCombo) self.onesVersionCombo = QComboBox(self) self.onesVersionCombo.addItems(['8.3', '8.2', '8.1', '8.0']) self.onesVersionCombo.setCurrentIndex(0) self.connectionToolBar.addWidget(self.onesVersionCombo) self.connectAction = self.connectionToolBar.addAction('Connect', self.connectOneS) self.disconnectAction = self.connectionToolBar.addAction('Disconnect', self.disconnectOneS) self.disconnectAction.setDisabled(True) self.logEdit = QPlainTextEdit(self) self.logDock = QDockWidget('Log', self) self.logDock.setWidget(self.logEdit) self.addDockWidget(Qt.BottomDockWidgetArea, self.logDock, Qt.Horizontal) self.splitter = QSplitter(Qt.Vertical, self) self.setCentralWidget(self.splitter) self.sqlEdit = QTextEdit(self) self.sqlEdit.setLineWrapMode(QTextEdit.NoWrap) path = os.path.join(self._home, 'last-sql.txt') if os.path.isfile(path): sql = open(path, 'r').read() self.sqlEdit.setText(sql) self.model = QStandardItemModel(self) self.tableView = QTableView(self) self.tableView.setModel(self.model) self.splitter.addWidget(self.sqlEdit) self.splitter.addWidget(self.tableView) self.splitter.setStretchFactor(0, 3) self.splitter.setStretchFactor(1, 2) def query(self, sql): if not self._connection: self.logEdit.appendPlainText('No connection') return None try: query = self._connection.NewObject('Query', sql) result = query.Execute() except Exception as e: self.logEdit.appendPlainText(str(e)) return None return result def refresh(self, result): self.model.clear() columns = list() result_columns = result.Columns for index in range(result_columns.Count()): name = result_columns.Get(index).Name columns.append(name) self.model.setColumnCount(len(columns)) for section, name in enumerate(columns): self.model.setHeaderData(section, Qt.Horizontal, name) select = result.Choose() self.logEdit.appendPlainText('Selected %d records' % select.Count()) while select.Next(): items = list() for index in range(len(columns)): value = select.Get(index) item = QStandardItem('') if isinstance(value, bool): item.setText(value and 'Yes' or 'No') elif isinstance(value, (int, str)): item.setText(str(value)) elif isinstance(value, datetime.datetime): item.setText(value.strftime('%Y.%m.%d %H:%M:%S')) else: item.setText(str(value)) items.append(item) self.model.appendRow(items) @Slot() def executeQuery(self): sql = self.sqlEdit.toPlainText() result = self.query(sql) if result: path = os.path.join(self._home, 'last-sql.txt') open(path, 'w').write(sql) self.refresh(result) @Slot() def connectOneS(self): uri = self.connectionUriCombo.currentText().strip() if not uri: self.logEdit.appendPlainText('Need a connection string') return version = self.onesVersionCombo.currentText() comName = "V%s.COMConnector" % str(version).replace('.', '') pythoncom.CoInitialize() try: obj = win32com.client.Dispatch(comName) self._connection = obj.Connect(uri) except Exception as e: self.logEdit.appendPlainText(str(e)) return self.connectAction.setDisabled(True) self.disconnectAction.setEnabled(True) self.queryAction.setEnabled(True) uri_history = list() for i in range(self.connectionUriCombo.count()): uri_history.append(self.connectionUriCombo.itemText(i)) if uri not in uri_history: self.connectionUriCombo.clearEditText() self.connectionUriCombo.addItem(uri) self.connectionUriCombo.setCurrentIndex(len(uri_history)) uri_history.append(uri) path = os.path.join(self._home, 'uri_history.txt') open(path, 'w').write('\n'.join(uri_history)) @Slot() def disconnectOneS(self): pythoncom.CoUninitialize() self._connection = None self.connectAction.setEnabled(True) self.disconnectAction.setDisabled(True) self.queryAction.setDisabled(True)
def initDock (self ): dock =QDockWidget ("binctrl",self ) dock .setAllowedAreas (Qt .TopDockWidgetArea |Qt .BottomDockWidgetArea ) dock .setWidget (QkFoBoard ()) self .addDockWidget (Qt .BottomDockWidgetArea ,dock )
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '--qt_from', default='pyqt', choices=['pyqt', 'pyqt5', 'pyside', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument( '--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyside() elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt() elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt5_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt5_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt5() elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_qtpy_ui import Ui_DockWidget as ui_widgets from ui.dw_views_qtpy_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_qtpy_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_qtpy_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment() elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt.QtGui import QApplication, QMainWindow, QDockWidget from pyqtgraph.Qt.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize #from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_menus_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqtgraph_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqtgraph_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if args.no_dark: style = '' def write_settings(window): """Get window settings and write it into a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') settings.setValue('pos', window.pos()) settings.setValue('size', window.size()) settings.setValue('state', window.saveState()) def read_settings(window): """Read and set window settings from a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') if args.qt_from == 'pyside': pos = settings.value('pos', window.pos()) size = settings.value('size', window.size()) state = settings.value('state', window.saveState()) else: pos = settings.value('pos', window.pos(), type='QPoint') size = settings.value('size', window.size(), type='QSize') state = settings.value('state', window.saveState(), type='QByteArray') window.restoreState(state) window.resize(size) window.move(pos) # create the application app = QApplication(sys.argv) app.setOrganizationName('QDarkStyle') app.setApplicationName('QDarkStyle Example') # setup stylesheet app.setStyleSheet(style) # create main window window = QMainWindow() window.setObjectName('mainwindow') ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__ + " - Example - Using " + args.qt_from) # create docks for buttons dw_buttons = QDockWidget() dw_buttons.setObjectName('buttons') ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() dw_displays.setObjectName('displays') ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - fields dw_inputs_fields = QDockWidget() dw_inputs_fields.setObjectName('_fields') ui_inputs_fields = ui_inputs_fields() ui_inputs_fields.setupUi(dw_inputs_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_fields) # create docks for inputs - no fields dw_inputs_no_fields = QDockWidget() dw_inputs_no_fields.setObjectName('inputs_no_fields') ui_inputs_no_fields = ui_inputs_no_fields() ui_inputs_no_fields.setupUi(dw_inputs_no_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_fields) # create docks for widgets dw_widgets = QDockWidget() dw_widgets.setObjectName('widgets') ui_widgets = ui_widgets() ui_widgets.setupUi(dw_widgets) window.addDockWidget(Qt.LeftDockWidgetArea, dw_widgets) # create docks for views dw_views = QDockWidget() dw_views.setObjectName('views') ui_views = ui_views() ui_views.setupUi(dw_views) window.addDockWidget(Qt.LeftDockWidgetArea, dw_views) # create docks for containters - tabs dw_containers_tabs = QDockWidget() dw_containers_tabs.setObjectName('containers') ui_containers_tabs = ui_containers_tabs() ui_containers_tabs.setupUi(dw_containers_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_tabs) # create docks for containers - no tabs dw_containers_no_tabs = QDockWidget() dw_containers_no_tabs.setObjectName('containers_no_tabs') ui_containers_no_tabs = ui_containers_no_tabs() ui_containers_no_tabs.setupUi(dw_containers_no_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_no_tabs) # tabify right docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs_fields) window.tabifyDockWidget(dw_inputs_fields, dw_inputs_no_fields) # auto quit after 2s when testing on travis-ci if "--test" in sys.argv: QTimer.singleShot(2000, app.exit) # run read_settings(window) window.showMaximized() app.exec_() write_settings(window)
def createDockWindows(self): #dock = QDockWidget("Tokens", self) #dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) #dock.setWidget(self.tokenTable) #self.addDockWidget(Qt.RightDockWidgetArea, dock) #self.viewMenu.addAction(dock.toggleViewAction()) dock = QDockWidget("Spectrogram", self) self.specgramWindow = SpecgramWidget(parent=dock) dock.setWidget(self.specgramWindow) self.addDockWidget(Qt.RightDockWidgetArea, dock) self.viewMenu.addAction(dock.toggleViewAction()) dock = QDockWidget("Auditory Representation", self) self.representationWindow = RepresentationWidget(parent=dock) dock.setWidget(self.representationWindow) self.addDockWidget(Qt.RightDockWidgetArea, dock) self.viewMenu.addAction(dock.toggleViewAction()) dock = QDockWidget("Distance", self) self.distanceWindow = DistanceWidget(parent=dock) dock.setWidget(self.distanceWindow) self.addDockWidget(Qt.RightDockWidgetArea, dock) self.viewMenu.addAction(dock.toggleViewAction())
def _init_widgets(self): main = QMainWindow() main.setWindowFlags(Qt.Widget) # main.setCorner(Qt.TopLeftCorner, Qt.TopDockWidgetArea) # main.setCorner(Qt.TopRightCorner, Qt.RightDockWidgetArea) pathtree = QPathTree(self, self.workspace, parent=main) pathtree_dock = QDockWidget('PathTree', pathtree) main.setCentralWidget(pathtree_dock) # main.addDockWidget(Qt.BottomDockWidgetArea, pathtree_dock) pathtree_dock.setWidget(pathtree) simgrs_logic = self.workspace.instance.simgrs if self.workspace.instance is not None else None simgrs = QSimulationManagers(simgrs_logic, main) pathgroups_dock = QDockWidget('SimulationManagers', simgrs) main.addDockWidget(Qt.RightDockWidgetArea, pathgroups_dock) pathgroups_dock.setWidget(simgrs) state_viewer = StateInspector(self.workspace, parent=self) state_viewer_dock = QDockWidget('Selected State', state_viewer) main.addDockWidget(Qt.RightDockWidgetArea, state_viewer_dock) state_viewer_dock.setWidget(state_viewer) self._pathtree = pathtree self._simgrs = simgrs self._state_viewer = state_viewer main_layout = QHBoxLayout() main_layout.addWidget(main) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout)