def __init__(self, renderController, parent=None): super(RenderParameterWidget, self).__init__(parent=parent) self.renderController = renderController self.renderController.visualizationChanged.connect(self.visualizationLoaded) self.paramWidget = None self.visTypeComboBox = QComboBox() for visualizationType in self.renderController.visualizationTypes: self.visTypeComboBox.addItem(visualizationType) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setSpacing(10) layout.setContentsMargins(10, 0, 10, 0) if len(self.renderController.visualizationTypes) > 1: layout.addWidget(QLabel("Visualization type:"), 0, 0) layout.addWidget(self.visTypeComboBox, 0, 1) self.setLayout(layout) self.scrollArea = QScrollArea() self.scrollArea.setFrameShape(QFrame.NoFrame) self.scrollArea.setAutoFillBackground(False) self.scrollArea.setAttribute(Qt.WA_TranslucentBackground) self.scrollArea.setWidgetResizable(True) self.visTypeComboBox.currentIndexChanged.connect(self.visTypeComboBoxChanged)
def init(self, parent): image = self.factory.image if image is None: image = self.value image_ctrl = QLabel() # w = self.item.width # if self.factory.scale: # w *= self.factory.scale if image is not None: image_ctrl.setPixmap( convert_bitmap( image, # width=w, # height=self.item.height )) self.image_ctrl = image_ctrl # self.image_ctrl.setMinimumWidth(self.item.width) # self.image_ctrl.setMinimumHeight(self.item.height) if self.factory.scrollable: scroll_area = QScrollArea() scroll_area.setWidget(image_ctrl) scroll_area.setWidgetResizable(True) scroll_area.setMinimumWidth(self.item.width) scroll_area.setMinimumHeight(self.item.height) self.control = scroll_area else: self.control = self.image_ctrl self.set_tooltip() self.sync_value(self.factory.refresh, 'refresh', 'from')
def test_set_widget_succeeding(self): parent = QScrollArea() ChildAdder.add(QLabel(), 'fred', parent) self.assertTrue(isinstance(parent.widget(), QLabel)) # We promise to setWidgetResizable(True), also. resizable = parent.widgetResizable() self.assertTrue(resizable)
def init(self, parent): image = self.factory.image if image is None: image = self.value image_ctrl = myQLabel() if image is not None: image_ctrl.setPixmap(convert_bitmap(image)) self.image_ctrl = image_ctrl self.image_ctrl.setScaledContents(True) if self.factory.scrollable: scroll_area = QScrollArea() scroll_area.setWidget(image_ctrl) scroll_area.setWidgetResizable(True) scroll_area.setMinimumWidth(max(0, self.item.width)) scroll_area.setMinimumHeight(max(0, self.item.height)) self.control = scroll_area else: self.control = self.image_ctrl self.set_tooltip() self.sync_value(self.factory.refresh, 'refresh', 'from') self.update_editor()
def _init_widgets(self): layout = QVBoxLayout() # address lbl_addr = QLabel() lbl_addr.setText("Address") txt_addr = QLineEdit() txt_addr.returnPressed.connect(self._on_address_entered) self._txt_addr = txt_addr top_layout = QHBoxLayout() top_layout.addWidget(lbl_addr) top_layout.addWidget(txt_addr) self._view = QMemoryView(self.workspace) area = QScrollArea() self._scrollarea = area area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setWidgetResizable(True) area.setWidget(self._view) layout.addLayout(top_layout) layout.addWidget(area) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self): super(PointsWidget, self).__init__() self.landmarkWidgets = [] self.activeIndex = 0 self.scrollArea = QScrollArea(self) self.scrollArea.setFrameShape(QFrame.NoFrame) self.scrollArea.setAutoFillBackground(False) self.scrollArea.setAttribute(Qt.WA_TranslucentBackground) self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scrollArea.setWidgetResizable(True) landmarkLocationsLayout = QGridLayout() landmarkLocationsLayout.setSpacing(0) landmarkLocationsLayout.setContentsMargins(0, 0, 0, 0) landmarkLocationsLayout.setAlignment(Qt.AlignTop) self.landmarkLocationsWidget = QWidget() Style.styleWidgetForTab(self.landmarkLocationsWidget) self.landmarkLocationsWidget.setLayout(landmarkLocationsLayout) self.scrollArea.setWidget(self.landmarkLocationsWidget) layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.scrollArea) self.setLayout(layout)
def __init__(self, parent=None): # This view is never made visible super(MetadataView, self).__init__() # A container for the controls self._form_container = FormContainer() # A scrollable container for the form self._form_scroll = QScrollArea(parent) self._form_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self._form_scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self._form_scroll.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self._form_scroll.setWidget(self._form_container) # Make the controls fill the available horizontal space # http://qt-project.org/forums/viewthread/11012 self._form_scroll.setWidgetResizable(True) # Title self._title = QLabel() # Title is fixed at the top - form can be scrolled layout = QVBoxLayout() layout.addWidget(self._title) layout.addWidget(self._form_scroll) # Top-level container for the title and form self.widget = QWidget(parent) self.widget.setLayout(layout)
def __init__(self, parent=None): """Initialize Widget.""" super().__init__(parent) self.setLayout(QVBoxLayout()) self.imglabel = QLabel() self.imglabel.setBackgroundRole(QPalette.Base) self.imglabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.imglabel.setScaledContents(True) # Resize pixmap along with label self.imglabel.setAlignment(Qt.AlignCenter) self.imglabel.setText("(No image yet)") self.namelabel = QLabel() self.scrollarea = QScrollArea() self.scrollarea.setWidget(self.imglabel) self.scrollarea.setWidgetResizable(False) self.scrollarea.setAlignment(Qt.AlignCenter) self.layout().addWidget(self.scrollarea) self.layout().addWidget(self.namelabel) self.scale_factor = 1.0 self._initial_size = QSize(0, 0) self._img_path = "" self.setContextMenuPolicy(Qt.CustomContextMenu) # pylint: disable=no-member self.customContextMenuRequested.connect(self.show_context_menu) self.menu = QMenu() self.add_actions_to_menu(self.menu)
def generate_dialogs(self): vlayout = QVBoxLayout() commit_button = QPushButton("&Commit") w_all = QWidget() v = QVBoxLayout() for cell in self.plasm.cells(): tendril_widgets = [] for name, tendril in cell.params: if self.whitelist is None or self.is_in_whitelist( cell.name(), name): tw = TendrilWidget(name, tendril) commit_button.clicked.connect(tw.thunker.commit) tendril_widgets.append(tw) if tendril_widgets: w = QWidget() cvlayout = QVBoxLayout() cvlayout.addWidget(QLabel(cell.name())) for tendril_widget in tendril_widgets: cvlayout.addWidget(tendril_widget) w.setLayout(cvlayout) # w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) v.addWidget(w) w_all.setLayout(v) s = QScrollArea() s.setWidget(w_all) vlayout.addWidget(s) vlayout.addWidget(commit_button) self.setLayout(vlayout)
def initUI(self): self.grid = QGridLayout() self.setLayout(self.grid) self.tree = TreeWidget(self, self.actionObjs, self.actionIDs, self.table) self.scrollArea = QScrollArea() self.scrollArea.setBackgroundRole(QPalette.Dark) self.scrollArea.setWidget(self.tree) if self.tree.rect().width() < 600: self.scrollArea.setFixedWidth(self.tree.rect().width() + 25) else: self.scrollArea.setFixedWidth(600) if self.tree.rect().height() < 600: self.scrollArea.setFixedHeight(self.tree.rect().height()) else: self.scrollArea.setFixedHeight(600) self.scrollArea.ensureWidgetVisible(self.tree, 500, 500) self.grid.addWidget(self.scrollArea, 0, 0, 10, 3) self.legend = Legend(self) self.grid.addWidget(self.legend, 0, 3, 1, 2) self.setWindowModality(Qt.ApplicationModal) self.show()
def _init_widgets(self): state = self._state if state is None: return if state.arch.name not in self.ARCH_REGISTERS: l.error( "Architecture %s is not listed in QRegisterViewer.ARCH_REGISTERS.", state.arch.name) return layout = QVBoxLayout() area = QScrollArea() area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setWidgetResizable(True) regs = self.ARCH_REGISTERS[state.arch.name] # common ones common_regs = regs['common'] for reg_name in common_regs: sublayout = QHBoxLayout() lbl_reg_name = QLabel(self) lbl_reg_name.setProperty('class', 'reg_viewer_label') lbl_reg_name.setText(reg_name) lbl_reg_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sublayout.addWidget(lbl_reg_name) sublayout.addSpacing(10) reg_value = QASTViewer(None, parent=self) self._registers[reg_name] = reg_value sublayout.addWidget(reg_value) layout.addLayout(sublayout) layout.setSpacing(0) layout.addStretch(0) layout.setContentsMargins(2, 2, 2, 2) # the container container = QFrame() container.setAutoFillBackground(True) palette = container.palette() palette.setColor(container.backgroundRole(), Qt.white) container.setPalette(palette) container.setLayout(layout) area.setWidget(container) base_layout = QVBoxLayout() base_layout.addWidget(area) self.setLayout(base_layout)
def createWidgets(self): self.fontLabel = QLabel("Fon&t:") self.fontComboBox = QFontComboBox() self.tooltips.append((self.fontComboBox, """\ <p><b>Font</b></p> <p>The font for displaying the characters.</p>""")) self.fontLabel.setBuddy(self.fontComboBox) self.sizeLabel = QLabel("&Size:") self.sizeComboBox = QComboBox() self.tooltips.append((self.sizeComboBox, """\ <p><b>Size</b></p> <p>The size of font for displaying the characters.</p>""")) self.sizeLabel.setBuddy(self.sizeComboBox) self.scrollArea = QScrollArea() self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.panel = Panel() self.scrollArea.setWidget(self.panel) self.copyTextLabel = QLabel("Copy T&ext") self.copyTextLineEdit = QLineEdit() self.tooltips.append((self.copyTextLineEdit, """\ <p><b>Copy Text editor</b></p> <p>The text for copying to the clipboard when <b>Copy</b> is pressed.</p>""")) self.copyTextLabel.setBuddy(self.copyTextLineEdit) self.findTextLabel = QLabel("&Find Text") self.findTextLineEdit = QLineEdit() self.tooltips.append((self.findTextLineEdit, """\ <p><b>Find Text editor</b></p> <p>The name or partial name of Unicode characters to be found, e.g., “star” will match many characters, including U+22C6 “Star operator”.</p>""")) self.findTextLabel.setBuddy(self.findTextLineEdit) self.buttonBox = QDialogButtonBox() self.addSelectedButton = QPushButton(QIcon(":/add.svg"), "&Add Selected") self.tooltips.append((self.addSelectedButton, """\ <p><b>Add Selected</b></p> <p>Append the selected character to the <b>Copy Text</b> editor.</p>""")) self.buttonBox.addButton(self.addSelectedButton, QDialogButtonBox.ActionRole) self.findNextButton = QPushButton(QIcon(":/edit-find.svg"), "Find &Next") self.tooltips.append((self.findNextButton, """\ <p><b>Find Next</b></p> <p>Find the next character whose Unicode name contains or equals the <b>Find Text</b>.</p>""")) self.buttonBox.addButton(self.findNextButton, QDialogButtonBox.ActionRole) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append( (self.helpButton, "Help on the Copy Character dialog")) self.buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) self.closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((self.closeButton, """<p><b>Cancel</b></p> <p>Close the dialog.</p>""")) self.buttonBox.addButton(self.closeButton, QDialogButtonBox.RejectRole)
def addTab(self, tab, name, index=0): """Add the given tab to the TabDialog under the given name at the given index. The index 0 means the tab will be the active one when the TabDialog is raised. """ viewArea = QScrollArea() viewArea.setWidget(tab) viewArea.setWidgetResizable(True) self.tabs.insertTab(index, viewArea, name) self.tabs.setCurrentIndex(0)
def __init__(self): super(RenderInfoWidget, self).__init__() self.scrollArea = QScrollArea() self.scrollArea.setFrameShape(QFrame.NoFrame) self.scrollArea.setAutoFillBackground(False) self.scrollArea.setAttribute(Qt.WA_TranslucentBackground) self.scrollArea.setWidgetResizable(True) Style.styleWidgetForTab(self) Style.styleWidgetForTab(self.scrollArea)
def _init_widgets(self): area = QScrollArea() area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setWidgetResizable(True) self._area = area base_layout = QVBoxLayout() base_layout.addWidget(area) self.setLayout(base_layout)
def initUI(self): hbox = QtGui.QHBoxLayout(self) first = QtGui.QFrame(self) first.setFrameShape(QtGui.QFrame.StyledPanel) scrollAreaLeft = QScrollArea() scrollAreaLeft.setWidgetResizable(True) scrollAreaLeft.setWidget(first) second = QtGui.QFrame(self) second.setFrameShape(QtGui.QFrame.StyledPanel) scrollAreaRight = QScrollArea() scrollAreaRight.setWidgetResizable(True) scrollAreaRight.setWidget(second) splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) splitter.addWidget(scrollAreaLeft) splitter.addWidget(scrollAreaRight) splitter.setSizes([10, 100]) hbox.addWidget(splitter) self.setLayout(hbox) self.setGeometry(600, 600, 600, 600) self.setWindowTitle('QtGui.QSplitter') self.show() print("scrollAreaLeft width: " + str(scrollAreaLeft.width())) print("scrollAreaRight width: " + str(scrollAreaRight.width()))
def __init__(self, *args, **kwargs): super(Widget_TypeAttributeList, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QVBoxLayout(self) mainLayout.setContentsMargins(0, 0, 0, 5) groupBox = QGroupBox("Search Attribute Types") groupBoxLayout = QVBoxLayout() groupBox.setStyleSheet("font-size:12px") groupBox.setLayout(groupBoxLayout) groupBoxLayout.setContentsMargins(0, 0, 0, 0) scrollArea = QScrollArea() scrollArea.setStyleSheet("font-size:11px") scrollAreaWidget = QWidget() scrollAreaLayout = QVBoxLayout(scrollAreaWidget) scrollArea.setWidgetResizable(True) scrollArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) scrollArea.setWidget(scrollAreaWidget) scrollAreaLayout.setContentsMargins(5, 0, 5, 0) scrollArea.resize(scrollArea.sizeHint()) groupBoxLayout.addWidget(scrollArea) self.get_csv_form_google_spreadsheets(Widget_TypeAttributeList.url, Widget_TypeAttributeList.csv) dict_list = self.get_dictList_from_csvPath( Widget_TypeAttributeList.csv) self.w_typeAttrs = [] for dict_data in dict_list: w_typeAttr = Widget_TypeAttribute(attr_name=dict_data['attr_name'], type_node=dict_data['type_node']) scrollAreaLayout.addWidget(w_typeAttr) self.w_typeAttrs.append(w_typeAttr) empty = QLabel() empty.setMinimumHeight(0) scrollAreaLayout.addWidget(empty) mainLayout.addWidget(groupBox) self.resize(0, 100)
def generate_dialogs(self): vlayout = QVBoxLayout() commit_button = QPushButton("&Commit") w_all = QWidget() v = QVBoxLayout() for cell in self.plasm.cells(): w = QWidget() cvlayout = QVBoxLayout() cvlayout.addWidget(QLabel(cell.name())) for name, tendril in cell.params: tw = TendrilWidget(name, tendril) cvlayout.addWidget(tw) commit_button.clicked.connect(tw.thunker.commit) w.setLayout(cvlayout) # w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) v.addWidget(w) w_all.setLayout(v) s = QScrollArea() s.setWidget(w_all) vlayout.addWidget(s) vlayout.addWidget(commit_button) self.setLayout(vlayout)
def __init__(self, *args, **kwargs): super(Dialog_deleteUnused, self).__init__(*args, **kwargs) self.installEventFilter(self) self.setObjectName(Dialog_deleteUnused.objectName) self.setWindowTitle(Dialog_deleteUnused.title) self.resize(Dialog_deleteUnused.defaultWidth, Dialog_deleteUnused.defaultHeight) mainLayout = QVBoxLayout(self) label_download = QLabel( "The following files will be deleted. Continue?".decode('utf-8')) label_download.setMaximumHeight(30) scrollArea = QScrollArea() fileList = QListWidget() scrollArea.setWidget(fileList) scrollArea.setWidgetResizable(True) hLayout_buttons = QHBoxLayout() button_delete = QPushButton("Delete All".decode('utf-8')) button_cancel = QPushButton("Cancel".decode('utf-8')) hLayout_buttons.addWidget(button_delete) hLayout_buttons.addWidget(button_cancel) mainLayout.addWidget(label_download) mainLayout.addWidget(scrollArea) mainLayout.addLayout(hLayout_buttons) self.fileList = fileList self.button_delete = button_delete QtCore.QObject.connect(button_delete, QtCore.SIGNAL('clicked()'), self.cmd_deleteSelected) QtCore.QObject.connect(button_cancel, QtCore.SIGNAL('clicked()'), self.cmd_cancel) QtCore.QObject.connect(self.fileList, QtCore.SIGNAL("itemSelectionChanged()"), self.cmd_setButtonCondition) self.fileList.setSelectionMode(QAbstractItemView.ExtendedSelection)
def createMainWidget(self): """ TOWRITE :return: TOWRITE :rtype: QScrollArea """ widget = QWidget(self) # Misc groupBoxMisc = QGroupBox(self.tr("General Information"), widget) labelStitchesTotal = QLabel(self.tr("Total Stitches:"), self) labelStitchesReal = QLabel(self.tr("Real Stitches:"), self) labelStitchesJump = QLabel(self.tr("Jump Stitches:"), self) labelStitchesTrim = QLabel(self.tr("Trim Stitches:"), self) labelColorTotal = QLabel(self.tr("Total Colors:"), self) labelColorChanges = QLabel(self.tr("Color Changes:"), self) labelRectLeft = QLabel(self.tr("Left:"), self) labelRectTop = QLabel(self.tr("Top:"), self) labelRectRight = QLabel(self.tr("Right:"), self) labelRectBottom = QLabel(self.tr("Bottom:"), self) labelRectWidth = QLabel(self.tr("Width:"), self) labelRectHeight = QLabel(self.tr("Height:"), self) fieldStitchesTotal = QLabel(u'%s' % (self.stitchesTotal), self) fieldStitchesReal = QLabel(u'%s' % (self.stitchesReal), self) fieldStitchesJump = QLabel(u'%s' % (self.stitchesJump), self) fieldStitchesTrim = QLabel(u'%s' % (self.stitchesTrim), self) fieldColorTotal = QLabel(u'%s' % (self.colorTotal), self) fieldColorChanges = QLabel(u'%s' % (self.colorChanges), self) fieldRectLeft = QLabel(u'%s' % (str(self.boundingRect.left()) + " mm"), self) fieldRectTop = QLabel(u'%s' % (str(self.boundingRect.top()) + " mm"), self) fieldRectRight = QLabel( u'%s' % (str(self.boundingRect.right()) + " mm"), self) fieldRectBottom = QLabel( u'%s' % (str(self.boundingRect.bottom()) + " mm"), self) fieldRectWidth = QLabel( u'%s' % (str(self.boundingRect.width()) + " mm"), self) fieldRectHeight = QLabel( u'%s' % (str(self.boundingRect.height()) + " mm"), self) gridLayoutMisc = QGridLayout(groupBoxMisc) gridLayoutMisc.addWidget(labelStitchesTotal, 0, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesReal, 1, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesJump, 2, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelStitchesTrim, 3, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelColorTotal, 4, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelColorChanges, 5, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectLeft, 6, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectTop, 7, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectRight, 8, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectBottom, 9, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectWidth, 10, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(labelRectHeight, 11, 0, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesTotal, 0, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesReal, 1, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesJump, 2, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldStitchesTrim, 3, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldColorTotal, 4, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldColorChanges, 5, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectLeft, 6, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectTop, 7, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectRight, 8, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectBottom, 9, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectWidth, 10, 1, Qt.AlignLeft) gridLayoutMisc.addWidget(fieldRectHeight, 11, 1, Qt.AlignLeft) gridLayoutMisc.setColumnStretch(1, 1) groupBoxMisc.setLayout(gridLayoutMisc) # TODO: Color Histogram # Stitch Distribution # groupBoxDist = QGroupBox(self.tr("Stitch Distribution"), widget) # TODO: Stitch Distribution Histogram # Widget Layout vboxLayoutMain = QVBoxLayout(widget) vboxLayoutMain.addWidget(groupBoxMisc) # vboxLayoutMain.addWidget(groupBoxDist) vboxLayoutMain.addStretch(1) widget.setLayout(vboxLayoutMain) scrollArea = QScrollArea(self) scrollArea.setWidgetResizable(True) scrollArea.setWidget(widget) return scrollArea
def setup(self): """initializes the uio of the erp client""" self.progress.setFixedWidth(1000) self.progress.setCancelButton(None) # self.progress.setWindowModality(Qt.WindowModal) self.progress.setValue(1) self.mainwindow.setObjectName("MainWindow") self.mainwindow.resize(832, 668) self.mainwindow.setStyleSheet( "QToolBar{\n" "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,\n" "stop:0 rgba(0,0,0),stop:1 rgb(162, 162, 162, 162));\n" "border: 0px;\n" "}\n" "QToolBar > QWidget{\n" "color:white;\n" "}\n" "QToolBar > QWidget:hover {\n" "background:transparent;\n" " }\n" "QToolBar > QWidget:checked {\n" "background:transparent;\n" " }\n" "#MainWindow{\n" "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,\n" "stop:0 rgba(0,0,0),stop:1 rgb(162, 162, 162, 162));\n" "border: 0px;\n" "}\n" "") self.centralWidget = QWidget(self.mainwindow) self.centralWidget.setObjectName("centralWidget") self.gridLayout_2 = QGridLayout(self.centralWidget) self.gridLayout_2.setObjectName("gridLayout_2") self.stackedWidget = QStackedWidget(self.centralWidget) self.stackedWidget.setStyleSheet("") self.stackedWidget.setObjectName("stackedWidget") self.shortcut = NewShortcut() scroll = QScrollArea() scroll.setWidget(self.shortcut.shortcut_setting) self.stackedWidget.addWidget(self.shortcut.shortcut_setting) self.home_page = QWidget() self.home_page.setObjectName("home_page") self.gridLayout = QGridLayout(self.home_page) self.gridLayout.setObjectName("gridLayout") self.billing_frame_2 = QFrame(self.home_page) self.billing_frame_2.setStyleSheet( "background-image:url(:/images/billing_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#6CBED2;") self.billing_frame_2.setFrameShape(QFrame.StyledPanel) self.billing_frame_2.setFrameShadow(QFrame.Raised) self.billing_frame_2.setObjectName("billing_frame_2") self.verticalLayout_4 = QVBoxLayout(self.billing_frame_2) self.verticalLayout_4.setObjectName("verticalLayout_4") spacerItem = QSpacerItem(20, 217, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_4.addItem(spacerItem) self.label_10 = QLabel(self.billing_frame_2) self.label_10.setStyleSheet("background:transparent;") self.label_10.setObjectName("label_10") self.verticalLayout_4.addWidget(self.label_10) self.gridLayout.addWidget(self.billing_frame_2, 0, 1, 1, 1) self.employee_frame_3 = QFrame(self.home_page) self.employee_frame_3.setStyleSheet( "background-image:url(:/images/employee_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#0099CC;") self.employee_frame_3.setFrameShape(QFrame.StyledPanel) self.employee_frame_3.setFrameShadow(QFrame.Raised) self.employee_frame_3.setObjectName("employee_frame_3") self.verticalLayout_5 = QVBoxLayout(self.employee_frame_3) self.verticalLayout_5.setObjectName("verticalLayout_5") spacerItem1 = QSpacerItem(20, 217, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_5.addItem(spacerItem1) self.label_11 = QLabel(self.employee_frame_3) self.label_11.setStyleSheet("background:transparent;") self.label_11.setObjectName("label_11") self.verticalLayout_5.addWidget(self.label_11) self.gridLayout.addWidget(self.employee_frame_3, 0, 2, 1, 1) self.menu_frame_4 = QFrame(self.home_page) self.menu_frame_4.setStyleSheet( "background-image:url(:/images/menu_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#297ACC;") self.menu_frame_4.setFrameShape(QFrame.StyledPanel) self.menu_frame_4.setFrameShadow(QFrame.Raised) self.menu_frame_4.setObjectName("menu_frame_4") self.verticalLayout_3 = QVBoxLayout(self.menu_frame_4) self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem2 = QSpacerItem(20, 216, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem2) self.label_12 = QLabel(self.menu_frame_4) self.label_12.setStyleSheet("background:transparent;") self.label_12.setObjectName("label_12") self.verticalLayout_3.addWidget(self.label_12) self.gridLayout.addWidget(self.menu_frame_4, 1, 0, 1, 1) self.report_frame_5 = QFrame(self.home_page) self.report_frame_5.setStyleSheet( "background-image:url(:/images/report_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#006BB2;") self.report_frame_5.setFrameShape(QFrame.StyledPanel) self.report_frame_5.setFrameShadow(QFrame.Raised) self.report_frame_5.setObjectName("report_frame_5") self.verticalLayout_6 = QVBoxLayout(self.report_frame_5) self.verticalLayout_6.setObjectName("verticalLayout_6") spacerItem3 = QSpacerItem(20, 216, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_6.addItem(spacerItem3) self.label_13 = QLabel(self.report_frame_5) self.label_13.setStyleSheet("background:transparent;") self.label_13.setObjectName("label_13") self.verticalLayout_6.addWidget(self.label_13) self.gridLayout.addWidget(self.report_frame_5, 1, 1, 1, 1) self.waste_frame_6 = QFrame(self.home_page) self.waste_frame_6.setStyleSheet( "background-image:url(:/images/waste_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#003D7A;") self.waste_frame_6.setFrameShape(QFrame.StyledPanel) self.waste_frame_6.setFrameShadow(QFrame.Raised) self.waste_frame_6.setObjectName("waste_frame_6") self.verticalLayout_7 = QVBoxLayout(self.waste_frame_6) self.verticalLayout_7.setObjectName("verticalLayout_7") spacerItem4 = QSpacerItem(20, 216, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_7.addItem(spacerItem4) self.label_14 = QLabel(self.waste_frame_6) self.label_14.setStyleSheet("background:transparent;") self.label_14.setObjectName("label_14") self.verticalLayout_7.addWidget(self.label_14) self.gridLayout.addWidget(self.waste_frame_6, 1, 2, 1, 1) self.inventory_frame_1 = QFrame(self.home_page) self.inventory_frame_1.setStyleSheet( "background-image:url(:/images/inventory_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#ADEBFF;") self.inventory_frame_1.setFrameShape(QFrame.StyledPanel) self.inventory_frame_1.setFrameShadow(QFrame.Raised) self.inventory_frame_1.setObjectName("inventory_frame_1") self.verticalLayout_2 = QVBoxLayout(self.inventory_frame_1) self.verticalLayout_2.setObjectName("verticalLayout_2") spacerItem5 = QSpacerItem(20, 217, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem5) self.label_9 = QLabel(self.inventory_frame_1) self.label_9.setStyleSheet("background:transparent;") self.label_9.setObjectName("label_9") self.verticalLayout_2.addWidget(self.label_9) self.gridLayout.addWidget(self.inventory_frame_1, 0, 0, 1, 1) self.stackedWidget.addWidget(self.home_page) self.detail_page = QWidget() self.detail_page.setObjectName("detail_page") self.horizontalLayout_2 = QHBoxLayout(self.detail_page) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.main_tabWidget = QTabWidget(self.detail_page) self.main_tabWidget.setAutoFillBackground(False) self.main_tabWidget.setStyleSheet("") self.main_tabWidget.setTabPosition(QTabWidget.West) self.main_tabWidget.setIconSize(QSize(60, 60)) self.main_tabWidget.setElideMode(Qt.ElideNone) self.main_tabWidget.setObjectName("main_tabWidget") ##initializes the tabs self.add_tabs() self.main_tabWidget.setFocusPolicy(Qt.StrongFocus) self.main_tabWidget.focusInEvent = self.change_focus self.main_tabWidget.currentChanged.connect(self.change_focus) self.stackedWidget.currentChanged.connect(self.change_focus) ###### self.horizontalLayout_2.addWidget(self.main_tabWidget) self.stackedWidget.addWidget(self.detail_page) if ('Admin', True) in self.access: self.stackedWidget.addWidget(Admin(self.mainwindow)) notification = NotificationTab() tab = notification.notificationTab_tab_4 tab.custom_class_object = notification # class_object is used to access the api through the self.stackedWidget.addWidget(tab) self.gridLayout_2.addWidget(self.stackedWidget, 0, 0, 1, 1) self.mainwindow.setCentralWidget(self.centralWidget) self.menuBar = QMenuBar(self.mainwindow) self.menuBar.setGeometry(QRect(0, 0, 832, 29)) self.menuBar.setObjectName("menuBar") self.mainwindow.setMenuBar(self.menuBar) self.mainToolBar = QToolBar(self.mainwindow) self.mainToolBar.setLayoutDirection(Qt.RightToLeft) self.mainToolBar.setStyleSheet("") self.mainToolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.mainToolBar.setObjectName("mainToolBar") self.mainwindow.addToolBar(Qt.TopToolBarArea, self.mainToolBar) self.statusBar = QStatusBar(self.mainwindow) self.statusBar.setObjectName("statusBar") self.mainwindow.setStatusBar(self.statusBar) self.toolBar = QToolBar(self.mainwindow) self.toolBar.setLayoutDirection(Qt.RightToLeft) self.toolBar.setStyleSheet("") self.toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.toolBar.setObjectName("toolBar") self.mainwindow.addToolBar(Qt.TopToolBarArea, self.toolBar) self.actionNotification = QAction(self.mainwindow) self.actionNotification.setCheckable(True) self.actionNotification.setChecked(False) self.actionNotification.setEnabled(True) icon6 = QIcon() icon6.addPixmap(QPixmap(":/images/notification.png"), QIcon.Normal, QIcon.Off) self.actionNotification.setIcon(icon6) self.actionNotification.setAutoRepeat(True) self.actionNotification.setVisible(True) self.actionNotification.setIconVisibleInMenu(False) self.actionNotification.setObjectName("actionNotification") self.actionNotification self.actionAdmin = QAction(self.mainwindow) # self.actionAdmin.setCheckable(True) icon7 = QIcon() icon7.addPixmap(QPixmap(":/images/admin.png"), QIcon.Normal, QIcon.Off) self.actionAdmin.setIcon(icon7) self.actionAdmin.setObjectName("actionAdmin") self.actionRefresh = QAction(self.mainwindow) icon8 = QIcon() icon8.addPixmap(QPixmap(":/images/refresh.png"), QIcon.Normal, QIcon.Off) self.actionRefresh.setIcon(icon8) self.actionRefresh.setObjectName("actionRefresh") self.actionHome = QAction(self.mainwindow) # self.actionHome.setCheckable(True) icon9 = QIcon() icon9.addPixmap(QPixmap(":/images/home.png"), QIcon.Normal, QIcon.Off) self.actionHome.setIcon(icon9) self.actionHome.setObjectName("actionHome") self.actionSettings = QAction(self.mainwindow) icon10 = QIcon() icon10.addPixmap(QPixmap(":/images/settings.png"), QIcon.Normal, QIcon.Off) self.actionSettings.setIcon(icon10) self.actionSettings.setObjectName("actionRefresh") self.toolBar.addAction(self.actionNotification) self.toolBar.addSeparator() self.toolBar.addAction(self.actionAdmin) if ('Admin', True) in self.access: self.toolBar.addSeparator() else: self.actionAdmin.setVisible(False) self.toolBar.addAction(self.actionHome) self.toolBar.addSeparator() self.toolBar.addAction(self.actionRefresh) self.toolBar.addSeparator() self.toolBar.addAction(self.actionSettings) ##retranslates self.mainwindow.setWindowTitle( QApplication.translate("MainWindow", settings.company, None, QApplication.UnicodeUTF8)) self.label_10.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">BILLING</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_11.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">EMPLOYEE</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_12.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">MENU</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_13.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">REPORT</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_14.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">WASTE</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_9.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">INVENTORY</p></body></html>", None, QApplication.UnicodeUTF8)) self.inventory_frame_1.setToolTip( QApplication.translate("MainWindow", "Go to the Inventory Tab", None, QApplication.UnicodeUTF8)) self.billing_frame_2.setToolTip( QApplication.translate("MainWindow", "Go to the Billing Tab", None, QApplication.UnicodeUTF8)) self.employee_frame_3.setToolTip( QApplication.translate("MainWindow", "Go to the Employee Tab", None, QApplication.UnicodeUTF8)) self.menu_frame_4.setToolTip( QApplication.translate("MainWindow", "Go to the Menu Tab", None, QApplication.UnicodeUTF8)) self.report_frame_5.setToolTip( QApplication.translate("MainWindow", "Go to the Report Tab", None, QApplication.UnicodeUTF8)) self.waste_frame_6.setToolTip( QApplication.translate("MainWindow", "Go to the Waste Tab", None, QApplication.UnicodeUTF8)) self.toolBar.setWindowTitle( QApplication.translate("MainWindow", "toolBar", None, QApplication.UnicodeUTF8)) self.actionNotification.setText("&&Notification") # QApplication.translate("MainWindow", "&Notification", None, QApplication.UnicodeUTF8)) self.actionNotification.setToolTip( QApplication.translate("MainWindow", "Click to see new notifications", None, QApplication.UnicodeUTF8)) # self.actionNotification.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+N", None, QApplication.UnicodeUTF8)) self.actionAdmin.setText('&&Admin') # QApplication.translate("MainWindow", "Admin", None, QApplication.UnicodeUTF8)) self.actionAdmin.setToolTip( QApplication.translate("MainWindow", "Click to go to admin interface", None, QApplication.UnicodeUTF8)) # self.actionAdmin.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+A", None, QApplication.UnicodeUTF8)) self.actionRefresh.setText("&&Refresh") # QApplication.translate("MainWindow", "Refresh", None, QApplication.UnicodeUTF8)) self.actionRefresh.setToolTip( QApplication.translate("MainWindow", "refreshes the data from the server", None, QApplication.UnicodeUTF8)) # self.actionRefresh.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+R", None, QApplication.UnicodeUTF8)) self.actionHome.setText('&&Home') # QApplication.translate("MainWindow", "Home", None, QApplication.UnicodeUTF8)) self.actionHome.setToolTip( QApplication.translate("MainWindow", "Go back to the home screen", None, QApplication.UnicodeUTF8)) self.actionSettings.setText('&&Settings') # QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.actionSettings.setToolTip( QApplication.translate("MainWindow", "Go to the settings panel", None, QApplication.UnicodeUTF8)) # self.actionHome.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+H", None, QApplication.UnicodeUTF8)) self.stackedWidget.setCurrentIndex(1) self.main_tabWidget.setCurrentIndex(0) self.ob = self.main_tabWidget.tabBar() # self.add_tool_tip(self.ob) todo avoided due to segmentation fault error, left for future fixes self.tb = EventHandlerForTabBar() self.ob.installEventFilter(self.tb) QMetaObject.connectSlotsByName(self.mainwindow)
def setup(self): self.dirty = False self.def_cfg = copy.deepcopy(self.config) self.config.update_from_user_file() self.base_cfg = copy.deepcopy(self.config) self.categories = QListWidget() #self.categories.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Expanding) self.settings = QStackedWidget() #self.categories.setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Expanding) QObject.connect(self.categories, SIGNAL('itemSelectionChanged()'), self.category_selected) self.widget_list = {} for cat in self.config.get_categories(): self.widget_list[cat] = {} longest_cat = 0 for cat in self.config.get_categories(): if len(cat) > longest_cat: longest_cat = len(cat) self.categories.addItem(cat) settings_layout = QGridLayout() r = 0 c = 0 for setting in self.config.get_settings(cat): info = self.config.get_setting(cat, setting, True) s = QWidget() s.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed) sl = QVBoxLayout() label = QLabel() if info.has_key('alias'): label.setText(info['alias']) else: label.setText(setting) if info.has_key('about'): label.setToolTip(info['about']) sl.addWidget(label) if info['type'] == constants.CT_LINEEDIT: w = LineEdit(self, self.config,cat,setting,info) elif info['type'] == constants.CT_CHECKBOX: w = CheckBox(self, self.config,cat,setting,info) elif info['type'] == constants.CT_SPINBOX: w = SpinBox(self, self.config,cat,setting,info) elif info['type'] == constants.CT_DBLSPINBOX: w = DoubleSpinBox(self, self.config,cat,setting,info) elif info['type'] == constants.CT_COMBO: w = ComboBox(self, self.config,cat,setting,info) w.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed) self.widget_list[cat][setting] = w sl.addWidget(w) s.setLayout(sl) c = self.config.config[cat].index(setting) % 2 settings_layout.addWidget(s, r, c) if c == 1: r += 1 settings = QWidget() settings.setLayout(settings_layout) settings_scroller = QScrollArea() settings_scroller.setWidget(settings) settings_scroller.setWidgetResizable(True) self.settings.addWidget(settings_scroller) font = self.categories.font() fm = QFontMetrics(font) self.categories.setMaximumWidth(fm.widthChar('X')*(longest_cat+4)) self.main = QWidget() self.main_layout = QVBoxLayout() self.config_layout = QHBoxLayout() self.config_layout.addWidget(self.categories) self.config_layout.addWidget(self.settings) self.mainButtons = QDialogButtonBox(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Reset | QDialogButtonBox.Apply) self.main_apply = self.mainButtons.button(QDialogButtonBox.StandardButton.Apply) self.main_reset = self.mainButtons.button(QDialogButtonBox.StandardButton.Reset) self.main_defaults = self.mainButtons.button(QDialogButtonBox.StandardButton.LastButton) QObject.connect(self.mainButtons, SIGNAL('clicked(QAbstractButton *)'), self.mainbutton_clicked) self.dirty_check() self.main_layout.addLayout(self.config_layout) self.main_layout.addWidget(self.mainButtons) self.main.setLayout(self.main_layout) self.setCentralWidget(self.main) self.setWindowTitle(self.title) self.setUnifiedTitleAndToolBarOnMac(True) self.categories.setCurrentItem(self.categories.item(0)) self.menuBar = QMenuBar() self.filemenu = QMenu('&File') self.quitAction = QAction(self) self.quitAction.setText('&Quit') if platform.system() != 'Darwin': self.quitAction.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q)) QObject.connect(self.quitAction, SIGNAL('triggered()'), self.quitApp) self.filemenu.addAction(self.quitAction) self.menuBar.addMenu(self.filemenu) self.setMenuBar(self.menuBar) self.show() self.activateWindow() self.raise_() self.setMinimumWidth(self.geometry().width()*1.2) screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)
def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("Cobaya input generator for Cosmology") self.setGeometry(0, 0, 1500, 1000) self.move( QApplication.desktop().screenGeometry().center() - self.rect().center()) self.show() # Main layout self.layout = QHBoxLayout() self.setLayout(self.layout) self.layout_left = QVBoxLayout() self.layout.addLayout(self.layout_left) self.layout_output = QVBoxLayout() self.layout.addLayout(self.layout_output) # LEFT: Options self.options = QWidget() self.layout_options = QVBoxLayout() self.options.setLayout(self.layout_options) self.options_scroll = QScrollArea() self.options_scroll.setWidget(self.options) self.options_scroll.setWidgetResizable(True) self.layout_left.addWidget(self.options_scroll) titles = odict([ ["Presets", odict([["preset", "Presets"]])], ["Cosmological Model", odict([ ["theory", "Theory code"], ["primordial", "Primordial perturbations"], ["geometry", "Geometry"], ["hubble", "Hubble parameter constraint"], ["matter", "Matter sector"], ["neutrinos", "Neutrinos and other extra matter"], ["dark_energy", "Lambda / Dark energy"], ["bbn", "BBN"], ["reionization", "Reionization history"]])], ["Data sets", odict([ ["like_cmb", "CMB experiments"], ["like_bao", "BAO experiments"], ["like_sn", "SN experiments"], ["like_H0", "Local H0 measurements"]])], ["Sampler", odict([["sampler", "Samplers"]])]]) self.combos = odict() for group, fields in titles.items(): group_box = QGroupBox(group) self.layout_options.addWidget(group_box) group_layout = QVBoxLayout(group_box) for a, desc in fields.items(): self.combos[a] = QComboBox() if len(fields) > 1: label = QLabel(desc) group_layout.addWidget(label) group_layout.addWidget(self.combos[a]) self.combos[a].addItems( [text(k, v) for k, v in getattr(input_database, a).items()]) # PLANCK NAMES CHECKBOX TEMPORARILY DISABLED # if a == "theory": # # Add Planck-naming checkbox # self.planck_names = QCheckBox( # "Keep common parameter names " # "(useful for fast CLASS/CAMB switching)") # group_layout.addWidget(self.planck_names) # Connect to refreshers -- needs to be after adding all elements for field, combo in self.combos.items(): if field == "preset": combo.currentIndexChanged.connect(self.refresh_preset) else: combo.currentIndexChanged.connect(self.refresh) # self.planck_names.stateChanged.connect(self.refresh_keep_preset) # RIGHT: Output + buttons self.display_tabs = QTabWidget() self.display = {} for k in ["yaml", "python", "citations"]: self.display[k] = QTextEdit() self.display[k].setLineWrapMode(QTextEdit.NoWrap) self.display[k].setFontFamily("mono") self.display[k].setCursorWidth(0) self.display[k].setReadOnly(True) self.display_tabs.addTab(self.display[k], k) self.layout_output.addWidget(self.display_tabs) # Buttons self.buttons = QHBoxLayout() self.save_button = QPushButton('Save', self) self.copy_button = QPushButton('Copy to clipboard', self) self.buttons.addWidget(self.save_button) self.buttons.addWidget(self.copy_button) self.save_button.released.connect(self.save_file) self.copy_button.released.connect(self.copy_clipb) self.layout_output.addLayout(self.buttons) self.save_dialog = QFileDialog() self.save_dialog.setFileMode(QFileDialog.AnyFile) self.save_dialog.setAcceptMode(QFileDialog.AcceptSave)
def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("Cobaya input generator for Cosmology") self.setStyleSheet("* {font-size:%s;}" % font_size) # Menu bar for defaults self.menubar = QMenuBar() defaults_menu = self.menubar.addMenu('&Show defaults and bibliography for a module...') menu_actions = {} for kind in _kinds: submenu = defaults_menu.addMenu(subfolders[kind]) modules = get_available_modules(kind) menu_actions[kind] = {} for module in modules: menu_actions[kind][module] = QAction(module, self) menu_actions[kind][module].setData((kind, module)) menu_actions[kind][module].triggered.connect(self.show_defaults) submenu.addAction(menu_actions[kind][module]) # Main layout self.menu_layout = QVBoxLayout() self.menu_layout.addWidget(self.menubar) self.setLayout(self.menu_layout) self.layout = QHBoxLayout() self.menu_layout.addLayout(self.layout) self.layout_left = QVBoxLayout() self.layout.addLayout(self.layout_left) self.layout_output = QVBoxLayout() self.layout.addLayout(self.layout_output) # LEFT: Options self.options = QWidget() self.layout_options = QVBoxLayout() self.options.setLayout(self.layout_options) self.options_scroll = QScrollArea() self.options_scroll.setWidget(self.options) self.options_scroll.setWidgetResizable(True) self.layout_left.addWidget(self.options_scroll) titles = odict([ ["Presets", odict([["preset", "Presets"]])], ["Cosmological Model", odict([ ["theory", "Theory code"], ["primordial", "Primordial perturbations"], ["geometry", "Geometry"], ["hubble", "Hubble parameter constraint"], ["matter", "Matter sector"], ["neutrinos", "Neutrinos and other extra matter"], ["dark_energy", "Lambda / Dark energy"], ["bbn", "BBN"], ["reionization", "Reionization history"]])], ["Data sets", odict([ ["like_cmb", "CMB experiments"], ["like_bao", "BAO experiments"], ["like_des", "DES measurements"], ["like_sn", "SN experiments"], ["like_H0", "Local H0 measurements"]])], ["Sampler", odict([["sampler", "Samplers"]])]]) self.combos = odict() for group, fields in titles.items(): group_box = QGroupBox(group) self.layout_options.addWidget(group_box) group_layout = QVBoxLayout(group_box) for a, desc in fields.items(): self.combos[a] = QComboBox() if len(fields) > 1: label = QLabel(desc) group_layout.addWidget(label) group_layout.addWidget(self.combos[a]) self.combos[a].addItems( [text(k, v) for k, v in getattr(input_database, a).items()]) # PLANCK NAMES CHECKBOX TEMPORARILY DISABLED # if a == "theory": # # Add Planck-naming checkbox # self.planck_names = QCheckBox( # "Keep common parameter names " # "(useful for fast CLASS/CAMB switching)") # group_layout.addWidget(self.planck_names) # Connect to refreshers -- needs to be after adding all elements for field, combo in self.combos.items(): if field == "preset": combo.currentIndexChanged.connect(self.refresh_preset) else: combo.currentIndexChanged.connect(self.refresh) # self.planck_names.stateChanged.connect(self.refresh_keep_preset) # RIGHT: Output + buttons self.display_tabs = QTabWidget() self.display = {} for k in ["yaml", "python", "bibliography"]: self.display[k] = QTextEdit() self.display[k].setLineWrapMode(QTextEdit.NoWrap) self.display[k].setFontFamily("mono") self.display[k].setCursorWidth(0) self.display[k].setReadOnly(True) self.display_tabs.addTab(self.display[k], k) self.layout_output.addWidget(self.display_tabs) # Buttons self.buttons = QHBoxLayout() self.save_button = QPushButton('Save', self) self.copy_button = QPushButton('Copy to clipboard', self) self.buttons.addWidget(self.save_button) self.buttons.addWidget(self.copy_button) self.save_button.released.connect(self.save_file) self.copy_button.released.connect(self.copy_clipb) self.layout_output.addLayout(self.buttons) self.save_dialog = QFileDialog() self.save_dialog.setFileMode(QFileDialog.AnyFile) self.save_dialog.setAcceptMode(QFileDialog.AcceptSave) self.read_settings() self.show()
def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("Cobaya input generator for Cosmology") self.setGeometry(0, 0, 1500, 1000) self.move( QApplication.desktop().screen().rect().center() - self.rect().center()) self.show() # Main layout self.layout = QHBoxLayout() self.setLayout(self.layout) self.layout_left = QVBoxLayout() self.layout.addLayout(self.layout_left) self.layout_output = QVBoxLayout() self.layout.addLayout(self.layout_output) # LEFT: Options self.options = QWidget() self.layout_options = QVBoxLayout() self.options.setLayout(self.layout_options) self.options_scroll = QScrollArea() self.options_scroll.setWidget(self.options) self.options_scroll.setWidgetResizable(True) self.layout_left.addWidget(self.options_scroll) self.atoms = odict() titles = odict([ ["preset", "Presets"], ["theory", "Theory code"], ["primordial", "Primordial perturbations"], ["geometry", "Geometry"], ["hubble", "Constaint on hubble parameter"], ["baryons", "Baryon sector"], ["dark_matter", "Dark matter"], ["dark_energy", "Lambda / Dark energy"], ["neutrinos", "Neutrinos and other extra matter"], ["bbn", "BBN"], ["reionization", "Reionization history"], ["cmb_lensing", "CMB lensing"], ["cmb", "CMB experiments"], ["sampler", "Samplers"]]) for a in titles: self.atoms[a] = { "group": QGroupBox(titles[a]), "combo": QComboBox()} self.layout_options.addWidget(self.atoms[a]["group"]) self.atoms[a]["layout"] = QVBoxLayout(self.atoms[a]["group"]) self.atoms[a]["layout"].addWidget(self.atoms[a]["combo"]) self.atoms[a]["combo"].addItems( [text(k,v) for k,v in getattr(input_database, a).items()]) # Connect to refreshers -- needs to be after adding all elements for a in self.atoms: if a == "preset": self.atoms["preset"]["combo"].currentIndexChanged.connect( self.refresh_preset) continue self.atoms[a]["combo"].currentIndexChanged.connect(self.refresh) # Add Planck-naming checkbox and connect to refresher too self.planck_names = QCheckBox("Keep common names") self.atoms["theory"]["layout"].addWidget(self.planck_names) self.planck_names.stateChanged.connect(self.refresh) # RIGHT: Output + buttons self.display_tabs = QTabWidget() self.display = {} for k in ["yaml", "python"]: self.display[k] = QTextEdit() self.display[k].setLineWrapMode(QTextEdit.NoWrap) self.display[k].setFontFamily("mono") self.display[k].setCursorWidth(0) self.display[k].setReadOnly(True) self.display_tabs.addTab(self.display[k], k) self.layout_output.addWidget(self.display_tabs) # Buttons self.buttons = QHBoxLayout() self.save_button = QPushButton('Save', self) self.copy_button = QPushButton('Copy to clipboard', self) self.buttons.addWidget(self.save_button) self.buttons.addWidget(self.copy_button) self.save_button.released.connect(self.save_file) self.copy_button.released.connect(self.copy_clipb) self.layout_output.addLayout(self.buttons) self.save_dialog = QFileDialog() self.save_dialog.setFileMode(QFileDialog.AnyFile) self.save_dialog.setAcceptMode(QFileDialog.AcceptSave)