def __init__(self, scriptaction,cli=False): self.scriptaction = scriptaction self.currentpath = self.scriptaction.currentPath() self.cli=cli self.forms = Kross.module("forms") if not self.cli: # launched from inside KPlato self.proj = KPlato.project() else: # launched as a standalone script... print("opening doc...") filename=self.showImportDialog() KPlato.document().openUrl(filename) print( filename) self.proj=KPlato.project() self.dialog = self.forms.createDialog(i18n("Busy Information Export")) self.dialog.setButtons("Ok|Cancel") self.dialog.setFaceType("List") #Auto Plain List Tree Tabbed datapage = self.dialog.addPage(i18n("Schedules"),i18n("Export Selected Schedule"),"document-export") self.scheduleview = KPlato.createScheduleListView(datapage) savepage = self.dialog.addPage(i18n("Save"),i18n("Export Busy Info File"),"document-save") self.savewidget = self.forms.createFileWidget(savepage, "kfiledialog:///kplatobusyinfoexportsave") self.savewidget.setMode("Saving") self.savewidget.setFilter("*.ics|%(1)s\n*|%(2)s" % { '1' : i18n("Calendar"), '2' : i18n("All Files") } ) if self.dialog.exec_loop(): try: self.doExport( self.proj ) except: self.forms.showMessageBox("Error", i18n("Error"), "%s" % "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
def printSchedule(sch): print "%-10s %-25s %-10s" % (sch.id(), sch.name(), sch.isScheduled()) print "sch ( %s )" % ";".join(dir(sch)) print sch.appointments() for i in range(sch.childCount()): printSchedule(sch.childAt(i)) forms = Kross.module("forms") print "forms: ", dir(forms) for mn in dir(KPlato): m = getattr(KPlato, mn) print mn, "===>", m.__doc__ KPlato.document().openUrl("/home/dimon/work/python/koffice-scripts/kplato/test_project.kplato") project = KPlato.project() print dir(KPlato.data) sid = -1 # get a schedule id if project.scheduleCount() > 0: sched = project.scheduleAt(0) sid = sched.id() print "appointments?? : ", KPlato.data(sched, "m_appointments") print project.id(), KPlato.data(project, "NodeName") printSchedules(project)