当前位置: 首页>>代码示例>>Python>>正文


Python userguide.addButton函数代码示例

本文整理汇总了Python中userguide.addButton函数的典型用法代码示例。如果您正苦于以下问题:Python addButton函数的具体用法?Python addButton怎么用?Python addButton使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了addButton函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, mainwindow):
     super(SessionManagerDialog, self).__init__(mainwindow)
     self.setWindowModality(Qt.WindowModal)
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     self.sessions = SessionList(self)
     layout.addWidget(self.sessions)
     
     self.imp = QPushButton(self)
     self.exp = QPushButton(self)
     self.act = QPushButton(self)
     self.imp.clicked.connect(self.importSession)
     self.exp.clicked.connect(self.exportSession)
     self.act.clicked.connect(self.activateSession)
     
     self.sessions.layout().addWidget(self.imp, 5, 1)
     self.sessions.layout().addWidget(self.exp, 6, 1)
     self.sessions.layout().addWidget(self.act, 7, 1)
     
     layout.addWidget(widgets.Separator())
     
     self.buttons = b = QDialogButtonBox(self)
     layout.addWidget(b)
     b.setStandardButtons(QDialogButtonBox.Close)
     b.rejected.connect(self.accept)
     userguide.addButton(b, "sessions")
     self.sessions.load()
     app.translateUI(self)
     self.sessions.changed.connect(self.enableButtons)
     self.sessions.listBox.itemSelectionChanged.connect(self.enableButtons)
     self.enableButtons()
开发者ID:brumleygap,项目名称:frescobaldi,代码行数:32,代码来源:dialog.py

示例2: __init__

    def __init__(self, mainwindow):
        super(ScoreWizardDialog, self).__init__(mainwindow)
        self.addAction(mainwindow.actionCollection.help_whatsthis)
        self._pitchLanguage = None

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.tabs = QTabWidget()
        b = self.dialogButtons = QDialogButtonBox()
        b.setStandardButtons(
            QDialogButtonBox.Reset
            | QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        userguide.addButton(b, "scorewiz")
        b.button(QDialogButtonBox.Reset).clicked.connect(self.reset)
        self.previewButton = b.addButton('', QDialogButtonBox.ActionRole)
        self.previewButton.clicked.connect(self.showPreview)
        layout.addWidget(self.tabs)
        layout.addWidget(b)

        self.header = Header(self)
        self.tabs.addTab(self.header, '')
        self.parts = Parts(self)
        self.tabs.addTab(self.parts, '')
        self.settings = Settings(self)
        self.tabs.addTab(self.settings, '')

        self.tabs.setCurrentIndex(0)
        self.tabs.widget(0).widget() # activate it
        self.tabs.currentChanged.connect(self.slotCurrentChanged)
        qutil.saveDialogSize(self, "scorewiz/dialog/size")
        app.translateUI(self)
        self.accepted.connect(self.slotAccepted)
开发者ID:19joho66,项目名称:frescobaldi,代码行数:35,代码来源:dialog.py

示例3: __init__

 def __init__(self, parent=None):
     super(SessionEditor, self).__init__(parent)
     self.setWindowModality(Qt.WindowModal)
     
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     grid = QGridLayout()
     layout.addLayout(grid)
     
     self.name = QLineEdit()
     self.nameLabel = l = QLabel()
     l.setBuddy(self.name)
     grid.addWidget(l, 0, 0)
     grid.addWidget(self.name, 0, 1)
     
     self.autosave = QCheckBox()
     grid.addWidget(self.autosave, 1, 1)
     
     self.basedir = widgets.urlrequester.UrlRequester()
     self.basedirLabel = l = QLabel()
     l.setBuddy(self.basedir)
     grid.addWidget(l, 2, 0)
     grid.addWidget(self.basedir, 2, 1)
     
     layout.addWidget(widgets.Separator())
     self.buttons = b = QDialogButtonBox(self)
     layout.addWidget(b)
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     userguide.addButton(b, "sessions")
     app.translateUI(self)
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:33,代码来源:dialog.py

示例4: __init__

    def __init__(self, parent=None):
        super(ModeShiftDialog, self).__init__(parent)
        
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)
        
        self.keyLabel = QLabel()
        self.keyInput = QLineEdit()
        self.modeCombo = QComboBox()
        self.modeLabel = QLabel()
        
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, "mode_shift")
        
        for m in sorted(modes.keys()):
            self.modeCombo.addItem(m)

        mainLayout.addWidget(self.keyLabel, 0, 0, 1, 1)
        mainLayout.addWidget(self.keyInput, 0, 1, 1, 1)
        mainLayout.addWidget(self.modeLabel, 1, 0, 1, 1)
        mainLayout.addWidget(self.modeCombo, 1, 1, 1, 1)
        mainLayout.addWidget(self.buttons, 9, 0, 2, 2)
        
        app.translateUI(self)
        qutil.saveDialogSize(self, "mode_shift/dialog/size", QSize(80, 60))
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        
        self.keyInput.textEdited.connect(self.readKeyInput)
        self.modeCombo.currentIndexChanged.connect(self.readSettings)
        
        self.loadSettings()
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:33,代码来源:dialog.py

