本文整理汇总了Python中kdecore.KApplication类的典型用法代码示例。如果您正苦于以下问题:Python KApplication类的具体用法?Python KApplication怎么用?Python KApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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
示例2: __init__
def __init__(self, *args):
KApplication.__init__(self)
cfg = BaseConfig()
self.cfg = cfg
dirs = KStandardDirs()
self.tmpdir = str(dirs.findResourceDir('tmp', '/'))
self.datadir = str(dirs.findResourceDir('data', '/'))
self.socketdir = str(dirs.findResourceDir('socket', '/'))
dsn = {}
self.cfg.setGroup('database')
dsn['user'] = self.cfg.readEntry('dbuser')
dsn['dbname'] = self.cfg.readEntry('dbname')
dsn['passwd'] = self.cfg.readEntry('dbpass')
self.cfg.setGroup('pgpool')
self.pgpool = None
usepgpool = self.cfg.readEntry('usepgpool')
if usepgpool != 'false':
print 'using pgpool'
self.pgpool = PgPool(self.cfg, self.tmpdir, self.datadir)
if not os.path.isfile(self.pgpool.pidfile):
self.pgpool.run()
else:
self.pgpool = None
dsn['host'] = 'localhost'
dsn['port'] = self.cfg.readEntry('port')
else:
self.cfg.setGroup('database')
dsn['host'] = self.cfg.readEntry('dbhost')
dsn['port'] = self.cfg.readEntry('dbport')
self.db = BaseDatabase(dsn, 'Konsultant', self)
self.db.app = self
self.connect(self, SIGNAL('aboutToQuit()'), self.quit)
示例3: main
def main():
aboutData = KAboutData(
PACKAGE, PROGRAMNAME, VERSION,
I18N_NOOP("LilyKDE servicemenu helper"),
KAboutData.License_GPL,
"Copyright (c) 2008, " + AUTHOR,
"", HOMEPAGE)
KCmdLineArgs.init (sys.argv, aboutData)
KCmdLineArgs.addCmdLineOptions([
("+files", I18N_NOOP("LilyPond files to convert"))
])
app = KApplication()
log = LogWidget()
app.setMainWidget(log)
log.setMinimumHeight(240)
log.setMinimumWidth(400)
log.setCaption(PROGRAMNAME)
log.show()
# get the files to convert
pa = KCmdLineArgs.parsedArgs()
files = map(pa.arg, range(pa.count()))
# start the first job. Itself takes care of running the rest.
Job(files, log)
app.exec_loop()
示例4: __init__
def __init__(self):
KApplication.__init__(self)
self.set_config()
self.conn = None
dirs = KStandardDirs()
self.tmpdir = str(dirs.findResourceDir('tmp', '/'))
self.datadir = str(dirs.findResourceDir('data', '/'))
# I probably don't need the socket dir
self.socketdir = str(dirs.findResourceDir('socket', '/'))
示例5: __init__
def __init__(self, *args):
KApplication.__init__(self)
self.cfg = PaellaConfig()
self.conn = PaellaConnection(self.cfg)
self.db = BaseDatabase(self.conn, 'paelladb', None)
dirs = KStandardDirs()
self.tmpdir = str(dirs.findResourceDir('tmp', '/'))
self.datadir = str(dirs.findResourceDir('data', '/'))
self.socketdir = str(dirs.findResourceDir('socket', '/'))
dsn = {}
示例6: __init__
def __init__(self):
KApplication.__init__(self)
# in case something needs done before quitting
self.connect(self, SIGNAL('aboutToQuit()'), self.quit)
self._setup_standard_directories()
#self._generate_data_directories()
dbfile = os.path.join(self.datadir, 'guests.db')
self.conn = Connection(dbname=dbfile, autocommit=True,
encoding='ascii')
self.guests = Guests(self.conn)
示例7: __init__
def __init__(self):
KApplication.__init__(self)
# in case something needs done before quitting
self.connect(self, SIGNAL('aboutToQuit()'), self.quit)
# place dcop object here
self.dcop = DosboxHandler()
self._setup_standard_directories()
self._generate_data_directories()
self.mainconfigfilename = os.path.join(self.datadir, 'dosbox-pykde.conf')
if os.path.isfile(self.mainconfigfilename):
self.generate_default_config()
self.generate_main_objects()
示例8: saveFileList
def saveFileList(self):
"""Update the list of monitored files in the configuration file."""
files = []
for mon in self.monitors:
files.append(mon.getFileName())
cfg = KApplication.kApplication().config()
cfg.setGroup("Monitor")
cfg.writeEntry("files", files)
示例9: __init__
def __init__(self, parent, name='BaseGameDataDialog'):
KDialogBase.__init__(self, parent, name)
# setup app pointer
self.app = KApplication.kApplication()
self.myconfig = self.app.myconfig
# we need a frame for the layout widget
# the layout widget won't work with a window as parent
self.frame = BaseGameDataFrame(self)
# set frame as main widget
self.setMainWidget(self.frame)
示例10: main
def main():
"""Main program."""
description = str(i18n("Simple log file viewer"))
version = "0.3"
about = KAboutData("lovi", "lovi", version, description,
KAboutData.License_GPL, "Copyright (C) 2005-2006 by Akos Polster")
about.addAuthor("Akos Polster", "", "[email protected]")
KCmdLineArgs.init(sys.argv, about)
KCmdLineArgs.addCmdLineOptions([("+files", "Files to monitor")])
app = KApplication()
mainWindow = MainWin(None, "lovi#")
app.setMainWidget(mainWindow)
# Get list of monitored files from the command line or from the cfg file
args = KCmdLineArgs.parsedArgs()
if args.count() > 0:
for i in range(0, args.count()):
mainWindow.monitor(args.arg(i))
else:
cfg = app.config()
cfg.setGroup("Monitor")
files = cfg.readListEntry("files")
for f in files:
mainWindow.monitor(str(f))
mainWindow.show()
app.exec_loop()
示例11: run_widget
def run_widget(myclass, use_kde=None):
""" run a qt app using myclass as the main widget.
This funtion calls sys.exit().
"""
global HASKDE
#pk.options.parse_args()
#if has_kde() and use_kde is None:
# use_kde = pk.options.get('use_kde')
HASKDE = use_kde
if use_kde:
from kdecore import KAboutData, KCmdLineArgs, KApplication
about = KAboutData('A pk app', 'run_widget', '0.1')
KCmdLineArgs.init(sys.argv, about)
a = KApplication()
w = myclass()
w.show()
a.exec_()
else:
from PyQt4.QtGui import QApplication
a = QApplication(sys.argv)
w = myclass()
w.show()
sys.exit(a.exec_())
示例12: runAction
def runAction(url):
"""
Runs an URL with KRun. If url starts with "email=" or "emailpreview=",
it is converted to a mailto: link with the url attached, and opened in
the default KDE mailer.
If url starts with "print=", the file is directly printed with lpr.
If url starts with "embed=", a subroutine in pdftk is called to embed
LilyPond documents in the output PDF.
"""
# hack: prevent QTextView recognizing mailto: urls cos it can't handle
# query string
url = unicode(url) # url could be a QString
m = re.match("([a-z]+)=(.*)", url)
if not m:
return krun(url)
command, url = m.groups()
if command == 'print':
path = unicode(KURL(url).path())
cmd = splitcommandline(config("commands").get("lpr", "lpr"))
cmd.append(path)
p = Popen(cmd, stderr=PIPE)
if p.wait() != 0:
error(_("Printing failed: %s") % p.stderr.read())
else:
info(_("The document has been sent to the printer."))
elif command in ('email', 'emailpreview'):
if command == "email" or warncontinue(_(
"This PDF has been created with point-and-click urls (preview "
"mode), which increases the file size dramatically. It's better "
"to email documents without point-and-click urls (publish mode), "
"because they are much smaller. Continue anyway?")):
KApplication.kApplication().invokeMailer(
KURL(u"mailto:?attach=%s" % url), "", True)
elif command == 'embed':
ly = unicode(KURL(url).path())
from lilykde import pdftk
pdftk.attach_files(ly)
示例13: openFile
def openFile(pdf):
""" Open the specified PDF document """
global _file
c = KApplication.dcopClient()
kpdf = DCOPApp(c.appId(), c).kpdf
# When LilyPond writes a PDF, it first deletes the old one.
# So the new PDF gets a different inode number, which causes
# KPDF to sometimes loose the 'watch' on the file.
# So we call KPDF to open the file, and remember the page number
# displayed ourselves, because KPDF also seems to forget the scroll
# position due to LilyPond deleting the old PDF first.
# It would be best that either KPDF is fixed to just look for a
# named file, even if it has a different inode number, or that
# LilyPond is fixed to not delete the old PDF first, but just
# truncate it and write the new data into it.
# Update June 17, 2008: LilyPond >= 2.11.49 does not delete the PDF
# anymore on unix platforms!
# Document already shown?
if _file == pdf:
# Yes this is the same PDF, see if we need to force KPDF to
# reload the document. If not, we trust that KPDF automatically
# updates its view.
from lilykde.version import version
if (
# User can force reload of PDF with config option
config('preferences')['force reload pdf'] == '1'
# LilyPond >= 2.11.49 does not delete the PDF anymore on unix
or version < (2, 11, 49) or os.name not in ('posix', 'mac')
# read KPDF's 'watch file' option (default is true)
or kconfig('kpdfpartrc', True, False).group('General')['WatchFile']
in ('false', '0', 'off', 'no')):
# Reopen same document, remembering page number
page = kpdf.currentPage()[1]
kpdf.openDocument(KURL(pdf))
QTimer.singleShot(100, lambda: kpdf.goToPage(page))
else:
# This is another PDF, just open it.
kpdf.openDocument(KURL(pdf))
_file = pdf
示例14: setDocument
def setDocument(self):
doc = open("examples/helloworld/Hello.html").read()
app = KApplication.kApplication()
# here we try to make a blank page first
# as in the KTextBrowser, but this doesn't do the trick
if True:
view = self.view()
view.layout()
self.begin()
self.write('')
self.end()
app.processEvents()
app.processEvents()
self.begin()
self.setAutoloadImages(True)
self.write(doc)
self.end()
self.connect(self, SIGNAL("completed()"),self.complete)
示例15: __init__
def __init__(self):
QObject.__init__(self)
self.sysTray = KMySystemTray()
self.sysTray.setPixmap(self.sysTray.loadIcon("ksmarttray"))
self.sysTray.show()
self.process = KProcIO()
self.state = KSmartTray.State.Waiting
self.lastKnownStatus = ""
self.blinkFlag = False
self.updateFailed = False
self.checkTimer = QTimer()
self.blinkTimer = QTimer()
QObject.connect(self.checkTimer, SIGNAL("timeout()"), self.checkUpgrades)
QObject.connect(self.process, SIGNAL("processExited(KProcess *)"),
self.processDone)
QObject.connect(self, PYSIGNAL("foundNewUpgrades()"), self.startBlinking)
QObject.connect(self, PYSIGNAL("foundNoUpgrades()"), self.stopBlinking)
QObject.connect(self.sysTray, PYSIGNAL("mouseEntered()"), self.stopBlinking)
QObject.connect(self.blinkTimer, SIGNAL("timeout()"), self.toggleBlink)
QObject.connect(self.sysTray.checkAction, SIGNAL("activated()"),
self.manualCheckUpgrades)
QObject.connect(self.sysTray.startSmartAction, SIGNAL("activated()"),
self.startSmart)
QObject.connect(self.sysTray.stopAction, SIGNAL("activated()"),
self.stopChecking)
QObject.connect(self.sysTray, SIGNAL("quitSelected()"),
KApplication.kApplication(), SLOT("quit()"))
QObject.connect(self.sysTray, PYSIGNAL("activated()"), self.runUpgrades)
self.checkTimer.start(5*60*1000)
self.checkUpgrades()