SF.net SVN: fclient:[912] trunk/fclient/fclient
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-08-16 07:59:01
|
Revision: 912 http://fclient.svn.sourceforge.net/fclient/?rev=912&view=rev Author: jUrner Date: 2008-08-16 07:59:09 +0000 (Sat, 16 Aug 2008) Log Message: ----------- isolated logger view Modified Paths: -------------- trunk/fclient/fclient/fclient.py Added Paths: ----------- trunk/fclient/fclient/impl/ViewLogger/ trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py trunk/fclient/fclient/impl/ViewLogger/__init__.py trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py Removed Paths: ------------- trunk/fclient/fclient/impl/ViewLogger.py trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui Modified: trunk/fclient/fclient/fclient.py =================================================================== --- trunk/fclient/fclient/fclient.py 2008-08-16 07:54:39 UTC (rev 911) +++ trunk/fclient/fclient/fclient.py 2008-08-16 07:59:09 UTC (rev 912) @@ -17,7 +17,7 @@ from .impl.ViewBrowser import ViewBrowser from .impl.ViewConnection import ViewConnection from .impl.ViewDownloads import ViewDownloadsWidget -from .impl.ViewLogger import ViewLoggerWidget +from .impl.ViewLogger import ViewLogger from .impl.ViewUploads import ViewUploadsWidget from .impl.DlgSingleAppError import DlgSingleAppError @@ -81,7 +81,7 @@ ViewDownloadsWidget(mainWindow), ViewUploadsWidget(mainWindow), ) - viewWidget.addBottomViews(ViewLoggerWidget(mainWindow)) + viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(mainWindow)) mainWindow.show() res = app.exec_() Added: trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui =================================================================== --- trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui (rev 0) +++ trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui 2008-08-16 07:59:09 UTC (rev 912) @@ -0,0 +1,30 @@ +<ui version="4.0" > + <class>ViewLoggerWidget</class> + <widget class="QWidget" name="ViewLoggerWidget" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>550</width> + <height>471</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QPlainTextEdit" name="edLogger" > + <property name="lineWrapMode" > + <enum>QPlainTextEdit::NoWrap</enum> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> Added: trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py =================================================================== --- trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py (rev 0) +++ trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py 2008-08-16 07:59:09 UTC (rev 912) @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui' +# +# Created: Sat Aug 16 09:56:26 2008 +# by: PyQt4 UI code generator 4.4.3-snapshot-20080705 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_ViewLoggerWidget(object): + def setupUi(self, ViewLoggerWidget): + ViewLoggerWidget.setObjectName("ViewLoggerWidget") + ViewLoggerWidget.resize(550, 471) + self.gridLayout = QtGui.QGridLayout(ViewLoggerWidget) + self.gridLayout.setObjectName("gridLayout") + self.edLogger = QtGui.QPlainTextEdit(ViewLoggerWidget) + self.edLogger.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap) + self.edLogger.setReadOnly(True) + self.edLogger.setObjectName("edLogger") + self.gridLayout.addWidget(self.edLogger, 0, 0, 1, 1) + + self.retranslateUi(ViewLoggerWidget) + QtCore.QMetaObject.connectSlotsByName(ViewLoggerWidget) + + def retranslateUi(self, ViewLoggerWidget): + ViewLoggerWidget.setWindowTitle(QtGui.QApplication.translate("ViewLoggerWidget", "Form", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + ViewLoggerWidget = QtGui.QWidget() + ui = Ui_ViewLoggerWidget() + ui.setupUi(ViewLoggerWidget) + ViewLoggerWidget.show() + sys.exit(app.exec_()) + Added: trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py =================================================================== --- trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py (rev 0) +++ trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py 2008-08-16 07:59:09 UTC (rev 912) @@ -0,0 +1,276 @@ + +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + +import sys +import logging + +from PyQt4 import QtCore, QtGui + +from .. import config +from ..lib import fcp2 + +from .Ui_LoggerWidget import Ui_ViewLoggerWidget +#********************************************************************************** +# +#********************************************************************************** +class Actions(config.ActionsBase): + + PrefixVerbosity = 'ActionVerbosity' + + def __init__(self, parent): + config.ActionsBase.__init__(self, parent) + + # for ease of use verbosities are mapped to verbosity actions like this: PrefixVerbosity + Verbosity + self.action( + name='ActionLoggerClear', + text=self.trUtf8('C&lear'), + trigger=parent.onActionLoggerClear, + ) + + groupVerbosity = self.group( + name='GroupVerbosity', + trigger=parent.onGroupVerbosityTriggered, + isExclusive=True, + ) + self.action( + name='ActionVerbosityInfo', + text=self.trUtf8('Info'), + group=groupVerbosity, + trigger=None, + isCheckable=True, + userData=fcp2.ConstDebugVerbosity.Info, + ) + self.action( + name='ActionVerbosityMessage', + text=self.trUtf8('Message'), + group=groupVerbosity, + trigger=None, + isCheckable=True, + userData=fcp2.ConstDebugVerbosity.Message, + ) + self.action( + name='ActionVerbosityDebug', + text=self.trUtf8('Debug'), + group=groupVerbosity, + trigger=None, + isCheckable=True, + userData=fcp2.ConstDebugVerbosity.Debug, + ) + self.action( + name='ActionVerbosityChatty', + text=self.trUtf8('Chatty'), + group=groupVerbosity, + trigger=None, + isCheckable=True, + userData=fcp2.ConstDebugVerbosity.Chatty, + ) + + +class GlobalFeedback(config.GlobalFeedbackBase): + """wrapper for global statusbar widgets, menus""" + + def __init__(self, parent, idGlobalFeedback): + config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback) + + # menus + self.menus = [] + if self.menuBar is not None and hasattr(parent, 'fcViewObject'): + menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar) + parent.populateMenu(menu) + self.menus.append(menu) + self.menuBar.addViewMenu(menu) + + # status bar widgets + self.label1 = None + #if self.statusBar is not None: + # self.label1 = QtGui.QLabel('foo here', self.statusBar) + + def setVisible(self, flag): + for menu in self.menus: + menu.children()[0].setVisible(flag) + if self.label1 is not None: + self.label1.setVisible(flag) + + +class Settings(config.SettingsBase): + + PrefixVerbosityColorFg = 'ColorFgVerbosity' + + _key_ = config.IdViewLoggerWidget + _settings_ = ( + ('MaxLines', 'UInt', 1000), + ('Verbosity', 'PyString', 'Info'), + + #TODO: Chatty does not seem to work. check in fcp2.client + ('ColorFgVerbosityCRITICAL', 'QColor', QtGui.QColor('red')), + ('ColorFgVerbosityERROR', 'QColor', QtGui.QColor('red')), + ('ColorFgVerbosityWARNING', 'QColor', QtGui.QColor('red')), + ('ColorFgVerbosityINFO', 'QColor', QtGui.QColor('black')), + ('ColorFgVerbosityMESSAGE', 'QColor', QtGui.QColor('blue')), + ('ColorFgVerbosityDEBUG', 'QColor', QtGui.QColor('slategray')), + ('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray')), + ) + + +class LoggerViewObject(config.ViewObject): + + def __init__(self, parent): + config.ViewObject. __init__(self, parent) + + self.name=parent.objectName() + self.displayName=self.trUtf8('Logger') + self.icon=QtGui.QIcon() + + +#*********************************************************************** +# +#*********************************************************************** +class MyLoggingHandler(logging.Handler): + + def __init__(self, cb, *args, **kwargs): + logging.Handler.__init__(self, *args, **kwargs) + self.cb = cb + + def emit(self, record): + self.cb(record) + +#*********************************************************************** +# +#*********************************************************************** +class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget): + + IdEdLogger = 'edLogger' + + + def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): + QtGui.QWidget.__init__(self, parent) + self._isCreated = False + self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff + + self.setupUi(self) + config.ObjectRegistry.register(self) + + self.fcActions = Actions(self) + self.fcSettings = Settings(self).restore() + self.fcViewObject = LoggerViewObject(self) + self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback) + + + # setup editbox + #NOTE: do not move to showEvent(). we want to be up and alive as soon as possible to catch logs + ed = self.controlById(self.IdEdLogger) + ed.document().setMaximumBlockCount(self.fcSettings.value('MaxLines')) + ed.contextMenuEvent = self.loggerContextMenuEvent + self.connect(ed, QtCore.SIGNAL('textChanged()'), self.onLoggerTextChanged) + + # setup logger + self.loggingHandler = MyLoggingHandler(self.addRecord) + logging.getLogger('').addHandler(self.loggingHandler) + + # setup actions + verbosity = self.fcSettings.value('Verbosity').title() + action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None) + if action is None: + verbosity = self.fcSettings.restoreDefaults('Verbosity')['Verbosity'] + action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None) + if action is None: + raise ValueError('default verbosity action "%s" not found. WTF?' % self.actions.PrefixVerbosity + verbosity) + action.trigger() + + ######################################### + ## methods + ######################################### + def addRecord(self, record): + """adds a logging record""" + ed = self.controlById(self.IdEdLogger) + fmt = ed.currentCharFormat() + colorFg = self.fcSettings.value(self.fcSettings.PrefixVerbosityColorFg + record.levelname) + fmt.setForeground(QtGui.QBrush(colorFg)) + ed.setCurrentCharFormat(fmt) + + text = '%s:%s:%s' % (record.levelname, record.name, record.getMessage()) + ed.appendPlainText(text) + + def controlById(self, idControl): + return getattr(self, idControl) + + def populateMenu(self, menu): + menu.addAction(self.fcActions['ActionLoggerClear']) + subMenu = menu.addMenu(self.trUtf8('Verbosity')) + subMenu.addActions(self.fcActions['GroupVerbosity'].actions()) + return menu + + ######################################### + ##view methods + ######################################### + def viewClose(self): + pass + + def viewDisplayName(self): + return self.trUtf8('Logger') + + def viewIcon(self): + return QtGui.QIcon() + + def viewName(self): + return self.objectName() + + ######################################### + ## overwritten events + ######################################### + def loggerContextMenuEvent(self, event): + """customize context menu of the logger QTextEdit""" + ed = self.controlById(self.IdEdLogger) + menu = ed.createStandardContextMenu() + self.populateMenu(menu) + menu.exec_(event.globalPos()) + + def hideEvent(self, event): + self.fcGlobalFeedback.setVisible(False) + + def showEvent(self, event): + self.fcGlobalFeedback.setVisible(True) + if self._isCreated: + return + self._isCreated = True + + ######################################### + ## event onrs + ######################################### + def onActionLoggerClear(self, action): + self.controlById(self.IdEdLogger).clear() + + def onGroupVerbosityTriggered(self, action): + nameVerbosity = action.objectName()[len(self.fcActions.PrefixVerbosity):] + self.fcSettings.setValues(Verbosity=nameVerbosity) + logging.getLogger().setLevel(action.userData()) + + def onLoggerTextChanged(self): + ed = self.controlById(self.IdEdLogger) + self.fcActions['ActionLoggerClear'].setEnabled(not ed.document().isEmpty()) + +#********************************************************************************** +# +#********************************************************************************** +if __name__ == '__main__': + import sys + + app = QtGui.QApplication(sys.argv) + w = ViewLoggerWidget(None) + + w.show() + res = app.exec_() + sys.exit(res) + + + Added: trunk/fclient/fclient/impl/ViewLogger/__init__.py =================================================================== --- trunk/fclient/fclient/impl/ViewLogger/__init__.py (rev 0) +++ trunk/fclient/fclient/impl/ViewLogger/__init__.py 2008-08-16 07:59:09 UTC (rev 912) @@ -0,0 +1 @@ + Added: trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py =================================================================== --- trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py (rev 0) +++ trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py 2008-08-16 07:59:09 UTC (rev 912) @@ -0,0 +1,99 @@ +'''in python 2.5 relative impports are srsly broken ..fix this to make relative imports work +when executing a module as main (-m), including relative imports up to the root package + +see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] + +@note: root package is the highest available package in the package hirarchy. +don't look at __name__ too closely. it gets adjusted for a module to just "do the right +thing" in __name__ == '__main__' comparisons +@note: this patch does not work if relative imports are done in __init__.py. no idea why +and to be honest, I don't wanna* know.. +@note: this is more or less a hack. so it may have unwanted side effects for example +when importing parent packages. use at your own risk. could improve this module +by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but +I don't think its worth it. see what python2.6 or 3k brings.. + +usage:: + + # place this at the top a module, before doing any relative imports + from fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + from ...foo import bar + + + +##<-- copy and paste code, assuming _fix_mexec resides in the current dir.. + +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + +##--> copy and paste code +''' + +import imp, os, sys +#******************************************************************************** +# +#******************************************************************************** +class MainName(str): + def __eq__(self, other): + if other == '__main__': return True + return str.__eq__(self, other) + def __ne__(self, other): + if other == '__main__': return False + return str.__ne__(self, other) + + +def fix_mexec(_name_, _file_): + """bugfix for relative imports not working + @param _name_: __name__ of the module + @param _file_: __file__ of the module + + @note: not complete: relies on __init__.py, .pyo (...) is ignored currently + """ + if _name_ == '__main__': + out = [] + # find allparent packages + p = os.path.dirname(os.path.abspath(_file_)) + prev = p + while True: + pkg = os.path.join(p, '__init__.py') + if os.path.isfile(pkg): + out.append([pkg, os.path.basename(p)]) + else: + break + prev = p + p = os.path.dirname(p) + if p == prev: + break + out.reverse() + + # adjust sub package names an import parent modules + name = None + for n, (fpath, name) in enumerate(out): + if n > 0: + name = out[n][1] = out[n -1][1] + '.' + out[n][1] + m = imp.load_source(name, fpath) + m.__path__ = [os.path.dirname(fpath)] + + # adjust name of the __main__ module + if name is not None: + m = sys.modules.pop('__main__') + # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected + ##m.__name__ = _Name_(name + '.' + '__main__') + m.__name__ = MainName(name) + sys.modules[m.__name__] = m + + + Deleted: trunk/fclient/fclient/impl/ViewLogger.py =================================================================== --- trunk/fclient/fclient/impl/ViewLogger.py 2008-08-16 07:54:39 UTC (rev 911) +++ trunk/fclient/fclient/impl/ViewLogger.py 2008-08-16 07:59:09 UTC (rev 912) @@ -1,269 +0,0 @@ - -from __future__ import absolute_import -if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below - import os; __path__ = [os.path.dirname(__file__)] - -import sys -import logging - -from PyQt4 import QtCore, QtGui - -from . import config -from .lib import fcp2 - -from .tpls.Ui_ViewLoggerWidgetTpl import Ui_ViewLoggerWidget -#********************************************************************************** -# -#********************************************************************************** -class Actions(config.ActionsBase): - - PrefixVerbosity = 'ActionVerbosity' - - def __init__(self, parent): - config.ActionsBase.__init__(self, parent) - - # for ease of use verbosities are mapped to verbosity actions like this: PrefixVerbosity + Verbosity - self.action( - name='ActionLoggerClear', - text=self.trUtf8('C&lear'), - trigger=parent.onActionLoggerClear, - ) - - groupVerbosity = self.group( - name='GroupVerbosity', - trigger=parent.onGroupVerbosityTriggered, - isExclusive=True, - ) - self.action( - name='ActionVerbosityInfo', - text=self.trUtf8('Info'), - group=groupVerbosity, - trigger=None, - isCheckable=True, - userData=fcp2.ConstDebugVerbosity.Info, - ) - self.action( - name='ActionVerbosityMessage', - text=self.trUtf8('Message'), - group=groupVerbosity, - trigger=None, - isCheckable=True, - userData=fcp2.ConstDebugVerbosity.Message, - ) - self.action( - name='ActionVerbosityDebug', - text=self.trUtf8('Debug'), - group=groupVerbosity, - trigger=None, - isCheckable=True, - userData=fcp2.ConstDebugVerbosity.Debug, - ) - self.action( - name='ActionVerbosityChatty', - text=self.trUtf8('Chatty'), - group=groupVerbosity, - trigger=None, - isCheckable=True, - userData=fcp2.ConstDebugVerbosity.Chatty, - ) - - -class GlobalFeedback(config.GlobalFeedbackBase): - """wrapper for global statusbar widgets, menus""" - - def __init__(self, parent, idGlobalFeedback): - config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback) - - # menus - self.menus = [] - if self.menuBar is not None and hasattr(parent, 'fcViewObject'): - menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar) - parent.populateMenu(menu) - self.menus.append(menu) - self.menuBar.addViewMenu(menu) - - # status bar widgets - self.label1 = None - #if self.statusBar is not None: - # self.label1 = QtGui.QLabel('foo here', self.statusBar) - - def setVisible(self, flag): - for menu in self.menus: - menu.children()[0].setVisible(flag) - if self.label1 is not None: - self.label1.setVisible(flag) - - -class Settings(config.SettingsBase): - - PrefixVerbosityColorFg = 'ColorFgVerbosity' - - _key_ = config.IdViewLoggerWidget - _settings_ = ( - ('MaxLines', 'UInt', 1000), - ('Verbosity', 'PyString', 'Info'), - - #TODO: Chatty does not seem to work. check in fcp2.client - ('ColorFgVerbosityCRITICAL', 'QColor', QtGui.QColor('red')), - ('ColorFgVerbosityERROR', 'QColor', QtGui.QColor('red')), - ('ColorFgVerbosityWARNING', 'QColor', QtGui.QColor('red')), - ('ColorFgVerbosityINFO', 'QColor', QtGui.QColor('black')), - ('ColorFgVerbosityMESSAGE', 'QColor', QtGui.QColor('blue')), - ('ColorFgVerbosityDEBUG', 'QColor', QtGui.QColor('slategray')), - ('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray')), - ) - - -class LoggerViewObject(config.ViewObject): - - def __init__(self, parent): - config.ViewObject. __init__(self, parent) - - self.name=parent.objectName() - self.displayName=self.trUtf8('Logger') - self.icon=QtGui.QIcon() - - -#*********************************************************************** -# -#*********************************************************************** -class MyLoggingHandler(logging.Handler): - - def __init__(self, cb, *args, **kwargs): - logging.Handler.__init__(self, *args, **kwargs) - self.cb = cb - - def emit(self, record): - self.cb(record) - -#*********************************************************************** -# -#*********************************************************************** -class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget): - - IdEdLogger = 'edLogger' - - - def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): - QtGui.QWidget.__init__(self, parent) - self._isCreated = False - self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff - - self.setupUi(self) - config.ObjectRegistry.register(self) - - self.fcActions = Actions(self) - self.fcSettings = Settings(self).restore() - self.fcViewObject = LoggerViewObject(self) - self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback) - - - # setup editbox - #NOTE: do not move to showEvent(). we want to be up and alive as soon as possible to catch logs - ed = self.controlById(self.IdEdLogger) - ed.document().setMaximumBlockCount(self.fcSettings.value('MaxLines')) - ed.contextMenuEvent = self.loggerContextMenuEvent - self.connect(ed, QtCore.SIGNAL('textChanged()'), self.onLoggerTextChanged) - - # setup logger - self.loggingHandler = MyLoggingHandler(self.addRecord) - logging.getLogger('').addHandler(self.loggingHandler) - - # setup actions - verbosity = self.fcSettings.value('Verbosity').title() - action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None) - if action is None: - verbosity = self.fcSettings.restoreDefaults('Verbosity')['Verbosity'] - action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None) - if action is None: - raise ValueError('default verbosity action "%s" not found. WTF?' % self.actions.PrefixVerbosity + verbosity) - action.trigger() - - ######################################### - ## methods - ######################################### - def addRecord(self, record): - """adds a logging record""" - ed = self.controlById(self.IdEdLogger) - fmt = ed.currentCharFormat() - colorFg = self.fcSettings.value(self.fcSettings.PrefixVerbosityColorFg + record.levelname) - fmt.setForeground(QtGui.QBrush(colorFg)) - ed.setCurrentCharFormat(fmt) - - text = '%s:%s:%s' % (record.levelname, record.name, record.getMessage()) - ed.appendPlainText(text) - - def controlById(self, idControl): - return getattr(self, idControl) - - def populateMenu(self, menu): - menu.addAction(self.fcActions['ActionLoggerClear']) - subMenu = menu.addMenu(self.trUtf8('Verbosity')) - subMenu.addActions(self.fcActions['GroupVerbosity'].actions()) - return menu - - ######################################### - ##view methods - ######################################### - def viewClose(self): - pass - - def viewDisplayName(self): - return self.trUtf8('Logger') - - def viewIcon(self): - return QtGui.QIcon() - - def viewName(self): - return self.objectName() - - ######################################### - ## overwritten events - ######################################### - def loggerContextMenuEvent(self, event): - """customize context menu of the logger QTextEdit""" - ed = self.controlById(self.IdEdLogger) - menu = ed.createStandardContextMenu() - self.populateMenu(menu) - menu.exec_(event.globalPos()) - - def hideEvent(self, event): - self.fcGlobalFeedback.setVisible(False) - - def showEvent(self, event): - self.fcGlobalFeedback.setVisible(True) - if self._isCreated: - return - self._isCreated = True - - ######################################### - ## event onrs - ######################################### - def onActionLoggerClear(self, action): - self.controlById(self.IdEdLogger).clear() - - def onGroupVerbosityTriggered(self, action): - nameVerbosity = action.objectName()[len(self.fcActions.PrefixVerbosity):] - self.fcSettings.setValues(Verbosity=nameVerbosity) - logging.getLogger().setLevel(action.userData()) - - def onLoggerTextChanged(self): - ed = self.controlById(self.IdEdLogger) - self.fcActions['ActionLoggerClear'].setEnabled(not ed.document().isEmpty()) - -#********************************************************************************** -# -#********************************************************************************** -if __name__ == '__main__': - import sys - from . import Ui_ViewLogger - - app = QtGui.QApplication(sys.argv) - w = ViewLoggerWidget(None) - - w.show() - res = app.exec_() - sys.exit(res) - - - Deleted: trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui =================================================================== --- trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui 2008-08-16 07:54:39 UTC (rev 911) +++ trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui 2008-08-16 07:59:09 UTC (rev 912) @@ -1,47 +0,0 @@ -<ui version="4.0" > - <class>SideBarLoadDetails</class> - <widget class="QWidget" name="SideBarLoadDetails" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>497</width> - <height>488</height> - </rect> - </property> - <property name="windowTitle" > - <string>Form</string> - </property> - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" > - <layout class="QHBoxLayout" name="horizontalLayout" > - <item> - <widget class="QLabel" name="header" > - <property name="text" > - <string>Load details</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="btClose" > - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <widget class="QTreeWidget" name="tree" > - <column> - <property name="text" > - <string>1</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> Deleted: trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py =================================================================== --- trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py 2008-08-16 07:54:39 UTC (rev 911) +++ trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py 2008-08-16 07:59:09 UTC (rev 912) @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file '/home/me/src/proj/fclient/trunk/fclient/src/fclient/tpls/ViewLoggerWidgetTpl.ui' -# -# Created: Tue Jul 15 16:03:24 2008 -# by: PyQt4 UI code generator 4.4.3-snapshot-20080705 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_ViewLoggerWidget(object): - def setupUi(self, ViewLoggerWidget): - ViewLoggerWidget.setObjectName("ViewLoggerWidget") - ViewLoggerWidget.resize(550, 471) - self.gridLayout = QtGui.QGridLayout(ViewLoggerWidget) - self.gridLayout.setObjectName("gridLayout") - self.edLogger = QtGui.QPlainTextEdit(ViewLoggerWidget) - self.edLogger.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap) - self.edLogger.setReadOnly(True) - self.edLogger.setObjectName("edLogger") - self.gridLayout.addWidget(self.edLogger, 0, 0, 1, 1) - - self.retranslateUi(ViewLoggerWidget) - QtCore.QMetaObject.connectSlotsByName(ViewLoggerWidget) - - def retranslateUi(self, ViewLoggerWidget): - ViewLoggerWidget.setWindowTitle(QtGui.QApplication.translate("ViewLoggerWidget", "Form", None, QtGui.QApplication.UnicodeUTF8)) - - -if __name__ == "__main__": - import sys - app = QtGui.QApplication(sys.argv) - ViewLoggerWidget = QtGui.QWidget() - ui = Ui_ViewLoggerWidget() - ui.setupUi(ViewLoggerWidget) - ViewLoggerWidget.show() - sys.exit(app.exec_()) - Deleted: trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui =================================================================== --- trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui 2008-08-16 07:54:39 UTC (rev 911) +++ trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui 2008-08-16 07:59:09 UTC (rev 912) @@ -1,30 +0,0 @@ -<ui version="4.0" > - <class>ViewLoggerWidget</class> - <widget class="QWidget" name="ViewLoggerWidget" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>550</width> - <height>471</height> - </rect> - </property> - <property name="windowTitle" > - <string>Form</string> - </property> - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" > - <widget class="QPlainTextEdit" name="edLogger" > - <property name="lineWrapMode" > - <enum>QPlainTextEdit::NoWrap</enum> - </property> - <property name="readOnly" > - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |