25The access2base.py module implements an interface between Python (user) scripts and the Access2Base Basic library.
28 from access2base
import *
29Additionally,
if Python
and LibreOffice are started
in separate processes:
30 If LibreOffice started
from console ... (example
for Linux)
31 ./soffice --accept=
'socket,host=localhost,port=2019;urp;'
32 then insert next statement
33 A2BConnect(hostname =
'localhost', port = 2019)
35Specific documentation about Access2Base
and Python:
36 http://www.access2base.com/access2base.html
42from platform import system as _opsys
43import datetime, os, sys, traceback
47_WRAPPERMODULE =
'Python'
50_vbGet, _vbLet, _vbMethod, _vbSet, _vbUNO = 2, 4, 1, 8, 16
55 A Singleton design pattern
56 Credits: « Python in a Nutshell » by Alex Martelli, O
'Reilly
67 VBA constants used in the Access2Base API.
68 Values derived
from MSAccess,
except when conflicts
74 Missing =
'+++MISSING+++'
75 FromIsoFormat =
'%Y-%m-%d %H:%M:%S'
93 acFormPropertySettings = -1
118 acDatabaseWindow = 102
124 docImpress =
"Impress"
160 vbAbortRetryIgnore = 2
168 vbDefaultButton1 = 128
169 vbDefaultButton2 = 256
170 vbDefaultButton3 = 512
171 vbApplicationModal = 0
243 acActiveDataObject = -1
247 acDataStoredProcedure = 9
258 acCmdAboutMicrosoftAccess = 35
259 acCmdAboutOpenOffice = 35
260 acCmdAboutLibreOffice = 35
261 acCmdVisualBasicEditor = 525
262 acCmdBringToFront = 52
264 acCmdToolbarsCustomize = 165
265 acCmdChangeToCommandButton = 501
266 acCmdChangeToCheckBox = 231
267 acCmdChangeToComboBox = 230
268 acCmdChangeToTextBox = 227
269 acCmdChangeToLabel = 228
270 acCmdChangeToImage = 234
271 acCmdChangeToListBox = 229
272 acCmdChangeToOptionButton = 233
275 acCmdCreateRelationship = 150
277 acCmdDatabaseProperties = 256
280 acCmdDesignView = 183
282 acCmdNewObjectForm = 136
283 acCmdNewObjectTable = 134
284 acCmdNewObjectView = 350
285 acCmdOpenDatabase = 25
286 acCmdNewObjectQuery = 135
287 acCmdShowAllRelationships = 149
288 acCmdNewObjectReport = 137
290 acCmdRemoveTable = 84
293 acCmdDeleteRecord = 223
294 acCmdApplyFilterSort = 93
297 acCmdInsertHyperlink = 259
298 acCmdMaximumRecords = 508
299 acCmdObjectBrowser = 200
301 acCmdPasteSpecial = 64
303 acCmdPrintPreview = 54
308 acCmdRemoveFilterSort = 144
312 acCmdSelectAllRecords = 109
314 acCmdSortDescending = 164
315 acCmdSortAscending = 163
317 acCmdDatasheetView = 282
318 acCmdZoomSelection = 371
341 acFormatPDF =
"writer_pdf_Export"
342 acFormatODT =
"writer8"
343 acFormatDOC =
"MS Word 97"
344 acFormatHTML =
"HTML"
345 acFormatODS =
"calc8"
346 acFormatXLS =
"MS Excel 97"
347 acFormatXLSX =
"Calc MS Excel 2007 XML"
348 acFormatTXT =
"Text - txt - csv (StarCalc)"
352 acExportQualityPrint = 0
353 acExportQualityScreen = 1
357 acSysCmdAccessDir = 9
358 acSysCmdAccessVer = 7
359 acSysCmdClearHelpTopic = 11
360 acSysCmdClearStatus = 5
361 acSysCmdGetObjectState = 10
362 acSysCmdGetWorkgroupFile = 13
364 acSysCmdInitMeter = 1
366 acSysCmdRemoveMeter = 3
368 acSysCmdSetStatus = 4
369 acSysCmdUpdateMeter = 2
401 dbHyperlinkField = 32768
403 dbUpdatableField = 32
408 dbOpenForwardOnly = 8
409 dbSQLPassThrough = 64
421 dbQSQLPassThrough = 1
433 msoBarTypeMenuBar = 1
435 msoBarTypeStatusBar = 11
436 msoBarTypeFloater = 12
447 if _opsys ==
'Windows':
return chr(13) + chr(10)
466COMPONENTCONTEXT, DESKTOP, SCRIPTPROVIDER, THISDATABASEDOCUMENT =
None,
None,
None,
None
470 Is the function to be set as new sys.excepthook to bypass the standard error handler
471 Derived
from https://stackoverflow.com/questions/31949760/how-to-limit-python-traceback-to-specific-files
472 Handler removes traces pointing to methods located
in access2base.py when error
is due to a user programming error
473 sys.excepthook = _ErrorHandler
477 def check_file(name):
478 return 'access2base.py' not in name
480 show = (fs
for fs
in traceback.extract_tb(tb)
if check_file(fs.filename))
481 fmt = traceback.format_list(show) + traceback.format_exception_only(type, value)
482 print(
''.join(fmt), end =
'', file = sys.stderr)
484 sys.excepthook = sys.__excepthook__
489 To be called explicitly by user scripts when Python process runs outside the LibreOffice process.
490 LibreOffice started as (Linux):
491 ./soffice --accept=
'socket,host=localhost,port=xxxx;urp;'
492 Otherwise called implicitly by the current module without arguments
493 Initializes COMPONENTCONTEXT, SCRIPTPROVIDER
and DESKTOP
494 :param hostname: probably
'localhost' or ''
495 :param port: port number
or 0
498 global XSCRIPTCONTEXT, COMPONENTCONTEXT, DESKTOP, SCRIPTPROVIDER
500 if len(hostname) > 0
and port > 0:
502 local_context = XSCRIPTCONTEXT.getComponentContext()
503 resolver = local_context.ServiceManager.createInstanceWithContext(
504 'com.sun.star.bridge.UnoUrlResolver', local_context)
506 conn =
'socket,host=%s,port=%d' % (hostname, port)
507 connection_url =
'uno:%s;urp;StarOffice.ComponentContext' % conn
508 established_context = resolver.resolve(connection_url)
510 raise ConnectionError(
'Connection to LibreOffice failed (host = ' + hostname +
', port = ' + str(port) +
')')
511 COMPONENTCONTEXT = established_context
513 elif len(hostname) == 0
and port == 0:
514 COMPONENTCONTEXT = XSCRIPTCONTEXT.getComponentContext()
515 DESKTOP = COMPONENTCONTEXT.ServiceManager.createInstanceWithContext(
'com.sun.star.frame.Desktop', COMPONENTCONTEXT)
517 raise SystemExit(
'The invocation of A2BConnect() has invalid arguments')
519 servicemanager = COMPONENTCONTEXT.ServiceManager
520 masterscript = servicemanager.createInstanceWithContext(
"com.sun.star.script.provider.MasterScriptProviderFactory", COMPONENTCONTEXT)
521 SCRIPTPROVIDER = masterscript.createScriptProvider(
"")
522 Script = _A2B.xScript(
'TraceLog',
'Trace')
523 Script.invoke((
'===>',
'Python wrapper loaded V.' + _VERSION,
False), (), ())
527class _A2B(object, metaclass = _Singleton):
529 Collection of helper functions implementing the protocol between Python and Basic
530 Read comments
in PythonWrapper Basic function
535 objs = {
'COLLECTION': _Collection
536 ,
'COMMANDBAR': _CommandBar
537 ,
'COMMANDBARCONTROL': _CommandBarControl
538 ,
'CONTROL': _Control
539 ,
'DATABASE': _Database
545 ,
'OPTIONGROUP': _OptionGroup
546 ,
'PROPERTY': _Property
547 ,
'QUERYDEF': _QueryDef
548 ,
'RECORDSET': _Recordset
549 ,
'SUBFORM': _SubForm
550 ,
'TABLEDEF': _TableDef
551 ,
'TEMPVAR': _TempVar
553 return objs[objectname]
558 At first call checks the existence of the Access2Base library
559 Initializes _LIBRARY with the found library name
560 First
and next calls execute the given script
in the given module of the _LIBRARY library
561 The script
and module are presumed to exist
562 :param script: name of script
563 :param module: name of module
564 :
return: the script object. NB: the execution
is done
with the invoke() method applied on the returned object
569 return 'vnd.sun.star.script:' + lib +
'.' + module +
'.' + script +
'?language=Basic&location=application'
572 for lib
in (
'Access2BaseDev',
'Access2Base'):
575 Script = SCRIPTPROVIDER.getScript(sScript(lib))
580 raise SystemExit(
'Access2Base basic library not found')
582 Script = SCRIPTPROVIDER.getScript(sScript(_LIBRARY))
588 Return the Access2Base error stack as a tuple
591 2 => short error message
592 3 => long error message
594 Script = cls.xScript('TraceErrorCode',
'Trace')
595 return Script.invoke((), (), ())[0]
600 Direct call to a named script/module pair with their arguments
601 If the arguments do
not match their definition at the Basic side, a TypeError
is raised
602 :param script: name of script
603 :param module: name of module
604 :param args: list of arguments to be passed to the script
605 :
return: the value returned by the script execution
608 Script = cls.
xScript(script, module)
610 Returned = Script.invoke((args), (), ())[0]
612 raise TypeError(
"Access2Base error: method '" + script +
"' in Basic module '" + module +
"' call error. Check its arguments.")
621 Call the Basic wrapper to invite it to execute the proposed action on a Basic object
622 If the arguments do not match their definition at the Basic side, a TypeError
is raised
623 After execution, a check
is done
if the execution has raised an error within Basic
624 If yes, a TypeError
is raised
625 :param action: Property Get, Property Let, Property Set, invoke Method
or return UNO object
626 :param basic: the reference of the Basic object, i.e. the index
in the array caching the addresses of the objects
627 conventionally Application = -1
and DoCmd = -2
628 :param script: the property
or method name
629 :param args: the arguments of the method,
if any
630 :
return: the value returned by the execution of the Basic routine
634 if basic == Application.basicmodule
and script ==
'Events':
635 Script = cls.
xScript(
'PythonEventsWrapper', _WRAPPERMODULE)
636 Returned = Script.invoke((args[0],), (), ())
638 Script = cls.
xScript(
'PythonWrapper', _WRAPPERMODULE)
639 NoArgs =
'+++NOARGS+++'
641 args = (action,) + (basic,) + (script,) + (NoArgs,)
643 args = (action,) + (basic,) + (script,) + args
645 Returned = Script.invoke((args), (), ())
647 raise TypeError(
"Access2Base error: method '" + script +
"' call error. Check its arguments.")
649 if isinstance(Returned[0], tuple):
651 if len(Returned[0])
in (3, 4):
652 if Returned[0][0] == 0:
653 return Returned[0][1]
654 elif Returned[0][0] == 1:
656 if len(Returned[0]) == 3:
657 return basicobject(Returned[0][1], Returned[0][2])
659 return basicobject(Returned[0][1], Returned[0][2], Returned[0][3])
660 elif Returned[0][0] == 2:
666 elif Returned[0] ==
None:
675 if errorstack[1]
in (
'ERROR',
'FATAL',
'ABORT'):
676 raise TypeError(
'Access2Base error: ' + errorstack[3])
681 """ Collection of methods located in the Application (Basic) module """
682 W = _A2B.invokeWrapper
687 return cls.
W(_vbMethod, cls.
basicmodule,
'AllDialogs', dialog)
690 return cls.
W(_vbMethod, cls.
basicmodule,
'AllForms', form)
693 return cls.
W(_vbMethod, cls.
basicmodule,
'AllModules', module)
696 return cls.
W(_vbMethod, cls.
basicmodule,
'CloseConnection')
699 return cls.
W(_vbMethod, cls.
basicmodule,
'CommandBars', bar)
707 def DAvg(cls, expression, domain, criteria = ''):
708 return cls.
W(_vbMethod, cls.
basicmodule,
'DAvg', expression, domain, criteria)
710 def DCount(cls, expression, domain, criteria = ''):
711 return cls.
W(_vbMethod, cls.
basicmodule,
'DCount', expression, domain, criteria)
713 def DLookup(cls, expression, domain, criteria = '', orderclause = ''):
714 return cls.
W(_vbMethod, cls.
basicmodule,
'DLookup', expression, domain, criteria, orderclause)
716 def DMax(cls, expression, domain, criteria = ''):
717 return cls.
W(_vbMethod, cls.
basicmodule,
'DMax', expression, domain, criteria)
719 def DMin(cls, expression, domain, criteria = ''):
720 return cls.
W(_vbMethod, cls.
basicmodule,
'DMin', expression, domain, criteria)
722 def DStDev(cls, expression, domain, criteria = ''):
723 return cls.
W(_vbMethod, cls.
basicmodule,
'DStDev', expression, domain, criteria)
725 def DStDevP(cls, expression, domain, criteria = ''):
726 return cls.
W(_vbMethod, cls.
basicmodule,
'DStDevP', expression, domain, criteria)
728 def DSum(cls, expression, domain, criteria = ''):
729 return cls.
W(_vbMethod, cls.
basicmodule,
'DSum', expression, domain, criteria)
731 def DVar(cls, expression, domain, criteria = ''):
732 return cls.
W(_vbMethod, cls.
basicmodule,
'DVar', expression, domain, criteria)
734 def DVarP(cls, expression, domain, criteria = ''):
735 return cls.
W(_vbMethod, cls.
basicmodule,
'DVarP', expression, domain, criteria)
738 return cls.
W(_vbMethod, cls.
basicmodule,
'Events', event)
740 def Forms(cls, form = acConstants.Missing):
744 return cls.
W(_vbMethod, cls.
basicmodule,
'getObject', shortcut)
745 GetObject = getObject
748 return cls.
W(_vbMethod, cls.
basicmodule,
'getValue', shortcut)
752 return cls.
W(_vbMethod, cls.
basicmodule,
'HtmlEncode', string, length)
755 global THISDATABASEDOCUMENT
758 THISDATABASEDOCUMENT = DESKTOP.getCurrentComponent()
759 return _A2B.invokeMethod(
'OpenConnection',
'Application', THISDATABASEDOCUMENT)
761 def OpenDatabase(cls, connectionstring, username = '', password = '', readonly = False):
762 return cls.
W(_vbMethod, cls.
basicmodule,
'OpenDatabase', connectionstring, username
763 , password, readonly)
769 return cls.
W(_vbMethod, cls.
basicmodule,
'setValue', shortcut, value)
772 def SysCmd(cls, action, text = '', value = -1):
773 return cls.
W(_vbMethod, cls.
basicmodule,
'SysCmd', action, text, value)
776 return cls.
W(_vbMethod, cls.
basicmodule,
'TempVars', var)
782class DoCmd(object, metaclass = _Singleton):
783 """ Collection of methods located in the DoCmd (Basic) module """
784 W = _A2B.invokeWrapper
788 def ApplyFilter(cls, filter = '', sqlwhere = '', controlname = ''):
789 return cls.
W(_vbMethod, cls.
basicmodule,
'ApplyFilter', filter, sqlwhere, controlname)
791 def Close(cls, objecttype, objectname, save = acConstants.acSavePrompt):
792 return cls.
W(_vbMethod, cls.
basicmodule,
'Close', objecttype, objectname, save)
794 def CopyObject(cls, sourcedatabase, newname, sourceobjecttype, sourceobjectname):
795 return cls.
W(_vbMethod, cls.
basicmodule,
'CopyObject', sourcedatabase, newname, sourceobjecttype
801 def FindRecord(cls, findwhat, match = acConstants.acEntire, matchcase = False, search = acConstants.acSearchAll
802 , searchasformatted = False, onlycurrentfield = acConstants.acCurrent, findfirst = True):
803 return cls.
W(_vbMethod, cls.
basicmodule,
'FindRecord', findwhat, match, matchcase, search
804 , searchasformatted, onlycurrentfield, findfirst)
807 return cls.
W(_vbMethod, cls.
basicmodule,
'GetHiddenAttribute', objecttype, objectname)
810 return cls.
W(_vbMethod, cls.
basicmodule,
'GoToControl', controlname)
812 def GoToRecord(cls, objecttype = acConstants.acActiveDataObject, objectname = '', record = acConstants.acNext
814 return cls.
W(_vbMethod, cls.
basicmodule,
'GoToRecord', objecttype, objectname, record, offset)
822 def MoveSize(cls, left = -1, top = -1, width = -1, height = -1):
823 return cls.
W(_vbMethod, cls.
basicmodule,
'MoveSize', left, top, width, height)
825 def OpenForm(cls, formname, view = acConstants.acNormal, filter = '', wherecondition = ''
826 , datamode = acConstants.acFormEdit, windowmode = acConstants.acWindowNormal, openargs = ''):
827 return cls.
W(_vbMethod, cls.
basicmodule,
'OpenForm', formname, view, filter, wherecondition
828 , datamode, windowmode, openargs)
830 def OpenQuery(cls, queryname, view = acConstants.acNormal, datamode = acConstants.acEdit):
831 return cls.
W(_vbMethod, cls.
basicmodule,
'OpenQuery', queryname, view, datamode)
834 return cls.
W(_vbMethod, cls.
basicmodule,
'OpenReport', queryname, view)
837 return cls.
W(_vbMethod, cls.
basicmodule,
'OpenSQL', sql, option)
839 def OpenTable(cls, tablename, view = acConstants.acNormal, datamode = acConstants.acEdit):
840 return cls.
W(_vbMethod, cls.
basicmodule,
'OpenTable', tablename, view, datamode)
842 def OutputTo(cls, objecttype, objectname = '', outputformat = '', outputfile = '', autostart = False, templatefile = ''
843 , encoding = acConstants.acUTF8Encoding, quality = acConstants.acExportQualityPrint):
844 if objecttype == acConstants.acOutputForm: encoding = 0
845 return cls.
W(_vbMethod, cls.
basicmodule,
'OutputTo', objecttype, objectname, outputformat
846 , outputfile, autostart, templatefile, encoding, quality)
852 return cls.
W(_vbMethod, cls.
basicmodule,
'RunApp', commandline)
855 return cls.
W(_vbMethod, cls.
basicmodule,
'RunCommand', command)
858 return cls.
W(_vbMethod, cls.
basicmodule,
'RunSQL', SQL, option)
860 def SelectObject(cls, objecttype, objectname = '', indatabasewindow = False):
861 return cls.
W(_vbMethod, cls.
basicmodule,
'SelectObject', objecttype, objectname, indatabasewindow)
863 def SendObject(cls, objecttype = acConstants.acSendNoObject, objectname = '', outputformat = '', to = '', cc = ''
864 , bcc = '', subject = '', messagetext = '', editmessage = True, templatefile = ''):
865 return cls.
W(_vbMethod, cls.
basicmodule,
'SendObject', objecttype, objectname, outputformat, to, cc
866 , bcc, subject, messagetext, editmessage, templatefile)
869 return cls.
W(_vbMethod, cls.
basicmodule,
'SetHiddenAttribute', objecttype, objectname, hidden)
872 return cls.
W(_vbMethod, cls.
basicmodule,
'SetOrderBy', orderby, controlname)
875 return cls.
W(_vbMethod, cls.
basicmodule,
'ShowAllRecords')
878class Basic(object, metaclass = _Singleton):
879 """ Collection of helper functions having the same behaviour as their Basic counterparts """
880 M = _A2B.invokeMethod
884 return cls.
M(
'PyConvertFromUrl', _WRAPPERMODULE, url)
888 return cls.
M(
'PyConvertToUrl', _WRAPPERMODULE, file)
892 return cls.
M(
'PyCreateUnoService', _WRAPPERMODULE, servicename)
896 if isinstance(datearg, datetime.datetime): datearg = datearg.isoformat()
897 dateadd = cls.
M(
'PyDateAdd', _WRAPPERMODULE, add, count, datearg)
898 return datetime.datetime.strptime(dateadd, acConstants.FromIsoFormat)
901 def DateDiff(cls, add, date1, date2, weekstart = 1, yearstart = 1):
902 if isinstance(date1, datetime.datetime): date1 = date1.isoformat()
903 if isinstance(date2, datetime.datetime): date2 = date2.isoformat()
904 return cls.
M(
'PyDateDiff', _WRAPPERMODULE, add, date1, date2, weekstart, yearstart)
907 def DatePart(cls, add, datearg, weekstart = 1, yearstart = 1):
908 if isinstance(datearg, datetime.datetime): datearg = datearg.isoformat()
909 return cls.
M(
'PyDatePart', _WRAPPERMODULE, add, datearg, weekstart, yearstart)
913 datevalue = cls.
M(
'PyDateValue', _WRAPPERMODULE, datestring)
914 return datetime.datetime.strptime(datevalue, acConstants.FromIsoFormat)
918 if isinstance(value, (datetime.datetime, datetime.date, datetime.time, )):
919 value = value.isoformat()
920 return cls.
M(
'PyFormat', _WRAPPERMODULE, value, format)
924 return cls.
M(
'PyGetGUIType', _WRAPPERMODULE)
932 return cls.
M(
'PyGetSystemTicks', _WRAPPERMODULE)
935 def MsgBox(cls, text, type = None, dialogtitle = None):
936 return cls.
M(
'PyMsgBox', _WRAPPERMODULE, text, type, dialogtitle)
941 return Basic.M(
'PyGlobalScope', _WRAPPERMODULE,
'Basic')
944 return Basic.M(
'PyGlobalScope', _WRAPPERMODULE,
'Dialog')
947 def InputBox(cls, text, title = None, default = None, xpos = None, ypos = None):
948 return cls.
M(
'PyInputBox', _WRAPPERMODULE, text, title, default, xpos, ypos)
952 return datetime.datetime.now()
955 def RGB(red, green, blue):
956 return int(
'%02x%02x%02x' % (red, green, blue), 16)
960 return cls.
M(
'PyTimer', _WRAPPERMODULE)
964 xrayscript =
'vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application'
965 xScript = SCRIPTPROVIDER.getScript(xrayscript)
966 xScript.invoke((myObject,), (), ())
972 Parent class of
Basic objects
973 Each subclass
is identified by its classProperties:
974 dictionary
with keys = allowed properties, value =
True if editable
or False
975 Each instance
is identified by its
976 - reference
in the cache managed by Basic
977 - type (
'DATABASE',
'COLLECTION', ...)
978 - name (form, control, ... name) - may be blank
979 Properties are got
and set following next strategy:
980 1. Property names are controlled strictly (
'Value' and not 'value')
981 2. Getting a property value
for the first time
is always done via a Basic call
982 3. Next occurrences are fetched
from the Python dictionary of the instance
if the property
is read-only, otherwise via a Basic call
983 4. Methods output might force the deletion of a property
from the dictionary (
'MoveNext' changes
'BOF' and 'EOF' properties)
984 5. Setting a property value
is done via a Basic call,
except if self.
internal ==
True
986 W = _A2B.invokeWrapper
987 internal_attributes = ('objectreference',
'objecttype',
'name',
'internal')
989 def __init__(self, reference = -1, objtype = None, name = ''):
997 if name
in (
'classProperties',
'localProperties'):
999 elif name
in self.classProperties:
1003 return super(_BasicObject, self).__getattribute__(name)
1006 if name
in (
'classProperties',
'localProperties'):
1008 elif name
in self.classProperties:
1011 elif self.classProperties[name] ==
True:
1014 raise AttributeError(
"type object '" + self.
objecttype +
"' has no editable attribute '" + name +
"'")
1018 raise AttributeError(
"type object '" + self.
objecttype +
"' has no attribute '" + name +
"'")
1019 object.__setattr__(self, name, value)
1024 if len(self.
name) > 0: repr +=
", name='" + self.
name +
"'"
1027 def _Reset(self, propertyname, basicreturn = None):
1028 """ force new value or erase properties from dictionary (done to optimize calls to Basic scripts) """
1029 if propertyname
in (
'BOF',
'EOF'):
1031 if isinstance(basicreturn, int):
1034 self.
BOF = basicreturn
in (2, 3, -2, -3)
1035 self.
EOF = basicreturn
in (1, 3, -1, -3)
1037 return ( basicreturn >= 0 )
1040 if property
in self.__dict__:
1041 del(self.propertyname)
1052 return self.
W(_vbMethod, self.
objectreference,
'getProperty', propertyname, index)
1053 GetProperty = getProperty
1055 return propertyname
in tuple(self.classProperties.keys())
1056 HasProperty = hasProperty
1059 def setProperty(self, propertyname, value, index = acConstants.Missing):
1061 if self.
W(_vbMethod, self.
objectreference,
'setProperty', propertyname, value, index):
1063 raise AttributeError(
"type object '" + self.
objecttype +
"' has no editable attribute '" + propertyname +
"'")
1064 SetProperty = setProperty
1068 """ Collection object built as a Python iterator """
1069 classProperties = dict(Count =
False)
1071 super().
__init__(reference, objtype)
1087 def Add(self, table, value = acConstants.Missing):
1088 if isinstance(table, _BasicObject):
1089 return self.
W(_vbMethod, self.
objectreference,
'Add', table.objectreference)
1092 self.
count = self.Count
1100 self.
count = self.Count
1104 self.
count = self.Count
1109 classProperties = dict(BuiltIn =
False, Parent =
False, Visible =
True)
1112 return self.
W(_vbMethod, self.
objectreference,
'CommandBarControls', index)
1118 classProperties = dict(BeginGroup =
False, BuiltIn =
False, Caption =
True, Index =
False, OnAction =
True
1119 , Parent =
False, TooltipText =
True, Type =
False, Visible =
True)
1126 classProperties = dict(BackColor =
True, BorderColor =
True, BorderStyle =
True, Cancel =
True, Caption =
True
1127 , ControlSource =
False, ControlTipText =
True, ControlType =
False, Default =
True
1128 , DefaultValue =
True, Enabled =
True, FontBold =
True, FontItalic =
True, FontName =
True
1129 , FontSize =
True, FontUnderline =
True, FontWeight =
True, ForeColor =
True, Form =
False
1130 , Format =
True, ItemData =
False, ListCount =
False, ListIndex =
True, Locked =
True, MultiSelect =
True
1131 , OnActionPerformed =
True, OnAdjustmentValueChanged =
True, OnApproveAction =
True
1132 , OnApproveReset =
True, OnApproveUpdate =
True, OnChanged =
True, OnErrorOccurred =
True
1133 , OnFocusGained =
True, OnFocusLost =
True, OnItemStateChanged =
True, OnKeyPressed =
True
1134 , OnKeyReleased =
True, OnMouseDragged =
True, OnMouseEntered =
True, OnMouseExited =
True
1135 , OnMouseMoved =
True, OnMousePressed =
True, OnMouseReleased =
True, OnResetted =
True, OnTextChanged =
True
1136 , OnUpdated =
True, OptionValue =
False, Page =
False, Parent =
False, Picture =
True, Required =
True
1137 , RowSource =
True, RowSourceType =
True, Selected =
True, SelLength =
True, SelStart =
True, SelText =
True
1138 , SubType =
False, TabIndex =
True, TabStop =
True, Tag =
True, Text =
False, TextAlign =
True
1139 , TripleState =
True, Value =
True, Visible =
True
1152 basicreturn = self.
W(_vbMethod, self.
objectreference,
'AddItem', value, index)
1160 return self.
W(_vbMethod, self.
objectreference,
'hasProperty', propertyname)
1161 HasProperty = hasProperty
1170 return self.
W(_vbMethod, self.
objectreference,
'SetSelected', value, index)
1176 classProperties = dict(Connect =
False, OnCreate =
True
1177 , OnFocus =
True, OnLoad =
True, OnLoadFinished =
True, OnModifyChanged =
True, OnNew =
True
1178 , OnPrepareUnload =
True, OnPrepareViewClosing =
True, OnSave =
True, OnSaveAs =
True
1179 , OnSaveAsDone =
True, OnSaveAsFailed =
True, OnSaveDone =
True, OnSaveFailed =
True
1180 , OnSubComponentClosed =
True, OnSubComponentOpened =
True, OnTitleChanged =
True, OnUnfocus =
True
1181 , OnUnload =
True, OnViewClosed =
True, OnViewCreated =
True, Version =
False
1196 return self.
W(_vbMethod, self.
objectreference,
'CreateQueryDef', name, sqltext, option)
1199 def DAvg(self, expression, domain, criteria = ''):
1200 return self.
W(_vbMethod, self.
objectreference,
'DAvg', expression, domain, criteria)
1201 def DCount(self, expression, domain, criteria = ''):
1202 return self.
W(_vbMethod, self.
objectreference,
'DCount', expression, domain, criteria)
1203 def DLookup(self, expression, domain, criteria = '', orderclause = ''):
1204 return self.
W(_vbMethod, self.
objectreference,
'DLookup', expression, domain, criteria, orderclause)
1205 def DMax(self, expression, domain, criteria = ''):
1206 return self.
W(_vbMethod, self.
objectreference,
'DMax', expression, domain, criteria)
1207 def DMin(self, expression, domain, criteria = ''):
1208 return self.
W(_vbMethod, self.
objectreference,
'DMin', expression, domain, criteria)
1209 def DStDev(self, expression, domain, criteria = ''):
1210 return self.
W(_vbMethod, self.
objectreference,
'DStDev', expression, domain, criteria)
1211 def DStDevP(self, expression, domain, criteria = ''):
1212 return self.
W(_vbMethod, self.
objectreference,
'DStDevP', expression, domain, criteria)
1213 def DVar(self, expression, domain, criteria = ''):
1214 return self.
W(_vbMethod, self.
objectreference,
'DVar', expression, domain, criteria)
1215 def DVarP(self, expression, domain, criteria = ''):
1216 return self.
W(_vbMethod, self.
objectreference,
'DVarP', expression, domain, criteria)
1218 return self.
W(_vbMethod, self.
objectreference,
'OpenRecordset', source, type, option, lockedit)
1221 def OutputTo(self, objecttype, objectname = '', outputformat = '', outputfile = '', autostart = False, templatefile = ''
1222 , encoding = acConstants.acUTF8Encoding, quality = acConstants.acExportQualityPrint):
1223 if objecttype == acConstants.acOutputForm: encoding = 0
1224 return self.
W(_vbMethod, self.
objectreference,
'OutputTo', objecttype, objectname, outputformat, outputfile
1225 , autostart, templatefile, encoding, quality)
1237 classProperties = dict(Caption =
True, Height =
True, IsLoaded =
False, OnFocusGained =
True
1238 , OnFocusLost =
True, OnKeyPressed =
True, OnKeyReleased =
True, OnMouseDragged =
True
1239 , OnMouseEntered =
True, OnMouseExited =
True, OnMouseMoved =
True, OnMousePressed =
True
1240 , OnMouseReleased =
True, Page =
True, Parent =
False, Visible =
True, Width =
True
1250 def Move(self, left = -1, top = -1, width = -1, height = -1):
1251 return self.
W(_vbMethod, self.
objectreference,
'Move', left, top, width, height)
1260 classProperties = dict(ButtonLeft =
False, ButtonMiddle =
False, ButtonRight =
False, ClickCount =
False
1261 , ContextShortcut =
False, EventName =
False, EventType =
False, FocusChangeTemporary =
False
1262 , KeyAlt =
False, KeyChar =
False, KeyCode =
False, KeyCtrl =
False, KeyFunction =
False, KeyShift =
False
1263 , Recommendation =
False, RowChangeAction =
False, Source =
False, SubComponentName =
False
1264 , SubComponentType =
False, XPos =
False, YPos =
False
1269 classProperties = dict(DataType =
False, DataUpdatable =
False, DbType =
False, DefaultValue =
True
1270 , Description =
True, FieldSize =
False, Size =
False, Source =
False
1271 , SourceField =
False, SourceTable =
False, TypeName =
False, Value =
True
1280 return self.
W(_vbMethod, self.
objectreference,
'GetChunk', offset, numbytes)
1292 classProperties = dict(AllowAdditions =
True, AllowDeletions =
True, AllowEdits =
True, Bookmark =
True
1293 , Caption =
True, CurrentRecord =
True, Filter =
True, FilterOn =
True, Height =
True
1294 , IsLoaded =
False, OnApproveCursorMove =
True, OnApproveParameter =
True, OnApproveReset =
True
1295 , OnApproveRowChange =
True, OnApproveSubmit =
True, OnConfirmDelete =
True, OnCursorMoved =
True
1296 , OnErrorOccurred =
True, OnLoaded =
True, OnReloaded =
True, OnReloading =
True, OnResetted =
True
1297 , OnRowChanged =
True, OnUnloaded =
True, OnUnloading =
True, OpenArgs =
False, OrderBy =
True
1298 , OrderByOn =
True, Parent =
False, Recordset =
False, RecordSource =
True, Visible =
True
1313 def Move(self, left = -1, top = -1, width = -1, height = -1):
1314 return self.
W(_vbMethod, self.
objectreference,
'Move', left, top, width, height)
1326 classProperties = dict(CountOfDeclarationLines =
False, CountOfLines =
False, Type =
False)
1328 def __init__(self, reference = -1, objtype = None, name = ''):
1329 super().
__init__(reference, objtype, name)
1332 def Find(self, target, startline, startcolumn, endline, endcolumn, wholeword = False
1333 , matchcase = False, patternsearch = False):
1334 Returned = self.
W(_vbMethod, self.
objectreference,
'Find', target, startline, startcolumn, endline
1335 , endcolumn, wholeword, matchcase, patternsearch)
1336 if isinstance(Returned, tuple):
1337 if Returned[0] ==
True and len(Returned) == 5:
1347 return self.
W(_vbMethod, self.
objectreference,
'ProcBodyLine', procname, prockind)
1349 return self.
W(_vbMethod, self.
objectreference,
'ProcCountLines', procname, prockind)
1351 Returned = self.
W(_vbMethod, self.
objectreference,
'ProcOfLine', line, prockind)
1352 if isinstance(Returned, tuple):
1353 if len(Returned) == 2:
1358 return self.
W(_vbMethod, self.
objectreference,
'ProcStartLine', procname, prockind)
1362 classProperties = dict(Count =
False, Value =
True)
1369 classProperties = dict(Value =
True)
1373 classProperties = dict(SQL =
True, Type =
False)
1380 def Fields(self, index = acConstants.Missing):
1383 return self.
W(_vbMethod, self.
objectreference,
'OpenRecordset', type, option, lockedit)
1387 classProperties = dict(AbsolutePosition =
True, BOF =
False, Bookmark =
True, Bookmarkable =
False
1388 , EditMode =
False, EOF =
False, Filter =
True, RecordCount =
False
1406 def Fields(self, index = acConstants.Missing):
1410 def Move(self, rows, startbookmark = acConstants.Missing):
1421 return self.
W(_vbMethod, self.
objectreference,
'OpenRecordset', type, option, lockedit)
1427 classProperties = dict(AllowAdditions =
True, AllowDeletions =
True, AllowEdits =
True, CurrentRecord =
True
1428 , Filter =
True, FilterOn =
True, LinkChildFields =
False, LinkMasterFields =
False
1429 , OnApproveCursorMove =
True, OnApproveParameter =
True, OnApproveReset =
True
1430 , OnApproveRowChange =
True, OnApproveSubmit =
True, OnConfirmDelete =
True, OnCursorMoved =
True
1431 , OnErrorOccurred =
True, OnLoaded =
True, OnReloaded =
True, OnReloading =
True, OnResetted =
True
1432 , OnRowChanged =
True, OnUnloaded =
True, OnUnloading =
True, OrderBy =
True
1433 , OrderByOn =
True, Parent =
False, Recordset =
False, RecordSource =
True, Visible =
True
1437 raise AttributeError(
"type object 'SubForm' has no method 'SetFocus'")
1441 classProperties = dict()
1447 return self.
W(_vbMethod, self.
objectreference,
'CreateField', name, type, size, attributes)
1448 def Fields(self, index = acConstants.Missing):
1451 return self.
W(_vbMethod, self.
objectreference,
'OpenRecordset', type, option, lockedit)
1455 classProperties = dict(Value =
True)
1458Set of directly callable error handling methods
1463 if isinstance(arg, _BasicObject):
1464 arg = (
'[' + arg.objecttype +
'] ' + arg.name).rstrip()
1465 dargs = dargs + (arg,)
1466 return _A2B.invokeMethod(
'DebugPrint', _WRAPPERMODULE, *dargs)
1469 return _A2B.invokeMethod(
'TraceError',
'Trace', tracelevel, errorcode, errorprocedure, errorline)
1470def TraceLevel(newtracelevel = 'ERROR'):
return _A2B.invokeMethod(
'TraceLevel',
'Trace', newtracelevel)
1472 return _A2B.invokeMethod(
'TraceLog',
'Trace', tracelevel, text, messagebox)
def DVar(cls, expression, domain, criteria='')
def AllModules(cls, module=acConstants.Missing)
def TempVars(cls, var=acConstants.Missing)
def DSum(cls, expression, domain, criteria='')
def getValue(cls, shortcut)
def DCount(cls, expression, domain, criteria='')
def DMax(cls, expression, domain, criteria='')
def OpenDatabase(cls, connectionstring, username='', password='', readonly=False)
def OpenConnection(cls, thisdatabasedocument=acConstants.Missing)
def AllForms(cls, form=acConstants.Missing)
def Forms(cls, form=acConstants.Missing)
def DLookup(cls, expression, domain, criteria='', orderclause='')
def DAvg(cls, expression, domain, criteria='')
def DStDev(cls, expression, domain, criteria='')
def DMin(cls, expression, domain, criteria='')
def DStDevP(cls, expression, domain, criteria='')
def CommandBars(cls, bar=acConstants.Missing)
def DVarP(cls, expression, domain, criteria='')
def setValue(cls, shortcut, value)
def SysCmd(cls, action, text='', value=-1)
def getObject(cls, shortcut)
def HtmlEncode(cls, string, length=0)
def AllDialogs(cls, dialog=acConstants.Missing)
def DialogLibraries(self)
def MsgBox(cls, text, type=None, dialogtitle=None)
def DateValue(cls, datestring)
def RGB(red, green, blue)
def Format(cls, value, format=None)
def DateDiff(cls, add, date1, date2, weekstart=1, yearstart=1)
def DateAdd(cls, add, count, datearg)
def ConvertFromUrl(cls, url)
def ConvertToUrl(cls, file)
def InputBox(cls, text, title=None, default=None, xpos=None, ypos=None)
def DatePart(cls, add, datearg, weekstart=1, yearstart=1)
def CreateUnoService(cls, servicename)
def OutputTo(cls, objecttype, objectname='', outputformat='', outputfile='', autostart=False, templatefile='', encoding=acConstants.acUTF8Encoding, quality=acConstants.acExportQualityPrint)
def OpenSQL(cls, sql, option=-1)
def OpenForm(cls, formname, view=acConstants.acNormal, filter='', wherecondition='', datamode=acConstants.acFormEdit, windowmode=acConstants.acWindowNormal, openargs='')
def RunSQL(cls, SQL, option=-1)
def GetHiddenAttribute(cls, objecttype, objectname='')
def ApplyFilter(cls, filter='', sqlwhere='', controlname='')
def OpenTable(cls, tablename, view=acConstants.acNormal, datamode=acConstants.acEdit)
def OpenQuery(cls, queryname, view=acConstants.acNormal, datamode=acConstants.acEdit)
def RunApp(cls, commandline)
def GoToRecord(cls, objecttype=acConstants.acActiveDataObject, objectname='', record=acConstants.acNext, offset=1)
def SendObject(cls, objecttype=acConstants.acSendNoObject, objectname='', outputformat='', to='', cc='', bcc='', subject='', messagetext='', editmessage=True, templatefile='')
def OpenReport(cls, queryname, view=acConstants.acNormal)
def SetOrderBy(cls, orderby='', controlname='')
def SelectObject(cls, objecttype, objectname='', indatabasewindow=False)
def RunCommand(cls, command)
def Close(cls, objecttype, objectname, save=acConstants.acSavePrompt)
def SetHiddenAttribute(cls, objecttype, objectname='', hidden=True)
def GoToControl(cls, controlname)
def MoveSize(cls, left=-1, top=-1, width=-1, height=-1)
def FindRecord(cls, findwhat, match=acConstants.acEntire, matchcase=False, search=acConstants.acSearchAll, searchasformatted=False, onlycurrentfield=acConstants.acCurrent, findfirst=True)
def CopyObject(cls, sourcedatabase, newname, sourceobjecttype, sourceobjectname)
def invokeWrapper(cls, action, basic, script, *args)
def xScript(cls, script, module)
def invokeMethod(cls, script, module, *args)
def BasicObject(cls, objectname)
def Properties(self, index=acConstants.Missing)
def getProperty(self, propertyname, index=acConstants.Missing)
tuple internal_attributes
def __getattr__(self, name)
def setProperty(self, propertyname, value, index=acConstants.Missing)
def hasProperty(self, propertyname)
def __init__(self, reference=-1, objtype=None, name='')
def _Reset(self, propertyname, basicreturn=None)
def __setattr__(self, name, value)
def Add(self, table, value=acConstants.Missing)
def __init__(self, reference=-1, objtype=None)
def Remove(self, tempvarname)
def CommandBarControls(self, index=acConstants.Missing)
def RemoveItem(self, index)
def AddItem(self, value, index=-1)
def SetSelected(self, value, index)
def Controls(self, index=acConstants.Missing)
def hasProperty(self, propertyname)
def DMin(self, expression, domain, criteria='')
def Recordsets(self, index=acConstants.Missing)
def DMax(self, expression, domain, criteria='')
def OpenSQL(self, SQL, option=-1)
def DStDev(self, expression, domain, criteria='')
def TableDefs(self, index=acConstants.Missing)
def DVar(self, expression, domain, criteria='')
def DAvg(self, expression, domain, criteria='')
def DCount(self, expression, domain, criteria='')
def CreateQueryDef(self, name, sqltext, option=-1)
def QueryDefs(self, index=acConstants.Missing)
def OpenRecordset(self, source, type=-1, option=-1, lockedit=-1)
def DVarP(self, expression, domain, criteria='')
def CreateTableDef(self, name)
def CloseAllRecordsets(self)
def RunSQL(self, SQL, option=-1)
def OutputTo(self, objecttype, objectname='', outputformat='', outputfile='', autostart=False, templatefile='', encoding=acConstants.acUTF8Encoding, quality=acConstants.acExportQualityPrint)
def DStDevP(self, expression, domain, criteria='')
def DLookup(self, expression, domain, criteria='', orderclause='')
def Move(self, left=-1, top=-1, width=-1, height=-1)
def EndExecute(self, returnvalue)
def OptionGroup(self, groupname)
def ReadAllText(self, file)
def GetChunk(self, offset, numbytes)
def AppendChunk(self, value)
def WriteAllText(self, file)
def ReadAllBytes(self, file)
def WriteAllBytes(self, file)
def Find(self, target, startline, startcolumn, endline, endcolumn, wholeword=False, matchcase=False, patternsearch=False)
def ProcCountLines(self, procname, prockind)
def Lines(self, line, numlines)
def ProcBodyLine(self, procname, prockind)
def ProcOfLine(self, line, prockind)
def __init__(self, reference=-1, objtype=None, name='')
def ProcStartLine(self, procname, prockind)
def Controls(self, index=acConstants.Missing)
def Execute(self, options=acConstants.Missing)
def Fields(self, index=acConstants.Missing)
def OpenRecordset(self, type=-1, option=-1, lockedit=-1)
def Move(self, rows, startbookmark=acConstants.Missing)
def GetRows(self, numrows)
def Fields(self, index=acConstants.Missing)
def OpenRecordset(self, type=-1, option=-1, lockedit=-1)
def __call__(cls, *args, **kwargs)
def CreateField(self, name, type, size=0, attributes=0)
def Fields(self, index=acConstants.Missing)
def OpenRecordset(self, type=-1, option=-1, lockedit=-1)
def TraceError(tracelevel, errorcode, errorprocedure, errorline)
def _ErrorHandler(type, value, tb)
def A2BConnect(hostname='', port=0)
def TraceLevel(newtracelevel='ERROR')
def TraceLog(tracelevel, text, messagebox=True)