Exemplo n.º 1
0
def test_OneLineInfoLabel(qtbot):
    labelText = 'Subtitle of my mixtape'
    info1 = utls.OneLineInfoLabel(labelText)
    qtbot.addWidget(info1)

    assert info1.text() == labelText
    assert info1.wordWrap() == False
Exemplo n.º 2
0
        def __init__(self, readmeText, parent=None):
            QGroupBox.__init__(self, parent)
            self.setLayout(QVBoxLayout())
            self.setContentsMargins(0, 0, 0, 0)

            self.layout().addWidget(utls.OneLineInfoLabel('Contributors:'))

            for c in readmeText.contributors:
                contrib = utls.ShortInfoLabel(c)
                contrib.setContentsMargins(10, 0, 0, 0)
                self.layout().addWidget(contrib)
Exemplo n.º 3
0
def test_OneLineInfoLabel_versionFont(qtbot):
    labelText = '1.0.0'
    versionFont = utls.versionFont()
    info1 = utls.OneLineInfoLabel(labelText, theFont=versionFont)
    qtbot.addWidget(info1)

    assert info1.text() == labelText
    assert info1.wordWrap() == False
    assert info1.font().bold() == False
    assert info1.font().italic() == True
    assert info1.font().pointSize() == 9
Exemplo n.º 4
0
def test_OneLineInfoLabel_subtitleFont(qtbot):
    labelText = 'A less important subtitle'
    subtitleFont = utls.subtitleFont()
    info1 = utls.OneLineInfoLabel(labelText, theFont=subtitleFont)
    qtbot.addWidget(info1)

    assert info1.text() == labelText
    assert info1.wordWrap() == False
    assert info1.font().bold() == False
    assert info1.font().italic() == False
    assert info1.font().pointSize() == 12
Exemplo n.º 5
0
def test_OneLineInfoLabel_titleFont(qtbot):
    labelText = 'A big important title'
    titleFont = utls.titleFont()
    info1 = utls.OneLineInfoLabel(labelText, theFont=titleFont)
    qtbot.addWidget(info1)

    assert info1.text() == labelText
    assert info1.wordWrap() == False
    assert info1.font().bold() == True
    assert info1.font().italic() == False
    assert info1.font().pointSize() == 14
Exemplo n.º 6
0
        def __init__(self, moduleDirectory, moduleAbout, parent=None):
            QWidget.__init__(self, parent)

            self.setLayout(QVBoxLayout())
            self.layout().setContentsMargins(10, 0, 0, 0)

            # handle required module fields
            titleLabel = self.ModuleTitleLabel(
                title=utls.cutTitle(moduleAbout["title"]))
            self.layout().addWidget(titleLabel)

            versionLabel = utls.OneLineInfoLabel(
                "version " + moduleAbout["version"], utls.versionFont())
            self.layout().addWidget(versionLabel)

            previewLabel = self.ModulePreviewWidget(
                moduleDirectory=moduleDirectory, moduleAbout=moduleAbout)
            self.layout().addWidget(previewLabel)
            self.layout().addSpacing(10)

            authorLabel = self.GenericOptionalLabel('Author(s):',
                                                    moduleAbout['author'])
            self.layout().addWidget(authorLabel)

            shortDescLabel = self.GenericOptionalLabel(
                'Description:', moduleAbout['shortdesc'])
            self.layout().addWidget(shortDescLabel)

            licenseLabel = self.GenericOptionalLabel('License:',
                                                     moduleAbout['license'])
            self.layout().addWidget(licenseLabel)

            # handle optional fields
            if 'longdesc' in moduleAbout:
                placeholder = 1

            if 'projurl' in moduleAbout:
                projurlLabel = self.GenericOptionalLabel(
                    'Proj. website:', moduleAbout['projurl'])
                self.layout().addWidget(projurlLabel)

            if 'projreadme' in moduleAbout:
                readmeLabel = self.GenericOptionalLabel(
                    'Proj. README:',
                    os.path.join(moduleDirectory, *moduleAbout['projreadme']))
                self.layout().addWidget(readmeLabel)

            self.layout().addStretch(10)

            self.launchButtons = self.ModuleLaunchButtonsWidget(
                moduleDirectory=moduleDirectory,
                moduleAbout=moduleAbout,
                parent=self)
            self.layout().addWidget(self.launchButtons)
Exemplo n.º 7
0
        def __init__(self, privatePath, parent=None):
            QWidget.__init__(self, parent)
            self.setLayout(QVBoxLayout())

            LogoBox = self.LogoBoxWidget()

            supportedText = utls.OneLineInfoLabel('SedEdu is supported by:')
            nsfLogo = self.LogoPixmapWidget(
                os.path.join(privatePath, 'nsf.gif'))
            riceLogo = self.LogoPixmapWidget(
                os.path.join(privatePath, 'rice.png'))

            self.layout().addWidget(supportedText)
            self.layout().addWidget(LogoBox)
            LogoBox.layout().addWidget(nsfLogo)
            LogoBox.layout().addWidget(riceLogo)
            LogoBox.layout().addStretch(1)
