本文整理汇总了Python中psychopy.app.localization._translate函数的典型用法代码示例。如果您正苦于以下问题:Python _translate函数的具体用法?Python _translate怎么用?Python _translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_translate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: onCopyCalib
def onCopyCalib(self, event):
"""Creates a new calibration entry for the monitor.
Note that the calibration date will reflect the save date/time
"""
# use time as initial guess at name
calibTime = time.localtime()
calibTimeStr = monitors.strFromDate(calibTime)
# then use dialogue so user can override
msg = _translate(
'Name of this calibration (for monitor "%(name)s") will be:)')
infoStr = msg % {'name': self.currentMon.name}
dlg = wx.TextEntryDialog(self, message=infoStr,
defaultValue=calibTimeStr,
caption=_translate('Input text'))
if dlg.ShowModal() == wx.ID_OK:
newCalibName = dlg.GetValue()
# update the GUI to reflect new calibration
self.currentMon.copyCalib(newCalibName)
self.currentMon.setCalibDate(calibTime)
self.onChangeCalibSelection(1, newCalibName)
self.updateCalibList()
self.unSavedMonitor = True
dlg.Destroy()
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:26,代码来源:MonitorCenter.py
示例2: __init__
def __init__(self, parent, levels):
wx.Dialog.__init__(self, parent, -1,
_translate('Recorded luminance values'),
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
pad = 5
panel = wx.Panel(self, -1)
mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(self.makeCalibBox(parent=panel, levels=levels), 1,
wx.EXPAND | wx.ALL, pad)
butBox = wx.BoxSizer(wx.HORIZONTAL)
btnOK = wx.Button(panel, wx.ID_OK, _translate(" OK "))
btnOK.SetDefault()
btnCANC = wx.Button(panel, wx.ID_CANCEL, _translate(" Cancel "))
butBox.Add(btnOK, 1, wx.BOTTOM | wx.ALIGN_RIGHT, pad)
butBox.Add(btnCANC, 1, wx.BOTTOM | wx.RIGHT | wx.ALIGN_RIGHT, pad)
mainSizer.Add(butBox, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM,
border=10)
# finalise panel layout
panel.SetAutoLayout(True)
panel.SetSizerAndFit(mainSizer)
mainSizer.Layout()
self.SetSize(self.GetBestSize())
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:26,代码来源:MonitorCenter.py
示例3: onNewMon
def onNewMon(self, event):
# open a dialogue to get the name
dlg = wx.TextEntryDialog(self, _translate('New monitor name:'),
caption=_translate('Input text'))
if dlg.ShowModal() == wx.ID_OK:
self.currentMonName = dlg.GetValue()
self.ctrlMonList.Append(self.currentMonName)
self.ctrlMonList.SetStringSelection(self.currentMonName)
self.currentMon = monitors.Monitor(
self.currentMonName, verbose=True)
self.updateCalibList()
self.onChangeCalibSelection(event=1)
self.unSavedMonitor = True
dlg.Destroy()
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:14,代码来源:MonitorCenter.py
示例4: __init__
def __init__(self, title=_translate('PsychoPy Dialog'),
pos=None, size=None, style=None,
labelButtonOK=_translate(" OK "),
labelButtonCancel=_translate(" Cancel "),
screen=-1):
global app # avoid recreating for every gui
app = ensureQtApp()
QtWidgets.QDialog.__init__(self, None, Qt.WindowTitleHint)
self.inputFields = []
self.inputFieldTypes = []
self.inputFieldNames = []
self.data = []
self.irow = 0
# QtWidgets.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
# add buttons for OK and Cancel
self.buttonBox = QtWidgets.QDialogButtonBox(Qt.Horizontal,
parent=self)
self.okbutton = QtWidgets.QPushButton(labelButtonOK,
parent=self)
self.cancelbutton = QtWidgets.QPushButton(labelButtonCancel,
parent=self)
self.buttonBox.addButton(self.okbutton,
QtWidgets.QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.cancelbutton,
QtWidgets.QDialogButtonBox.ActionRole)
self.okbutton.clicked.connect(self.accept)
self.cancelbutton.clicked.connect(self.reject)
if style:
raise RuntimeWarning("Dlg does not currently support the "
"style kwarg.")
self.pos = pos
self.size = size
self.screen = screen
# self.labelButtonOK = labelButtonOK
# self.labelButtonCancel = labelButtonCancel
self.layout = QtWidgets.QGridLayout()
self.layout.setColumnStretch(1, 1)
self.layout.setSpacing(10)
self.layout.setColumnMinimumWidth(1, 250)
self.setLayout(self.layout)
self.setWindowTitle(title)
开发者ID:bergwiesel,项目名称:psychopy,代码行数:50,代码来源:qtgui.py
示例5: test_set
def test_set(self):
lang = localization.getID('En_US')
assert lang == 'en'
for lang in ['En_US', 'Ja_JP', 'ja_JP']:
setlang = localization.getID(lang)
out = _translate(welcome)
assert setlang == lang.lower()[:2]
assert out == trans[setlang]
开发者ID:balajisriram,项目名称:psychopy,代码行数:9,代码来源:test_locale.py
示例6: __init__
def __init__(self, title=_translate('PsychoPy dialogue'),
pos=None, size=wx.DefaultSize,
style=wx.DEFAULT_DIALOG_STYLE | wx.DIALOG_NO_PARENT,
labelButtonOK=_translate(" OK "),
labelButtonCancel=_translate(" Cancel ")):
style = style | wx.RESIZE_BORDER
global app # avoid recreating for every gui
app = ensureWxApp()
super().__init__(parent=None, id=-1, title=title, style=style)
self.inputFields = []
self.inputFieldTypes = []
self.inputFieldNames = []
self.data = []
# prepare a frame in which to hold objects
self.sizer = wx.BoxSizer(wx.VERTICAL)
# self.addText('') # insert some space at top of dialogue
self.pos = pos
self.labelButtonOK = labelButtonOK
self.labelButtonCancel = labelButtonCancel
开发者ID:balajisriram,项目名称:psychopy,代码行数:19,代码来源:wxgui.py
示例7: onBtnFindPhotometer
def onBtnFindPhotometer(self, event):
# safer to get by index, but GetStringSelection will work for
# nonlocalized techincal names:
photName = self.ctrlPhotomType.GetStringSelection()
# not sure how
photPort = self.ctrlPhotomPort.GetValue().strip()
# [0] == Scan all ports
if not photPort or photPort == self._photomChoices[0]:
photPort = None
elif photPort.isdigit():
photPort = int(photPort)
# search all ports
self.comPortLabel.SetLabel(_translate('Scanning ports...'))
self.Update()
self.photom = hardware.findPhotometer(device=photName, ports=photPort)
if self.photom is not None and self.photom.OK:
self.btnFindPhotometer.Disable()
self.btnCalibrateGamma.Enable(True)
self.btnTestGamma.Enable(True)
if hasattr(self.photom, 'getLastSpectrum'):
self.btnCalibrateColor.Enable(True)
msg = _translate('%(photomType)s found on %(photomPort)s')
self.comPortLabel.SetLabel(msg %
{'photomType': self.photom.type,
'photomPort': self.photom.portString})
else:
self.comPortLabel.SetLabel(_translate('No photometers found'))
self.photom = None
# does this device need a dark calibration?
if (hasattr(self.photom, 'getNeedsCalibrateZero') and
self.photom.getNeedsCalibrateZero()):
# prompt user if we need a dark calibration for the device
if self.photom.getNeedsCalibrateZero():
dlg = wx.Dialog(self, title=_translate(
'Dark calibration of ColorCAL'))
msg = _translate('Your ColorCAL needs to be calibrated first.'
' Please block all light from getting into '
'the lens and press OK.')
while self.photom.getNeedsCalibrateZero():
txt = _translate('Dark calibration of ColorCAL')
dlg = dialogs.MessageDialog(self, message=msg,
title=txt,
type='Info')
# info dlg has only an OK button
resp = dlg.ShowModal()
if resp == wx.ID_CANCEL:
self.photom = None
self.comPortLabel.SetLabel('')
return 0
elif resp == wx.ID_OK:
self.photom.calibrateZero()
# this failed at least once. Try again.
msg = _translate('Try again. Cover the lens fully and '
'press OK')
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:56,代码来源:MonitorCenter.py
示例8: summary
def summary(self, items=None):
"""Return a list of (item, color) for gui display. For non-fatal items
"""
config = {}
for item in items:
config[item[0]] = [item[1], item[2], item[3]] # [3] = warn or not
green = '#009933'
red = '#CC3300'
check = u"\u2713 "
summary = [(check + _translate('video card drivers'), green)]
ofInterest = ('python version', 'available memory', 'openGL version',
'visual sync (refresh)', 'refresh stability (SD)',
'no dropped frames', 'internet access')
# ofInterest.append('background processes')
for item in ofInterest:
if not item in config.keys():
continue # eg, microphone latency
if config[item][2]: # warn True
summary.append(("X " + _translate(item), red))
else:
summary.append((check + _translate(item), green))
return summary
开发者ID:cheesealmighty,项目名称:psychopy,代码行数:22,代码来源:wizard.py
示例9: fileOpenDlg
def fileOpenDlg(tryFilePath="",
tryFileName="",
prompt=_translate("Select file to open"),
allowed=None):
"""A simple dialogue allowing read access to the file system.
:parameters:
tryFilePath: string
default file path on which to open the dialog
tryFileName: string
default file name, as suggested file
prompt: string (default "Select file to open")
can be set to custom prompts
allowed: string (available since v1.62.01)
a string to specify file filters.
e.g. "Text files (\*.txt) ;; Image files (\*.bmp \*.gif)"
See http://pyqt.sourceforge.net/Docs/PyQt4/qfiledialog.html
#getOpenFileNames
for further details
If tryFilePath or tryFileName are empty or invalid then
current path and empty names are used to start search.
If user cancels, then None is returned.
"""
global qtapp # avoid recreating for every gui
qtapp = ensureQtApp()
if allowed is None:
allowed = ("All files (*.*);;"
"PsychoPy Data (*.psydat);;"
"txt (*.txt *.dlm *.csv);;"
"pickled files (*.pickle *.pkl);;"
"shelved files (*.shelf)")
fdir = os.path.join(tryFilePath, tryFileName)
filesToOpen = QtWidgets.QFileDialog.getOpenFileNames(parent=None,
caption=prompt,
directory=fdir,
filter=allowed)
if type(filesToOpen) == tuple: # some versions(?) of PyQt return (files, filter)
filesToOpen = filesToOpen[0]
filesToOpen = [str(fpath) for fpath in filesToOpen
if os.path.exists(fpath)]
if len(filesToOpen) == 0:
return None
return filesToOpen
开发者ID:bergwiesel,项目名称:psychopy,代码行数:51,代码来源:qtgui.py
示例10: makeCalibBox
def makeCalibBox(self, parent, levels):
'''do my best to make a calibration box'''
gammaBox = wx.StaticBox(parent, -1, _translate('Luminance Values'))
gammaBox.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL))
gammaBoxSizer = wx.StaticBoxSizer(gammaBox, wx.VERTICAL)
theCols = map(str, levels)
self.gammaGrid = SimpleGrid(parent, id=-1,
cols=theCols,
rows=['lum', 'R', 'G', 'B'])
gammaBoxSizer.Add(self.gammaGrid)
grid.EVT_GRID_CELL_CHANGE(self.gammaGrid, self.onChangeGammaGrid)
gammaBoxSizer.Layout()
return gammaBoxSizer
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:15,代码来源:MonitorCenter.py
示例11: fileSaveDlg
def fileSaveDlg(initFilePath="", initFileName="",
prompt=_translate("Select file to save"),
allowed=None):
"""A simple dialogue allowing write access to the file system.
(Useful in case you collect an hour of data and then try to
save to a non-existent directory!!)
:parameters:
initFilePath: string
default file path on which to open the dialog
initFileName: string
default file name, as suggested file
prompt: string (default "Select file to open")
can be set to custom prompts
allowed: string
A string to specify file filters.
e.g. "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
See http://www.wxpython.org/docs/api/wx.FileDialog-class.html
for further details
If initFilePath or initFileName are empty or invalid then
current path and empty names are used to start search.
If user cancels the None is returned.
"""
if allowed is None:
allowed = "All files (*.*)|*.*"
# "txt (*.txt)|*.txt"
# "pickled files (*.pickle, *.pkl)|*.pickle"
# "shelved files (*.shelf)|*.shelf"
global app # avoid recreating for every gui
app = ensureWxApp()
dlg = wx.FileDialog(None, prompt, initFilePath,
initFileName, allowed, wx.SAVE)
if dlg.ShowModal() == OK:
# get names of images and their directory
outName = dlg.GetFilename()
outPath = dlg.GetDirectory()
dlg.Destroy()
# tmpApp.Destroy() # this causes an error message for some reason
fullPath = os.path.join(outPath, outName)
else:
fullPath = None
return fullPath
开发者ID:balajisriram,项目名称:psychopy,代码行数:48,代码来源:wxgui.py
示例12: onDeleteCalib
def onDeleteCalib(self, event):
calToDel = self.ctrlCalibList.GetStringSelection()
# warn user that data will be lost
msg = _translate('Are you sure you want to delete this calibration? '
'(cannot be undone)')
dlg = dialogs.MessageDialog(parent=self,
message=msg,
type='Warning')
if dlg.ShowModal() == wx.ID_YES:
# delete it
self.currentMon.delCalib(calToDel)
# load most recent calibration instead
# this will load calibration "-1" (last calib)
self.onChangeCalibSelection(event=None, newCalib=-1)
self.updateCalibList()
dlg.Destroy()
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:16,代码来源:MonitorCenter.py
示例13: onCloseWindow
def onCloseWindow(self, event):
if self.unSavedMonitor:
# warn user that data will be lost
msg = _translate(
'Save changes to monitor settings before quitting?')
dlg = dialogs.MessageDialog(self, message=msg, type='Warning')
resp = dlg.ShowModal()
if resp == wx.ID_CANCEL:
return 1 # return before quitting
elif resp == wx.ID_YES:
# save then quit
self.currentMon.saveMon()
elif resp == wx.ID_NO:
pass # don't save just quit
dlg.Destroy()
self.onCopyMon() # save current monitor name to clipboard
self.Destroy()
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:17,代码来源:MonitorCenter.py
示例14: plotSpectra
def plotSpectra(self, event=None):
msg = _translate('%(monName)s %(calibName)s Spectra')
figTitle = msg % {'monName': self.currentMonName,
'calibName': self.currentCalibName}
plotWindow = PlotFrame(self, 1003, figTitle)
figure = Figure(figsize=(5, 5), dpi=80)
figureCanvas = FigureCanvas(plotWindow, -1, figure)
plt = figure.add_subplot(111)
plt.hold('off')
nm, spectraRGB = self.currentMon.getSpectra()
if nm != None:
plt.plot(nm, spectraRGB[0, :], 'r-', linewidth=1.5)
plt.hold('on')
plt.plot(nm, spectraRGB[1, :], 'g-', linewidth=2)
plt.plot(nm, spectraRGB[2, :], 'b-', linewidth=2)
figureCanvas.draw() # update the canvas
plotWindow.addCanvas(figureCanvas)
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:18,代码来源:MonitorCenter.py
示例15: onDeleteMon
def onDeleteMon(self, event):
monToDel = self.currentMonName
msg = _translate('Are you sure you want to delete all details for %s? '
'(cannot be undone)')
dlg = dialogs.MessageDialog(parent=self, message=msg % monToDel,
type='Warning')
response = dlg.ShowModal()
dlg.Destroy()
if response == wx.ID_YES:
# delete it
monitorFileName = os.path.join(monitors.monitorFolder,
monToDel + ".calib")
os.remove(monitorFileName)
self.currentMon = None
self.currentMonName = None
self.updateMonList()
# load most recent calibration instead
# this will load calibration "-1" (last calib)
self.onChangeMonSelection(event=None)
self.updateCalibList()
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:20,代码来源:MonitorCenter.py
示例16: fileOpenDlg
def fileOpenDlg(tryFilePath="",
tryFileName="",
prompt=_translate("Select file(s) to open"),
allowed=None):
"""A simple dialogue allowing read access to the file system.
:parameters:
tryFilePath: string
default file path on which to open the dialog
tryFileName: string
default file name, as suggested file
prompt: string (default "Select file to open")
can be set to custom prompts
allowed: string (available since v1.62.01)
a string to specify file filters.
e.g. "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
See http://www.wxpython.org/docs/api/wx.FileDialog-class.html
for further details
If tryFilePath or tryFileName are empty or invalid then
current path and empty names are used to start search.
If user cancels, then None is returned.
"""
if allowed is None:
allowed = ("PsychoPy Data (*.psydat)|*.psydat|"
"txt (*.txt,*.dlm,*.csv)|*.txt;*.dlm;*.csv|"
"pickled files (*.pickle, *.pkl)|*.pickle|"
"shelved files (*.shelf)|*.shelf|"
"All files (*.*)|*.*")
global app # avoid recreating for every gui
app = ensureWxApp()
dlg = wx.FileDialog(None, prompt, tryFilePath, tryFileName, allowed,
wx.OPEN | wx.FILE_MUST_EXIST | wx.MULTIPLE)
if dlg.ShowModal() == OK:
# get names of images and their directory
fullPaths = dlg.GetPaths()
else:
fullPaths = None
dlg.Destroy()
return fullPaths
开发者ID:balajisriram,项目名称:psychopy,代码行数:41,代码来源:wxgui.py
示例17: onChangeMonSelection
def onChangeMonSelection(self, event):
if self.unSavedMonitor:
if self.currentMonName == self.ctrlMonList.GetStringSelection():
# it didnt' really change
return 1
# warn user that data will be lost
msg = _translate('Save changes to monitor?')
dlg = dialogs.MessageDialog(self, msg, type='Warning')
resp = dlg.ShowModal()
dlg.Destroy()
if resp == wx.ID_CANCEL:
# revert and return
self.ctrlMonList.SetStringSelection(self.currentMonName)
return False # return before quitting
elif resp == wx.ID_YES:
# save then change
self.currentMon.saveMon()
elif resp == wx.ID_NO:
pass # don't save just change
self.currentMonName = self.ctrlMonList.GetStringSelection()
self.loadMonitor(self.currentMonName)
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:21,代码来源:MonitorCenter.py
示例18: makeMenuBar
def makeMenuBar(self):
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
fileMenu.Append(idMenuSave,
_translate('Save\tCtrl+S'),
_translate('Save the current monitor'))
wx.EVT_MENU(self, idMenuSave, self.onSaveMon)
_hint = _translate(
'Close Monitor Center (but not other PsychoPy windows)')
fileMenu.Append(wx.ID_CLOSE,
_translate('Close Monitor Center\tCtrl+W'),
_hint)
wx.EVT_MENU(self, wx.ID_CLOSE, self.onCloseWindow)
menuBar.Append(fileMenu, _translate('&File'))
# Edit
editMenu = wx.Menu()
id = wx.NewId()
_hint = _translate("Copy the current monitor's name to clipboard")
editMenu.Append(id, _translate('Copy\tCtrl+C'), _hint)
wx.EVT_MENU(self, id, self.onCopyMon)
menuBar.Append(editMenu, _translate('&Edit'))
self.SetMenuBar(menuBar)
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:24,代码来源:MonitorCenter.py
示例19: fileSaveDlg
def fileSaveDlg(initFilePath="", initFileName="",
prompt=_translate("Select file to save"),
allowed=None):
"""A simple dialogue allowing write access to the file system.
(Useful in case you collect an hour of data and then try to
save to a non-existent directory!!)
:parameters:
initFilePath: string
default file path on which to open the dialog
initFileName: string
default file name, as suggested file
prompt: string (default "Select file to open")
can be set to custom prompts
allowed: string
a string to specify file filters.
e.g. "Text files (\*.txt) ;; Image files (\*.bmp \*.gif)"
See http://pyqt.sourceforge.net/Docs/PyQt4/qfiledialog.html
#getSaveFileName
for further details
If initFilePath or initFileName are empty or invalid then
current path and empty names are used to start search.
If user cancels the None is returned.
"""
if allowed is None:
allowed = ("All files (*.*);;"
"txt (*.txt);;"
"pickled files (*.pickle *.pkl);;"
"shelved files (*.shelf)")
global qtapp # avoid recreating for every gui
qtapp = ensureQtApp()
fdir = os.path.join(initFilePath, initFileName)
r = QtWidgets.QFileDialog.getSaveFileName(parent=None, caption=prompt,
directory=fdir, filter=allowed)
return str(r) or None
开发者ID:bergwiesel,项目名称:psychopy,代码行数:38,代码来源:qtgui.py
示例20: OnInit
def OnInit(self):
frame = MainFrame(None, _translate('PsychoPy Monitor Center'))
frame.Show(True)
self.SetTopWindow(frame)
return True
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:5,代码来源:MonitorCenter.py
注:本文中的psychopy.app.localization._translate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论