示例5: __init__

 def __init__(self, parent=None):
     super(SessionEditor, self).__init__(parent)
     self.setWindowModality(Qt.WindowModal)
     
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     grid = QGridLayout()
     layout.addLayout(grid)
     
     self.name = QLineEdit()
     self.nameLabel = l = QLabel()
     l.setBuddy(self.name)
     grid.addWidget(l, 0, 0)
     grid.addWidget(self.name, 0, 1)
     
     self.autosave = QCheckBox()
     grid.addWidget(self.autosave, 1, 1)
     
     self.basedir = widgets.urlrequester.UrlRequester()
     self.basedirLabel = l = QLabel()
     l.setBuddy(self.basedir)
     grid.addWidget(l, 2, 0)
     grid.addWidget(self.basedir, 2, 1)
     
     self.setPaths = QCheckBox()
     grid.addWidget(self.setPaths, 3, 1)
     
     self.inclPaths = ip = QWidget(self)
     ipLayout = QVBoxLayout()
     ip.setLayout(ipLayout)
     
     self.include = widgets.listedit.FilePathEdit()
     self.include.listBox.setDragDropMode(QAbstractItemView.InternalMove)
     ipLayout.addWidget(self.include)
     
     grid.addWidget(ip, 4, 1)
     
     self.revt = QPushButton(self)
     self.clean = QPushButton(self)
     self.revt.clicked.connect(self.revertPaths)
     self.clean.clicked.connect(self.cleanPaths)
    
     self.include.layout().addWidget(self.revt, 5, 1)
     self.include.layout().addWidget(self.clean, 6, 1)
     
     self.setPaths.toggled.connect(self.showInclPaths)
     
     layout.addWidget(widgets.Separator())
     self.buttons = b = QDialogButtonBox(self)
     layout.addWidget(b)
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     userguide.addButton(b, "sessions")
     app.translateUI(self)
开发者ID:cognot,项目名称:frescobaldi,代码行数:56,代码来源:dialog.py

示例6: openEditor

 def openEditor(self, item):
     dlg = widgets.dialog.TextDialog(None,
         _("Enter a regular expression to match:"),
         app.caption("Outline"))
     userguide.addButton(dlg.buttonBox(), "outline_configure")
     dlg.setValidateFunction(is_regex)
     dlg.setText(item.text())
     if dlg.exec_():
         item.setText(dlg.text())
         return True
     return False
开发者ID:19joho66,项目名称:frescobaldi,代码行数:11,代码来源:tools.py

示例7: getText

