本文整理汇总了Python中puddlestuff.translations.translate函数的典型用法代码示例。如果您正苦于以下问题:Python translate函数的具体用法?Python translate怎么用?Python translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了translate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, title='Add Action', shortcut=u'', actions=None, names=None, shortcuts=None, parent=None):
super(Editor, self).__init__(parent)
self.setWindowTitle(title)
self._items = {}
self._name = QLineEdit('Name')
if shortcut and shortcut in shortcuts:
shortcuts.remove(shortcut)
self._shortcut = puddleobjects.ShortcutEditor(shortcuts)
self._shortcut.setText(shortcut)
clear = QPushButton(translate('Shortcuts', '&Clear'))
self.connect(clear, SIGNAL('clicked()'), self._shortcut.clear)
if names is None:
names = []
self._names = names
self._actionList = ListBox()
self.connect(self._actionList,
SIGNAL('itemDoubleClicked (QListWidgetItem *)'), self._addAction)
self._newActionList = ListBox()
listbuttons = ListButtons()
listbuttons.duplicate.hide()
listbuttons.insertStretch(0)
self.connect(listbuttons, SIGNAL('add'), self._addAction)
self._newActionList.connectToListButtons(listbuttons)
okcancel = OKCancel()
self.connect(okcancel, SIGNAL('ok'), self.okClicked)
self.connect(okcancel, SIGNAL('cancel'), self.close)
self._ok = okcancel.ok
self.connect(self._name, SIGNAL('textChanged(const QString)'), self.enableOk)
scut_status = QLabel('')
self.connect(self._shortcut, SIGNAL('validityChanged'),
lambda v: scut_status.setText(u'') if v or (not self._shortcut.text()) else
scut_status.setText(translate('Shortcuts', "Invalid shortcut sequence.")))
okcancel.insertWidget(0, scut_status)
hbox = QHBoxLayout()
hbox.addLayout(
create_buddy('Actions', self._actionList, QVBoxLayout()), 1)
hbox.addLayout(listbuttons, 0)
hbox.addLayout(create_buddy('Actions to run for shortcut',
self._newActionList, QVBoxLayout()), 1)
layout = QVBoxLayout()
layout.addLayout(create_buddy('Shortcut &Name: ', self._name))
scut_layout = create_buddy('&Keyboard Shortcut: ', self._shortcut)
scut_layout.addWidget(clear)
layout.addLayout(scut_layout)
layout.addLayout(hbox)
layout.addLayout(okcancel)
self.setLayout(layout)
if actions:
self.setActions(actions)
示例2: __init__
def __init__(self, parent = None, cenwid = None, status=None):
QFrame.__init__(self, parent)
self.title = translate('Settings', "Patterns")
connect = lambda c, signal, s: self.connect(c, SIGNAL(signal), s)
self.setFrameStyle(QFrame.Box)
self.listbox = ListBox()
self.listbox.setSelectionMode(self.listbox.ExtendedSelection)
buttons = ListButtons()
self.listbox.addItems(status['patterns'])
hbox = QHBoxLayout()
hbox.addWidget(self.listbox)
self.setLayout(hbox)
vbox = QVBoxLayout()
sortlistbox = QPushButton(translate("Pattern Settings", '&Sort'))
self._sortOrder = Qt.AscendingOrder
connect(sortlistbox, 'clicked()', self._sortListBox)
vbox.addWidget(sortlistbox)
vbox.addLayout(buttons)
vbox.addStretch()
hbox.addLayout(vbox)
connect(buttons, "add", self.addPattern)
connect(buttons, "edit", self.editItem)
buttons.duplicate.setVisible(False)
self.listbox.connectToListButtons(buttons)
self.listbox.editButton = buttons.edit
connect(self.listbox, 'itemDoubleClicked(QListWidgetItem *)',
self._doubleClicked)
示例3: setReleases
def setReleases(self, releases, files=None):
from puddlestuff.masstag import find_best
self.model().setupModelData(releases)
#FIXME: The expander isn't shown if I don't do this. However
#I can still click on it...Qt bug probably.
QApplication.processEvents()
if files:
matches = find_best(releases, files, self.albumBound)
if not matches:
self.emit(SIGNAL('statusChanged'), translate(
'WebDB', 'No matching albums were found.'))
elif len(matches) > 1:
self.emit(SIGNAL('statusChanged'), translate(
'WebDB', 'More than one album matches. None will be retrieved.'))
else:
self.emit(SIGNAL('statusChanged'), translate(
'WebDB', 'Retrieving album.'))
model = self.model()
children = [z.itemData for z in model.rootItem.childItems]
if children:
row = children.index(matches[0][0])
index = model.index(row, 0, QModelIndex())
x = lambda: self.emitExactMatches(
model.rootItem.childItems[row], files)
model.retrieve(index, x)
示例4: loadLib
def loadLib(self):
"""Loads the currently selected library.
Emits 'adddock' signal if successful with a LibraryTree class as its
widget.
"""
p = ProgressWin(self, 0,
translate('MusicLib', 'Loading music library...'), False)
p.show()
t = PuddleThread(self._loadLib, self)
t.start()
while t.isRunning():
QApplication.processEvents()
library = t.retval
p.close()
QApplication.processEvents()
if isinstance(library, basestring):
error_msg = library
msg = translate('MusicLib',
'An error occured while loading the %1 library: <b>%2</b>')
msg = msg.arg(self.currentlib['name']).arg(error_msg)
QMessageBox.critical(self, translate('Defaults', "Error"),
msg, QMessageBox.Ok, QMessageBox.NoButton,
QMessageBox.NoButton)
else:
dialog = partial(LibraryDialog, library)
self.emit(SIGNAL('adddock'),
translate('MusicLib', 'Music Library'), dialog, RIGHTDOCK)
self.close()
示例5: contextMenuEvent
def contextMenuEvent(self, event):
connect = lambda o,s: self.connect(o, SIGNAL('triggered()'), s)
menu = QMenu(self)
refresh = QAction(translate("Dirview",
'Refresh Directory'), self)
index = self.indexAt(event.pos())
connect(refresh, lambda: self.model().refresh(index))
header = self.header()
if self.header().isHidden():
show_header = QAction(translate("Dirview",
'Show Header'), self)
connect(show_header, header.show)
else:
show_header = QAction(translate("Dirview",
'Hide Header'), self)
connect(show_header, header.hide)
open_dir = QAction(translate(
'Dirview', 'Open in File Manager'), self)
connect(open_dir, lambda: self.openExtern(index))
menu.addAction(refresh)
menu.addAction(show_header)
menu.addAction(open_dir)
menu.exec_(event.globalPos())
super(DirView, self).contextMenuEvent(event)
示例6: __init__
def __init__(self, parent = None):
QWidget.__init__(self, parent)
def hbox(*widgets):
box = QHBoxLayout()
[box.addWidget(z) for z in widgets]
box.addStretch()
return box
vbox = QVBoxLayout()
startlabel = QLabel(translate('Autonumbering Wizard', "&Start: "))
self._start = QSpinBox()
startlabel.setBuddy(self._start)
self._start.setValue(1)
self._start.setMaximum(65536)
vbox.addLayout(hbox(startlabel, self._start))
label = QLabel(translate('Autonumbering Wizard', 'Max length after padding with zeroes: '))
self._padlength = QSpinBox()
label.setBuddy(self._padlength)
self._padlength.setValue(1)
self._padlength.setMaximum(65535)
self._padlength.setMinimum(1)
vbox.addLayout(hbox(label, self._padlength))
self._restart_numbering = QCheckBox(translate('Autonumbering Wizard', "&Restart numbering at each directory."))
vbox.addWidget(self._restart_numbering)
vbox.addStretch()
self.setLayout(vbox)
示例7: openFile
def openFile(self, filename=None, dirpath=None):
"""Open the file and fills the textboxes."""
if not dirpath:
dirpath = self.lastDir
if not filename:
filedlg = QFileDialog()
filename = unicode(filedlg.getOpenFileName(self,
'OpenFolder', dirpath))
if not filename:
return True
try:
f = open(filename, 'r')
except (IOError, OSError), detail:
errormsg = translate('Text File -> Tag',
"The file <b>%1</b> couldn't be loaded.<br /> "
"Do you want to choose another?")
ret = QMessageBox.question(self,
translate('Text File -> Tag', "Error"),
translate('Text File -> Tag', errormsg.arg(filename)),
translate('Text File -> Tag', "&Yes"),
translate('Text File -> Tag', "&No"))
if ret == 0:
return self.openFile()
else:
return detail
示例8: _dirChanged
def _dirChanged(self, dirs):
if not dirs:
self.setWindowTitle('puddletag')
return
if isinstance(dirs, basestring):
dirs = [dirs]
dirs = [encode_fn(d) for d in dirs]
if self._lastdir:
initial = self._lastdir[0]
else:
initial = None
if initial not in dirs:
initial = dirs[0]
if isinstance(initial, str):
initial = initial.decode('utf8', 'replace')
if len(dirs) > 1:
self.setWindowTitle(translate("Main Window", 'puddletag: %1 + others').arg(initial))
else:
self.setWindowTitle(translate("Main Window", 'puddletag: %1').arg(initial))
self._lastdir = dirs
示例9: __init__
def __init__(self,parent = None, filename = None, clipboard = None):
QDialog.__init__(self, parent)
self.setWindowTitle(
translate('Text File -> Tag', "Import tags from text file"))
winsettings('importwin', self)
grid = QGridLayout()
self.label = QLabel(translate('Text File -> Tag', "Text"))
grid.addWidget(self.label, 0, 0)
self.label = QLabel(translate('Text File -> Tag', "Tag preview"))
grid.addWidget(self.label, 0, 2)
self.file = QTextEdit()
grid.addWidget(self.file, 1, 0, 1, 2)
self.tags = QTextEdit()
grid.addWidget(self.tags,1, 2, 1, 2)
self.tags.setLineWrapMode(QTextEdit.NoWrap)
hbox = QHBoxLayout()
self.patterncombo = QComboBox()
self.patterncombo.setEditable(True)
self.patterncombo.setDuplicatesEnabled(False)
okcancel = OKCancel()
self.ok = okcancel.ok
self.cancel = okcancel.cancel
self.openfile = QPushButton(
translate('Text File -> Tag', "&Select File"))
getclip = QPushButton(
translate('Text File -> Tag', "&Paste Clipboard"))
self.connect(getclip, SIGNAL('clicked()'), self.openClipBoard)
hbox.addWidget(self.openfile)
hbox.addWidget(getclip)
hbox.addWidget(self.patterncombo,1)
hbox.addLayout(okcancel)
grid.addLayout(hbox, 3, 0, 1, 4)
self.setLayout(grid)
self.connect(self.openfile,SIGNAL("clicked()"),self.openFile)
self.connect(self.cancel, SIGNAL("clicked()"),self.close)
self.connect(self.ok, SIGNAL("clicked()"), self.emitValues)
if clipboard:
self.openClipBoard()
return
self.lastDir = HOMEDIR
if filename is not None:
self.openFile(filename)
示例10: __init__
def __init__(self, parent=None, status=None):
ButtonsAndList.__init__(self, parent,
translate('ViewAllFields', 'View All Fields'),
translate("ViewAllFields", 'Add Field'),
translate("ViewAllFields", 'Edit fields for "View All Fields"'),
)
self.addItems(load_fields())
self.status = status
示例11: enableNumTracks
def enableNumTracks(self, state):
if state == Qt.Checked:
self._numtracks.setVisible(False)
self._separator.setText(translate('Autonumbering Wizard',
"Add track &separator ['/']"))
else:
self._numtracks.setVisible(True)
self._separator.setText(translate('Autonumbering Wizard',
"Add track &separator ['/']: Number of tracks"))
示例12: __init__
def __init__(self, actions, parent=None):
super(ActionEditorDialog, self).__init__(parent)
self.actions = actions
help = QLabel(translate("Shortcut Settings", '<b>Double click a cell in the Shortcut Column' \
' to <br />modify the key sequence.</b>'))
self.actionTable = QTableWidget(self)
self.actionTable.setSelectionBehavior(QTableWidget.SelectRows)
self.actionTable.setEditTriggers(QTableWidget.DoubleClicked)
self.actionTable.setColumnCount(2)
self.actionTable.setHorizontalHeaderLabels(
[translate("Shortcut Settings", "Description"),
translate("Shortcut Settings", "Shortcut")]
)
self.actionTable.horizontalHeader().setStretchLastSection(True)
self.actionTable.verticalHeader().hide()
self.actionTable.setItemDelegate(ActionEditorDelegate(self))
self.connect(self.actionTable, SIGNAL("cellChanged(int, int)"),
self.validateAction)
row = 0
for action in self.actions:
if action.text().isEmpty():
continue
self.actionTable.insertRow(self.actionTable.rowCount())
item = QTableWidgetItem()
item.setText(action.text())
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
self.actionTable.setItem(row, 0, item)
item = QTableWidgetItem()
item.setText(action.shortcut().toString())
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable)
item.oldShortcutText = item.text()
self.actionTable.setItem(row, 1, item)
row += 1
self.actionTable.resizeColumnsToContents()
mainLayout = QVBoxLayout()
mainLayout.addWidget(help)
mainLayout.setMargin(8)
mainLayout.setSpacing(8)
mainLayout.addWidget(self.actionTable)
self.setLayout(mainLayout)
self._model = self.actionTable.model()
self._model.edited = False
self.actionTable.model().edited = False
self.setWindowTitle(translate("Shortcut Settings", "Edit Shortcuts"))
示例13: changeInfo
def changeInfo(self, info):
labels = [translate('Plugin Settings', 'Name'),
translate('Plugin Settings', 'Author'),
translate('Plugin Settings', 'Description'),
translate('Plugin Settings', 'Version')]
properties = [NAME, AUTHOR, DESC, VERSION]
text = u'<br />'.join([u'<b>%s:</b> %s' % (disp, info[prop]) for
disp, prop in zip(labels, properties)])
self.setText(text)
示例14: lookup
def lookup(self):
button = self.sender()
if self._startButton.text() != translate('Masstagging', '&Stop'):
self.__flag.stop = False
self._log.clear()
self._startButton.setText(translate('Masstagging', '&Stop'))
self._start()
else:
self._startButton.setText(translate('Masstagging', '&Search'))
self.__flag.stop = True
示例15: __init__
def __init__(self):
object.__init__(self)
self.min_score = 0.80
self.preferences = [
[translate("AcoustID", 'Minimum Score'), SPINBOX, [0, 100, 80]],
[translate("AcoustID", "AcoustID Key"), TEXT, u""]
]
self.__lasttime = time.time()
acoustid._send_request = self._send_request
self.__user_key = ""