本文整理汇总了Python中Translator.Translator._translate方法的典型用法代码示例。如果您正苦于以下问题:Python Translator._translate方法的具体用法?Python Translator._translate怎么用?Python Translator._translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translator.Translator
的用法示例。
在下文中一共展示了Translator._translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Box
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class Box(QTabWidget):
def __init__(self, parent=None):
QTabWidget.__init__(self, parent)
self.Parent = parent
self.tr = Translator("Thrifty")
self.setMovable(True)
self.setIconSize(QSize(32, 32))
self.checkFile = CheckFile(self)
self.backUp = BackUp(self)
self.cleanUp = CleanUp(self)
self.broken = Broken(self)
self.addTab(self.checkFile, QIcon("/usr/share/thrifty/icons/file.png"), QString(self.tr._translate("File")))
self.setTabToolTip(0, self.tr._translate("Checks file belonging to a rpmdb"))
self.addTab(self.backUp, QIcon("/usr/share/thrifty/icons/backup.png"), QString(self.tr._translate("BackUp")))
self.setTabToolTip(1, self.tr._translate('Back up "rpmdb-out" files <b>(User\Root Mode)</b>.'))
self.addTab(self.cleanUp, QIcon("/usr/share/thrifty/icons/cleanup.png"), QString(self.tr._translate("CleanUp")))
self.setTabToolTip(2, self.tr._translate('Clean up "rpmdb-out" files <b>(Root Mode only)</b> or test.'))
self.addTab(self.broken, QIcon("/usr/share/thrifty/icons/file.png"), QString(self.tr._translate("Broken")))
self.setTabToolTip(3, self.tr._translate("Search broken packages <b>(Root Mode only)</b>."))
def setTabsState(self, state):
self.checkFile.setState(state)
self.backUp.setState(state)
self.cleanUp.setState(state)
self.broken.setState(state)
self.Parent.stopProcess.setEnabled(not state)
示例2: PageDialog
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class PageDialog(QDialog):
okClicked = pyqtSignal()
cancelClicked = pyqtSignal()
settingsCancelled = pyqtSignal()
def __init__(self, parent = None):
QDialog.__init__(self, parent)
self.prnt = parent
self.tr = Translator()
self.setWindowTitle(self.tr._translate('[email protected] Checker : Settings'))
self.tabWidget = QTabWidget(self)
self.tabWidget.setTabPosition(QTabWidget.North)
self.layout = QVBoxLayout()
self.buttonLayout = QHBoxLayout()
self.ok = QPushButton(QIcon.fromTheme("dialog-ok"), "", self)
self.cancel = QPushButton(QIcon.fromTheme("dialog-cancel"), "", self)
self.buttonLayout.addWidget(self.ok)
self.buttonLayout.addWidget(self.cancel)
self.layout.addWidget(self.tabWidget)
self.layout.addItem(self.buttonLayout)
self.setLayout(self.layout)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setMinimumWidth(100)
self.ok.clicked.connect(self.accepted)
self.cancel.clicked.connect(self.rejected)
QTimer.singleShot(100, self._restoreGeometry)
def _restoreGeometry(self):
self.restoreGeometry(self.prnt.Settings.value('SettingsGeometry').toByteArray())
def addPage(self, wdg, wdgName):
self.tabWidget.addTab(wdg, wdgName)
def accepted(self): self.okClicked.emit()
def rejected(self):
self.settingsCancelled.emit()
self.cancelClicked.emit()
def closeEvent(self, ev):
ev.ignore()
self.rejected()
def _close(self):
self.prnt.Settings.setValue('SettingsGeometry', self.saveGeometry())
if not self.prnt.isVisible() :
self.prnt.show()
self.prnt.autoHide(3)
if self.prnt.isMinimized() :
self.prnt.showNormal()
self.done(0)
示例3: Box
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class Box(QTabWidget):
mailAttr = pyqtSignal(dict)
mailData = pyqtSignal(dict)
def __init__(self, data = {}, parent = None):
QTabWidget.__init__(self, parent)
self.Parent = parent
self.tr = Translator('mailViewer')
self.mails = []
self.webViewWDGs = []
self.iconDatabasePath = os.path.join('/tmp', randomString(24))
os.mkdir(self.iconDatabasePath)
self.Settings = Settings
self.setMovable(True)
self.setIconSize(QSize(SIZE, SIZE))
if 'ids' in data and len(data['ids']) :
i = 0
for idx in data['ids'] :
self.mails.append(Mail(idx, self))
self.addTab(self.mails[i], QIcon().fromTheme("mail"), QString(self.tr._translate('Mail') + ' ' + idx))
self.setTabToolTip(i, self.tr._translate('Mail') + ' #' + idx)
i += 1
self.Parent.statusBar.showMessage(self.tr._translate('Getting mail...'))
self.mailAttr.connect(self.setMailAttr)
self.mailData.connect(self.setMailData)
self.getMail = GetMail(data, self)
self.startGetMail()
else :
self.Parent.statusBar.showMessage(self.tr._translate('Empty Job.'))
def startGetMail(self):
self.Parent.reload_.setEnabled(False)
self.getMail.start()
def setMailAttr(self, d):
i = 0
for m in self.mails :
if m.idx == d['number'] : break
else : i += 1
self.mails[i].fromField.setText(d['from'])
self.mails[i].subjField.setText(d['subj'])
self.mails[i].dateField.setText(d['date'])
self.mails[i].reply_to = d['ReplyTo']
self.mails[i]._from_subj = d['_F_S']
def setMailData(self, d):
ll = d['data'][0]
data = d['data'][1]
i = 0
for m in self.mails :
if m.idx == d['number'] : break
else : i += 1
fileName = None
if d['type'] == 'html' :
_data = changeImagePath(data, d['boundary'])
''' create temporary html-file '''
fileName = os.path.join(self.iconDatabasePath, randomString(24) + '.html')
with open(fileName, 'w') as f : f.write(insertMetaData(_data))
wdg = QWebView()
wdg.triggerPageAction(QWebPage.Reload, True)
wdg.triggerPageAction(QWebPage.Stop, True)
wdg.triggerPageAction(QWebPage.Back, True)
wdg.triggerPageAction(QWebPage.Forward, True)
wdg.settings().setAttribute(QWebSettings.AutoLoadImages, \
self.Parent.autoLoadImage)
wdg.settings().setAttribute(QWebSettings.PrivateBrowsingEnabled, \
self.Parent.privateEnable)
if wdg.settings().iconDatabasePath().isEmpty() :
wdg.settings().setIconDatabasePath(self.iconDatabasePath)
wdg.load(QUrl('file://' + fileName))
#print dateStamp(), QUrl('file://' + fileName), ' created'
wdg.show()
self.webViewWDGs.append(wdg)
elif d['type'] in ('plain') :
wdg = QTextBrowser()
wdg.setAcceptRichText(True)
wdg.setOpenExternalLinks(True)
wdg.setOpenLinks(True)
data = data.replace('<', '< ')
data = data.replace('>', ' >')
wdg.setHtml(changeLink(data))
elif d['type'] == 'header' :
wdg = QLabel()
wdg.setText(data)
wdg.linkHovered.connect(self.linkDisplay)
wdg.setAlignment(Qt.AlignLeft)
else :
''' create temporary file '''
fileName = os.path.join(self.iconDatabasePath, d['data'][2])
with open(fileName, 'wb') as f : f.write(data)
wdg = QLabel()
wdg.setOpenExternalLinks(True)
ins = self.tr._translate('Inserted:')
wdg.setText(QString('<a href="%1">%2 %3</a>').arg(fileName).arg(ins).arg(d['type']))
wdg.linkHovered.connect(self.linkDisplay)
wdg.setAlignment(Qt.AlignLeft)
wdg.setToolTip(ll)
splt = QSplitter()
#.........这里部分代码省略.........
示例4: AkonadiResources
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class AkonadiResources(QWidget):
edit = pyqtSignal(QListWidgetItem)
edited = pyqtSignal()
reloadAkonadi = pyqtSignal()
def __init__(self, obj = None, parent = None):
QWidget.__init__(self)
self.Parent = obj
self.prnt = parent
self.Settings = self.Parent.Settings
self.checkAccess = self.Parent.checkAccess
self.tr = Translator('EditAccounts')
print dateStamp(), 'Module PyKDE4.akonadi is'
if not A.AkonadiModuleExist :
print '\tnot'
print '\tavailable.'
self.init()
def init(self):
self.layout = QGridLayout()
self.VBLayout = QVBoxLayout()
self.akonadiServer = QPushButton('&Restart')
self.akonadiServer.setToolTip(self.tr._translate("Restart Akonadi Server"))
self.akonadiServer.clicked.connect(self.reloadAkonadiStuff)
self.layout.addWidget(self.akonadiServer, 0, 4)
self.akonadiState = QLabel()
if not A.AkonadiModuleExist :
self.akonadiState.setText(self.tr._translate("Module PyKDE4.akonadi isn`t available."))
akonadiAccList = []
else :
self.akonadiState.setText( self.tr._translate("Akonadi Server is : ") + \
A.StateSTR[A.Akonadi.ServerManager.state()] )
akonadiAccList = self.Parent.akonadiAccountList()
self.layout.addWidget(self.akonadiState, 0, 0)
self.VBLayout.addLayout(self.layout)
self.editList = EditList(self.Parent, self)
self.editParams = EditParam(self)
self.VBLayout.addWidget(self.editList)
self.VBLayout.addWidget(self.editParams)
self.setLayout(self.VBLayout)
self.edit.connect(self.editEvent)
self.edited.connect(self.editedEvent)
self.StateChanged = False
self.setEditWidgetsState()
def setEditWidgetsState(self):
if A.AkonadiModuleExist and A.Akonadi.ServerManager.state() != A.Akonadi.ServerManager.State(4) :
#self.editParams.changeSelfActivity(False)
self.editList.changeSelfActivity(True)
else :
self.editList.changeSelfActivity(False)
self.editParams.changeSelfActivity(False)
def editEvent(self, item):
self.StateChanged = True
self.editList.changeSelfActivity(False)
self.editParams.changeSelfActivity(True)
self.editParams.initWidgets(item)
def editedEvent(self):
self.editParams.changeSelfActivity(False)
self.editList.changeSelfActivity(True)
self.StateChanged = False
def collectionSearch(self):
if not A.AkonadiModuleExist : return None
self.Control = A.ControlWidget()
if self.Control.exec_() :
self.Control.move(self.Parent.popupPosition(self.Control.size()))
col = self.Control.selectedCollection()
## print dateStamp(), col.name().toUtf8(), col.id(), col.resource()
self.editParams.collectionID.setText(str(col.id()))
self.editParams.nameColl = col.name()
#self.editList.stringEditor.setText(self.editParams.nameColl)
self.editParams.collectionResource.setText(col.resource())
def restartAkonadi(self):
if not A.AkonadiModuleExist :
self.akonadiState.setText(self.tr._translate("Module PyKDE4.akonadi isn`t available."))
akonadiAccList = []
else :
server = A.Akonadi.Control()
#server.widgetNeedsAkonadi(self)
if A.Akonadi.ServerManager.isRunning() :
if not server.restart(self) :
print dateStamp(), 'Unable to start Akonadi Server '
else :
if not server.start(self) :
print dateStamp(), 'Unable to start Akonadi Server '
self.akonadiState.setText( self.tr._translate("Akonadi Server is : ") + \
A.StateSTR[A.Akonadi.ServerManager.state()] )
self.setEditWidgetsState()
#.........这里部分代码省略.........
示例5: Box
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class Box(QTabWidget):
mailAttr = pyqtSignal(dict)
mailData = pyqtSignal(dict)
def __init__(self, data = {}, parent = None):
QTabWidget.__init__(self, parent)
self.Parent = parent
self.tr = Translator('mailViewer')
self.mails = []
self.webViewWDGs = []
self.iconDatabasePath = os.path.join('/tmp', randomString(24))
os.mkdir(self.iconDatabasePath)
self.Settings = Settings
self.SoundEnabled = self.Settings.value('Sound', False).toBool()
self.setMovable(True)
self.setIconSize(QSize(SIZE, SIZE))
if 'ids' in data and len(data['ids']) :
i = 0
for idx in data['ids'] :
self.mails.append(Mail(idx, self))
self.addTab(self.mails[i], QIcon().fromTheme("mail"), QString(self.tr._translate('Mail') + ' ' + idx))
self.setTabToolTip(i, self.tr._translate('Mail') + ' #' + idx)
i += 1
self.Parent.statusBar.showMessage(self.tr._translate('Getting mail...'))
self.mailAttr.connect(self.setMailAttr)
self.mailData.connect(self.setMailData)
self.getMail = GetMail(data, self)
self.startGetMail()
else :
self.Parent.statusBar.showMessage(self.tr._translate('Empty Job.'))
def startGetMail(self):
self.Parent.reload_.setEnabled(False)
self.getMail.start()
def setMailAttr(self, d):
i = 0
for m in self.mails :
if m.idx == d['number'] : break
else : i += 1
self.mails[i].fromField.setText(d['from'])
self.mails[i].subjField.setText(d['subj'])
self.mails[i].dateField.setText(d['date'])
self.mails[i].reply_to = d['ReplyTo']
self.mails[i]._from_subj = d['_F_S']
def setMailData(self, d):
ll = d['data'][0]
data = d['data'][1]
i = 0
for m in self.mails :
if m.idx == d['number'] : break
else : i += 1
fileName = None
if d['type'] == 'html' :
_data = changeImagePath(data, d['boundary'])
''' create temporary html-file '''
fileName = os.path.join(self.iconDatabasePath, randomString(24) + '.html')
try :
with open(fileName, 'w') as f :
f.write(insertMetaData(_data))
except Exception, err :
print dateStamp(), err
with open(fileName, 'w') as f :
f.write(str(err))
finally : pass
wdg = QWebView()
wdg.triggerPageAction(QWebPage.Reload, True)
wdg.triggerPageAction(QWebPage.Stop, True)
wdg.triggerPageAction(QWebPage.Back, True)
wdg.triggerPageAction(QWebPage.Forward, True)
wdg.settings().setAttribute(QWebSettings.AutoLoadImages, \
self.Parent.autoLoadImage)
wdg.settings().setAttribute(QWebSettings.PrivateBrowsingEnabled, \
self.Parent.privateEnable)
if wdg.settings().iconDatabasePath().isEmpty() :
wdg.settings().setIconDatabasePath(self.iconDatabasePath)
wdg.load(QUrl('file://' + fileName))
#print dateStamp(), QUrl('file://' + fileName), ' created'
wdg.show()
self.webViewWDGs.append(wdg)
elif d['type'] in ('plain') :
wdg = QTextBrowser()
wdg.setAcceptRichText(True)
wdg.setOpenExternalLinks(True)
wdg.setOpenLinks(True)
data = data.replace('<', '< ')
data = data.replace('>', ' >')
wdg.setHtml(changeLink(data))
示例6: MainWindow
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class MainWindow(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.runned = False
self.tr = Translator("Thrifty")
# self.resize(450, 350)
self.setWindowTitle(self.tr._translate("Thrifty"))
self.setWindowIcon(QIcon("/usr/share/thrifty/icons/sniper_soldier.png"))
self.Settings = QSettings("thrifty", "thrifty")
self.exit_ = QAction(QIcon("/usr/share/thrifty/icons/exit.png"), self.tr._translate("&Exit"), self)
self.exit_.setShortcut("Ctrl+Q")
self.exit_.setStatusTip(self.tr._translate("Exit application"))
self.connect(self.exit_, SIGNAL("triggered()"), self._close)
listHelp = QAction(QIcon("/usr/share/thrifty/icons/help.png"), self.tr._translate("&About Thrifty"), self)
listHelp.setStatusTip(self.tr._translate("Read help"))
self.connect(listHelp, SIGNAL("triggered()"), self.showMSG)
self.stopProcess = QAction(
QIcon("/usr/share/thrifty/icons/terminate.png"), self.tr._translate("&Terminate Task"), self
)
self.stopProcess.setShortcut("Ctrl+T")
self.stopProcess.setStatusTip(self.tr._translate("Terminate running task ..."))
self.stopProcess.setEnabled(False)
self.connect(self.stopProcess, SIGNAL("triggered()"), self.terminateRunningTask)
self.separator = QAction("", self)
self.separator.setSeparator(True)
self.checkMode = QAction(self.tr._translate("check file`s &mode"), self)
self.checkMode.setCheckable(True)
value = str(self.Settings.value("checkFileMode", "False").toString())
if value.lower() == "true":
self.checkMode.setChecked(True)
else:
self.checkMode.setChecked(False)
self.connect(self.checkMode, SIGNAL("changed()"), self.setCheckMode)
self.checkOwners = QAction(self.tr._translate("check file`s &owners"), self)
self.checkOwners.setCheckable(True)
value = str(self.Settings.value("checkFileOwners", "False").toString())
if value.lower() == "true":
self.checkOwners.setChecked(True)
else:
self.checkOwners.setChecked(False)
self.connect(self.checkOwners, SIGNAL("changed()"), self.setCheckOwners)
self.checkMtime = QAction(self.tr._translate("check file`s mt&ime"), self)
self.checkMtime.setCheckable(True)
value = str(self.Settings.value("checkFileMtime", "False").toString())
if value.lower() == "true":
self.checkMtime.setChecked(True)
else:
self.checkMtime.setChecked(False)
self.connect(self.checkMtime, SIGNAL("changed()"), self.setCheckMtime)
self.statusBar = StatusBar(self)
self.setStatusBar(self.statusBar)
self.prelink = QAction(QIcon("/usr/share/thrifty/icons/prelink.png"), self.tr._translate("&Prelink"), self)
self.prelink.setShortcut("Ctrl+P")
self.prelink.setStatusTip(self.tr._translate("Prelink now"))
self.prelink.setEnabled(prelinkInstalled)
self.connect(self.prelink, SIGNAL("triggered()"), self.runPrelink)
menubar = self.menuBar()
file_ = menubar.addMenu(self.tr._translate("&File"))
file_.addAction(self.prelink)
file_.addAction(self.exit_)
set_ = menubar.addMenu(self.tr._translate("&Control"))
set_.addAction(self.stopProcess)
set_.addAction(self.separator)
set_.addAction(self.checkMode)
set_.addAction(self.checkOwners)
set_.addAction(self.checkMtime)
help_ = menubar.addMenu(self.tr._translate("&Help"))
help_.addAction(listHelp)
self.menuTab = Box(self)
self.setCentralWidget(self.menuTab)
def setCheckMode(self):
state = self.checkMode.isChecked()
print state
self.Settings.setValue("checkFileMode", state)
def setCheckOwners(self):
state = self.checkOwners.isChecked()
# print state
self.Settings.setValue("checkFileOwners", state)
def setCheckMtime(self):
state = self.checkMtime.isChecked()
# print state
#.........这里部分代码省略.........
示例7: Font_n_Colour
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
#.........这里部分代码省略.........
self.fieldSubjSizeVar = self.initValue('fieldSubjSize')
self.fieldSubjBoldVar = self.initValue('fieldSubjBold')
self.fieldSubjItalVar = self.initValue('fieldSubjItal')
self.fieldSubjColourVar = self.initValue('fieldSubjColour')
self.fieldDateFontVar = self.initValue('fieldDateFont', ' ')
self.fieldDateSizeVar = self.initValue('fieldDateSize')
self.fieldDateBoldVar = self.initValue('fieldDateBold')
self.fieldDateItalVar = self.initValue('fieldDateItal')
self.fieldDateColourVar = self.initValue('fieldDateColour')
self.headerColourStyle = self.getRGBaStyle(QString(self.headerColourVar).toUInt())
self.accountColourStyle = self.getRGBaStyle(QString(self.accountColourVar).toUInt())
self.accountSColourStyle = self.getRGBaStyle(QString(self.accountSColourVar).toUInt())
self.accountToolTipColourStyle = self.getRGBaStyle(QString(self.accountToolTipColourVar).toUInt())
self.accountToolTipSColourStyle = self.getRGBaStyle(QString(self.accountToolTipSColourVar).toUInt())
self.countColourStyle = self.getRGBaStyle(QString(self.countColourVar).toUInt())
self.countSColourStyle = self.getRGBaStyle(QString(self.countSColourVar).toUInt())
self.countToolTipColourStyle = self.getRGBaStyle(QString(self.countToolTipColourVar).toUInt())
self.countToolTipSColourStyle = self.getRGBaStyle(QString(self.countToolTipSColourVar).toUInt())
self.fieldBoxColourStyle = self.getRGBaStyle(QString(self.fieldBoxColourVar).toUInt())
self.fieldFromColourStyle = self.getRGBaStyle(QString(self.fieldFromColourVar).toUInt())
self.fieldSubjColourStyle = self.getRGBaStyle(QString(self.fieldSubjColourVar).toUInt())
self.fieldDateColourStyle = self.getRGBaStyle(QString(self.fieldDateColourVar).toUInt())
self.fontIcon = QIcon().fromTheme("preferences-desktop-font")
self.colourIcon = QIcon().fromTheme("format-text-color")
self.init()
def init(self):
self.layout = QGridLayout()
self.label1 = QLabel(self.tr._translate("Normal"))
self.label2 = QLabel(self.tr._translate("Select"))
self.label1.setMaximumHeight(30)
self.label2.setMaximumHeight(30)
self.layout.addWidget(self.label1, 0, 0)
self.layout.addWidget(self.label2, 0, 5)
prefix, suffix = self.cursive_n_bold(self.headerBoldVar, self.headerItalVar)
self.headerFontLabel = QLabel('<font face="' + self.headerFontVar + \
'">' + prefix + self.tr._translate('Header :') + suffix + '</font>')
self.headerFontLabel.setStyleSheet(self.headerColourStyle)
self.layout.addWidget(self.headerFontLabel, 1, 0)
self.headerFontButton = QPushButton(self.fontIcon, '')
self.headerFontButton.setToolTip('Font')
self.headerFontButton.clicked.connect(self.headerFont)
self.layout.addWidget(self.headerFontButton, 1, 1)
self.headerColourButton = QPushButton(self.colourIcon, '')
self.headerColourButton.setToolTip('Color')
self.connect(self.headerColourButton, SIGNAL('clicked()'), self.headerColour)
self.layout.addWidget(self.headerColourButton, 1, 2)
prefix, suffix = self.cursive_n_bold(self.accountBoldVar, self.accountItalVar)
self.accountFontLabel = QLabel('<font face="' + \
self.accountFontVar + '">' + prefix + self.tr._translate('Account :') + suffix + '</font>')
self.accountFontLabel.setStyleSheet(self.accountColourStyle)
self.layout.addWidget(self.accountFontLabel, 2, 0)
prefix, suffix = self.cursive_n_bold(self.accountSBoldVar, self.accountSItalVar)
self.accountSFontLabel = QLabel('<font face="' + self.accountSFontVar + \
'">' + prefix + self.tr._translate('Account :') + suffix + '</font>')
self.accountSFontLabel.setStyleSheet(self.accountSColourStyle)
self.layout.addWidget(self.accountSFontLabel, 2, 5)
示例8: Filters
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class Filters(QWidget):
def __init__(self, obj = None, parent= None):
QWidget.__init__(self, parent)
self.Parent = obj
self.prnt = parent
self.tr = Translator('Filters')
dir_ = os.path.expanduser('~/.config/plasmaMailChecker')
self.filterFROM = os.path.join(dir_, 'filter.from')
self.filterSUBJ = os.path.join(dir_, 'filter.subj')
i = 0
for path in (self.filterFROM, self.filterSUBJ) :
if not os.path.isfile(path) :
name = self.filterSUBJ if i else self.filterFROM
with open(name, 'wb') as f : pass
#print path, 'not exist'
i += 1
self.listFROM = dataToList(self.filterFROM)
self.listSUBJ = dataToList(self.filterSUBJ)
self.layout = QGridLayout()
self.layout.setSpacing(0)
self.labelFROM = QLabel(self.tr._translate("FROM field"))
self.labelSUBJ = QLabel(self.tr._translate("SUBJ field"))
self.layout.addWidget(self.labelFROM, 0, 1, Qt.AlignHCenter)
self.layout.addWidget(self.labelSUBJ, 0, 2, Qt.AlignHCenter)
self.fromEditor = QLineEdit()
self.subjEditor = QLineEdit()
self.fromListBox = QListWidget()
self.fromListBox.setSortingEnabled(True)
self.fromListBox.setToolTip(self.tr._translate("Filter`s strings"))
self.fromListBox.addItems(self.listFROM)
self.fromListBox.currentTextChanged.connect(self.from_FiltersChanged)
self.subjListBox = QListWidget()
self.subjListBox.setSortingEnabled(True)
self.subjListBox.setToolTip(self.tr._translate("Filter`s strings"))
self.subjListBox.addItems(self.listSUBJ)
self.subjListBox.currentTextChanged.connect(self.subj_FiltersChanged)
self.layout.addWidget(self.fromEditor, 1, 1)
self.layout.addWidget(self.subjEditor, 1, 2)
self.layout.addWidget(self.fromListBox, 2, 1)
self.layout.addWidget(self.subjListBox, 2, 2)
self.buttonFROM = ButtonPanel(0, self)
self.buttonSUBJ = ButtonPanel(1, self)
self.layout.addWidget(self.buttonFROM, 2, 0)
self.layout.addWidget(self.buttonSUBJ, 2, 3)
self.setLayout(self.layout)
self.buttonFROM.setCurrentState()
self.buttonSUBJ.setCurrentState()
self.StateChanged = [False, False]
def from_FiltersChanged(self):
self.StateChanged[0] = True
def subj_FiltersChanged(self):
self.StateChanged[1] = True
def addItem(self, id_):
if id_ :
text = self.subjEditor.text()
if not text.isEmpty() :
self.subjListBox.addItem(text)
self.StateChanged[id_] = True
self.subjEditor.clear()
else :
text = self.fromEditor.text()
if not text.isEmpty() :
self.fromListBox.addItem(text)
self.StateChanged[id_] = True
self.fromEditor.clear()
def delItem(self, id_):
if id_ :
item_ = self.subjListBox.currentRow()
self.subjListBox.takeItem(item_)
else :
item_ = self.fromListBox.currentRow()
self.fromListBox.takeItem(item_)
self.StateChanged[id_] = True
def saveFilter(self, id_):
if id_ :
i = 0
filter_ = []
while i < self.subjListBox.count() :
filter_.append(self.subjListBox.item(i).text().toUtf8().data())
#print unicode(QString().fromUtf8(self.subjListBox.item(i).text()))
i += 1
saveListToFile(filter_, self.filterSUBJ)
SUBJ_filter = dataToList(self.filterSUBJ)
else :
i = 0
filter_ = []
while i < self.fromListBox.count() :
#.........这里部分代码省略.........
示例9: Editor
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class Editor(QMainWindow):
def __init__(self, path = '', mode = 1, parent = None, task = None):
QMainWindow.__init__(self, parent)
self.tr = Translator('Thrifty')
#self.resize(450, 350)
self.setWindowTitle(self.tr._translate('Thrifty'))
self.setWindowIcon(QIcon('/usr/share/thrifty/icons/sniper_soldier.png'))
self.save_ = QAction(QIcon('/usr/share/thrifty/icons/save.png'), self.tr._translate('&Save'), self)
self.save_.setShortcut('Ctrl+S')
self.save_.setStatusTip(self.tr._translate('Save file'))
self.connect(self.save_, SIGNAL('triggered()'), self._save)
self.exit_ = QAction(QIcon('/usr/share/thrifty/icons/exit.png'), self.tr._translate('&Exit'), self)
self.exit_.setShortcut('Ctrl+Q')
self.exit_.setStatusTip(self.tr._translate('Exit application'))
self.connect(self.exit_, SIGNAL('triggered()'), self._close)
self.giveToYum = QAction(QIcon('/usr/share/thrifty/icons/exit.png'), self.tr._translate('to &Yum'), self)
self.giveToYum.setShortcut('Ctrl+Y')
self.giveToYum.setStatusTip(self.tr._translate('Give package list to Yum for reinstall'))
self.connect(self.giveToYum, SIGNAL('triggered()'), self.runYum)
self.giveToYum.setEnabled(False)
menubar = self.menuBar()
file_ = menubar.addMenu(self.tr._translate('&File'))
file_.addAction(self.save_)
file_.addAction(self.exit_)
toYum = menubar.addMenu(self.tr._translate('&Action'))
toYum.addAction(self.giveToYum)
if task is not None :
self.save_.setEnabled(False)
if task : self.giveToYum.setEnabled(True)
self.editor = QTextEdit(parent = self)
self.setCentralWidget(self.editor)
self.statusBar = StatusBar(self)
self.setStatusBar(self.statusBar)
self.Parent = parent
self.mode = mode
self.path = path
self.editor.setUndoRedoEnabled(True)
self.editor.setOverwriteMode(True)
self.editor.createStandardContextMenu()
if task is None :
s = readFile(self.path)
else :
s_ = readFile(self.path)
if self.path == '' :
s = s_
else :
l = []
for item in s_.split('\n') :
chunks = item.split(' ')
if len(chunks) >= task + 1 :
if chunks[task] != '' and chunks[task] not in l:
l.append(chunks[task])
_s = [s_ + '\n' for s_ in l]
_s.sort()
s = ''.join(_s)
#print [s, QString().fromUtf8(s)]
self.editor.setPlainText(QString().fromUtf8(s))
self.statusBar.showMessage('Edit : ' + self.path)
def runYum(self):
self.save_.setEnabled(False)
self.exit_.setEnabled(False)
self.giveToYum.setEnabled(False)
packageList = self.editor.toPlainText()
self.editor.clear()
self.editor.setReadOnly(True)
Data = QStringList()
Data.append('yum')
Data.append('-y')
Data.append('reinstall')
for item in packageList.split('\n') :
if item != '' :
#print [item]
Data.append(item)
## run yum in dispatched process
self.y = QProcess()
self.y.readyReadStandardOutput.connect(self.appendOutputString)
self.y.readyReadStandardError.connect(self.appendErrorString)
self.y.finished.connect(self.showResult)
self.y.start('pkexec', Data)
if self.y.waitForStarted() :
#print self.y.state()
self.statusBar.showMessage(self.tr._translate('Yum runned...'))
else :
self.showResult()
def appendOutputString(self):
output = self.y.readAllStandardOutput()
self.editor.append(QString().fromUtf8(output))
#.........这里部分代码省略.........
示例10: Broken
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class Broken(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.Parent = parent
self.tr = Translator('Thrifty')
self.runned = False
self.pathToLog = None
self.layout = QGridLayout()
self.layout.setAlignment(Qt.AlignCenter)
self.dirList = QListWidget()
#self.dirList.setMaximumHeight(150)
self.dirList.setToolTip(self.tr._translate('A list of directories processed'))
self.buttonLayout = QVBoxLayout()
self.buttonLayout.setAlignment(Qt.AlignCenter)
self.addPath = QPushButton(QIcon('/usr/share/thrifty/icons/plus.png'), '')
self.addPath.setIconSize(QSize(32,32))
self.delPath = QPushButton(QIcon('/usr/share/thrifty/icons/delete.png'), '')
self.delPath.setIconSize(QSize(32,32))
self.showTargets = QPushButton(QIcon('/usr/share/thrifty/icons/show.png'), '')
self.showTargets.setIconSize(QSize(32,32))
self.mode = QComboBox()
self.mode.setIconSize(QSize(32,32))
self.mode.setToolTip(self.tr._translate('Packages'))
self.mode.addItem (QIcon('/usr/share/thrifty/icons/packages.png'), '')
self.mode.addItem (QIcon('/usr/share/thrifty/icons/files.png'), '')
self.start = QPushButton(QIcon('/usr/share/thrifty/icons/start.png'), '')
self.start.setIconSize(QSize(32,32))
self.addPath.setToolTip(self.tr._translate('Add to List'))
self.delPath.setToolTip(self.tr._translate('Delete from List'))
self.showTargets.setToolTip(self.tr._translate('show Targets file'))
self.start.setToolTip(self.tr._translate('Start task'))
self.addPath.clicked.connect(self.addDirPath)
self.delPath.clicked.connect(self.delDirPath)
self.showTargets.clicked.connect(self.showTargetsList)
self.start.clicked.connect(self.runSearchBroken)
self.buttonLayout.addWidget(self.addPath)
self.buttonLayout.addWidget(self.delPath)
self.buttonLayout.addWidget(self.start)
self.buttonLayout.addWidget(self.mode)
self.buttonLayout.addWidget(self.showTargets)
self.progress = QProgressBar()
self.progress.setOrientation(Qt.Vertical)
self.progress.hide()
self.progress.setRange(0, 0)
self.logIn = QLabel('')
self.logIn.setToolTip(self.tr._translate('Log of processed task'))
self.logIn.setOpenExternalLinks(True)
self.layout.addWidget(self.dirList, 0, 0)
self.layout.addItem(self.buttonLayout, 0, 1)
self.layout.addWidget(self.progress, 0, 2)
self.layout.addWidget(self.logIn, 1, 0)
self.setLayout(self.layout)
self.mode.currentIndexChanged.connect(self.changeModeContent)
def addDirPath(self):
_nameDir = QFileDialog.getExistingDirectory(self, self.tr._translate('Path_to_'), '~', QFileDialog.ShowDirsOnly)
nameDir = _nameDir.toLocal8Bit().data()
if os.path.isdir(nameDir) and \
os.access(nameDir, os.R_OK) and os.access(nameDir, os.X_OK) :
self.dirList.addItem(_nameDir)
else :
msg = QMessageBox.information(self, 'ERROR', self.tr._translate('error'), QMessageBox.Ok)
def delDirPath(self):
item = self.dirList.takeItem(self.dirList.currentRow())
def changeModeContent(self, i = 0):
if i :
self.mode.setToolTip(self.tr._translate('Files'))
else :
self.mode.setToolTip(self.tr._translate('Packages'))
def runSearchBroken(self):
self.Parent.setTabsState(False)
self.progress.show()
self.runned = True
self.pathToLog = None
print 'Search broken running ...'
self.t = QProcess()
Data = QStringList()
Data.append('--user')
Data.append('root')
Data.append('/usr/share/thrifty/thrifty.py')
mode = '-b'
value = str(self.Parent.Parent.Settings.value('checkFileOwners', 'False').toString())
if value.lower() == 'true' :
mode += 'O'
value = str(self.Parent.Parent.Settings.value('checkFileMode', 'False').toString())
if value.lower() == 'true' :
mode += 'M'
value = str(self.Parent.Parent.Settings.value('checkFileMtime', 'False').toString())
if value.lower() == 'true' :
#.........这里部分代码省略.........
示例11: Mail
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class Mail(QWidget):
def __init__(self, idx = None, parent = None):
QWidget.__init__(self, parent)
self.idx = idx
self.Parent = parent
self.tr = Translator('mailViewer')
self.reply_to = None
self._from_subj = (None, None)
self.fromField = QLabel(self.tr._translate('From:'))
self.fromField.setOpenExternalLinks(True)
self.fromField.linkHovered.connect(self.linkDisplay)
self.subjField = QLabel(self.tr._translate('Subj:'))
self.dateField = QLabel(self.tr._translate('Date:'))
self.sendRe = QPushButton(QIcon.fromTheme('mail-reply-custom'), '')
self.sendRe.setToolTip(self.tr._translate('Quick Answer'))
self.sendRe.setFixedWidth(self.Parent.iconSize().width())
self.sendRe.setMinimumHeight(self.Parent.iconSize().height())
self.sendRe.setContentsMargins(0, 0, 0, 0)
self.sendRe.clicked.connect(self.sendReMail)
self.sendFw = QPushButton(QIcon.fromTheme('mail-forward'), '')
self.sendFw.setToolTip(self.tr._translate('Quick Forward'))
self.sendFw.setFixedWidth(self.Parent.iconSize().width())
self.sendFw.setMinimumHeight(self.Parent.iconSize().height())
self.sendFw.setContentsMargins(0, 0, 0, 0)
self.sendFw.clicked.connect(self.sendFwMail)
self.mailField = QSplitter()
self.mailField.setChildrenCollapsible(True)
self.mailField.setOrientation(Qt.Vertical)
self.mailField.setStretchFactor(1, 1)
self.mailField.setHandleWidth(5)
self.panel = QHBoxLayout()
self.mailInfo = QVBoxLayout()
self.mailInfo.addWidget(self.fromField)
self.mailInfo.addWidget(self.subjField)
self.mailInfo.addWidget(self.dateField)
self.buttons = QVBoxLayout()
self.buttons.addWidget(self.sendRe)
self.buttons.addWidget(self.sendFw)
self.panel.addItem(self.mailInfo)
self.panel.addItem(self.buttons)
self.layout = QVBoxLayout()
self.layout.addItem(self.panel)
self.layout.addWidget(self.mailField)
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
self.setLayout(self.layout)
def linkDisplay(self, s):
self.Parent.Parent.statusBar.showMessage(s)
def sendReMail(self):
self.sendMail('Re: ')
def sendFwMail(self):
self.sendMail('Fw: ')
def sendMail(self, prefix):
splt = self.mailField.widget(0)
wdg = splt.widget(splt.count() - 1)
if hasattr(wdg, 'toPlainText') : text = wdg.toPlainText()
elif hasattr(wdg, 'title') : text = wdg.title()
else : text = QString('<UNKNOWN_ERROR>')
to_ = self._from_subj[0] if self.reply_to is None else self.reply_to
self.sender = MailSender(to_, prefix, self._from_subj[1], text, self)
self.sender.exec_()
def __del__(self): self.close()
示例12: MainWindow
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class MainWindow(QMainWindow):
def __init__(self, data = {}, parent = None):
QMainWindow.__init__(self, parent)
self.runned = False
self.tr = Translator('mailViewer')
self.autoLoadImage = False
self.privateEnable = False
self.data = data
self.setWindowTitle(self.tr._translate('Mail Viewer'))
self.setWindowIcon(QIcon().fromTheme("mail"))
self.reload_ = QAction(QIcon().fromTheme("view-refresh"), '&'+self.tr._translate('Reload Job'), self)
self.reload_.setShortcut('Ctrl+R')
self.connect(self.reload_, SIGNAL('triggered()'), self.reloadJob)
self.exit_ = QAction(QIcon().fromTheme("application-exit"), '&'+self.tr._translate('Exit'), self)
self.exit_.setShortcut('Ctrl+Q')
self.connect(self.exit_, SIGNAL('triggered()'), self._close)
self.image_ = QAction(self.tr._translate('Image AutoLoad'), self)
self.image_.setShortcut('Ctrl+I')
self.image_.setCheckable(True)
self.image_.setChecked(self.autoLoadImage)
#self.image_.setIcon(QIcon().fromTheme("arrow-down-double"))
self.connect(self.image_, SIGNAL('triggered()'), self._image)
self.priv_ = QAction(self.tr._translate('Private Browsing'), self)
self.priv_.setShortcut('Ctrl+P')
self.priv_.setCheckable(True)
self.priv_.setChecked(self.privateEnable)
#self.priv_.setIcon(QIcon().fromTheme("user-group-delete"))
self.connect(self.priv_, SIGNAL('triggered()'), self._private)
self.menubar = self.menuBar()
file_ = self.menubar.addMenu('&'+self.tr._translate('File'))
file_.addAction(self.reload_)
file_.addAction(self.exit_)
sett_ = self.menubar.addMenu('&'+self.tr._translate('Settings'))
sett_.addAction(self.image_)
sett_.addAction(self.priv_)
self.statusBar = QStatusBar(self)
self.setStatusBar(self.statusBar)
self.menuTab = Box(self.data, self)
self.setCentralWidget(self.menuTab)
def _image(self): self.regimeChange('image', self.image_.isChecked())
def _private(self): self.regimeChange('private', self.priv_.isChecked())
def regimeChange(self, parameter, state):
if parameter == 'image' :
attr = QWebSettings.AutoLoadImages
else :
attr = QWebSettings.PrivateBrowsingEnabled
for wdg in self.menuTab.webViewWDGs :
wdg.settings().setAttribute(attr, state)
wdg.reload()
def reloadJob(self):
self.menuTab = Box(self.data, self)
self.setCentralWidget(self.menuTab)
self.menuTab.startGetMail()
def _close(self): self.eventClose()
def closeEvent(self, ev):
self.menuTab.__del__()
def eventClose(self):
self.close()
示例13: AppletSettings
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class AppletSettings(QWidget):
def __init__(self, obj = None, parent= None):
QWidget.__init__(self, parent)
self.Parent = obj
self.prnt = parent
self.tr = Translator('AppletSettings')
self.Settings = self.Parent.Settings
self.checkAccess = self.Parent.checkAccess
timeOut = self.initValue('TimeOut', '600')
AutoRun = self.initValue('AutoRun', '0')
countProbe = self.initValue('CountProbe', '3')
showError = self.initValue('ShowError', '1')
waitThread = self.initValue('WaitThread', '120')
stayDebLog = self.initValue('stayDebLog', '5')
showVersion = self.initValue('ShowVersion', '1')
timeOutGroup = self.initValue('TimeOutGroup', '3')
maxShowedMail = self.initValue('MaxShowedMail', '1024')
mailsInGroup = self.initValue('MailsInGroup', '5')
self.layout = QGridLayout()
self.timeOutLabel = QLabel(self.tr._translate("Timeout checking (sec.):"))
self.layout.addWidget(self.timeOutLabel,0,0)
self.timeOutBox = KIntSpinBox(10, 7200, 1, int(timeOut), self)
self.timeOutBox.setMaximumWidth(75)
self.layout.addWidget(self.timeOutBox, 0, 5)
self.autoRunLabel = QLabel(self.tr._translate("Autorun mail checking :"))
self.layout.addWidget(self.autoRunLabel,1,0)
self.AutoRunBox = QCheckBox()
if int(AutoRun) > 0 :
self.AutoRunBox.setCheckState(Qt.Checked)
self.layout.addWidget(self.AutoRunBox,1,5)
self.countProbe = QLabel(self.tr._translate("Count of connect probe\nto mail server:"))
self.layout.addWidget(self.countProbe,2,0)
self.countProbeBox = KIntSpinBox(1, 10, 1, int(countProbe), self)
self.layout.addWidget(self.countProbeBox, 2, 5)
self.showError = QLabel(self.tr._translate("Show error messages :"))
self.layout.addWidget(self.showError,3,0)
self.showErrorBox = QCheckBox()
if int(showError) > 0 :
self.showErrorBox.setCheckState(Qt.Checked)
self.layout.addWidget(self.showErrorBox,3,5)
self.waitThreadLabel = QLabel(self.tr._translate("Autoexit of connect (sec.):"))
self.layout.addWidget(self.waitThreadLabel,4,0)
self.waitThreadBox = KIntSpinBox(3, 7200, 1, int(waitThread), self)
self.layout.addWidget(self.waitThreadBox, 4, 5)
self.stayDebLogLabel = QLabel(self.tr._translate("Stay Debug output Log :"))
self.layout.addWidget(self.stayDebLogLabel,5,0)
self.stayDebLogBox = KIntSpinBox(1, 50, 1, int(stayDebLog), self)
self.stayDebLogBox.setMaximumWidth(75)
self.layout.addWidget(self.stayDebLogBox, 5, 5)
self.showVersion = QLabel(self.tr._translate("Show Version :"))
self.layout.addWidget(self.showVersion,6,0)
self.showVersionBox = QCheckBox()
if int(showVersion) > 0 :
self.showVersionBox.setCheckState(Qt.Checked)
self.layout.addWidget(self.showVersionBox,6,5)
self.timeOutGroupLabel = QLabel(self.tr._translate("Group Akonadi events timeout (sec.):"))
self.timeOutGroupLabel.setEnabled(AkonadiModuleExist)
self.layout.addWidget(self.timeOutGroupLabel, 7, 0)
self.timeOutGroupBox = KIntSpinBox(1, 200, 1, int(timeOutGroup), self)
self.timeOutGroupBox.setMaximumWidth(75)
self.timeOutGroupBox.setEnabled(AkonadiModuleExist)
self.layout.addWidget(self.timeOutGroupBox, 7, 5)
self.maxMailLabel = QLabel(self.tr._translate("Max Count of Showed Mail :"))
self.layout.addWidget(self.maxMailLabel, 8, 0)
self.maxMailBox = KIntSpinBox(1, 1024, 1, int(maxShowedMail), self)
self.maxMailBox.setMaximumWidth(75)
self.maxMailBox.valueChanged[int].connect(self.showMailGroupping)
self.layout.addWidget(self.maxMailBox, 8, 5)
self.mailInGroupLabel = QLabel('\t' + self.tr._translate("Count of Mail in Group for account:"))
self.mailInGroupLabel.setEnabled(False)
self.layout.addWidget(self.mailInGroupLabel, 9, 0)
self.mailInGroupBox = KIntSpinBox(1, 10, 1, int(mailsInGroup), self)
self.mailInGroupBox.setMaximumWidth(75)
self.mailInGroupBox.setEnabled(False)
self.layout.addWidget(self.mailInGroupBox, 9, 5)
self.setLayout(self.layout)
self.maxMailBox.valueChanged.emit(int(maxShowedMail))
def initValue(self, key_, default = '0'):
if self.Settings.contains(key_) :
#print dateStamp() , key_, self.Settings.value(key_).toString()
return self.Settings.value(key_).toString()
else :
self.Settings.setValue(key_, QVariant(default))
#print dateStamp() , key_, self.Settings.value(key_).toString()
return default
#.........这里部分代码省略.........
示例14: CheckFile
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class CheckFile(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.Parent = parent
self.runned = False
self.otherDataList = [""]
self.tr = Translator("Thrifty")
self.trChunk0 = self.tr._translate("<pre>WARNING: not unique data in rpmDB (")
self.trChunk1 = self.tr._translate(" records)")
self.layout = QGridLayout()
self.pathLayout = QHBoxLayout()
self.pathString = QLineEdit("")
self.pathString.returnPressed.connect(self.checkFile)
self.searchPath = QPushButton(QIcon("/usr/share/thrifty/icons/file.png"), "")
self.searchPath.setIconSize(QSize(32, 32))
self.searchPath.setToolTip(self.tr._translate("Path to file"))
self.searchPath.clicked.connect(self.addPath)
self.pathLayout.addWidget(self.pathString)
self.pathLayout.addWidget(self.searchPath)
self.layout.addItem(self.pathLayout, 0, 0, 2, 3)
self.package = QLabel(self.tr._translate("Package :"))
self.mode = QComboBox()
self.mode.setIconSize(QSize(32, 32))
self.mode.addItem(QIcon("/usr/share/thrifty/icons/user.png"), "")
self.mode.addItem(QIcon("/usr/share/thrifty/icons/admin.png"), "")
self.mode.setToolTip(self.tr._translate("User Mode"))
self.start = QPushButton(QIcon("/usr/share/thrifty/icons/start.png"), "")
self.start.setIconSize(QSize(32, 32))
self.start.clicked.connect(self.checkFile)
self.start.setToolTip(self.tr._translate("Start task"))
self.packageCheckSumm = QLabel(self.tr._translate("Package CheckSumm :"))
self.checkSumm = QLabel(self.tr._translate("Real CheckSumm :"))
self.packageRes = QComboBox()
self.packageRes.setSizeAdjustPolicy(QComboBox.AdjustToContents)
self.packageCheckSummRes = QLabel("")
self.checkSummRes = QLabel("")
self.otherData = QLabel("")
self.layout.addWidget(self.package, 3, 0)
self.layout.addWidget(self.mode, 4, 0, Qt.AlignLeft)
self.layout.addWidget(self.start, 4, 0, Qt.AlignRight)
self.layout.addWidget(self.packageCheckSumm, 5, 0)
self.layout.addWidget(self.checkSumm, 6, 0)
self.layout.addWidget(self.packageRes, 3, 1)
self.layout.addWidget(self.otherData, 4, 1)
self.layout.addWidget(self.packageCheckSummRes, 5, 1)
self.layout.addWidget(self.checkSummRes, 6, 1)
self.setLayout(self.layout)
self.mode.currentIndexChanged.connect(self.changeMode)
self.packageRes.currentIndexChanged.connect(self.changePackageContent)
self.setMinimumSize(32, 32)
def changeMode(self, i=0):
if i:
self.mode.setToolTip(self.tr._translate("Root Mode"))
else:
self.mode.setToolTip(self.tr._translate("User Mode"))
def changePackageContent(self, i=0):
self.otherData.setText(wrapData(self.otherDataList[i], self.trChunk0, self.trChunk1))
self.checkSummRes.setText(self.otherDataList[i][13])
self.packageCheckSummRes.setText(self.otherDataList[i][14])
def addPath(self):
fileName = QFileDialog.getOpenFileName(self, self.tr._translate("Path_to_"), "~")
name_ = fileName.toLocal8Bit().data()
if os.path.lexists(name_): # and \
# not stat.S_ISLNK(os.lstat(name_).st_mode) and os.access(name_, os.R_OK) :
self.pathString.setText(fileName)
self.pathString.setFocus()
else:
msg = QMessageBox.information(self, "ERROR", self.tr._translate("error"), QMessageBox.Ok)
def checkFile(self):
self.Parent.setTabsState(False)
self.runned = True
self.packageRes.currentIndexChanged.disconnect(self.changePackageContent)
self.packageRes.clear()
self.packageCheckSummRes.setText("")
self.checkSummRes.setText("")
self.otherData.setText("")
self.otherDataList = [["" for i in xrange(12)] + ["0", "", "", "", ""]]
mode = 0 if self.mode.currentIndex() else 1
path = self.pathString.text().toUtf8().data()
if not os.access(path, os.R_OK) and mode == 1:
with open("/dev/shm/thrifty.lastTask", "wb") as f:
message = self.tr._translate("Permission denied or File not exist.")
f.write("package:" + message.toUtf8() + "\nmulti:0")
self.showResult()
return
self.t = QProcess()
Data = QStringList()
#.........这里部分代码省略.........
示例15: BackUp
# 需要导入模块: from Translator import Translator [as 别名]
# 或者: from Translator.Translator import _translate [as 别名]
class BackUp(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.Parent = parent
self.tr = Translator('Thrifty')
self.runned = False
self.trChunk0 = self.tr._translate('backs up own $HOME only')
self.trChunk1 = self.tr._translate('without Excludes path.')
self.trChunk2 = self.tr._translate('backs up catalogs:')
self.trChunk3 = self.tr._translate('all real $HOMEs in system')
self.layout = QGridLayout()
self.layout.setAlignment(Qt.AlignLeft)
self.buttonLayout = QVBoxLayout()
self.buttonLayout.setAlignment(Qt.AlignCenter)
self.mode = QComboBox()
self.mode.setIconSize(QSize(32,32))
#self.mode.addItems(QStringList() << 'User' << 'Root')
self.mode.addItem (QIcon('/usr/share/thrifty/icons/user.png'), '')
self.mode.addItem (QIcon('/usr/share/thrifty/icons/admin.png'), '')
self.mode.setToolTip(self.tr._translate('User Mode'))
self.speed = QComboBox()
self.speed.setIconSize(QSize(32,32))
#self.speed.addItems(QStringList() << 'Slow' << 'Normal' << 'Fast' << 'Fast+')
self.speed.addItem (QIcon('/usr/share/thrifty/icons/slow.png'), '')
self.speed.addItem (QIcon('/usr/share/thrifty/icons/normal.png'), '')
self.speed.addItem (QIcon('/usr/share/thrifty/icons/fast.png'), '')
self.speed.addItem (QIcon('/usr/share/thrifty/icons/fast+.png'), '')
self.speed.setToolTip(self.tr._translate('Slow'))
self.editExcludes = QPushButton(QIcon('/usr/share/thrifty/icons/edit.png'), '')
self.editExcludes.setIconSize(QSize(32,32))
self.editExcludes.setToolTip(self.tr._translate('Edit Excludes file for current regime'))
self.editExcludes.clicked.connect(self.editExcludesFile)
self.start = QPushButton(QIcon('/usr/share/thrifty/icons/start.png'), '')
self.start.setIconSize(QSize(32,32))
self.start.clicked.connect(self.runBackUp)
self.start.setToolTip(self.tr._translate('Start task'))
self.buttonLayout.addWidget(self.mode)
self.buttonLayout.addWidget(self.speed)
self.buttonLayout.addWidget(self.editExcludes)
self.buttonLayout.addWidget(self.start)
self.descriptionTask = QLabel('')
self.descriptionTask.setAlignment(Qt.AlignLeft)
self.progress = QProgressBar()
self.progress.setOrientation(Qt.Vertical)
self.progress.hide()
self.progress.setRange(0, 0)
self.logIn = QLabel('')
self.logIn.setToolTip(self.tr._translate('Log of processed task'))
self.logIn.setOpenExternalLinks(True)
self.layout.addItem(self.buttonLayout, 0, 0)
self.layout.addWidget(self.progress, 0, 1)
self.layout.addWidget(self.descriptionTask, 0, 2)
self.layout.addWidget(self.logIn, 1, 0)
self.setLayout(self.layout)
self.mode.currentIndexChanged.connect(self.changeModeContent)
self.speed.currentIndexChanged.connect(self.changeSpeedContent)
self.mode.currentIndexChanged.emit(0)
def changeModeContent(self, i = 0):
if i :
self.mode.setToolTip(self.tr._translate('Root Mode'))
self.descriptionTask.setText(ROOT_DESCRIPTION(self.trChunk2, self.trChunk3, self.trChunk1))
self.editExcludes.setToolTip(self.tr._translate('Edit Excludes file for ') + \
'<font color=red><b>ROOT</b></font> ' + \
self.tr._translate('mode'))
else :
self.mode.setToolTip(self.tr._translate('User Mode'))
self.descriptionTask.setText(USER_DESCRIPTION(self.trChunk0, self.trChunk1))
self.editExcludes.setToolTip(self.tr._translate('Edit Excludes file for ') + \
'<font color=green><b>USER</b></font> ' + \
self.tr._translate('mode'))
def changeSpeedContent(self, i = 0):
if i == 3 :
self.speed.setToolTip(self.tr._translate('Fast+'))
elif i == 2 :
self.speed.setToolTip(self.tr._translate('Fast'))
elif i == 1 :
self.speed.setToolTip(self.tr._translate('Normal'))
else :
self.speed.setToolTip(self.tr._translate('Slow'))
def runBackUp(self):
self.Parent.setTabsState(False)
self.progress.show()
self.runned = True
mode = 0 if self.mode.currentIndex() else 1
speed = SPEED[self.speed.currentIndex()]
print 'BackUp running in %i mode and %i speed ...' % (mode, speed)
self.t = QProcess()
Data = QStringList()
Data.append('/usr/share/thrifty/thrifty.py')
#.........这里部分代码省略.........