def do_paint(self, painter, option, index): text = unicode(index.data(Qt.DisplayRole).toString()) font = QFont(option.font) font.setPointSize(QFontInfo(font).pointSize() * 1.5) font2 = QFont(font) font2.setFamily(text) system, has_latin = writing_system_for_font(font2) if has_latin: font = font2 r = option.rect if option.state & QStyle.State_Selected: painter.setPen(QPen(option.palette.highlightedText(), 0)) if (option.direction == Qt.RightToLeft): r.setRight(r.right() - 4) else: r.setLeft(r.left() + 4) painter.setFont(font) painter.drawText(r, Qt.AlignVCenter|Qt.AlignLeading|Qt.TextSingleLine, text) if (system != QFontDatabase.Any): w = painter.fontMetrics().width(text + " ") painter.setFont(font2) sample = QFontDatabase().writingSystemSample(system) if (option.direction == Qt.RightToLeft): r.setRight(r.right() - w) else: r.setLeft(r.left() + w) painter.drawText(r, Qt.AlignVCenter|Qt.AlignLeading|Qt.TextSingleLine, sample)
def _getHeaderFont(self): """ Returns the font used for the header. @return: the header font @rtype: QFont """ font = QFont() font.setFamily(PM_HEADER_FONT) font.setPointSize(PM_HEADER_FONT_POINT_SIZE) font.setBold(PM_HEADER_FONT_BOLD) return font
def getButtonFont(self): """ Returns the font for the tool buttons in the grid. @return: Button font. @rtype: U{B{QFont}<http://doc.trolltech.com/4/qfont.html>} """ # Font for tool buttons. buttonFont = QFont(self.font()) buttonFont.setFamily(BUTTON_FONT) buttonFont.setPointSize(BUTTON_FONT_POINT_SIZE) buttonFont.setBold(BUTTON_FONT_BOLD) return buttonFont
def __init__(self, widget: Dependency('widget/', lambda v: hasattr(v.view, 'mode'))): view = widget.view mode = view.mode if mode.name in self.mode_lexer_map: lexer_cls = self.mode_lexer_map[mode.name] else: lexer_name_possibilities = ["QsciLexer" + mode.name, "QsciLexer" + mode.name.title(), "QsciLexer" + mode.name.upper()] for lexer_name in lexer_name_possibilities: if hasattr(Qsci, lexer_name): lexer_cls = getattr(Qsci, lexer_name, None) break else: lexer_cls = None if lexer_cls is not None: font = QFont() font.setFamily('DejaVu Sans Mono') font.setFixedPitch(True) font.setPointSize(10) lexer = lexer_cls(widget) lexer.setDefaultFont(font) widget.setLexer(lexer)
def do_paint(self, painter, option, index): text = unicode(index.data(Qt.DisplayRole).toString()) font = QFont(option.font) font.setPointSize(QFontInfo(font).pointSize() * 1.5) font2 = QFont(font) font2.setFamily(text) system, has_latin = writing_system_for_font(font2) if has_latin: font = font2 r = option.rect if option.state & QStyle.State_Selected: painter.setPen(QPen(option.palette.highlightedText(), 0)) if (option.direction == Qt.RightToLeft): r.setRight(r.right() - 4) else: r.setLeft(r.left() + 4) painter.setFont(font) painter.drawText(r, Qt.AlignVCenter | Qt.AlignLeading | Qt.TextSingleLine, text) if (system != QFontDatabase.Any): w = painter.fontMetrics().width(text + " ") painter.setFont(font2) sample = QFontDatabase().writingSystemSample(system) if (option.direction == Qt.RightToLeft): r.setRight(r.right() - w) else: r.setLeft(r.left() + w) painter.drawText( r, Qt.AlignVCenter | Qt.AlignLeading | Qt.TextSingleLine, sample)
def ui_MMKit_GroupBox(self, MMKitDialog): #Start MMKit groupbox (includes atom, clipboard and library tabs) self.MMKit_groupBox = QtGui.QGroupBox(MMKitDialog) self.MMKit_groupBox.setObjectName("MMKit_groupBox") self.MMKit_groupBox.setAutoFillBackground(True) palette = MMKitDialog.getGroupBoxPalette() self.MMKit_groupBox.setPalette(palette) styleSheet = MMKitDialog.getGroupBoxStyleSheet() self.MMKit_groupBox.setStyleSheet(styleSheet) self.MMKitGrpBox_VBoxLayout = QtGui.QVBoxLayout(self.MMKit_groupBox) self.MMKitGrpBox_VBoxLayout.setMargin(pmGrpBoxVboxLayoutMargin) self.MMKitGrpBox_VBoxLayout.setSpacing(pmGrpBoxVboxLayoutSpacing) self.MMKitGrpBox_VBoxLayout.setObjectName("MMKitGrpBox_VBoxLayout") self.MMKitGrpBox_TitleButton = MMKitDialog.getGroupBoxTitleButton("MMKit", self.MMKit_groupBox) self.MMKitGrpBox_VBoxLayout.addWidget(self.MMKitGrpBox_TitleButton) self.mmkit_tab = QtGui.QTabWidget(self.MMKit_groupBox) self.mmkit_tab.setEnabled(True) # Height is fixed. Mark 2007-05-29. self.mmkit_tab.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred), QSizePolicy.Policy(QSizePolicy.Fixed))) self.mmkit_tab.setObjectName("mmkit_tab") self.atomsPage = QtGui.QWidget() self.atomsPage.setObjectName("atomsPage") self.mmkit_tab.addTab(self.atomsPage, "") self.atomsPageFrame = QtGui.QFrame(self.atomsPage) # atomsPageFrame needs to be reviewed carefully. Mark 2007-06-20 sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Policy(3),QtGui.QSizePolicy.Policy(1)) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.atomsPageFrame.sizePolicy().hasHeightForWidth()) self.atomsPageFrame.setSizePolicy(sizePolicy) self.atomsPageFrame.setFrameShape(QtGui.QFrame.NoFrame) self.atomsPageFrame.setFrameShadow(QtGui.QFrame.Plain) self.atomsPageFrame.setMinimumSize(QtCore.QSize(100,100)) self.atomsPageFrame.setObjectName("atomsPageFrame") self.atomsPage_VBoxLayout = QtGui.QVBoxLayout(self.atomsPageFrame) self.atomsPage_VBoxLayout.setMargin(pmMMKitPageMargin) # Was 4. Mark 2007-05-30 self.atomsPage_VBoxLayout.setSpacing(2) # Element Button GroupBox begins here. ##################### self.elementButtonGroup = QtGui.QGroupBox(self.atomsPageFrame) sizePolicy = QtGui.QSizePolicy( QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.elementButtonGroup.setSizePolicy(sizePolicy) self.elementButtonGroup.setMinimumSize( QtCore.QSize(pmMMKitButtonWidth * 4, pmMMKitButtonHeight * 4 + 4)) self.elementButtonGroup.setObjectName("elementButtonGroup") self.MMKit_GridLayout = QtGui.QGridLayout(self.elementButtonGroup) self.MMKit_GridLayout.setMargin(1) # Was 0. Mark 2007-05-30 self.MMKit_GridLayout.setSpacing(0) self.MMKit_GridLayout.setObjectName("MMKit_GridLayout") # Font for toolbuttons. font = QFont(self.atomsPageFrame.font()) font.setFamily(pmMMKitButtonFont) font.setPointSize(pmMMKitButtonFontPointSize) font.setBold(pmMMKitButtonFontBold) #font.setWeight(75) #font.setItalic(False) #font.setUnderline(False) #font.setStrikeOut(False) # All this would be much nicer using a dictionary in a loop. # Later, when time permits. Mark 2007-05-30. self.toolButton1 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton1.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton1.setCheckable(True) self.toolButton1.setFont(font) self.toolButton1.setObjectName("toolButton1") self.MMKit_GridLayout.addWidget(self.toolButton1,0,4,1,1) self.toolButton2 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton2.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton2.setCheckable(True) self.toolButton2.setFont(font) self.toolButton2.setObjectName("toolButton2") self.MMKit_GridLayout.addWidget(self.toolButton2,0,5,1,1) self.toolButton6 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton6.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton6.setCheckable(True) self.toolButton6.setFont(font) self.toolButton6.setObjectName("toolButton6") self.MMKit_GridLayout.addWidget(self.toolButton6,1,1,1,1) self.toolButton7 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton7.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton7.setCheckable(True) self.toolButton7.setFont(font) self.toolButton7.setObjectName("toolButton7") self.MMKit_GridLayout.addWidget(self.toolButton7,1,2,1,1) self.toolButton8 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton8.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton8.setCheckable(True) self.toolButton8.setFont(font) self.toolButton8.setObjectName("toolButton8") self.MMKit_GridLayout.addWidget(self.toolButton8,1,3,1,1) self.toolButton10 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton10.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton10.setCheckable(True) self.toolButton10.setFont(font) self.toolButton10.setObjectName("toolButton10") self.MMKit_GridLayout.addWidget(self.toolButton10,1,5,1,1) self.toolButton9 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton9.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton9.setCheckable(True) self.toolButton9.setFont(font) self.toolButton9.setObjectName("toolButton9") self.MMKit_GridLayout.addWidget(self.toolButton9,1,4,1,1) self.toolButton13 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton13.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton13.setCheckable(True) self.toolButton13.setFont(font) self.toolButton13.setObjectName("toolButton13") self.MMKit_GridLayout.addWidget(self.toolButton13,2,0,1,1) self.toolButton17 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton17.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton17.setCheckable(True) self.toolButton17.setFont(font) self.toolButton17.setObjectName("toolButton17") self.MMKit_GridLayout.addWidget(self.toolButton17,2,4,1,1) self.toolButton5 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton5.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton5.setCheckable(True) self.toolButton5.setFont(font) self.toolButton5.setObjectName("toolButton5") self.MMKit_GridLayout.addWidget(self.toolButton5,1,0,1,1) self.toolButton10_2 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton10_2.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton10_2.setCheckable(True) self.toolButton10_2.setFont(font) self.toolButton10_2.setObjectName("toolButton10_2") self.MMKit_GridLayout.addWidget(self.toolButton10_2,2,5,1,1) self.toolButton15 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton15.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton15.setCheckable(True) self.toolButton15.setFont(font) self.toolButton15.setObjectName("toolButton15") self.MMKit_GridLayout.addWidget(self.toolButton15,2,2,1,1) self.toolButton16 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton16.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton16.setCheckable(True) self.toolButton16.setFont(font) self.toolButton16.setObjectName("toolButton16") self.MMKit_GridLayout.addWidget(self.toolButton16,2,3,1,1) self.toolButton14 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton14.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton14.setCheckable(True) self.toolButton14.setFont(font) self.toolButton14.setObjectName("toolButton14") self.MMKit_GridLayout.addWidget(self.toolButton14,2,1,1,1) self.toolButton33 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton33.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton33.setCheckable(True) self.toolButton33.setFont(font) self.toolButton33.setObjectName("toolButton33") self.MMKit_GridLayout.addWidget(self.toolButton33,3,2,1,1) self.toolButton34 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton34.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton34.setCheckable(True) self.toolButton34.setFont(font) self.toolButton34.setObjectName("toolButton34") self.MMKit_GridLayout.addWidget(self.toolButton34,3,3,1,1) self.toolButton35 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton35.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton35.setCheckable(True) self.toolButton35.setFont(font) self.toolButton35.setObjectName("toolButton35") self.MMKit_GridLayout.addWidget(self.toolButton35,3,4,1,1) self.toolButton32 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton32.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton32.setCheckable(True) self.toolButton32.setFont(font) self.toolButton32.setObjectName("toolButton32") self.MMKit_GridLayout.addWidget(self.toolButton32,3,1,1,1) self.toolButton36 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton36.setFixedSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.toolButton36.setCheckable(True) self.toolButton36.setFont(font) self.toolButton36.setObjectName("toolButton36") self.MMKit_GridLayout.addWidget(self.toolButton36,3,5,1,1) self.atomsPage_VBoxLayout.addWidget(self.elementButtonGroup) # Height is fixed (i.e. locked). Mark 2007-05-29. self.elementButtonGroup.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred), QSizePolicy.Policy(QSizePolicy.Fixed))) # Atomic Hybrid label self.atomic_hybrids_label = QtGui.QLabel(self.atomsPageFrame) self.atomic_hybrids_label.setText("Atomic Hybrids :") self.atomsPage_VBoxLayout.addWidget(self.atomic_hybrids_label) # Elements Button GroupBox ends here. ####################### # This special HBoxLayout contains both the hybrid button group and a # vert spacer (width = 0) to keep the Qt layout working properly # in certain situations like that described in bug 2407. # Mark 2007-06-20. self.special_HBoxLayout = QtGui.QHBoxLayout() self.special_HBoxLayout.setMargin(0) self.special_HBoxLayout.setSpacing(6) self.special_HBoxLayout.setObjectName("special_HBoxLayout") self.atomsPage_VBoxLayout.addLayout(self.special_HBoxLayout) # Hybrid GroupBox begins here ############################### self.hybrid_btngrp = QtGui.QGroupBox(self.atomsPageFrame) self.hybrid_btngrp.setObjectName("hybrid_btngrp") self.special_HBoxLayout.addWidget(self.hybrid_btngrp) self.hybridBtns_HBoxLayout = QtGui.QHBoxLayout(self.hybrid_btngrp) self.hybridBtns_HBoxLayout.setMargin(2) self.hybridBtns_HBoxLayout.setSpacing(0) self.hybridBtns_HBoxLayout.setObjectName("hybridBtns_HBoxLayout") self.sp3_btn = QtGui.QToolButton(self.hybrid_btngrp) self.sp3_btn.setMinimumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.sp3_btn.setMaximumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.sp3_btn.setCheckable(True) self.sp3_btn.setObjectName("sp3_btn") self.hybridBtns_HBoxLayout.addWidget(self.sp3_btn) self.sp2_btn = QtGui.QToolButton(self.hybrid_btngrp) self.sp2_btn.setMinimumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.sp2_btn.setMaximumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.sp2_btn.setCheckable(True) self.sp2_btn.setObjectName("sp2_btn") self.hybridBtns_HBoxLayout.addWidget(self.sp2_btn) self.sp_btn = QtGui.QToolButton(self.hybrid_btngrp) self.sp_btn.setMinimumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.sp_btn.setMaximumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.sp_btn.setCheckable(True) self.sp_btn.setObjectName("sp_btn") self.hybridBtns_HBoxLayout.addWidget(self.sp_btn) self.graphitic_btn = QtGui.QToolButton(self.hybrid_btngrp) self.graphitic_btn.setMinimumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.graphitic_btn.setMaximumSize(QtCore.QSize(pmMMKitButtonWidth,pmMMKitButtonHeight)) self.graphitic_btn.setCheckable(True) self.graphitic_btn.setObjectName("graphitic_btn") self.hybridBtns_HBoxLayout.addWidget(self.graphitic_btn) # This VSpacer is needed to help (but not completely) fix bug 2407. It # maintains the height of the layout(s) containing the hybrid button # group when it is hidden using hide(). Without this spacer the layout # gets screwed up in special situations like that described in bug 2407. # The + 10 below is needed to account for the margin (4 pixels) and # the additional 6 just help (I have a theory that the height of the # frame containing the label above the hybrid group box shrinks when # the label is hidden by inserting a space character). I'm # not going to worry about this now. +10 works well enough. # Mark 2007-06-20. VSpacer = QtGui.QSpacerItem(0, pmMMKitButtonHeight + 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) #self.hybridBtns_HBoxLayout.addItem(VSpacer) self.special_HBoxLayout.addItem(VSpacer) self.hybridBtns_HBoxLayout.addStretch(0) # Height is fixed. Mark 2007-05-29. self.hybrid_btngrp.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding), QSizePolicy.Policy(QSizePolicy.Fixed))) # This spacer keeps the MMKit button grid compressed when # the hybrid button group is hidden. self.atomsPageBottomVSpacer = \ QtGui.QSpacerItem(5, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.MinimumExpanding) self.atomsPage_VBoxLayout.addItem(self.atomsPageBottomVSpacer) # Clipboard page begins here ############################################ self.clipboardPage = QtGui.QWidget() self.clipboardPage.setObjectName("clipboardPage") self.gridlayout3 = QtGui.QGridLayout(self.clipboardPage) self.gridlayout3.setMargin(pmMMKitPageMargin) # Was 4. Mark 2007-05-30 self.gridlayout3.setSpacing(2) self.gridlayout3.setObjectName("gridlayout3") self.chunkListBox = QtGui.QListWidget(self.clipboardPage) self.chunkListBox.setMinimumSize(QtCore.QSize(100,100)) # Height is fixed. Mark 2007-05-29. self.chunkListBox.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding), QSizePolicy.Policy(QSizePolicy.Fixed))) self.chunkListBox.setObjectName("chunkListBox") self.gridlayout3.addWidget(self.chunkListBox,0,0,1,1) self.mmkit_tab.addTab(self.clipboardPage, "") self.libraryPage = QtGui.QWidget() #self.libraryPage = QtGui.QScrollArea() #self.libraryPageWidget = QtGui.QWidget() #self.libraryPage.setWidget(self.libraryPageWidget) self.libraryPage.setObjectName("libraryPage") self.mmkit_tab.addTab(self.libraryPage, "") self.MMKitGrpBox_VBoxLayout.addWidget(self.mmkit_tab) self.transmuteAtomsAction = QtGui.QWidgetAction(self.w) self.transmuteAtomsAction.setText("Transmute Atoms") self.transmuteAtomsAction.setIcon(geticon( 'ui/actions/Toolbars/Smart/Transmute_Atoms')) self.transmuteAtomsAction.setCheckable(False) transmuteBtn_HBoxLayout = QtGui.QHBoxLayout() self.transmuteBtn = QtGui.QToolButton(self.MMKit_groupBox) self.transmuteBtn.setDefaultAction(self.transmuteAtomsAction) self.transmuteBtn.setFixedSize(QtCore.QSize(36, 36)) self.transmuteBtn.setIconSize(QtCore.QSize(22,22)) transmuteBtn_HBoxLayout.addWidget(self.transmuteBtn) self.browseButton = QtGui.QPushButton(MMKitDialog) transmuteBtn_HBoxLayout.addWidget(self.browseButton) self.defaultPartLibButton = QtGui.QPushButton(MMKitDialog) transmuteBtn_HBoxLayout.addWidget(self.defaultPartLibButton) self.atomsPageSpacer = QtGui.QSpacerItem(0, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) transmuteBtn_HBoxLayout.addItem(self.atomsPageSpacer) self.MMKitGrpBox_VBoxLayout.addLayout(transmuteBtn_HBoxLayout) self.transmuteCB = QtGui.QCheckBox(" Force to Keep Bonds", self.MMKit_groupBox) self.MMKitGrpBox_VBoxLayout.addWidget(self.transmuteCB) #End MMKit groupbox self.pmVBoxLayout.addWidget(self.MMKit_groupBox) # This line is important. Without it, the MMKit groupbox is # too wide by default and causes a horizontal scrollbar # to be displayed at the bottom of the PropMgr. Mark 2007-05-30 self.MMKit_groupBox.setMinimumWidth(200) # Height is fixed. Mark 2007-05-29. self.MMKit_groupBox.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding), QSizePolicy.Policy(QSizePolicy.Fixed)))
def ui_MMKit_GroupBox(self, MMKitDialog): #Start MMKit groupbox (includes atom, clipboard and library tabs) self.MMKit_groupBox = QtGui.QGroupBox(MMKitDialog) self.MMKit_groupBox.setObjectName("MMKit_groupBox") self.MMKit_groupBox.setAutoFillBackground(True) palette = MMKitDialog.getGroupBoxPalette() self.MMKit_groupBox.setPalette(palette) styleSheet = MMKitDialog.getGroupBoxStyleSheet() self.MMKit_groupBox.setStyleSheet(styleSheet) self.MMKitGrpBox_VBoxLayout = QtGui.QVBoxLayout(self.MMKit_groupBox) self.MMKitGrpBox_VBoxLayout.setMargin(pmGrpBoxVboxLayoutMargin) self.MMKitGrpBox_VBoxLayout.setSpacing(pmGrpBoxVboxLayoutSpacing) self.MMKitGrpBox_VBoxLayout.setObjectName("MMKitGrpBox_VBoxLayout") self.MMKitGrpBox_TitleButton = MMKitDialog.getGroupBoxTitleButton( "MMKit", self.MMKit_groupBox) self.MMKitGrpBox_VBoxLayout.addWidget(self.MMKitGrpBox_TitleButton) self.mmkit_tab = QtGui.QTabWidget(self.MMKit_groupBox) self.mmkit_tab.setEnabled(True) # Height is fixed. Mark 2007-05-29. self.mmkit_tab.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred), QSizePolicy.Policy(QSizePolicy.Fixed))) self.mmkit_tab.setObjectName("mmkit_tab") self.atomsPage = QtGui.QWidget() self.atomsPage.setObjectName("atomsPage") self.mmkit_tab.addTab(self.atomsPage, "") self.atomsPageFrame = QtGui.QFrame(self.atomsPage) # atomsPageFrame needs to be reviewed carefully. Mark 2007-06-20 sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Policy(3), QtGui.QSizePolicy.Policy(1)) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.atomsPageFrame.sizePolicy().hasHeightForWidth()) self.atomsPageFrame.setSizePolicy(sizePolicy) self.atomsPageFrame.setFrameShape(QtGui.QFrame.NoFrame) self.atomsPageFrame.setFrameShadow(QtGui.QFrame.Plain) self.atomsPageFrame.setMinimumSize(QtCore.QSize(100, 100)) self.atomsPageFrame.setObjectName("atomsPageFrame") self.atomsPage_VBoxLayout = QtGui.QVBoxLayout(self.atomsPageFrame) self.atomsPage_VBoxLayout.setMargin( pmMMKitPageMargin) # Was 4. Mark 2007-05-30 self.atomsPage_VBoxLayout.setSpacing(2) # Element Button GroupBox begins here. ##################### self.elementButtonGroup = QtGui.QGroupBox(self.atomsPageFrame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.elementButtonGroup.setSizePolicy(sizePolicy) self.elementButtonGroup.setMinimumSize( QtCore.QSize(pmMMKitButtonWidth * 4, pmMMKitButtonHeight * 4 + 4)) self.elementButtonGroup.setObjectName("elementButtonGroup") self.MMKit_GridLayout = QtGui.QGridLayout(self.elementButtonGroup) self.MMKit_GridLayout.setMargin(1) # Was 0. Mark 2007-05-30 self.MMKit_GridLayout.setSpacing(0) self.MMKit_GridLayout.setObjectName("MMKit_GridLayout") # Font for toolbuttons. font = QFont(self.atomsPageFrame.font()) font.setFamily(pmMMKitButtonFont) font.setPointSize(pmMMKitButtonFontPointSize) font.setBold(pmMMKitButtonFontBold) #font.setWeight(75) #font.setItalic(False) #font.setUnderline(False) #font.setStrikeOut(False) # All this would be much nicer using a dictionary in a loop. # Later, when time permits. Mark 2007-05-30. self.toolButton1 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton1.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton1.setCheckable(True) self.toolButton1.setFont(font) self.toolButton1.setObjectName("toolButton1") self.MMKit_GridLayout.addWidget(self.toolButton1, 0, 4, 1, 1) self.toolButton2 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton2.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton2.setCheckable(True) self.toolButton2.setFont(font) self.toolButton2.setObjectName("toolButton2") self.MMKit_GridLayout.addWidget(self.toolButton2, 0, 5, 1, 1) self.toolButton6 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton6.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton6.setCheckable(True) self.toolButton6.setFont(font) self.toolButton6.setObjectName("toolButton6") self.MMKit_GridLayout.addWidget(self.toolButton6, 1, 1, 1, 1) self.toolButton7 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton7.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton7.setCheckable(True) self.toolButton7.setFont(font) self.toolButton7.setObjectName("toolButton7") self.MMKit_GridLayout.addWidget(self.toolButton7, 1, 2, 1, 1) self.toolButton8 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton8.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton8.setCheckable(True) self.toolButton8.setFont(font) self.toolButton8.setObjectName("toolButton8") self.MMKit_GridLayout.addWidget(self.toolButton8, 1, 3, 1, 1) self.toolButton10 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton10.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton10.setCheckable(True) self.toolButton10.setFont(font) self.toolButton10.setObjectName("toolButton10") self.MMKit_GridLayout.addWidget(self.toolButton10, 1, 5, 1, 1) self.toolButton9 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton9.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton9.setCheckable(True) self.toolButton9.setFont(font) self.toolButton9.setObjectName("toolButton9") self.MMKit_GridLayout.addWidget(self.toolButton9, 1, 4, 1, 1) self.toolButton13 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton13.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton13.setCheckable(True) self.toolButton13.setFont(font) self.toolButton13.setObjectName("toolButton13") self.MMKit_GridLayout.addWidget(self.toolButton13, 2, 0, 1, 1) self.toolButton17 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton17.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton17.setCheckable(True) self.toolButton17.setFont(font) self.toolButton17.setObjectName("toolButton17") self.MMKit_GridLayout.addWidget(self.toolButton17, 2, 4, 1, 1) self.toolButton5 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton5.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton5.setCheckable(True) self.toolButton5.setFont(font) self.toolButton5.setObjectName("toolButton5") self.MMKit_GridLayout.addWidget(self.toolButton5, 1, 0, 1, 1) self.toolButton10_2 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton10_2.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton10_2.setCheckable(True) self.toolButton10_2.setFont(font) self.toolButton10_2.setObjectName("toolButton10_2") self.MMKit_GridLayout.addWidget(self.toolButton10_2, 2, 5, 1, 1) self.toolButton15 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton15.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton15.setCheckable(True) self.toolButton15.setFont(font) self.toolButton15.setObjectName("toolButton15") self.MMKit_GridLayout.addWidget(self.toolButton15, 2, 2, 1, 1) self.toolButton16 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton16.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton16.setCheckable(True) self.toolButton16.setFont(font) self.toolButton16.setObjectName("toolButton16") self.MMKit_GridLayout.addWidget(self.toolButton16, 2, 3, 1, 1) self.toolButton14 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton14.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton14.setCheckable(True) self.toolButton14.setFont(font) self.toolButton14.setObjectName("toolButton14") self.MMKit_GridLayout.addWidget(self.toolButton14, 2, 1, 1, 1) self.toolButton33 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton33.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton33.setCheckable(True) self.toolButton33.setFont(font) self.toolButton33.setObjectName("toolButton33") self.MMKit_GridLayout.addWidget(self.toolButton33, 3, 2, 1, 1) self.toolButton34 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton34.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton34.setCheckable(True) self.toolButton34.setFont(font) self.toolButton34.setObjectName("toolButton34") self.MMKit_GridLayout.addWidget(self.toolButton34, 3, 3, 1, 1) self.toolButton35 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton35.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton35.setCheckable(True) self.toolButton35.setFont(font) self.toolButton35.setObjectName("toolButton35") self.MMKit_GridLayout.addWidget(self.toolButton35, 3, 4, 1, 1) self.toolButton32 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton32.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton32.setCheckable(True) self.toolButton32.setFont(font) self.toolButton32.setObjectName("toolButton32") self.MMKit_GridLayout.addWidget(self.toolButton32, 3, 1, 1, 1) self.toolButton36 = QtGui.QToolButton(self.elementButtonGroup) self.toolButton36.setFixedSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.toolButton36.setCheckable(True) self.toolButton36.setFont(font) self.toolButton36.setObjectName("toolButton36") self.MMKit_GridLayout.addWidget(self.toolButton36, 3, 5, 1, 1) self.atomsPage_VBoxLayout.addWidget(self.elementButtonGroup) # Height is fixed (i.e. locked). Mark 2007-05-29. self.elementButtonGroup.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred), QSizePolicy.Policy(QSizePolicy.Fixed))) # Atomic Hybrid label self.atomic_hybrids_label = QtGui.QLabel(self.atomsPageFrame) self.atomic_hybrids_label.setText("Atomic Hybrids :") self.atomsPage_VBoxLayout.addWidget(self.atomic_hybrids_label) # Elements Button GroupBox ends here. ####################### # This special HBoxLayout contains both the hybrid button group and a # vert spacer (width = 0) to keep the Qt layout working properly # in certain situations like that described in bug 2407. # Mark 2007-06-20. self.special_HBoxLayout = QtGui.QHBoxLayout() self.special_HBoxLayout.setMargin(0) self.special_HBoxLayout.setSpacing(6) self.special_HBoxLayout.setObjectName("special_HBoxLayout") self.atomsPage_VBoxLayout.addLayout(self.special_HBoxLayout) # Hybrid GroupBox begins here ############################### self.hybrid_btngrp = QtGui.QGroupBox(self.atomsPageFrame) self.hybrid_btngrp.setObjectName("hybrid_btngrp") self.special_HBoxLayout.addWidget(self.hybrid_btngrp) self.hybridBtns_HBoxLayout = QtGui.QHBoxLayout(self.hybrid_btngrp) self.hybridBtns_HBoxLayout.setMargin(2) self.hybridBtns_HBoxLayout.setSpacing(0) self.hybridBtns_HBoxLayout.setObjectName("hybridBtns_HBoxLayout") self.sp3_btn = QtGui.QToolButton(self.hybrid_btngrp) self.sp3_btn.setMinimumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.sp3_btn.setMaximumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.sp3_btn.setCheckable(True) self.sp3_btn.setObjectName("sp3_btn") self.hybridBtns_HBoxLayout.addWidget(self.sp3_btn) self.sp2_btn = QtGui.QToolButton(self.hybrid_btngrp) self.sp2_btn.setMinimumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.sp2_btn.setMaximumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.sp2_btn.setCheckable(True) self.sp2_btn.setObjectName("sp2_btn") self.hybridBtns_HBoxLayout.addWidget(self.sp2_btn) self.sp_btn = QtGui.QToolButton(self.hybrid_btngrp) self.sp_btn.setMinimumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.sp_btn.setMaximumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.sp_btn.setCheckable(True) self.sp_btn.setObjectName("sp_btn") self.hybridBtns_HBoxLayout.addWidget(self.sp_btn) self.graphitic_btn = QtGui.QToolButton(self.hybrid_btngrp) self.graphitic_btn.setMinimumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.graphitic_btn.setMaximumSize( QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight)) self.graphitic_btn.setCheckable(True) self.graphitic_btn.setObjectName("graphitic_btn") self.hybridBtns_HBoxLayout.addWidget(self.graphitic_btn) # This VSpacer is needed to help (but not completely) fix bug 2407. It # maintains the height of the layout(s) containing the hybrid button # group when it is hidden using hide(). Without this spacer the layout # gets screwed up in special situations like that described in bug 2407. # The + 10 below is needed to account for the margin (4 pixels) and # the additional 6 just help (I have a theory that the height of the # frame containing the label above the hybrid group box shrinks when # the label is hidden by inserting a space character). I'm # not going to worry about this now. +10 works well enough. # Mark 2007-06-20. VSpacer = QtGui.QSpacerItem(0, pmMMKitButtonHeight + 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) #self.hybridBtns_HBoxLayout.addItem(VSpacer) self.special_HBoxLayout.addItem(VSpacer) self.hybridBtns_HBoxLayout.addStretch(0) # Height is fixed. Mark 2007-05-29. self.hybrid_btngrp.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding), QSizePolicy.Policy(QSizePolicy.Fixed))) # This spacer keeps the MMKit button grid compressed when # the hybrid button group is hidden. self.atomsPageBottomVSpacer = \ QtGui.QSpacerItem(5, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.MinimumExpanding) self.atomsPage_VBoxLayout.addItem(self.atomsPageBottomVSpacer) # Clipboard page begins here ############################################ self.clipboardPage = QtGui.QWidget() self.clipboardPage.setObjectName("clipboardPage") self.gridlayout3 = QtGui.QGridLayout(self.clipboardPage) self.gridlayout3.setMargin(pmMMKitPageMargin) # Was 4. Mark 2007-05-30 self.gridlayout3.setSpacing(2) self.gridlayout3.setObjectName("gridlayout3") self.chunkListBox = QtGui.QListWidget(self.clipboardPage) self.chunkListBox.setMinimumSize(QtCore.QSize(100, 100)) # Height is fixed. Mark 2007-05-29. self.chunkListBox.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding), QSizePolicy.Policy(QSizePolicy.Fixed))) self.chunkListBox.setObjectName("chunkListBox") self.gridlayout3.addWidget(self.chunkListBox, 0, 0, 1, 1) self.mmkit_tab.addTab(self.clipboardPage, "") self.libraryPage = QtGui.QWidget() #self.libraryPage = QtGui.QScrollArea() #self.libraryPageWidget = QtGui.QWidget() #self.libraryPage.setWidget(self.libraryPageWidget) self.libraryPage.setObjectName("libraryPage") self.mmkit_tab.addTab(self.libraryPage, "") self.MMKitGrpBox_VBoxLayout.addWidget(self.mmkit_tab) self.transmuteAtomsAction = QtGui.QWidgetAction(self.w) self.transmuteAtomsAction.setText("Transmute Atoms") self.transmuteAtomsAction.setIcon( geticon('ui/actions/Toolbars/Smart/Transmute_Atoms')) self.transmuteAtomsAction.setCheckable(False) transmuteBtn_HBoxLayout = QtGui.QHBoxLayout() self.transmuteBtn = QtGui.QToolButton(self.MMKit_groupBox) self.transmuteBtn.setDefaultAction(self.transmuteAtomsAction) self.transmuteBtn.setFixedSize(QtCore.QSize(36, 36)) self.transmuteBtn.setIconSize(QtCore.QSize(22, 22)) transmuteBtn_HBoxLayout.addWidget(self.transmuteBtn) self.browseButton = QtGui.QPushButton(MMKitDialog) transmuteBtn_HBoxLayout.addWidget(self.browseButton) self.defaultPartLibButton = QtGui.QPushButton(MMKitDialog) transmuteBtn_HBoxLayout.addWidget(self.defaultPartLibButton) self.atomsPageSpacer = QtGui.QSpacerItem(0, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) transmuteBtn_HBoxLayout.addItem(self.atomsPageSpacer) self.MMKitGrpBox_VBoxLayout.addLayout(transmuteBtn_HBoxLayout) self.transmuteCB = QtGui.QCheckBox(" Force to Keep Bonds", self.MMKit_groupBox) self.MMKitGrpBox_VBoxLayout.addWidget(self.transmuteCB) #End MMKit groupbox self.pmVBoxLayout.addWidget(self.MMKit_groupBox) # This line is important. Without it, the MMKit groupbox is # too wide by default and causes a horizontal scrollbar # to be displayed at the bottom of the PropMgr. Mark 2007-05-30 self.MMKit_groupBox.setMinimumWidth(200) # Height is fixed. Mark 2007-05-29. self.MMKit_groupBox.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding), QSizePolicy.Policy(QSizePolicy.Fixed)))