Пример #1
0
def main(fileName=None):
    """ This is a simple wrapper for starting the main
    sconcho sconcho.gui.

    For now we check if any command line arguments were
    passed. If yes, we assume the first one was meant to
    be a sconcho spf file and then pass it on to
    sconcho_gui_launcher().
    """

    # load settings
    defaultSettings = settings.DefaultSettings(ORGANIZATION, APPLICATION)
    currPath = os.path.dirname(__file__)
    symbolPaths = misc.set_up_symbol_paths(currPath, defaultSettings)

    # set up logging if requested
    doLogging = defaultSettings.doLogging.value
    loggingPath = defaultSettings.loggingPath.value
    if doLogging and loggingPath:
        logHandle = create_log_file(loggingPath)
    else:
        logHandle = None

    install_exception_handler(logHandle)
    initialize_logger(logHandle)

    # check that file exists; this is required since Sconcho.app
    # on OS X seems to pass some bogus string that then causes
    # issues
    if len(sys.argv) > 1:
        fileNameTmp = sys.argv[1]
        if os.path.isfile(fileNameTmp):
            fileName = fileNameTmp

    # We attempt to read all available knitting symbols
    # before firing up the MainWindow. At the very least we
    # require to find a symbol for a "knit" stitch. If not,
    # we terminate right away.
    knittingSymbols = parser.parse_all_symbols(symbolPaths)
    try:
        knittingSymbols[QString("knit")]
    except KeyError:
        sys.exit(msg.errorOpeningKnittingSymbols % symbolPaths)

    sconcho_gui_launcher(currPath, defaultSettings, knittingSymbols, fileName)
    logging.shutdown()
Пример #2
0
    def refresh_symbol_widget_after_addition(self, synchronizer, symbolName,
                                             categoryName):
        """ This slot is called when a symbol in categoryName was added.

        This only happens if the user adds a custom symbol.

        """

        symbolPaths = misc.set_up_symbol_paths(self._topLevelPath,
                                               self.settings)
        knittingSymbols = parser.parse_all_symbols(symbolPaths)
        symbolsByCategory = symbols_by_category(knittingSymbols)

        if categoryName in symbolsByCategory:
            symbol = knittingSymbols[symbolName]
            synchronizer.unselect()

            if categoryName in self.symbolSelector:
                widget = self.symbolSelector[categoryName]
                wList = add_to_category_widget(widget, symbol, synchronizer)
            else:
                symbols = symbolsByCategory[categoryName]
                (widget, wList) = \
                    generate_category_widget(categoryName, symbols, synchronizer)
                self.symbolCategoryChooser.addItem(categoryName)
                self.symbolSelector[categoryName] = widget

            self.symbolSelectorWidgets = \
                dict(list(self.symbolSelectorWidgets.items()) +
                     list(wList.items()))

        else:
            message = ("MainWindow: Problem updating symbol dialog\n"
                       "after custom symbol change. "
                       "It is highly recommended to save your\n"
                       "current project and restart sconcho.")
            logger.error(message)
Пример #3
0
    def refresh_symbol_widget_after_addition(self, synchronizer, symbolName,
                                             categoryName):
        """ This slot is called when a symbol in categoryName was added.

        This only happens if the user adds a custom symbol.

        """

        symbolPaths = misc.set_up_symbol_paths(self._topLevelPath,
                                               self.settings)
        knittingSymbols = parser.parse_all_symbols(symbolPaths)
        symbolsByCategory = symbols_by_category(knittingSymbols)

        if categoryName in symbolsByCategory:
            symbol = knittingSymbols[symbolName]
            synchronizer.unselect()

            if categoryName in self.symbolSelector:
                widget = self.symbolSelector[categoryName]
                wList = add_to_category_widget(widget, symbol, synchronizer)
            else:
                symbols = symbolsByCategory[categoryName]
                (widget, wList) = \
                    generate_category_widget(categoryName, symbols, synchronizer)
                self.symbolCategoryChooser.addItem(categoryName)
                self.symbolSelector[categoryName] = widget

            self.symbolSelectorWidgets = \
                dict(self.symbolSelectorWidgets.items() +
                     wList.items())

        else:
            message = ("MainWindow: Problem updating symbol dialog\n"
                       "after custom symbol change. "
                       "It is highly recommended to save your\n"
                       "current project and restart sconcho.")
            logger.error(message)