本文整理匯總了Python中qt.QTimer.changeInterval方法的典型用法代碼示例。如果您正苦於以下問題:Python QTimer.changeInterval方法的具體用法?Python QTimer.changeInterval怎麽用?Python QTimer.changeInterval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qt.QTimer
的用法示例。
在下文中一共展示了QTimer.changeInterval方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MainApplication
# 需要導入模塊: from qt import QTimer [as 別名]
# 或者: from qt.QTimer import changeInterval [as 別名]
class MainApplication(KApplication):
def __init__(self):
KApplication.__init__(self)
# in case something needs done before quitting
self.connect(self, SIGNAL('aboutToQuit()'), self.quit)
self.dcop = ToolBoxDCOPInterface()
self._setup_standard_directories()
#self._generate_data_directories()
dbfile = os.path.join(self.datadir, 'main.db')
#self.conn = Connection(dbname=dbfile, autocommit=True,
# encoding='ascii')
#self.guests = Guests(self.conn)
#self.db = EntityManager(self.conn)
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
self.engine = create_engine('sqlite:///%s' % dbfile)
if not self.engine.table_names():
from newschema import metadata
metadata.create_all(self.engine)
self.DbSession = sessionmaker(bind=self.engine,
autoflush=True, transactional=False)
self.session = self.DbSession()
self.db = EntityManager(self.session)
self.urlhandler = MainUrlHandler(self)
self.filehandler = BaseFileHandler(self)
# setup the timer to handle background jobs
self.timer = QTimer()
# every five seconds
self.timer.changeInterval(1000)
self.connect(self.timer, SIGNAL('timeout()'), self._timer_done)
self.main_window = None
# this method sets up the directories used by the application
# with respect to the KDE environment
# currently the main config file is placed in self.datadir
# changes in the file dialogs used in the application will
# be stored in the config file in its proper location
# when I am ready to deal with changes to that config file
# that my code doesn't use, I will probably move the main
# config file to the regular config location
def _setup_standard_directories(self):
self._std_dirs = KStandardDirs()
self.tmpdir_parent = str(self._std_dirs.findResourceDir('tmp', '/'))
self.datadir_parent = str(self._std_dirs.findResourceDir('data', '/'))
self.tmpdir = os.path.join(self.tmpdir_parent, 'toolbox')
self.datadir = os.path.join(self.datadir_parent, 'toolbox')
# we need this in dosbox object (for now)
self.main_config_dir = self.datadir
if not os.path.exists(self.datadir):
os.mkdir(self.datadir)
# This method is currently useless, but may be useful later
# if some house cleaning needs doing before quitting
def quit(self):
# house cleaning chores go here
KApplication.quit(self)
def _timer_done(self):
self.urlhandler.scan_jobs()
if self.urlhandler.completed_jobs():
self.urlhandler.handle_completed_jobs()
self.emit(PYSIGNAL('UrlHandled'),(True,))
jobs = self.urlhandler.jobs
if jobs:
self.main_window.label.setText('toolbox: %d jobs running' % len(jobs))
else:
self.main_window.label.setText('toolbox')