def __init__(self, parent=None): QTabWidget.__init__(self, parent) self.setTabBar(TabBarSupport(self)) self.setMovable(False) self.setTabsClosable(True) self.setDocumentMode(False) self.navigationButton = QPushButton( QIcon(getPath('iconDir', 'navigation.png')), "", self) self.navigationButton.setFlat(True) self.closeButton = QPushButton( QIcon(getPath('iconDir', 'navclose.png')), "", self) self.closeButton.setFlat(True) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setMargin(0) self.rightCornerWidgetLayout.setSpacing(0) self.rightCornerWidgetLayout.addWidget(self.navigationButton) self.rightCornerWidgetLayout.addWidget(self.closeButton) self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) QObject.connect(self.navigationButton, SIGNAL("pressed()"), self.__evt_navigation) QObject.connect( self.closeButton, SIGNAL("clicked(bool)"), lambda: self.emit( SIGNAL("tabCloseRequested (int)"), self.currentIndex())) QObject.connect(self, SIGNAL("tabCloseRequested (int)"), self.__evt_close_tab_click) QObject.connect(self.tabBar(), SIGNAL('customContextMenuRequested(const QPoint &)'), self.__evt_showContextMenu)
def test_toolbox(self): w = QWidget() layout = QHBoxLayout() reg = registry_tests.small_testing_registry() qt_reg = QtWidgetRegistry(reg) triggered_actions = [] model = qt_reg.model() one_action = qt_reg.action_for_widget("one") box = WidgetToolBox() box.setModel(model) box.triggered.connect(triggered_actions.append) layout.addWidget(box) box.setButtonSize(QSize(50, 80)) w.setLayout(layout) w.show() one_action.trigger() box.setButtonSize(QSize(60, 80)) box.setIconSize(QSize(35, 35)) box.setTabButtonHeight(40) box.setTabIconSize(QSize(30, 30)) self.app.exec_()
def __init__(self, parent): QWidget.__init__(self, parent) self._layout = QHBoxLayout(self) self._label = QLabel("Very important option", self) self._layout.addWidget(self._label) self.edit = QLineEdit(self) self._layout.addWidget(self.edit)
class SettingsPage(QWidget): """Settings page for Hello World plugin """ def __init__(self, parent): QWidget.__init__(self, parent) self._layout = QHBoxLayout(self) self._label = QLabel("Very important option", self) self._layout.addWidget(self._label) self.edit = QLineEdit(self) self._layout.addWidget(self.edit)
def __init__(self, parent): super(SchemesManagerWidget, self).__init__(parent, Qt.Dialog) self.setWindowTitle(translations.TR_EDITOR_SCHEMES) self.resize(700, 500) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) # Footer hbox = QHBoxLayout() btn_close = QPushButton(self.tr('Close')) btnReload = QPushButton(self.tr("Reload")) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.show() self._schemes = [] self._loading = True self.downloadItems = [] #Load Themes with Thread self.connect(btnReload, SIGNAL("clicked()"), self._reload_themes) self._thread = ui_tools.ThreadExecution(self.execute_thread) self.connect(self._thread, SIGNAL("finished()"), self.load_skins_data) self.connect(btn_close, SIGNAL('clicked()'), self.close) self._reload_themes()
def __init__(self,parent=None): QTabWidget.__init__(self,parent) self.setTabBar(TabBarSupport(self)) self.setMovable(False) self.setTabsClosable(True) self.setDocumentMode(False) self.navigationButton = QPushButton(QIcon(getPath('iconDir','navigation.png')),"",self) self.navigationButton.setFlat(True) self.closeButton = QPushButton(QIcon(getPath('iconDir','navclose.png')),"",self) self.closeButton.setFlat(True) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setMargin(0) self.rightCornerWidgetLayout.setSpacing(0) self.rightCornerWidgetLayout.addWidget(self.navigationButton) self.rightCornerWidgetLayout.addWidget(self.closeButton) self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) QObject.connect(self.navigationButton, SIGNAL("pressed()"),self.__evt_navigation) QObject.connect(self.closeButton, SIGNAL("clicked(bool)"),lambda:self.emit(SIGNAL("tabCloseRequested (int)"),self.currentIndex())) QObject.connect(self, SIGNAL("tabCloseRequested (int)"),self.__evt_close_tab_click) QObject.connect(self.tabBar(), SIGNAL('customContextMenuRequested(const QPoint &)'),self.__evt_showContextMenu)
def __init__(self): QDialog.__init__(self) self.setWindowTitle(translations.TR_PLUGIN_ERROR_REPORT) self.resize(600, 400) vbox = QVBoxLayout(self) label = QLabel(translations.TR_SOME_PLUGINS_REMOVED) vbox.addWidget(label) self._tabs = QTabWidget() vbox.addWidget(self._tabs) hbox = QHBoxLayout() btnAccept = QPushButton(translations.TR_ACCEPT) btnAccept.setMaximumWidth(100) hbox.addWidget(btnAccept) vbox.addLayout(hbox) #signals self.connect(btnAccept, SIGNAL("clicked()"), self.close)
def __init__(self, parent=None): super(MigrationWidget, self).__init__(parent, Qt.WindowStaysOnTopHint) self._migration, vbox, hbox = {}, QVBoxLayout(self), QHBoxLayout() lbl_title = QLabel(translations.TR_CURRENT_CODE) lbl_suggestion = QLabel(translations.TR_SUGGESTED_CHANGES) self.current_list, self.suggestion = QListWidget(), QPlainTextEdit() self.suggestion.setReadOnly(True) self.btn_apply = QPushButton(translations.TR_APPLY_CHANGES + " !") self.suggestion.setToolTip(translations.TR_SAVE_BEFORE_APPLY + " !") self.btn_apply.setToolTip(translations.TR_SAVE_BEFORE_APPLY + " !") # pack up all widgets hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(self.btn_apply) vbox.addWidget(lbl_title) vbox.addWidget(self.current_list) vbox.addWidget(lbl_suggestion) vbox.addWidget(self.suggestion) vbox.addLayout(hbox) # connections self.connect(self.current_list, SIGNAL("itemClicked(QListWidgetItem*)"), self.load_suggestion) self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_changes) # registers IDE.register_service('tab_migration', self) ExplorerContainer.register_tab(translations.TR_TAB_MIGRATION, self)
def test_drop_shadow_old(self): w = dropshadow._DropShadowWidget() w.setContentsMargins(20, 20, 20, 20) w.setLayout(QHBoxLayout()) w.layout().setContentsMargins(0, 0, 0, 0) w.layout().addWidget(QListView()) w.show() QTimer.singleShot(1500, lambda: w.setRadius(w.radius + 5)) self.app.exec_()
def __init__(self, parent=None): super(Form, self).__init__(parent) # self.le = QLabel() self.le = QLineEdit() self.le.setObjectName("Empty") self.le.setText("Empty") self.pb = QPushButton() self.pb.setObjectName("browse") self.pb.setText("Browse") layout = QHBoxLayout() layout.addWidget(self.le) layout.addWidget(self.pb) self.setLayout(layout) self.connect(self.pb, SIGNAL("clicked()"), self.button_click) self.setWindowTitle("Learning")
def __init__(self, requirements_dict): super(DependenciesHelpDialog, self).__init__() self.setWindowTitle(translations.TR_REQUIREMENTS) self.resize(525, 400) vbox = QVBoxLayout(self) label = QLabel(translations.TR_SOME_PLUGINS_NEED_DEPENDENCIES) vbox.addWidget(label) self._editor = QPlainTextEdit() self._editor.setReadOnly(True) vbox.addWidget(self._editor) hbox = QHBoxLayout() btnAccept = QPushButton(translations.TR_ACCEPT) btnAccept.setMaximumWidth(100) hbox.addWidget(btnAccept) vbox.addLayout(hbox) #signals self.connect(btnAccept, SIGNAL("clicked()"), self.close) command_tmpl = "<%s>:\n%s\n" for name, description in list(requirements_dict.items()): self._editor.insertPlainText(command_tmpl % (name, description))
def __init__(self, sliderOrientation=None): super(QLabelSlider, self).__init__() self._slider = QSlider(sliderOrientation) self.setLayout(QVBoxLayout()) self._labelTicksWidget = QWidget(self) self._labelTicksWidget.setLayout(QHBoxLayout()) self._labelTicksWidget.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self._slider) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self._labelTicksWidget)
def __init__(self, parent, available): QWidget.__init__(self, parent) self._parent = parent self._available = available vbox = QVBoxLayout(self) self._table = ui_tools.CheckableHeaderTable(1, 2) self._table.setSelectionMode(QTableWidget.SingleSelection) self._table.removeRow(0) vbox.addWidget(self._table) ui_tools.load_table( self._table, (translations.TR_PROJECT_NAME, translations.TR_VERSION), _format_for_table(available)) self._table.setColumnWidth(0, 500) self._table.setSortingEnabled(True) self._table.setAlternatingRowColors(True) hbox = QHBoxLayout() btnInstall = QPushButton(translations.TR_INSTALL) btnInstall.setMaximumWidth(100) hbox.addWidget(btnInstall) hbox.addWidget(QLabel(translations.TR_NINJA_NEEDS_TO_BE_RESTARTED)) vbox.addLayout(hbox) self.connect(btnInstall, SIGNAL("clicked()"), self._install_plugins) self.connect(self._table, SIGNAL("itemSelectionChanged()"), self._show_item_description)
def test_dock_standalone(self): widget = QWidget() layout = QHBoxLayout() widget.setLayout(layout) layout.addStretch(1) widget.show() dock = CollapsibleDockWidget() layout.addWidget(dock) list_view = QListView() list_view.setModel(QStringListModel(["a", "b"], list_view)) label = QLabel("A label. ") label.setWordWrap(True) dock.setExpandedWidget(label) dock.setCollapsedWidget(list_view) dock.setExpanded(True) self.app.processEvents() def toogle(): dock.setExpanded(not dock.expanded()) self.singleShot(2000, toogle) toogle() self.app.exec_()
def __init__(self, suggested, parent=None): super(PythonDetectDialog, self).__init__(parent, Qt.Dialog) self.setMaximumSize(QSize(0, 0)) self.setWindowTitle("Configure Python Path") vbox = QVBoxLayout(self) msg_str = ("We have detected that you are using " "Windows,\nplease choose the proper " "Python application for you:") lblMessage = QLabel(self.tr(msg_str)) vbox.addWidget(lblMessage) self.listPaths = QListWidget() self.listPaths.setSelectionMode(QListWidget.SingleSelection) vbox.addWidget(self.listPaths) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) btnCancel = QPushButton(self.tr("Cancel")) btnAccept = QPushButton(self.tr("Accept")) hbox.addWidget(btnCancel) hbox.addWidget(btnAccept) vbox.addLayout(hbox) self.connect(btnAccept, SIGNAL("clicked()"), self._set_python_path) self.connect(btnCancel, SIGNAL("clicked()"), self.close) for path in suggested: self.listPaths.addItem(path) self.listPaths.setCurrentRow(0)
def cb_initialize_plugin(self): # -------------------------------- # Create Widget # -------------------------------- # Create Widget needed for this plugin self.config = self.pl_get_current_config_ref() self.SESWidget = QWidget() self.pl_set_widget_for_internal_usage( self.SESWidget ) hbox = QHBoxLayout() self.SESWidget.setLayout(hbox) self.status_label = QLabel() self.status_label.setText('offline...') hbox.addWidget(self.status_label) self.control_button = QPushButton('Start External Script') self.control_button.clicked.connect(self.button_click_callback) hbox.addWidget(self.control_button) self.SESWidget.setContextMenuPolicy(Qt.CustomContextMenu) self.SESWidget.customContextMenuRequested.connect(self.show_context_menu) # --------------------------- # Create Legend # --------------------------- self.external_state = 'offline' self.path = self.config['path']['value'] file = os.path.basename(self.path) self.dir = self.path[:-len(file)] return True
def __init__(self, parent): super(Theme, self).__init__() self._preferences, vbox = parent, QVBoxLayout(self) vbox.addWidget(QLabel(self.tr("<b>Select Theme:</b>"))) self.list_skins = QListWidget() self.list_skins.setSelectionMode(QListWidget.SingleSelection) vbox.addWidget(self.list_skins) self.btn_delete = QPushButton(self.tr("Delete Theme")) self.btn_preview = QPushButton(self.tr("Preview Theme")) self.btn_create = QPushButton(self.tr("Create Theme")) hbox = QHBoxLayout() hbox.addWidget(self.btn_delete) hbox.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) hbox.addWidget(self.btn_preview) hbox.addWidget(self.btn_create) vbox.addLayout(hbox) self._refresh_list() self.connect(self.btn_preview, SIGNAL("clicked()"), self.preview_theme) self.connect(self.btn_delete, SIGNAL("clicked()"), self.delete_theme) self.connect(self.btn_create, SIGNAL("clicked()"), self.create_theme) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
def __init__(self, parent): QDialog.__init__(self, parent, Qt.Dialog) self.setWindowTitle(translations.TR_PLUGIN_MANAGER) self.resize(700, 600) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) self._txt_data = QTextBrowser() self._txt_data.setOpenLinks(False) vbox.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION)) vbox.addWidget(self._txt_data) # Footer hbox = QHBoxLayout() btn_close = QPushButton(translations.TR_CLOSE) btnReload = QPushButton(translations.TR_RELOAD) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.hide() self._oficial_available = [] self._community_available = [] self._locals = [] self._updates = [] self._loading = True self._requirements = {} self.connect(btnReload, SIGNAL("clicked()"), self._reload_plugins) self.thread = ThreadLoadPlugins(self) self.connect(self.thread, SIGNAL("finished()"), self._load_plugins_data) self.connect(self.thread, SIGNAL("plugin_downloaded(PyQt_PyObject)"), self._after_download_plugin) self.connect(self.thread, SIGNAL("plugin_manually_installed(PyQt_PyObject)"), self._after_manual_install_plugin) self.connect(self.thread, SIGNAL("plugin_uninstalled(PyQt_PyObject)"), self._after_uninstall_plugin) self.connect(self._txt_data, SIGNAL("anchorClicked(const QUrl&)"), self._open_link) self.connect(btn_close, SIGNAL('clicked()'), self.close) self.overlay.show() self._reload_plugins()
def __init__(self, scheme, parent): super(EditorSchemeDesigner, self).__init__(parent, Qt.Dialog) self.original_style = copy.copy(resources.CUSTOM_SCHEME) self._avoid_on_loading, self.saved, self._components = True, False, {} self.setWindowTitle(translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER) self.setMinimumSize(450, 480) self.setMaximumSize(500, 900) self.resize(450, 600) # all layouts and groupboxes group0 = QGroupBox(translations.TR_PROJECT_NAME) # scheme filename group1 = QGroupBox(translations.TR_PROJECT_PROPERTIES) # properties group2 = QGroupBox(translations.TR_PREVIEW) # quick preview thingy group0_hbox, group1_vbox = QHBoxLayout(group0), QVBoxLayout(group1) this_dialog_vbox, group2_vbox = QVBoxLayout(self), QVBoxLayout(group2) self._grid, scrollArea, frame = QGridLayout(), QScrollArea(), QFrame() # widgets self.line_name, btnSave = QLineEdit(), QPushButton( translations.TR_SAVE) self.line_name.setPlaceholderText(getuser().capitalize() + "s_scheme") group0_hbox.addWidget(self.line_name) group0_hbox.addWidget(btnSave) self.connect(btnSave, SIGNAL("clicked()"), self.save_scheme) _demo = "<center>" + ascii_letters # demo text for preview self.preview_label1, self.preview_label2 = QLabel(_demo), QLabel(_demo) group2_vbox.addWidget(self.preview_label1) group2_vbox.addWidget(self.preview_label2) # rows titles self._grid.addWidget(QLabel("<b>" + translations.TR_PROJECT_NAME), 0, 0) self._grid.addWidget(QLabel("<b>" + translations.TR_CODE), 0, 1) self._grid.addWidget( QLabel("<b>" + translations.TR_EDITOR_SCHEME_PICK_COLOR), 0, 2) # fill rows for key in sorted(tuple(resources.COLOR_SCHEME.keys())): self.add_item(key, scheme) self.preview_label1.setStyleSheet('background:transparent') self.preview_label2.setStyleSheet('color: transparent') # fill the scroll area frame.setLayout(self._grid) scrollArea.setWidget(frame) group1_vbox.addWidget(scrollArea) # put groups on the dialog this_dialog_vbox.addWidget(group1) this_dialog_vbox.addWidget(group2) this_dialog_vbox.addWidget(group0) self._avoid_on_loading = self._modified = False
def test_widgettoolgrid(self): w = QWidget() layout = QHBoxLayout() reg = registry_tests.small_testing_registry() qt_reg = QtWidgetRegistry(reg) triggered_actions1 = [] triggered_actions2 = [] model = qt_reg.model() data_descriptions = qt_reg.widgets("Constants") one_action = qt_reg.action_for_widget("one") actions = list(map(qt_reg.action_for_widget, data_descriptions)) grid = ToolGrid(w) grid.setActions(actions) grid.actionTriggered.connect(triggered_actions1.append) layout.addWidget(grid) grid = WidgetToolGrid(w) # First category ("Data") grid.setModel(model, rootIndex=model.index(0, 0)) self.assertIs(model, grid.model()) # Test order of buttons grid_layout = grid.layout() for i in range(len(actions)): button = grid_layout.itemAtPosition(i / 4, i % 4).widget() self.assertIs(button.defaultAction(), actions[i]) grid.actionTriggered.connect(triggered_actions2.append) layout.addWidget(grid) w.setLayout(layout) w.show() one_action.trigger() self.app.exec_()
def __init__(self, parent): super(ShortcutDialog, self).__init__() self.keys = 0 #Keyword modifiers! self.keyword_modifiers = (Qt.Key_Control, Qt.Key_Meta, Qt.Key_Shift, Qt.Key_Alt, Qt.Key_Menu) #main layout main_vbox = QVBoxLayout(self) self.line_edit = QLineEdit() self.line_edit.setReadOnly(True) #layout for buttons buttons_layout = QHBoxLayout() ok_button = QPushButton(translations.TR_ACCEPT) cancel_button = QPushButton(translations.TR_CANCEL) #add widgets main_vbox.addWidget(self.line_edit) buttons_layout.addWidget(ok_button) buttons_layout.addWidget(cancel_button) main_vbox.addLayout(buttons_layout) self.line_edit.installEventFilter(self) #buttons signals self.connect(ok_button, SIGNAL("clicked()"), self.save_shortcut) self.connect(cancel_button, SIGNAL("clicked()"), self.close)
def cb_initialize_plugin(self): # -------------------------------- # Create Widget # -------------------------------- # Create Widget needed for this plugin self.config = self.pl_get_current_config_ref() self.SESWidget = QWidget() self.pl_set_widget_for_internal_usage(self.SESWidget) hbox = QHBoxLayout() self.SESWidget.setLayout(hbox) self.status_label = QLabel() self.status_label.setText('offline...') hbox.addWidget(self.status_label) self.control_button = QPushButton('Start External Script') self.control_button.clicked.connect(self.button_click_callback) hbox.addWidget(self.control_button) self.SESWidget.setContextMenuPolicy(Qt.CustomContextMenu) self.SESWidget.customContextMenuRequested.connect( self.show_context_menu) # --------------------------- # Create Legend # --------------------------- self.external_state = 'offline' self.path = self.config['path']['value'] file = os.path.basename(self.path) self.dir = self.path[:-len(file)] return True
class MainTabWidget(QTabWidget): """ The main tabWidget """ def __init__(self,parent=None): QTabWidget.__init__(self,parent) self.setTabBar(TabBarSupport(self)) self.setMovable(False) self.setTabsClosable(True) self.setDocumentMode(False) self.navigationButton = QPushButton(QIcon(getPath('iconDir','navigation.png')),"",self) self.navigationButton.setFlat(True) self.closeButton = QPushButton(QIcon(getPath('iconDir','navclose.png')),"",self) self.closeButton.setFlat(True) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setMargin(0) self.rightCornerWidgetLayout.setSpacing(0) self.rightCornerWidgetLayout.addWidget(self.navigationButton) self.rightCornerWidgetLayout.addWidget(self.closeButton) self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) QObject.connect(self.navigationButton, SIGNAL("pressed()"),self.__evt_navigation) QObject.connect(self.closeButton, SIGNAL("clicked(bool)"),lambda:self.emit(SIGNAL("tabCloseRequested (int)"),self.currentIndex())) QObject.connect(self, SIGNAL("tabCloseRequested (int)"),self.__evt_close_tab_click) QObject.connect(self.tabBar(), SIGNAL('customContextMenuRequested(const QPoint &)'),self.__evt_showContextMenu) def __evt_contextMenuCloseOthers(self,index): """ Private method to close the other tabs. """ for i in range(self.count() - 1, index, -1) : self.__evt_close_tab_click(i) for i in range(index - 1, -1, -1): self.__evt_close_tab_click(i) def __evt_showContextMenu(self,point): _tabbar = self.tabBar() for index in range(_tabbar.count()): rect = _tabbar.tabRect(index) if rect.contains(point): menu = QMenu(self) action = QAction("close",self,triggered=lambda:self.__evt_close_tab_click(index)) action.setEnabled(self.count()>1 and index is not 0) menu.addAction(action) action = QAction("close others",self,triggered=lambda:self.__evt_contextMenuCloseOthers(index)) action.setEnabled(self.count()>1) menu.addAction(action) action = QAction("close all",self,triggered=lambda:self.__evt_contextMenuCloseOthers(0)) action.setEnabled(self.count()>1) menu.addAction(action) menu.exec_(self.mapToGlobal(point)) def __evt_navigation(self): menu = QMenu() actions = {} for i in range(self.count()): actions[i] = QAction(self.tabBar().tabIcon(i),self.tabBar().tabText(i),self,\ triggered=lambda re,i=i:self.setCurrentIndex(i) and self.navigationButton) for key in actions.keys(): actions[key].setIconVisibleInMenu(True) menu.addAction(actions[key]) self.navigationButton.setMenu(menu) self.navigationButton.showMenu() menu.clear() def __evt_close_tab_click(self,index): """ because the first tab is the main window we'll show so we never close it . If the tab's content need save , we also remind the user. """ if 0 == index :return if hasattr(self.widget(index),"bufferon") and self.widget(index).bufferon(): reply = QMessageBox.question(self, "Save or not?", "Save your content first?\n%s" % self.tabText(index), QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) if reply == QMessageBox.Yes: if hasattr(self.widget(index),"save"): self.widget(index).save() self.removeTab(index) Seeking().new().emit(SIGNAL('updateWindows()')) return "yes" elif reply == QMessageBox.No: self.removeTab(index) Seeking().new().emit(SIGNAL('updateWindows()')) return "no" elif reply == QMessageBox.Cancel: return "cancel" else: self.removeTab(index) Seeking().new().emit(SIGNAL('updateWindows()')) return "yes"
def __init__(self, parent): super(ManualInstallWidget, self).__init__() self._parent = parent vbox = QVBoxLayout(self) form = QFormLayout() self._txtName = QLineEdit() self._txtName.setPlaceholderText('my_plugin') self._txtVersion = QLineEdit() self._txtVersion.setPlaceholderText('0.1') form.addRow(translations.TR_PROJECT_NAME, self._txtName) form.addRow(translations.TR_VERSION, self._txtVersion) vbox.addLayout(form) hPath = QHBoxLayout() self._txtFilePath = QLineEdit() self._txtFilePath.setPlaceholderText( os.path.join(os.path.expanduser('~'), 'full', 'path', 'to', 'plugin.zip')) self._btnFilePath = QPushButton(QIcon(":img/open"), '') self.completer, self.dirs = QCompleter(self), QDirModel(self) self.dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot) self.completer.setModel(self.dirs) self._txtFilePath.setCompleter(self.completer) hPath.addWidget(QLabel(translations.TR_FILENAME)) hPath.addWidget(self._txtFilePath) hPath.addWidget(self._btnFilePath) vbox.addLayout(hPath) vbox.addSpacerItem( QSpacerItem(0, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) self._btnInstall = QPushButton(translations.TR_INSTALL) hbox.addWidget(self._btnInstall) vbox.addLayout(hbox) #Signals self.connect(self._btnFilePath, SIGNAL("clicked()"), self._load_plugin_path) self.connect(self._btnInstall, SIGNAL("clicked()"), self.install_plugin)
def createCentralWidget(self): self._centralWidget = default.EditorWidgetBase() #self.modelRoot) self._centralWidget.setLayout(QHBoxLayout()) # self.plotWidgetContainer = PlotWidgetContainer(self.modelRoot) self.geometry = neuroextractor.model( moose.element(self.modelRoot + "/model")) self.morphology = self.createMorphology(self.geometry) self.morphology.set_compartment_order( map(lambda x: x.path, self.compartmentOrder)) self.vms = np.empty(len(self.compartmentOrder), dtype=np.float, order='C') self.ims = np.empty(len(self.compartmentOrder), dtype=np.float, order='C') # self.visualizer.insertPlainText(pprint.pformat(self.geometry, indent = 4)) # self.visualizer = QTextEdit()#NeuroKitVisualizer(self.modelRoot) desktop = QtGui.QApplication.desktop() # print("**********************") # print(desktop.screenGeometry()) # print("***********************") self.visualizer = MorphologyEditor(self.morphology, desktop.screenGeometry().width(), desktop.screenGeometry().height(), self.plugin) # self.scheduler = self.getSchedulingDockWidget().widget() # self._centralWidget.setChildWidget(self.scheduler, False, 0,0,1,-1) self.visualizer.setGeometry(0, 0, 1200, 400) self.visualizer.show() # self.visualizer.start() self._centralWidget.layout().addWidget(self.visualizer) # self._centralWidget.setChildWidget(self.visualizer, False, 0, 0,-1,1) # self._centralWidget.setChildWidget(self.plotWidgetContainer, False, 0, 1,-1,1) # self._centralWidget.setPlotWidgetContainer(self.plotWidgetContainer) # label = QLabel("Aviral Goel") # self._centralWidget.setChildWidget(label, False, 0, 0) # self._centralWidget.setWindowTitle("Aviral Goel") # self.scheduler = self.getSchedulingDockWidget().widget() # self.scheduler.runner.update.connect(self.kkitRunView.getCentralWidget().changeBgSize) # self.scheduler.runner.resetAndRun.connect(self.kkitRunView.getCentralWidget().resetColor) ######################################################## # self.schedular = self.getSchedulingDockWidget().widget() # self.schedular.runner.simulationProgressed.connect(self.update) # self.schedular.runner.simulationReset.connect(self.reset) preferences.getView().setCurrentIndex(1) preferences.getView().electricalBaseColorDialog.colorSelected.connect( lambda x: self.reset()) preferences.getView().electricalPeakColorDialog.colorSelected.connect( lambda x: self.reset()) preferences.getView( ).electricalBackgroundColorDialog.colorSelected.connect( lambda x: self.reset()) preferences.getView( ).electricalPeakMembraneVoltage.editingFinished.connect(self.reset) preferences.getView( ).electricalBaseMembraneVoltage.editingFinished.connect(self.reset) # print("getting central widget") # self._centralWidget.show() # print(self.schedular.runner._updateInterval) self.reset() return self._centralWidget
class MainTabWidget(QTabWidget): """ The main tabWidget """ def __init__(self, parent=None): QTabWidget.__init__(self, parent) self.setTabBar(TabBarSupport(self)) self.setMovable(False) self.setTabsClosable(True) self.setDocumentMode(False) self.navigationButton = QPushButton( QIcon(getPath('iconDir', 'navigation.png')), "", self) self.navigationButton.setFlat(True) self.closeButton = QPushButton( QIcon(getPath('iconDir', 'navclose.png')), "", self) self.closeButton.setFlat(True) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setMargin(0) self.rightCornerWidgetLayout.setSpacing(0) self.rightCornerWidgetLayout.addWidget(self.navigationButton) self.rightCornerWidgetLayout.addWidget(self.closeButton) self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) QObject.connect(self.navigationButton, SIGNAL("pressed()"), self.__evt_navigation) QObject.connect( self.closeButton, SIGNAL("clicked(bool)"), lambda: self.emit( SIGNAL("tabCloseRequested (int)"), self.currentIndex())) QObject.connect(self, SIGNAL("tabCloseRequested (int)"), self.__evt_close_tab_click) QObject.connect(self.tabBar(), SIGNAL('customContextMenuRequested(const QPoint &)'), self.__evt_showContextMenu) def __evt_contextMenuCloseOthers(self, index): """ Private method to close the other tabs. """ for i in range(self.count() - 1, index, -1): self.__evt_close_tab_click(i) for i in range(index - 1, -1, -1): self.__evt_close_tab_click(i) def __evt_showContextMenu(self, point): _tabbar = self.tabBar() for index in range(_tabbar.count()): rect = _tabbar.tabRect(index) if rect.contains(point): menu = QMenu(self) action = QAction( "close", self, triggered=lambda: self.__evt_close_tab_click(index)) action.setEnabled(self.count() > 1 and index is not 0) menu.addAction(action) action = QAction( "close others", self, triggered=lambda: self.__evt_contextMenuCloseOthers(index)) action.setEnabled(self.count() > 1) menu.addAction(action) action = QAction( "close all", self, triggered=lambda: self.__evt_contextMenuCloseOthers(0)) action.setEnabled(self.count() > 1) menu.addAction(action) menu.exec_(self.mapToGlobal(point)) def __evt_navigation(self): menu = QMenu() actions = {} for i in range(self.count()): actions[i] = QAction(self.tabBar().tabIcon(i),self.tabBar().tabText(i),self,\ triggered=lambda re,i=i:self.setCurrentIndex(i) and self.navigationButton) for key in actions.keys(): actions[key].setIconVisibleInMenu(True) menu.addAction(actions[key]) self.navigationButton.setMenu(menu) self.navigationButton.showMenu() menu.clear() def __evt_close_tab_click(self, index): """ because the first tab is the main window we'll show so we never close it . If the tab's content need save , we also remind the user. """ if 0 == index: return if hasattr(self.widget(index), "bufferon") and self.widget(index).bufferon(): reply = QMessageBox.question( self, "Save or not?", "Save your content first?\n%s" % self.tabText(index), QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) if reply == QMessageBox.Yes: if hasattr(self.widget(index), "save"): self.widget(index).save() self.removeTab(index) Seeking().new().emit(SIGNAL('updateWindows()')) return "yes" elif reply == QMessageBox.No: self.removeTab(index) Seeking().new().emit(SIGNAL('updateWindows()')) return "no" elif reply == QMessageBox.Cancel: return "cancel" else: self.removeTab(index) Seeking().new().emit(SIGNAL('updateWindows()')) return "yes"
def hstack(items): layout = QHBoxLayout() for item in items: stack(item, layout) return layout
def __init__(self, parent): super(ThemeEditor, self).__init__(parent, Qt.Dialog) vbox = QVBoxLayout(self) hbox = QHBoxLayout() self.line_name = QLineEdit() self.btn_save = QPushButton(translations.TR_SAVE) self.line_name.setPlaceholderText(getuser().capitalize() + "s_theme") hbox.addWidget(self.line_name) hbox.addWidget(self.btn_save) self.edit_qss = QPlainTextEdit() css = 'QPlainTextEdit {color: %s; background-color: %s;' \ 'selection-color: %s; selection-background-color: %s;}' \ % (resources.CUSTOM_SCHEME.get( 'editor-text', resources.COLOR_SCHEME['Default']), resources.CUSTOM_SCHEME.get( 'EditorBackground', resources.COLOR_SCHEME['EditorBackground']), resources.CUSTOM_SCHEME.get( 'EditorSelectionColor', resources.COLOR_SCHEME['EditorSelectionColor']), resources.CUSTOM_SCHEME.get( 'EditorSelectionBackground', resources.COLOR_SCHEME['EditorSelectionBackground'])) self.edit_qss.setStyleSheet(css) self.btn_apply = QPushButton(self.tr("Apply Style Sheet")) hbox2 = QHBoxLayout() hbox2.addSpacerItem( QSpacerItem(10, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) hbox2.addWidget(self.btn_apply) hbox2.addSpacerItem( QSpacerItem(10, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) vbox.addWidget(self.edit_qss) vbox.addLayout(hbox) vbox.addLayout(hbox2) self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_stylesheet) self.connect(self.btn_save, SIGNAL("clicked()"), self.save_stylesheet)
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) self.resize(1920, 1080) self.status = False self.setAutoFillBackground(False) self.setDocumentMode(False) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.exitAct = QAction(QIcon('exit.png'), '&Exit', self) self.exitAct.setShortcut('Ctrl+Q') self.exitAct.setStatusTip('Exit application') self.exitAct.triggered.connect(qApp.quit) self.loadAct = QAction(QIcon('exit.png'), '&Import Unfolding', self) self.loadAct.setShortcut('Ctrl+L') self.loadAct.setStatusTip('Import Unfolding') self.loadAct.triggered.connect(self.openFileNameDialog) self.exportAct = QAction(QIcon('exit.png'), '&Export Unfolding', self) self.exportAct.setShortcut('Ctrl+E') self.exportAct.setStatusTip('Export Unfolding') self.exportAct.triggered.connect(self.exportUnfolding) self.writeNPAct = QAction(QIcon('exit.png'), '&Write coordinates as np file', self) self.writeNPAct.setShortcut('Ctrl+W') self.writeNPAct.setStatusTip('Write coordinates') self.writeNPAct.triggered.connect(self.writeNP_file) self.loadGeometryAct = QAction(QIcon('exit.png'), '&Load geometry from .log file', self) #self.loadGeometry.setShortcut('Ctrl+W') self.loadGeometryAct.setStatusTip('Load geometry') self.loadGeometryAct.triggered.connect(self.loadGeometry) self.select_directoryAct = QAction( QIcon('exit.png'), '&Select a directory to generate hdf5 files from', self) self.select_directoryAct.setStatusTip('Select directory') self.select_directoryAct.triggered.connect(self.select_directory) self.load_HDF5Act = QAction(QIcon('exit.png'), '&Select a hdf5 files for the DFT data', self) self.load_HDF5Act.setStatusTip('Select HDF5') self.load_HDF5Act.triggered.connect(self.load_hdf5_scan) self.statusBar() self.menubar = self.menuBar() self.fileMenu = self.menubar.addMenu('&File') self.fileMenu.addAction(self.exitAct) self.fileMenu.addAction(self.loadAct) self.fileMenu.addAction(self.exportAct) self.fileMenu.addAction(self.writeNPAct) self.fileMenu.addAction(self.loadGeometryAct) self.fileMenu.addAction(self.select_directoryAct) self.fileMenu.addAction(self.load_HDF5Act) self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setSpacing(10) self.verticalLayout = QVBoxLayout() ### Containing the integration buttons self.horizontalLayout_2 = QHBoxLayout() ### Containing the inital/final position show self.finalPositionLayout = QHBoxLayout() self.gl_widget = gl.GLViewWidget() self.gl_widget.setCameraPosition(distance=20, elevation=40) self.gl_widget.setGeometry(0, 110, 1920, 1080) self.energy_Plot = PlotWidget() self.energy_Plot.setObjectName(_fromUtf8("energyPlot")) self.energy_Plot.setBackground('k') # set properties of the label for y axis self.energy_Plot.setLabel('left', 'E(B3LYP)', units='H') # set properties of the label for x axis self.energy_Plot.setLabel('bottom', 'CC-distance', units='A') # adding legend self.energy_Plot.addLegend() self.horizontalLayout.addWidget(self.gl_widget, 4) ### Push button for sinle integration self.btnUp = QPushButton() self.btnUp.setObjectName(_fromUtf8("btnUp")) ### Check box for continous integration self.chkIntegrate = QCheckBox() self.chkIntegrate.setObjectName(_fromUtf8("chkIntegrate")) ### SpinBox to set the size of the integration step self.spinStep = QSpinBox() self.spinStep.setMinimum(0) self.spinStep.setMaximum(10000) self.spinStep.setObjectName(_fromUtf8("spinStep")) ### final position button self.btnFin = QPushButton() self.btnFin.setObjectName(_fromUtf8("btnFin")) ### initial position button self.btnInit = QPushButton() self.btnInit.setObjectName(_fromUtf8("btnPos")) ### select hinges button self.btnSelHinge = QPushButton() self.btnSelHinge.setObjectName(_fromUtf8("btnSelHinge")) ### close unfolding button self.btnClose = QPushButton() self.btnClose.setObjectName(_fromUtf8("btnClose")) ### add the buttons to the integration layout self.horizontalLayout_2.addWidget(self.spinStep) self.horizontalLayout_2.addWidget(self.btnUp) self.horizontalLayout_2.addWidget(self.chkIntegrate) ## add final position button to layout self.finalPositionLayout.addWidget(self.btnInit) self.finalPositionLayout.addWidget(self.btnFin) self.finalPositionLayout.addWidget(self.btnSelHinge) self.finalPositionLayout.addWidget(self.btnClose) ### add integration and final position layout and plot widget to right side layout self.verticalLayout.addLayout(self.horizontalLayout_2, 1) self.verticalLayout.addLayout(self.finalPositionLayout, 1) self.verticalLayout.addWidget(self.energy_Plot, 6) self.horizontalLayout.addLayout(self.verticalLayout, 1) self.widget = QWidget() self.widget.setLayout(self.horizontalLayout) self.setCentralWidget(self.widget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.setWindowTitle('Fullerene Unfolding')