def getText(
        parent = None,
        title = "",
        message = "",
        text = "",
        icon = None,
        help = None,
        validate = None,
        regexp = None,
        wordWrap = True,
        complete = None,
        ):
    """Asks a string of text from the user.

    Arguments:

    parent: parent widget or None
    title: dialog window title (without appname)
    message: message, question
    text: pre-entered text in the line edit
    icon: which icon to show
    help: help page or name
    validate: a function that accepts text and returns whether it is valid.
    regexp: a regular expression string. If given it provides an alternate
        validation method using a QRegExpValidator.
    wordWrap: whether to word-wrap the message text (default: True).
    complete: a string list or QAbstractItemModel to provide completions.

    """
    dlg = widgets.dialog.TextDialog(parent,
        title=app.caption(title), message=message, icon=icon)
    dlg.setText(text)
    dlg.setMinimumWidth(320)
    dlg.messageLabel().setWordWrap(wordWrap)
    if help is not None:
        userguide.addButton(dlg.buttonBox(), help)
        dlg.setWindowModality(Qt.WindowModal)
    else:
        dlg.setWindowModality(Qt.ApplicationModal)
    if regexp:
        dlg.setValidateRegExp(regexp)
    elif validate:
        dlg.setValidateFunction(validate)
    if complete:
        c = QCompleter(complete, dlg.lineEdit())
        dlg.lineEdit().setCompleter(c)
    if dlg.exec_():
        return dlg.text()
开发者ID:19joho66,项目名称:frescobaldi,代码行数:48,代码来源:inputdialog.py

示例8: __init__

 def __init__(self, parent):
     super(InfoDialog, self).__init__(parent)
     self.setWindowModality(Qt.WindowModal)
     
     layout = QVBoxLayout()
     layout.setSpacing(10)
     self.setLayout(layout)
     grid = QGridLayout()
     grid.setSpacing(4)
     layout.addLayout(grid)
     
     self.lilyname = QLineEdit()
     self.lilynameLabel = l = QLabel()
     l.setBuddy(self.lilyname)
     grid.addWidget(l, 0, 0)
     grid.addWidget(self.lilyname, 0, 1)
     
     self.lilypond = widgets.urlrequester.UrlRequester()
     self.lilypond.setFileMode(QFileDialog.ExistingFile)
     self.lilypondLabel = l = QLabel()
     l.setBuddy(self.lilypond)
     grid.addWidget(l, 1, 0, 1, 2)
     grid.addWidget(self.lilypond, 2, 0, 1, 2)
     
     self.convert_ly = QLineEdit()
     self.convert_lyLabel = l = QLabel()
     l.setBuddy(self.convert_ly)
     grid.addWidget(l, 3, 0)
     grid.addWidget(self.convert_ly, 3, 1)
     
     self.lilypond_book = QLineEdit()
     self.lilypond_bookLabel = l = QLabel()
     l.setBuddy(self.lilypond_book)
     grid.addWidget(l, 4, 0)
     grid.addWidget(self.lilypond_book, 4, 1)
     
     self.auto = QCheckBox()
     grid.addWidget(self.auto, 5, 1)
     
     layout.addWidget(widgets.Separator())
     b = self.buttons = QDialogButtonBox(self)
     layout.addWidget(b)
     
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     userguide.addButton(b, "prefs_lilypond")
     app.translateUI(self)
开发者ID:rdoursenaud,项目名称:frescobaldi,代码行数:48,代码来源:lilypond.py

示例9: __init__

 def __init__(self, parent=None):
     super(RestoreDialog, self).__init__(parent)
     self.messageLabel().setWordWrap(True)
     userguide.addButton(self.buttonBox(), "snippets")
     self.tree = QTreeWidget(headerHidden=True, rootIsDecorated=False)
     self.setMainWidget(self.tree)
     
     self.deletedItem = QTreeWidgetItem(self.tree)
     self.deletedItem.setFlags(Qt.ItemIsUserCheckable)
     self.changedItem = QTreeWidgetItem(self.tree)
     self.changedItem.setFlags(Qt.ItemIsUserCheckable)
     self.tree.itemChanged.connect(self.slotItemChanged)
     
     app.translateUI(self)
     app.languageChanged.connect(self.populate)
     self.accepted.connect(self.updateSnippets)
     qutil.saveDialogSize(self, "snippettool/restoredialog/size")
开发者ID:EdwardBetts,项目名称:frescobaldi,代码行数:17,代码来源:restore.py

