本文整理汇总了Python中Kross.module方法的典型用法代码示例。如果您正苦于以下问题:Python Kross.module方法的具体用法?Python Kross.module怎么用?Python Kross.module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kross
的用法示例。
在下文中一共展示了Kross.module方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def start(action, myconfig, myorca):
while True:
try:
myorca.speak(T.i18n("Calligra Spreadsheet"))
break
except IOError:
forms = Kross.module("forms")
dialog = forms.createDialog(T.i18n("Orca Screen Reader"))
dialog.minimumWidth = 400
dialog.minimumHeight = 40
dialog.setButtons("Ok|Cancel")
page = dialog.addPage("", "")
label = forms.createWidget(page, "QLabel")
label.text = T.i18n("Failed to connect with the Orca HTTP-Server.")
widget = forms.createWidget(page, "QWidget")
layout = forms.createLayout(widget, "QHBoxLayout")
forms.createWidget(widget, "QLabel").text = T.i18n("Url:")
urlEdit = forms.createWidget(widget, "QLineEdit")
urlEdit.text = myconfig.url
if not dialog.exec_loop():
return
myconfig.url = urlEdit.text
mykspread = MyKSpread(action, myorca)
setattr(__main__, "_KSpreadOrca", mykspread)
MyDialog(self, mykspread)
示例2: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, action, config):
self.action = action
self.config = config
forms = Kross.module("forms")
dialog = forms.createDialog(T.i18n("Import vCard"))
#dialog.minimumWidth = 400
#dialog.minimumHeight = 300
dialog.setButtons("Ok|Cancel")
dialog.setFaceType("List") #Auto Plain List Tree Tabbed
filepage = dialog.addPage(T.i18n("Open"), T.i18n("vCard File"), "document-open")
#deffile = "/home/kde4/vcardtest/addressbook.vcf" #"kfiledialog:///kspreadvcardimport"
deffile = "kfiledialog:///kspreadvcardimport"
self.openwidget = forms.createFileWidget(filepage, deffile)
self.openwidget.setMode("Opening")
self.openwidget.setFilter("*.vcf|%(1)s\n*|%(2)s" % { '1' : T.i18n("vCard Files"), '2' : T.i18n("All Files") } )
datapage = dialog.addPage(T.i18n("Import"),T.i18n("Import to sheet beginning at cell"),"document-import")
self.sheetslistview = KSpread.createSheetsListView(datapage)
self.sheetslistview.setEditorType("Cell")
if not dialog.exec_loop():
return
vcardfilename = self.openwidget.selectedFile()
if not os.path.isfile(vcardfilename):
raise Exception, T.i18n("File '%1' not found.", [vcardfilename])
currentSheet = self.sheetslistview.sheet()
if not currentSheet:
raise Exception, T.i18n("No current sheet.")
self.importVCardFile(vcardfilename, currentSheet)
示例3: initWidget
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def initWidget(widget):
# the Kross forms module does provide methods to create
# widgets for us. You are for example able to load a UI
# file, create layouts or just any other supported widget.
forms = Kross.module("forms")
frame = forms.createWidget("QWidget")
forms.createLayout(frame, "QHBoxLayout")
# here we load the KHTML KPart that is our full powered
# webbrowser widget.
khtml_part = forms.loadPart(frame, "libkhtmlpart")
khtml_part.javaScriptEnabled = True
khtml_part.javaEnabled = False
khtml_part.pluginsEnabled = False
# now we add the frame to our widget and will earn a
# proxywidget for it.
proxywidget = karamba.createCanvasWidget(widget, frame)
# the following lines demonstrate, how to control the
# webbrowser using the JavaScript language. The KHTML
# KPart does provide different signals we are able to
# connect our own functions too. Just see here the
# kdelibs/khtml/khtmlpart.h file.
def selectionChanged():
print khtml_part.executeScript("window.scrollBy(0,50);")
khtml_part.connect("selectionChanged()", selectionChanged)
# and finally we like to load an url and display something.
khtml_part.openUrl("http://www.kde.org")
示例4: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self):
self.forms = Kross.module("forms")
self.dialog = self.forms.createDialog("KHTML Part")
self.dialog.minimumWidth = 720
self.dialog.minimumHeight = 480
#dialog.setButtons("Ok|Cancel")
self.dialog.setFaceType("Plain") #Auto Plain List Tree Tabbed
page = self.dialog.addPage("", "")
#self.part = self.forms.loadPart(page, "libkhtmlpart", "file:///home/kde4/kspreaddocument2.html")
#self.part = self.forms.loadPart(page, "libkhtmlpart", "http://127.0.0.1:8282/")
self.part = self.forms.loadPart(page, "libkhtmlpart", "http://techbase.kde.org/Development/Tutorials/KWord_Scripting")
if not self.part:
raise "Failed to load the KHTML KPart"
self.part.javaScriptEnabled = False
self.part.javaEnabled = False
self.part.pluginsEnabled = False
#part.openUrl("/home/kde4/kspreaddocument2.html")
self.part.connect("popupMenu(const QString&, const QPoint&)", self.popupMenu)
self.part.connect("selectionChanged()", self.selectionChanged)
self.part.connect("formSubmitNotification(const char*,const QString&,const QByteArray&,const QString&,const QString&, const QString&)", self.formSubmitNotification)
#print self.part
#print dir(self.part)
self.dialog.exec_loop()
示例5: configure
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def configure(self):
forms = Kross.module("forms")
dialog = forms.createDialog(t.i18n("E-Mail Script Settings"))
dialog.setButtons("Ok|Cancel")
page = page = dialog.addPage(t.i18n("E-Mail Settings"),t.i18n("E-Mail Settings"),"mail-send")
widget = forms.createWidgetFromUIFile(page,KTScriptingPlugin.scriptDir("email_notifications") + "emailconfig.ui")
widget["username"].text = self.mail_user
widget["password"].text = self.mail_pwd
widget["server"].text = self.mail_server
widget["port"].value = self.mail_port
widget["to"].text = self.mail_dest
widget["cc"].text = self.mail_cc
widget["bcc"].text = self.mail_bcc
widget["add_cc"].checked = self.mail_add_cc
widget["add_bcc"].checked = self.mail_add_bcc
widget["cc"].enabled = self.mail_add_cc
widget["bcc"].enabled = self.mail_add_bcc
widget["tls"].checked = self.mail_use_tls
if dialog.exec_loop():
# update settings
self.mail_user = widget["username"].text
self.mail_pwd = widget["password"].text
self.mail_server = widget["server"].text
self.mail_port = widget["port"].value
self.mail_dest = widget["to"].text
self.mail_cc = widget["cc"].text
self.mail_bcc = widget["bcc"].text
self.mail_add_cc = widget["add_cc"].checked
self.mail_add_bcc = widget["add_bcc"].checked
self.mail_use_tls = widget["tls"].checked
self.save()
示例6: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, action, config):
self.config = config
forms = Kross.module("forms")
self.dialog = forms.createDialog("ReportLab.org")
self.dialog.setButtons("Ok|Cancel")
self.dialog.setFaceType("Plain") # Auto Plain List Tree Tabbed
self.dialog.minimumWidth = 580
self.dialog.minimumHeight = 400
# if not self.config.writeFileName:
savepage = self.dialog.addPage("Save", "Export to PDF Document", "document-save")
savewidget = forms.createFileWidget(savepage, "kfiledialog:///wordsreportlab")
savewidget.setFilter("*.pdf|PDF Documents\n*|All Files")
savewidget.setMode("Saving")
# page = self.dialog.addPage("Template","Template","book")
# pagewidget = forms.createWidgetFromUIFile(page, os.path.join(action.currentPath(), "kwreportlabpage.ui"))
if self.dialog.exec_loop():
if not self.config.writeFileName:
self.config.writeFileName = savewidget.selectedFile()
if not self.config.writeFileName:
raise "No file selected."
writer = MyWriter(config)
writer.write()
示例7: showDialog
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def showDialog(self):
""" Shows the import-dialog and let the user define the imagefile which
should be imported. """
import Kross, os
forms = Kross.module("forms")
dialog = forms.createDialog("Python Imaging Library Import")
try:
dialog.setFaceType("List")
dialog.setButtons("Ok|Cancel")
filepage = dialog.addPage("File","Import Image From File","document-open")
filewidget = forms.createFileWidget(filepage, "kfiledialog:///kritapilimport")
filewidget.setMode("Opening")
filewidget.setFilter(self.getFilters())
optionspage = dialog.addPage("Options","Import Options","configure")
currentpath = self.scriptaction.currentPath()
uifile = os.path.join(currentpath, "pilimport.ui")
optionswidget = forms.createWidgetFromUIFile(optionspage, uifile)
if dialog.exec_loop():
self.filename = filewidget.selectedFile()
self.colorspace = self.getOption(optionswidget, "Colorspace", ["RGB","CMYK"])
self.destination = self.getOption(optionswidget, "Destination", ["NewLayer","ActiveLayer"])
self.size = self.getOption(optionswidget, "Size", ["Resize","Scale","Ignore"])
if not os.path.isfile(self.filename):
raise "No valid file to import from choosen."
self.doImport()
finally:
dialog.delayedDestruct()
示例8: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, scriptaction):
self.scriptaction = scriptaction
#self.currentpath = self.scriptaction.currentPath()
#self.undostack = KSpread.undoStack()
#self.undostack.connect("indexChanged(int)",self.indexChanged)
#file = os.path(self.getLogDir(),"KSpread.log")
self.forms = Kross.module("forms")
self.dialog = self.forms.createDialog("Logger")
self.dialog.setButtons("Ok|Cancel")
self.dialog.setFaceType("Plain") #Auto Plain List Tree Tabbed
savepage = self.dialog.addPage("Save","Save to Log File","document-save")
self.savewidget = self.forms.createFileWidget(savepage, "kfiledialog:///kspreadlogger")
self.savewidget.setMode("Saving")
self.savewidget.setFilter("*.txt *.log|Log File\n*|All Files")
if self.dialog.exec_loop():
filename = self.savewidget.selectedFile()
if os.path.isfile(filename):
if self.forms.showMessageBox("WarningContinueCancel", "Overwrite file?", "The file \"%s\" does already exist. Overwrite the file?" % filename) != "Continue":
raise "Aborted."
sheetname = KSpread.currentSheet().sheetName()
cellrange = "A1:F50" #FIXME
try:
self.file = open(filename, "w")
self.startLogging(sheetname, cellrange)
except IOError, (errno, strerror):
raise "Failed to write Log File \"%s\":\n%s" % (filename,strerror)
示例9: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, scriptaction):
self.scriptaction = scriptaction
self.currentpath = self.scriptaction.currentPath()
self.forms = Kross.module("forms")
self.dialog = self.forms.createDialog(T.i18n("CSV Import"))
self.dialog.setButtons("Ok|Cancel")
self.dialog.setFaceType("List") # Auto Plain List Tree Tabbed
openpage = self.dialog.addPage(T.i18n("Open"), T.i18n("Import from CSV File"), "document-open")
self.openwidget = self.forms.createFileWidget(openpage, "kfiledialog:///kspreadcsvimportopen")
self.openwidget.setMode("Opening")
self.openwidget.setFilter(
"*.csv *.txt|%(1)s\n*|%(2)s" % {"1": T.i18n("Comma-Separated-Value Files"), "2": T.i18n("All Files")}
)
datapage = self.dialog.addPage(T.i18n("Import"), T.i18n("Import to sheet beginning at cell"), "document-import")
self.sheetslistview = KSpread.createSheetsListView(datapage)
self.sheetslistview.setEditorType("Cell")
optionspage = self.dialog.addPage(T.i18n("Options"), T.i18n("Comma Separated Value Options"), "configure")
self.optionswidget = self.forms.createWidgetFromUIFile(
optionspage, os.path.join(self.currentpath, "csvoptions.ui")
)
if self.dialog.exec_loop():
try:
self.doImport()
except:
self.forms.showMessageBox(
"Error",
T.i18n("Error"),
"%s" % "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])),
)
示例10: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, scriptaction):
self.scriptaction = scriptaction
self.currentpath = self.scriptaction.currentPath()
self.forms = Kross.module("forms")
self.dialog = self.forms.createDialog(T.i18n("CSV Export"))
self.dialog.setButtons("Ok|Cancel")
self.dialog.setFaceType("List") #Auto Plain List Tree Tabbed
savepage = self.dialog.addPage(T.i18nc("Options page name", "Save"),T.i18n("Export to CSV File"),"document-save")
self.savewidget = self.forms.createFileWidget(savepage, "kfiledialog:///kspreadcsvexportsave")
self.savewidget.setMode("Saving")
self.savewidget.setFilter("*.csv *.txt|%(1)s\n*|%(2)s" % { '1' : T.i18n("Comma-Separated-Value Files"), '2' : T.i18n("All Files") } )
datapage = self.dialog.addPage(T.i18nc("Options page name", "Export"),T.i18n("Export Sheets and ranges"),"document-export")
self.sheetslistview = KSpread.createSheetsListView(datapage)
self.sheetslistview.setSelectionType("MultiSelect")
self.sheetslistview.setEditorType("Range")
optionspage = self.dialog.addPage(T.i18n("Options"),T.i18n("Comma Separated Value Options"),"configure")
self.optionswidget = self.forms.createWidgetFromUIFile(optionspage, os.path.join(self.currentpath, "csvoptions.ui"))
if self.dialog.exec_loop():
try:
self.doExport()
except:
self.forms.showMessageBox("Error", T.i18n("Error"), "%s" % "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
示例11: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, scriptaction):
self.scriptaction = scriptaction
#self.currentpath = self.scriptaction.currentPath()
self.forms = Kross.module("forms")
self.dialog = self.forms.createDialog("Insert Shape")
self.dialog.minimumWidth = 500
self.dialog.minimumHeight = 360
self.dialog.setButtons("Ok|Cancel")
#self.dialog.setFaceType("List") #Auto Plain List Tree Tabbed
self.shapes = Words.shapeKeys()
page = self.dialog.addPage("", "")
widget = self.forms.createWidgetFromUI(page,
'<ui version="4.0" >'
' <class>Form</class>'
' <widget class="QWidget" name="Form" >'
' <layout class="QHBoxLayout" >'
' <item>'
' <widget class="QListWidget" name="List">'
' <property name="currentRow"><number>%i</number></property>'
' %s'
' </widget>'
' </item>'
' </layout>'
' </widget>'
'</ui>'
% ( 0, ''.join( [ '<item><property name="text" ><string>%s</string></property></item>' % s for s in self.shapes ] ) )
)
self.widgetlist = widget["List"]
if self.dialog.exec_loop():
self.doInsert()
示例12: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, scriptaction):
self.scriptaction = scriptaction
self.proj = Plan.project()
self.forms = Kross.module("forms")
self.dialog = self.forms.createDialog(T.i18n("Resources Import"))
self.dialog.setButtons("Ok|Cancel")
self.dialog.setFaceType("List") #Auto Plain List Tree Tabbed
#TODO add options page ( import Calendars? Select calendars, Select resources... )
openpage = self.dialog.addPage(T.i18n("Open"),T.i18n("Plan Resources"),"document-open")
self.openwidget = self.forms.createFileWidget(openpage, "kfiledialog:///kplatresourcesimportopen")
self.openwidget.setMode("Opening")
self.openwidget.setFilter("*.plan|%(1)s\n*|%(2)s" % { '1' : T.i18n("Plan"), '2' : T.i18n("All Files") } )
if self.dialog.exec_loop():
try:
Plan.beginCommand( T.i18nc( "(qtundo_format )", "Import resources" ) )
self.doImport( self.proj )
Plan.endCommand()
except:
Plan.revertCommand() # play safe in case parts where loaded
self.forms.showMessageBox("Error", T.i18n("Error"), "%s" % "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
示例13: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, scriptaction):
""" Some initial work like the import of the Kross and KSpread functionality
and test functions are added to demonstrate the usage. """
import os, sys
try:
import Kross
except:
raise "Failed to import the Kross module."
self.scriptaction = scriptaction
#self.currentpath = self.scriptaction.currentPath()
self.embeddedInKSpread = False
try:
import KSpread
self.kspread = KSpread
self.embeddedInKSpread = True
except ImportError:
try:
import Kross
self.kspread = Kross.module("kspread")
except ImportError:
raise "Failed to import the Sheets Kross module. Please run this script with \"kross thisscriptfile.py\""
self.addTestFunctions()
示例14: __init__
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def __init__(self, scriptaction):
self.scriptaction = scriptaction
self.currentpath = self.scriptaction.currentPath()
self.forms = Kross.module("forms")
try:
self.start()
except Exception, inst:
self.forms.showMessageBox("Sorry", T.i18n("Error"), "%s" % inst)
示例15: doImport
# 需要导入模块: import Kross [as 别名]
# 或者: from Kross import module [as 别名]
def doImport( self, project ):
filename = self.openwidget.selectedFile()
if not os.path.isfile(filename):
raise Exception, T.i18n("No file selected")
Tables = Kross.module("kspread")
if not Tables:
raise Exception, T.i18n("Could not start Calligra Sheets")
if not Tables.openUrl(filename):
self.forms.showMessageBox("Sorry", T.i18n("Error"), T.i18n("Could not open document: %1", [filename]))
return
def findParentTask(parent, wbs):
if wbs == project.data(parent, 'WBSCode'):
return parent
for i in range(parent.childCount()):
task = findParentTask(parent.childAt(i), wbs)
if task is not None:
return task
return None
def parentTask(wbs):
codes = wbs.split('.')
if len(codes) > 1:
codes.pop()
pwbs = '.'.join(codes)
for i in range(project.taskCount()):
parent = findParentTask(project.taskAt(i), pwbs)
if parent is not None:
return parent
return project
def createTask(properties, data):
if len(data) == 0:
return
task = project.createTask(parentTask(data[0]))
if task is None:
raise Exception, T.i18n("Failed to create task")
for i in range(1, len(properties)):
project.setData(task, properties[i], data[i])
# Get data into list that can be sorted after wbs code
reader = Tables.reader()
props = []
def changedRow(row):
if row == 1:
props.append(reader.currentValues())
else:
data = reader.currentValues()
# skip lines without wbs code
if data[0] is not None:
createTask(props[0], data)
reader.setSheet("Sheet1")
reader.connect("changedRow(int)", changedRow)
reader.start()