Exemplo n.º 8
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setLayout(QVBoxLayout())

        # construct readme data to parse out into fields
        readmeText = self._ReadmeFileData(self.parent().thisPath)

        # construct the header
        categoryLabelText = utls.OneLineInfoLabel('About the SedEdu project:',
                                                  utls.titleFont())

        # construct the summary multiline text
        descLabel = utls.ParagraphInfoLabel(readmeText.summary)

        # construct the contributors box
        contribBox = self._ContributorWidget(readmeText)

        # construct the more information text
        completeInfoLabel = utls.ShortInfoLabel(
            'For complete information visit \
            the [SedEdu project page](https://github.com/amoodie/sededu).',
            utls.titleFont())

        # construct the supported by box
        SupportedBy = self._SupportedByWidget(self.parent().privatePath)

        # add widgets in specific vertical order
        self.layout().addWidget(categoryLabelText)
        self.layout().addWidget(descLabel)
        self.layout().addWidget(utls.ShortInfoLabel(readmeText.license))

        self.layout().addStretch(1)
        self.layout().addWidget(contribBox)

        self.layout().addStretch(2)
        self.layout().addWidget(completeInfoLabel)

        self.layout().addStretch(10)
        self.layout().addWidget(SupportedBy)
Exemplo n.º 9
0
    def __init__(self, category, parent):
        QWidget.__init__(self, parent)
        self.setLayout(QGridLayout())

        # get the path of the category folder
        self.categoryPath = os.path.join(self.parent().thisPath,
                                         "sededu", "modules",
                                         utls.category2path(category))

        # list all the subdirectories (i.e., the modules)
        modulePathList = utls.subDirPath(self.categoryPath)

        # initialize the module list, module information page stack,
        # module doc list stack, and category label
        self.ModuleList = self._ModuleListWidget(self)
        self.ModuleInformationPageStack = self._ModuleInformationPageStackWidget(
            self)
        self.ModuleDocStack = QStackedWidget()
        self.categoryLabelText = utls.OneLineInfoLabel(
            utls.cutTitle(category + " modules:"), utls.titleFont())

        # add the widgets to the grid
        self.layout().addWidget(self.categoryLabelText, 0, 0)
        self.layout().addWidget(self.ModuleList, 1, 0)
        self.layout().addWidget(self.ModuleDocStack, 2, 0)
        self.layout().addWidget(self.ModuleInformationPageStack, 0, 1, 4, 1)
        self.layout().setContentsMargins(15, 15, 15, 15)

        # loop through all the modules
        moduleNum = 0
        for iModuleDirectory in modulePathList:
            # check out and prepare the about.json file
            moduleAboutPath = os.path.join(iModuleDirectory, "about.json")
            if os.path.isfile(moduleAboutPath):
                # read the raw file
                moduleAboutRawText = open(moduleAboutPath)

                # get module metadata from the about.json file
                iModuleAbout = json.load(moduleAboutRawText)

                # check and add defaults to moduleAbout if needed
                iModuleAbout = self.validateModuleAbout(
                    iModuleAbout, iModuleDirectory)
            else:
                print("No about.json file found, crash likely incoming...\n")
                print("Alternatively, your module may just not be loaded")
                continue

            # construct and add the item to the module list
            iModuleListItem = self._ModuleListItemWidget(
                moduleNum, iModuleAbout)
            self.ModuleList.addItem(iModuleListItem)
            self.ModuleList.setCurrentRow(0)

            # construct and add the info page to the stack
            iModuleInfoPage = self._ModuleInformationPage(
                iModuleDirectory, iModuleAbout)
            self.ModuleInformationPageStack.addWidget(iModuleInfoPage)

            # construct and add the doc page to the stack
            iModuleDocPath = os.path.join(iModuleDirectory,
                                          *iModuleAbout["docloc"])
            iModuleDocNames = iModuleAbout["doclist"]
            iModuleDocLaunchList = [
                os.path.join(iModuleDocPath, f)
                for f in list(iModuleDocNames.keys())
            ]
            iModuleDocPage = self._ModuleDocumentPage()
            self.ModuleDocStack.addWidget(iModuleDocPage)

            # construct and add the document list to the doc page
            iModuleDocList = self._DocumentListWidget(iModuleDocLaunchList)
            iModuleDocPage.layout().addWidget(iModuleDocList)

            # loop through the docs and add to the list
            docNum = 0
            for iDoc in iModuleDocNames:
                iDocInfo = iModuleAbout["doclist"]
                iDocTitle = list(iDocInfo.values())[docNum]
                iDocFile = list(iDocInfo.keys())[docNum]
                iDocListItem = QListWidgetItem(iDocTitle)
                iDocListItem.setSizeHint(QtCore.QSize(100, 30))
                iModuleDocList.addItem(iDocListItem)
                docNum += 1
            iModuleDocList.setCurrentRow(0)

            # create a document launcher button if docs
            if len(iModuleDocLaunchList) > 0:
                iModuleDocLaunchButton = utls.GenericLargePushButton(
                    text='Open activity', height=40)
                iModuleDocLaunchButton.clicked.connect(
                    lambda x, lL=iModuleDocLaunchList: iModuleDocList.
                    docLaunch(lL))
                iModuleInfoPage.launchButtons.layout().addWidget(
                    iModuleDocLaunchButton, 0, 0)

            # increment to next module
            moduleNum += 1