示例10: __init__

 def __init__(self):
     super(ChangedDocumentsListDialog, self).__init__(buttons=('close',))
     self.setWindowModality(Qt.NonModal)
     self.setAttribute(Qt.WA_QuitOnClose, False)
     
     layout = QGridLayout(margin=0)
     self.mainWidget().setLayout(layout)
     self.tree = QTreeWidget(headerHidden=True, rootIsDecorated=False,
                             columnCount=2, itemsExpandable=False)
     self.tree.setSelectionMode(QTreeWidget.ExtendedSelection)
     
     self.buttonReload = QPushButton()
     self.buttonReloadAll = QPushButton()
     self.buttonSave = QPushButton()
     self.buttonSaveAll = QPushButton()
     self.buttonShowDiff = QPushButton()
     self.checkWatchingEnabled = QCheckBox(checked=enabled())
     
     layout.addWidget(self.tree, 0, 0, 6, 1)
     layout.addWidget(self.buttonReload, 0, 1)
     layout.addWidget(self.buttonReloadAll, 1, 1)
     layout.addWidget(self.buttonSave, 2, 1)
     layout.addWidget(self.buttonSaveAll, 3, 1)
     layout.addWidget(self.buttonShowDiff, 4, 1)
     layout.addWidget(self.checkWatchingEnabled, 6, 0, 1, 2)
     layout.setRowStretch(5, 10)
     
     app.documentClosed.connect(self.removeDocument)
     app.documentSaved.connect(self.removeDocument)
     app.documentUrlChanged.connect(self.removeDocument)
     app.documentLoaded.connect(self.removeDocument)
     self.tree.itemSelectionChanged.connect(self.updateButtons)
     self.buttonReload.clicked.connect(self.slotButtonReload)
     self.buttonReloadAll.clicked.connect(self.slotButtonReloadAll)
     self.buttonSave.clicked.connect(self.slotButtonSave)
     self.buttonSaveAll.clicked.connect(self.slotButtonSaveAll)
     self.buttonShowDiff.clicked.connect(self.slotButtonShowDiff)
     self.checkWatchingEnabled.toggled.connect(setEnabled)
 
     app.translateUI(self)
     qutil.saveDialogSize(self, 'externalchanges/dialog/size', QSize(400, 200))
     userguide.addButton(self.buttonBox(), "externalchanges")
     self.button('close').setFocus()
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:43,代码来源:widget.py

示例11: __init__

    def __init__(self, mainwindow):
        super(HyphenDialog, self).__init__(mainwindow)
        self.setWindowModality(Qt.WindowModal)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.topLabel = QLabel()
        self.listWidget = QListWidget()

        layout.addWidget(self.topLabel)
        layout.addWidget(self.listWidget)
        layout.addWidget(widgets.Separator())

        self.buttons = b = QDialogButtonBox()
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(b, "lyrics")
        b.rejected.connect(self.reject)
        b.accepted.connect(self.accept)

        self.load()
        app.translateUI(self)
        qutil.saveDialogSize(self, "hyphenation/dialog/size")
开发者ID:19joho66,项目名称:frescobaldi,代码行数:22,代码来源:hyphendialog.py

示例12: __init__

 def __init__(self, parent=None):
     super(Dialog, self).__init__(parent)
     self._document = None
     self.messageLabel().setWordWrap(True)
     self.document = d = QTextDocument()
     d.setDocumentLayout(QPlainTextDocumentLayout(d))
     self.highlighter = highlighter.highlighter(d)
     self.view = View(d)
     self.matcher = Matcher(self.view)
     self.completer = Completer(self.view)
     self.setMainWidget(self.view)
     userguide.addButton(self.buttonBox(), "musicview_editinplace")
     # action for completion popup
     self._showPopupAction = QAction(None, triggered=self.slotCompletionPopup)
     self.addAction(self._showPopupAction)
     # make Ctrl+Return accept the dialog
     self.button("ok").setShortcut(QKeySequence("Ctrl+Return"))
     qutil.saveDialogSize(self, "editinplace/dialog/size")
     
     self.accepted.connect(self.save)
     app.translateUI(self)
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:23,代码来源:editinplace.py

