forked from openlp/openlp
Better logging
Icons can come from a PNG file or from resource file bzr-revno: 95
This commit is contained in:
parent
b6edf96d32
commit
e6110cf27d
@ -3,10 +3,12 @@ from openlp.resources import *
|
||||
# from openlp.plugins import Plugin
|
||||
import logging
|
||||
|
||||
import os, sys
|
||||
mypath=os.path.split(os.path.abspath(__file__))[0]
|
||||
class ToolbarButton(QtGui.QToolButton):
|
||||
log=logging.getLogger("ToolbarBtn")
|
||||
log.info("loaded")
|
||||
def __init__(self, parent, name, pixmap, tooltiptext, statustip=None):
|
||||
self.log=logging.getLogger("TlrBtn%s"% name)
|
||||
self.log.info("loaded")
|
||||
self.log.info("create '%s', '%s'"%(name, pixmap))
|
||||
QtGui.QToolButton.__init__(self, parent.Toolbar)
|
||||
self.icon = QtGui.QIcon()
|
||||
@ -21,18 +23,22 @@ class ToolbarButton(QtGui.QToolButton):
|
||||
self.setToolTip(QtGui.QApplication.translate("main_window", tooltiptext, None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.setText(QtGui.QApplication.translate("main_window", tooltiptext, None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.setStatusTip(QtGui.QApplication.translate("main_window", statustip, None, QtGui.QApplication.UnicodeUTF8))
|
||||
# xxx button events
|
||||
|
||||
class MediaManagerItem(QtGui.QWidget):
|
||||
log=logging.getLogger("MediaMgrItem")
|
||||
log.info("loaded")
|
||||
name="Default_Item"
|
||||
iconname=":/media/media_video.png" # xxx change this to some default bare icon
|
||||
# iconname=":/media/media_video.png" # xxx change this to some default bare icon
|
||||
iconname=None
|
||||
iconfile=os.path.join(mypath, "red-x.png")
|
||||
def __init__(self):
|
||||
QtGui.QWidget.__init__(self)
|
||||
self.log.info("init")
|
||||
self.icon = QtGui.QIcon()
|
||||
if self.iconname is not None:
|
||||
self.icon.addPixmap(QtGui.QPixmap(self.iconname), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
if self.iconfile is not None:
|
||||
self.icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(self.iconfile)), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
|
||||
self.Layout = QtGui.QVBoxLayout(self)
|
||||
self.Layout.setSpacing(0)
|
||||
@ -49,11 +55,20 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.ToolbarButtons.append(ToolbarButton(self, "LoadItem", ":/images/image_load.png", "Load something", "Load something in"))
|
||||
self.ToolbarButtons.append(ToolbarButton(self, "DeleteItem", ":/images/image_delete.png", "Delete something", "Delete something from"))
|
||||
|
||||
# xxx button events
|
||||
QtCore.QObject.connect(self.ToolbarButtons[0], QtCore.SIGNAL("clicked()"), self.LoadItemclicked)
|
||||
QtCore.QObject.connect(self.ToolbarButtons[1], QtCore.SIGNAL("clicked()"), self.DeleteItemclicked)
|
||||
# add somewhere for "choosing" to happen
|
||||
self.choose_area=QtGui.QWidget(self)
|
||||
self.Layout.addWidget(self.choose_area)
|
||||
self.choose_area.text="Stuff and Nonsense"
|
||||
|
||||
def LoadItemclicked(self):
|
||||
self.log.info("LoadItemClicked")
|
||||
self.choose_area.text+="+"
|
||||
def DeleteItemclicked(self):
|
||||
self.log.info("DeleteItemClicked")
|
||||
self.choose_area.text+="-"
|
||||
def paintEvent(self, evt):
|
||||
paint = QtGui.QPainter()#self.choose_area)
|
||||
paint.begin(self)
|
||||
|
@ -1,14 +1,14 @@
|
||||
from PyQt4 import QtCore, QtGui
|
||||
import logging
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
|
||||
format='%(asctime)s %(name)-30s %(levelname)-8s %(message)s',
|
||||
datefmt='%m-%d %H:%M',
|
||||
filename='plugins.log',
|
||||
filemode='w')
|
||||
|
||||
console=logging.StreamHandler()
|
||||
# set a format which is simpler for console use
|
||||
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
|
||||
formatter = logging.Formatter('%(name)24s: %(levelname)-8s %(message)s')
|
||||
# tell the handler to use this format
|
||||
console.setFormatter(formatter)
|
||||
logging.getLogger('').addHandler(console)
|
||||
|
Loading…
Reference in New Issue
Block a user