from PyQt4 import QtCore, QtGui import socket import logging socket.setdefaulttimeout(8) appIcon = 'gfx/icon.png' APPNAME = 'nephilim' ORGNAME = 'nephilim' def doEvents(): """Make some time for necessary events.""" QtCore.QEventLoop().processEvents(QtCore.QEventLoop.AllEvents) def sec2min(secs): """Converts seconds to min:sec.""" min=int(secs/60) sec=secs%60 if sec<10:sec='0'+str(sec) return str(min)+':'+str(sec) class Button(QtGui.QPushButton): iconSize=32 """A simple Button class which calls $onClick when clicked.""" def __init__(self, caption, onClick=None, iconPath=None, iconOnly=False, parent=None): QtGui.QPushButton.__init__(self, parent) if onClick: self.connect(self, QtCore.SIGNAL('clicked(bool)'), onClick) if iconPath: self.changeIcon(iconPath) if not(iconPath and iconOnly): QtGui.QPushButton.setText(self, caption) self.setToolTip(caption) def setText(self, caption): self.setToolTip(caption) if self.icon()==None: self.setText(caption) def changeIcon(self, iconPath): icon=QtGui.QIcon() icon.addFile(iconPath, QtCore.QSize(self.iconSize, self.iconSize)) self.setIcon(icon) def expand_tags(str, expanders): #ensure that str is QString str = QtCore.QString(str) for expander in expanders: str = expander.expand_tags(str) #remove unexpanded tags return str.replace(QtCore.QRegExp('\\$\\w+'), '')