示例13: __init__

    def __init__(self, parent=None):
        super(Dialog, self).__init__(parent)
        self._document = None
        self._path = None
        
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)
        
        tabs = QTabWidget()
        
        import_tab = QWidget()
        post_tab = QWidget()
        
        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)
        
        tabs.addTab(import_tab, "musicxml2ly")
        tabs.addTab(post_tab, "after import")
        
        self.noartCheck = QCheckBox()
        self.norestCheck = QCheckBox()
        self.nolayoutCheck = QCheckBox()
        self.nobeamCheck = QCheckBox()
        self.useAbsCheck = QCheckBox()
        self.commMidiCheck = QCheckBox()
        
        self.langCombo = QComboBox()
        self.langLabel = QLabel()
        
        self.impChecks = [self.noartCheck,
						  self.norestCheck,
						  self.nolayoutCheck,
						  self.nobeamCheck,
						  self.useAbsCheck,
						  self.commMidiCheck]
		
        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()
						   
        self.postChecks = [self.formatCheck,
						   self.trimDurCheck,
						   self.removeScalesCheck,
						   self.runEngraverCheck]								  
        
        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)
        
        self.setChecksObjectNames()
        
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, "musicxml_import")
        
        self.langCombo.addItem('')
        self.langCombo.addItems(_langlist)

        itabLayout.addWidget(self.noartCheck, 0, 0, 1, 2)
        itabLayout.addWidget(self.norestCheck, 1, 0, 1, 2)
        itabLayout.addWidget(self.nolayoutCheck, 2, 0, 1, 2)
        itabLayout.addWidget(self.nobeamCheck, 3, 0, 1, 2)
        itabLayout.addWidget(self.useAbsCheck, 4, 0, 1, 2)
        itabLayout.addWidget(self.commMidiCheck, 5, 0, 1, 2)
        itabLayout.addWidget(self.langLabel, 6, 0, 1, 2)
        itabLayout.addWidget(self.langCombo, 7, 0, 1, 2)
        itabLayout.addWidget(widgets.Separator(), 8, 0, 1, 2)
        itabLayout.addWidget(self.commandLineLabel, 9, 0, 1, 2)
        itabLayout.addWidget(self.commandLine, 10, 0, 1, 2)
        
        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)       
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 10)
        
        mainLayout.addWidget(tabs, 0, 0, 9, 2)
        mainLayout.addWidget(self.buttons, 10, 0, 1, 2)
        
        app.translateUI(self)
        qutil.saveDialogSize(self, "xml_import/dialog/size", QSize(480, 260))
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        
        self.noartCheck.toggled.connect(self.makeCommandLine)
        self.norestCheck.toggled.connect(self.makeCommandLine)
        self.nolayoutCheck.toggled.connect(self.makeCommandLine)
        self.nobeamCheck.toggled.connect(self.makeCommandLine)
        self.useAbsCheck.toggled.connect(self.makeCommandLine)
        self.commMidiCheck.toggled.connect(self.makeCommandLine)
        self.langCombo.currentIndexChanged.connect(self.makeCommandLine)
        self.makeCommandLine()
        
        self.loadSettings()
开发者ID:brumleygap,项目名称:frescobaldi,代码行数:94,代码来源:musicxml.py

示例14: __init__

    def __init__(self, parent=None):
        super(ToLyDialog, self).__init__(parent)
        self._info = None
        self._document = None
        self._path = None
        
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)
        
        tabs = QTabWidget()
        
        import_tab = QWidget()
        post_tab = QWidget()
        
        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)
        
        tabs.addTab(import_tab, self.imp_prgm)
        tabs.addTab(post_tab, "after import")

        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()

        self.postChecks = [self.formatCheck,
                           self.trimDurCheck,
                           self.removeScalesCheck,
                           self.runEngraverCheck]
                           
        self.versionLabel = QLabel()
        self.lilyChooser = lilychooser.LilyChooser()

        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)
        
        self.formatCheck.setObjectName("reformat")
        self.trimDurCheck.setObjectName("trim-durations")
        self.removeScalesCheck.setObjectName("remove-scaling")
        self.runEngraverCheck.setObjectName("engrave-directly")
        
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, self.userg)
        
        row = 0
        for r, w in enumerate(self.impChecks):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)
            w.toggled.connect(self.makeCommandLine)
        row += 1    
        for r, w in enumerate(self.impExtra):
            row += r 
            itabLayout.addWidget(w, row, 0, 1, 2)
        
        itabLayout.addWidget(widgets.Separator(), row + 1, 0, 1, 2)
        itabLayout.addWidget(self.versionLabel, row + 2, 0, 1, 0)
        itabLayout.addWidget(self.lilyChooser, row + 3, 0, 1, 2)
        itabLayout.addWidget(widgets.Separator(), row + 4, 0, 1, 2)
        itabLayout.addWidget(self.commandLineLabel, row + 5, 0, 1, 2)
        itabLayout.addWidget(self.commandLine, row + 6, 0, 1, 2)
        
        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)       
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 10)
        
        mainLayout.addWidget(tabs, 0, 0, 9, 2)
        mainLayout.addWidget(self.buttons, 10, 0, 1, 2)
        
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        
        self.lilyChooser.currentIndexChanged.connect(self.slotLilyPondVersionChanged)
        self.slotLilyPondVersionChanged()
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:76,代码来源:toly_dialog.py

示例15: load

def load(filename, widget):
    """Loads snippets from a file, displaying them in a list.
    
    The user can then choose:
    - overwrite builtin snippets or not
    - overwrite own snippets with same title or not
    - select and view snippets contents.
    
    """
    try:
        d = ET.parse(filename)
        elements = list(d.findall('snippet'))
        if not elements:
            raise ValueError(_("No snippets found."))
    except Exception as e:
        QMessageBox.critical(widget, app.caption(_("Error")),
        _("Can't read from source:\n\n{url}\n\n{error}").format(
            url=filename, error=e))
        return


    dlg = widgets.dialog.Dialog(widget)
    dlg.setWindowModality(Qt.WindowModal)
    dlg.setWindowTitle(app.caption(_("dialog title", "Import Snippets")))
    tree = QTreeWidget(headerHidden=True, rootIsDecorated=False)
    dlg.setMainWidget(tree)
    userguide.addButton(dlg.buttonBox(), "snippet_import_export")
    
    allnames = frozenset(snippets.names())
    builtins = frozenset(builtin.builtin_snippets)
    titles = dict((snippets.title(n), n) for n in allnames if n not in builtins)
    
    new = QTreeWidgetItem(tree, [_("New Snippets")])
    updated = QTreeWidgetItem(tree, [_("Updated Snippets")])
    unchanged = QTreeWidgetItem(tree, [_("Unchanged Snippets")])
    
    new.setFlags(Qt.ItemIsEnabled)
    updated.setFlags(Qt.ItemIsEnabled)
    unchanged.setFlags(Qt.ItemIsEnabled)
    
    new.setExpanded(True)
    updated.setExpanded(True)
    
    items = []
    for snip in elements:
        item = QTreeWidgetItem()
        
        item.body = snip.find('body').text
        item.title = snip.find('title').text
        item.shortcuts = list(e.text for e in snip.findall('shortcuts/shortcut'))
        
        title = item.title or snippets.maketitle(snippets.parse(item.body).text)
        item.setText(0, title)
        
        name = snip.get('id')
        name = name if name in builtins else None
        
        
        # determine if new, updated or unchanged
        if not name:
            name = titles.get(title)
        item.name = name
        
        if not name or name not in allnames:
            new.addChild(item)
            items.append(item)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
            item.setCheckState(0, Qt.Checked)
        elif name:
            if (item.body != snippets.text(name)
                or title != snippets.title(name)
                or (item.shortcuts and item.shortcuts != 
                    [s.toString() for s in model.shortcuts(name) or ()])):
                updated.addChild(item)
                items.append(item)
                item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
                item.setCheckState(0, Qt.Checked)
            else:
                unchanged.addChild(item)
                item.setFlags(Qt.ItemIsEnabled)
    # count:
    for i in new, updated, unchanged:
        i.setText(0, i.text(0) + " ({0})".format(i.childCount()))
    for i in new, updated:
        if i.childCount():
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
            i.setCheckState(0, Qt.Checked)
    
    def changed(item):
        if item in (new, updated):
            for i in range(item.childCount()):
                c = item.child(i)
                c.setCheckState(0, item.checkState(0))
            
    tree.itemChanged.connect(changed)
    
    importShortcuts = QTreeWidgetItem([_("Import Keyboard Shortcuts")])
    if items:
        tree.addTopLevelItem(importShortcuts)
        importShortcuts.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:frescobaldi,代码行数:101,代码来源:import_export.py


注:本文中的userguide.addButton函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。