Add shape
This commit is contained in:
parent
2676ccc29b
commit
70e1933537
|
@ -0,0 +1,601 @@
|
||||||
|
|
||||||
|
## Trabajar con celdas y rangos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **address**
|
||||||
|
|
||||||
|
Referencia por dirección.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
rango = hoja['C10:D15']
|
||||||
|
|
||||||
|
app.debug(celda)
|
||||||
|
app.debug(rango)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **doc**
|
||||||
|
|
||||||
|
Devuelve el documento padre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
rango = hoja['A1:C5']
|
||||||
|
|
||||||
|
doc = rango.doc
|
||||||
|
app.debug(doc)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **in**
|
||||||
|
|
||||||
|
Verificar si un rango esta dentro de otro.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['C5']
|
||||||
|
rango = hoja['A1:E10']
|
||||||
|
|
||||||
|
resultado = celda in rango
|
||||||
|
app.debug(resultado)
|
||||||
|
|
||||||
|
celda = hoja['C50']
|
||||||
|
resultado = celda in rango
|
||||||
|
app.debug(resultado)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **iter**
|
||||||
|
|
||||||
|
Iterar cada celda de un rango.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
rango = hoja['B10:C15']
|
||||||
|
|
||||||
|
for celda in rango:
|
||||||
|
app.debug(celda)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **position**
|
||||||
|
|
||||||
|
Referencia por posición.
|
||||||
|
|
||||||
|
Para celdas: `HOJA[fila,columna]`
|
||||||
|
|
||||||
|
Para rangos: `HOJA[fila_inicial:fila_final, columna_inicial:columna_final]`
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
# ~ Cell A10
|
||||||
|
celda = hoja[9,0]
|
||||||
|
|
||||||
|
# ~ Range A1:C10
|
||||||
|
rango = hoja[0:10,0:3]
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! tip "Atención"
|
||||||
|
|
||||||
|
Recuerde que las filas y columnas empiezan en cero, por lo que `fila_final` y la `columna_final` deben de ser la fila y columna deseada más 1.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **selection**
|
||||||
|
|
||||||
|
Referencia por selección actual.
|
||||||
|
|
||||||
|
```py
|
||||||
|
seleccion = app.active.selection
|
||||||
|
app.debug(seleccion)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! tip "Atención"
|
||||||
|
|
||||||
|
Recuerde que la selección actual pueden ser varias cosas diferentes.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Propiedades
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **address**
|
||||||
|
|
||||||
|
Devuelve la dirección de la celda como una estructura: `com.sun.star.table.CellAddress`
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
if celda.is_cell:
|
||||||
|
app.debug(celda.address)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **back_color**
|
||||||
|
|
||||||
|
Devuelve o aplica el color de fondo del rango.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
rango = hoja['A1:E10']
|
||||||
|
rango.back_color = 'red'
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **current_region**
|
||||||
|
|
||||||
|
Devuelve la región actual.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
rango = celda.current_region
|
||||||
|
app.debug(rango)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **data**
|
||||||
|
|
||||||
|
Alias de `data_array` al obtener los datos. Al establecer los datos, si es un rango se comporta como `data_array`, pero si es una celda, se autoajusta al tamaño de los datos.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
datos = (
|
||||||
|
(1, 'Uno'),
|
||||||
|
(2, 'Dos'),
|
||||||
|
(3, 'Tres'),
|
||||||
|
)
|
||||||
|
|
||||||
|
celda.data = datos
|
||||||
|
app.debug(celda.current_region.data)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning "Cuidado"
|
||||||
|
|
||||||
|
Siempre valide que haya suficientes celdas libres para los datos para evitar sobreescribirlos.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **data_array**
|
||||||
|
|
||||||
|
Devuelve o establece los datos de un rango. Es un alias de `DataArray`.
|
||||||
|
|
||||||
|
```py
|
||||||
|
rango = app.active.selection
|
||||||
|
|
||||||
|
datos = rango.data_array
|
||||||
|
app.debug(datos)
|
||||||
|
rango.data_array = datos
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning "Cuidado"
|
||||||
|
|
||||||
|
El tamaño de los datos, debe ser **exactamente** del tamaño del rango destino. De lo contrario obtendrá un error.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **date**
|
||||||
|
|
||||||
|
Devuelve o establece el contenido de la celda como fecha.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.date = app.dates.date(1974, 1, 15)
|
||||||
|
app.debug(type(celda.date), celda.date)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
20/08/2022 18:38:53 - DEBUG - <class 'datetime.date'> 1974-01-15
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **datetime**
|
||||||
|
|
||||||
|
Devuelve o establece el contenido de la celda como fecha y tiempo.
|
||||||
|
|
||||||
|
```python
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.datetime = app.dates.datetime(1974, 1, 15, 10, 11, 12)
|
||||||
|
app.debug(type(celda.datetime), celda.datetime)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **dict**
|
||||||
|
|
||||||
|
Devuelve o establece los datos como diccionarios. Automáticamente ajusta el rango al tamaño de los datos.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
|
||||||
|
datos = (
|
||||||
|
{'No': 1, 'Nombre': 'Ingrid'},
|
||||||
|
{'No': 2, 'Nombre': 'Sophia'},
|
||||||
|
{'No': 3, 'Nombre': 'Scarlette'},
|
||||||
|
)
|
||||||
|
|
||||||
|
celda.dict = datos
|
||||||
|
app.debug(celda.current_region.dict)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning "Consejo"
|
||||||
|
|
||||||
|
Siempre valide que haya suficientes celdas libres para los datos para evitar sobreescribirlos, a menos que eso sea lo que realmente quiera.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **error**
|
||||||
|
|
||||||
|
Si la celda tiene una formula con error, devuelve el número de error.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.value = '=RAND()/0'
|
||||||
|
app.debug(celda.error)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **float**
|
||||||
|
|
||||||
|
Devuelve o establece el contenido de la celda como valor.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.float = 12345
|
||||||
|
app.debug(celda.type, celda.float)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **formula**
|
||||||
|
|
||||||
|
Devuelve o establece la formula de la celda.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.formula = '=RAND()'
|
||||||
|
app.debug(celda.type, celda.formula)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **formula_array**
|
||||||
|
|
||||||
|
Devuelve o establece los datos de un rango. Es un alias de `FormulaArray`.
|
||||||
|
|
||||||
|
```py
|
||||||
|
rango = app.active.selection
|
||||||
|
|
||||||
|
datos = rango.data_array
|
||||||
|
app.debug(datos)
|
||||||
|
datos = rango.formula_array
|
||||||
|
app.debug(datos)
|
||||||
|
rango.formula_array = datos
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! tip "Consejo"
|
||||||
|
|
||||||
|
**data_array** devolverá los resultados de las celdas con formulas. **formula_array** devolverá las formulas en dichas celdas.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **is_cell**
|
||||||
|
|
||||||
|
Verdadero (True) si el objeto es de una celda.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
app.debug(celda.is_cell)
|
||||||
|
|
||||||
|
rango = hoja['A1:C5']
|
||||||
|
app.debug(rango.is_cell)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **is_range**
|
||||||
|
|
||||||
|
Verdadero (True) si el objeto es de un rango.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
app.debug(celda.is_range)
|
||||||
|
|
||||||
|
rango = hoja['A1:C5']
|
||||||
|
app.debug(rango.is_range)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **len**
|
||||||
|
|
||||||
|
Devolver el tamaño del rango en filas y columnas.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
rango = hoja['A1:E100']
|
||||||
|
filas = len(rango)
|
||||||
|
columnas = rango.len_columns
|
||||||
|
app.debug(filas, columnas)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **name**
|
||||||
|
|
||||||
|
Devuelve la dirección de la celda o rango como texto.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
app.debug(celda.name)
|
||||||
|
|
||||||
|
rango = hoja['A1:C5']
|
||||||
|
app.debug(rango.name)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **next_free**
|
||||||
|
|
||||||
|
Devuelve la siguiente celda libre después de la región actual.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
|
||||||
|
celda_libre = celda.next_free
|
||||||
|
app.debug(celda_libre)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **range_address**
|
||||||
|
|
||||||
|
Devuelve la dirección del rango como una estructura: `com.sun.star.table.CellRangeAddress`
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
rango = hoja['A1:C5']
|
||||||
|
if rango.is_range:
|
||||||
|
app.debug(rango.range_address)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **range_data**
|
||||||
|
|
||||||
|
Devuelve la región actual del rango excepto la primer fila.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
rango = celda.range_data
|
||||||
|
app.debug(rango)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **sheet**
|
||||||
|
|
||||||
|
Devuelve la hoja padre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
rango = hoja['A1:C5']
|
||||||
|
|
||||||
|
hoja = rango.sheet
|
||||||
|
app.debug(hoja)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **string**
|
||||||
|
|
||||||
|
Devuelve o establece el contenido de la celda como texto.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.string = 'Maldito Mundo'
|
||||||
|
app.debug(celda.type, celda.string)
|
||||||
|
|
||||||
|
celda = hoja['A2']
|
||||||
|
celda.string = 12345
|
||||||
|
app.debug(celda.type, celda.string)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **style**
|
||||||
|
|
||||||
|
Devuelve o aplica el estilo de celda.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
rango = hoja['A1:C5']
|
||||||
|
rango.style = 'Good'
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **time**
|
||||||
|
|
||||||
|
Devuelve o establece el contenido de la celda como tiempo.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.time = app.dates.time(10, 11, 12)
|
||||||
|
app.debug(type(celda.time), celda.time)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **type**
|
||||||
|
|
||||||
|
Devuelve el tipo de contenido de la celda: texto, número o formula.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
celda = hoja['A1']
|
||||||
|
app.debug(celda.type)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! tip "Consejo"
|
||||||
|
|
||||||
|
Asegurese de que la selección siempre sea una sola celda.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **value**
|
||||||
|
|
||||||
|
Devuelve o establece el valor de la celda, estableciendo el tipo de dato automáticamente.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
celda = hoja['A1']
|
||||||
|
celda.value = 'Soy Texto'
|
||||||
|
app.debug(celda.type, celda.value)
|
||||||
|
|
||||||
|
celda = hoja['A2']
|
||||||
|
celda.value = 12345
|
||||||
|
app.debug(celda.type, celda.value)
|
||||||
|
|
||||||
|
celda = hoja['A3']
|
||||||
|
celda.value = '=RAND()'
|
||||||
|
app.debug(celda.type, celda.value)
|
||||||
|
|
||||||
|
celda = hoja['A4']
|
||||||
|
celda.value = app.dates.date(1974, 1, 15)
|
||||||
|
app.debug(celda.type, celda.value)
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
23/04/2023 19:49:05 - DEBUG - <Enum instance com.sun.star.table.CellContentType ('TEXT')> Soy Texto
|
||||||
|
23/04/2023 19:49:05 - DEBUG - <Enum instance com.sun.star.table.CellContentType ('VALUE')> 12345.0
|
||||||
|
23/04/2023 19:49:05 - DEBUG - <Enum instance com.sun.star.table.CellContentType ('FORMULA')> =RAND()
|
||||||
|
23/04/2023 19:49:05 - DEBUG - <Enum instance com.sun.star.table.CellContentType ('VALUE')> 27044.0
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Métodos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **clear**
|
||||||
|
|
||||||
|
Limpia el rango. Por default solo borra datos. Mire [API CellFlags][1] para más información.
|
||||||
|
|
||||||
|
```python
|
||||||
|
rango.clear()
|
||||||
|
```
|
||||||
|
|
||||||
|
Para borrar todo.
|
||||||
|
```python
|
||||||
|
rango.clear(app.ALL)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **len**
|
||||||
|
|
||||||
|
Devuelve el tamaño en filas y columnas del rango.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
rango = hoja['A1:C100']
|
||||||
|
filas, columnas = rango.len()
|
||||||
|
app.debug(filas, columnas)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **offset**
|
||||||
|
|
||||||
|
Devuelve la celda inmediata a la derecha en la misma fila.
|
||||||
|
|
||||||
|
```py
|
||||||
|
cell = app.active.active['A1']
|
||||||
|
app.debug(cell)
|
||||||
|
cell = cell.offset()
|
||||||
|
app.debug(cell)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
23/04/2023 21:22:15 - DEBUG - Cell: $Sheet1.$A$1
|
||||||
|
23/04/2023 21:22:15 - DEBUG - Cell: $Sheet1.$B$1
|
||||||
|
```
|
||||||
|
|
||||||
|
Se puede establecer la distancia a la celda a devolver en filas y columnas.
|
||||||
|
|
||||||
|
```py
|
||||||
|
cell = app.active.active['A1']
|
||||||
|
app.debug(cell)
|
||||||
|
cell = cell.offset(4,2)
|
||||||
|
app.debug(cell)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
23/04/2023 21:24:59 - DEBUG - Cell: $Sheet1.$A$1
|
||||||
|
23/04/2023 21:24:59 - DEBUG - Cell: $Sheet1.$C$5
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **to_size**
|
||||||
|
|
||||||
|
Espande el tamaño del rango actual tantas filas y columnas se pasen como argumentos.
|
||||||
|
|
||||||
|
```py
|
||||||
|
cell = app.active.active['A1']
|
||||||
|
app.debug(cell)
|
||||||
|
cell = cell.to_size(10,5)
|
||||||
|
app.debug(cell)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
23/04/2023 21:30:56 - DEBUG - Cell: $Sheet1.$A$1
|
||||||
|
23/04/2023 21:30:56 - DEBUG - Range: $Sheet1.$A$1:$E$10
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
[1]: https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1sheet_1_1CellFlags.html
|
|
@ -0,0 +1,394 @@
|
||||||
|
---
|
||||||
|
title: Documento
|
||||||
|
---
|
||||||
|
|
||||||
|
Devolver el documento activo.
|
||||||
|
|
||||||
|
### **active**
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Propiedades
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **active**
|
||||||
|
|
||||||
|
Devuelve la hoja activa.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc.active
|
||||||
|
app.debug(hoja)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **headers**
|
||||||
|
|
||||||
|
Mostrar u ocultar encabezados de filas y columnas.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
app.msgbox(doc.headers)
|
||||||
|
doc.headers = not doc.headers
|
||||||
|
app.msgbox(doc.headers)
|
||||||
|
doc.headers = not doc.headers
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **names**
|
||||||
|
|
||||||
|
Devolver una tupla con los nombres de todas las hojas.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
nombres = doc.names
|
||||||
|
app.debug(nombres)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **selection**
|
||||||
|
|
||||||
|
Devolver la selección activa.
|
||||||
|
|
||||||
|
!!! warning inline end "Cuidado"
|
||||||
|
|
||||||
|
La selección actual pueden ser muchas cosas diferentes.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
seleccion = doc.selection
|
||||||
|
app.debug(seleccion)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **tabs**
|
||||||
|
|
||||||
|
Mostrar u ocultar las pestañas de las hojas.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
app.msgbox(doc.tabs)
|
||||||
|
doc.tabs = not doc.tabs
|
||||||
|
app.msgbox(doc.tabs)
|
||||||
|
doc.tabs = not doc.tabs
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Métodos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **activate**
|
||||||
|
|
||||||
|
Activar hoja, argumento como objeto.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[-1]
|
||||||
|
doc.activate(hoja)
|
||||||
|
```
|
||||||
|
|
||||||
|
Activar hoja por nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
doc.activate('Hoja3')
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **copy**
|
||||||
|
|
||||||
|
Copiar hoja dentro del mismo documento.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[0]
|
||||||
|
|
||||||
|
doc.copy_sheet(hoja, 'Otra hoja')
|
||||||
|
```
|
||||||
|
|
||||||
|
Por nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc.copy_sheet('Hoja1', 'Nueva Hoja')
|
||||||
|
```
|
||||||
|
|
||||||
|
Si no se establece el nuevo nombre, se generá de forma automática: `nombre + índice`.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc.copy_sheet(hoja)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **copy_from**
|
||||||
|
|
||||||
|
Copiar hojas de otro documento. Copiar con el mismo nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
documento_origen = app.docs['Contactos.ods']
|
||||||
|
nombre_origen = 'Nombres'
|
||||||
|
|
||||||
|
doc.copy_from(documento_origen, nombre_origen)
|
||||||
|
```
|
||||||
|
|
||||||
|
Copiar con un nuevo nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc.copy_from(documento_origen, nombre_origen, 'NuevoNombre')
|
||||||
|
```
|
||||||
|
|
||||||
|
Si solo se establece el documento origen, se copian todas las hojas.
|
||||||
|
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc.copy_from(documento_origen)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! info "Información"
|
||||||
|
|
||||||
|
Si algún nombre de hoja en el origen existe en el destino, se copiará con un nuevo índice concatenado el nombre origen.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **insert**
|
||||||
|
|
||||||
|
Inserta una nueva hoja, se devuelve la hoja insertada.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc.insert('HojaInsertada')
|
||||||
|
```
|
||||||
|
|
||||||
|
Insertar varias hojas. Devolverá la última insertada.
|
||||||
|
|
||||||
|
```py
|
||||||
|
nombres = ('Enero', 'Febrero', 'Marzo')
|
||||||
|
hoja = doc.insert(nombres)
|
||||||
|
app.debug(hoja)
|
||||||
|
```
|
||||||
|
|
||||||
|
Creando una nueva instancia y asignandola.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
doc['NuevaHoja'] = doc.new_sheet()
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning "Cuidado"
|
||||||
|
|
||||||
|
Si la hoja existe, obtendrá un error, verifique siempre que no exista primero.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **move**
|
||||||
|
|
||||||
|
Mover hojas.
|
||||||
|
|
||||||
|
Pasar la hoja como objeto, de forma predetermianda se mueve a la última posición.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[0]
|
||||||
|
doc.move(hoja)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! info "Información"
|
||||||
|
|
||||||
|
Al mover una hoja, cambian sus índices.
|
||||||
|
|
||||||
|
Pasar la hoja por nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
doc.move('Hoja1')
|
||||||
|
```
|
||||||
|
|
||||||
|
Especificar la posición destino.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[0]
|
||||||
|
doc.move(hoja, 2)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **remove**
|
||||||
|
|
||||||
|
!!! warning "Cuidado"
|
||||||
|
|
||||||
|
Siempre debe haber al menos una hoja en un documento.
|
||||||
|
|
||||||
|
Eliminar hoja por índice.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
sheet = doc[0]
|
||||||
|
|
||||||
|
doc.remove(sheet)
|
||||||
|
```
|
||||||
|
|
||||||
|
Eliminar por nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc.remove('Hoja2')
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **start_range_selection**
|
||||||
|
|
||||||
|
Permitir al usuario seleccionar un rango. Es necesario pasarle una clase con el nombre que prefiera (`Eventos` es recomendable) con dos métodos para procesar la captura como en el siguiente ejemplo:
|
||||||
|
|
||||||
|
```py
|
||||||
|
class Eventos():
|
||||||
|
|
||||||
|
def __init__(self, doc):
|
||||||
|
self.doc = doc
|
||||||
|
|
||||||
|
def range_selection_done(self, range_selection):
|
||||||
|
if range_selection:
|
||||||
|
app.debug(range_selection)
|
||||||
|
self.doc.remove_range_selection_listener()
|
||||||
|
return
|
||||||
|
|
||||||
|
def range_selection_aborted(self):
|
||||||
|
self.doc.remove_range_selection_listener()
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
doc = app.active
|
||||||
|
doc.start_range_selection(Eventos)
|
||||||
|
return
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **select**
|
||||||
|
|
||||||
|
Seleccionar una celda o rango.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
cell = doc[0]['A1']
|
||||||
|
doc.select(cell)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! tip "Consejo"
|
||||||
|
|
||||||
|
**No es necesario** seleccionar celdas o rangos para manipularlos.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **sort**
|
||||||
|
|
||||||
|
Ordenar hojas en orden alfabetico.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
doc.sort()
|
||||||
|
```
|
||||||
|
|
||||||
|
Ordenar de forma inversa.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
doc.sort(True)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Eventos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Obtener una tupla con los eventos soportados por el documento.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
nombres = doc.events.names
|
||||||
|
for nombre in nombres:
|
||||||
|
app.debug(nombre)
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnStartApp
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnCloseApp
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnCreate
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnNew
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnLoadFinished
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnLoad
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnPrepareUnload
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnUnload
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnSave
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnSaveDone
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnSaveFailed
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnSaveAs
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnSaveAsDone
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnSaveAsFailed
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnCopyTo
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnCopyToDone
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnCopyToFailed
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnFocus
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnUnfocus
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnPrint
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnViewCreated
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnPrepareViewClosing
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnViewClosed
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnModifyChanged
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnTitleChanged
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnVisAreaChanged
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnModeChanged
|
||||||
|
23/04/2023 13:54:10 - DEBUG - OnStorageChanged
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### Asignar una macro a un evento.
|
||||||
|
|
||||||
|
```py
|
||||||
|
def doc_on_focus(event):
|
||||||
|
app.debug('Documento activado...')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
doc = app.active
|
||||||
|
events = doc.events
|
||||||
|
if 'OnFocus' in events:
|
||||||
|
macro = {'library': 'test', 'name': 'doc_on_focus'}
|
||||||
|
events['OnFocus'] = macro
|
||||||
|
return
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### Eliminar la asignación del evento.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
doc.events['OnFocus'] = {}
|
||||||
|
```
|
||||||
|
|
||||||
|
O
|
||||||
|
|
||||||
|
```python
|
||||||
|
doc = app.active
|
||||||
|
doc.events.remove('OnFocus')
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
|
@ -0,0 +1,175 @@
|
||||||
|
## Trabajar con conjuntos de rangos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **address**
|
||||||
|
|
||||||
|
Referencia a un rango por su dirección.
|
||||||
|
|
||||||
|
```py
|
||||||
|
rango = rangos['Hoja1.A1:B5']
|
||||||
|
app.debug(rango)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **in**
|
||||||
|
|
||||||
|
Verificar si un rango esta en la colección.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc.active
|
||||||
|
rangos = doc.selection
|
||||||
|
|
||||||
|
resultado = hoja['D5:F10'] in rangos
|
||||||
|
app.debug(resultado)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **index**
|
||||||
|
|
||||||
|
Referencia a un rango por índice.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
rangos = doc.selection
|
||||||
|
|
||||||
|
rango = rangos[1]
|
||||||
|
app.debug(rango)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **iter**
|
||||||
|
|
||||||
|
Iterar entre los rangos.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
for rango in doc.selection:
|
||||||
|
app.debug(rango)
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
20/08/2022 13:27:03 - DEBUG - Range: $Sheet1.$B$4:$D$7
|
||||||
|
20/08/2022 13:27:03 - DEBUG - Range: $Sheet1.$G$10:$H$14
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **len**
|
||||||
|
|
||||||
|
Contar los rangos en la colección.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
contar = len(doc.selection)
|
||||||
|
app.debug(contar)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **selection**
|
||||||
|
|
||||||
|
Obtener una referencia desde la selección actual. Deben de estar seleccionados más de un rango de celdas.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
seleccion = doc.selection
|
||||||
|
app.debug(seleccion)
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
20/08/2022 13:21:17 - DEBUG - Ranges: ('Sheet1.A5:C8', 'Sheet1.E11:F14')
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Propiedades
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **data**
|
||||||
|
|
||||||
|
Devolver y establecer datos.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
rangos = doc.selection
|
||||||
|
|
||||||
|
datos = rangos.data
|
||||||
|
app.debug(datos)
|
||||||
|
rangos.data = datos
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning "Cuidado"
|
||||||
|
|
||||||
|
Al asignar esta propiedad, cada matriz de datos debe tener exactamente el mismo tamaño del rango destino.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **names**
|
||||||
|
|
||||||
|
Devolver las direcciones de los rangos.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
rangos = doc.selection
|
||||||
|
|
||||||
|
nombres = rangos.names
|
||||||
|
app.debug(nombres)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **style**
|
||||||
|
|
||||||
|
Establecer el estilo de todos los rangos de la colección.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
rangos = doc.selection
|
||||||
|
rangos.style = 'Good'
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Métodos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **add**
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc.active
|
||||||
|
|
||||||
|
rangos = doc.ranges()
|
||||||
|
rangos.add(hoja['A1:B2'])
|
||||||
|
rangos.add(hoja['D5:F10'])
|
||||||
|
app.debug(rangos)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **ranges**
|
||||||
|
|
||||||
|
Crear un nuevo contender de rangos vacío.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
rangos = doc.ranges()
|
||||||
|
app.debug(rangos)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **remove**
|
||||||
|
|
||||||
|
```py
|
||||||
|
rangos.remove(hoja['A1:B2'])
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
|
@ -0,0 +1,354 @@
|
||||||
|
---
|
||||||
|
title: Hojas
|
||||||
|
---
|
||||||
|
|
||||||
|
## Trabajar con hojas
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Referencia por **índice**
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[0]
|
||||||
|
app.debug(hoja.name)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Referencia por **nombre**
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc['datos']
|
||||||
|
app.debug(hoja.name)
|
||||||
|
```
|
||||||
|
|
||||||
|
### **in**
|
||||||
|
|
||||||
|
Verificar por nombre si una hoja existe.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
existe = 'Hoja2' in doc
|
||||||
|
app.debug(existe)
|
||||||
|
```
|
||||||
|
|
||||||
|
### **len**
|
||||||
|
|
||||||
|
Contar la cantidad de hojas en el documento.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
contar = len(doc)
|
||||||
|
app.debug(contar)
|
||||||
|
```
|
||||||
|
|
||||||
|
### **iter**
|
||||||
|
|
||||||
|
Recorrer todas las hojas.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
for hoja in doc:
|
||||||
|
app.debug(hoja)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Propiedades
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **code_name**
|
||||||
|
|
||||||
|
Nombre editable y accesible solo por código.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
app.msgbox(hoja.code_name)
|
||||||
|
hoja.code_name = 'datos'
|
||||||
|
app.msgbox(hoja.code_name)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **color**
|
||||||
|
|
||||||
|
Color de la pestaña.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
app.msgbox(hoja.color)
|
||||||
|
|
||||||
|
hoja.color = 'red'
|
||||||
|
app.msgbox(hoja.color)
|
||||||
|
|
||||||
|
# RGB
|
||||||
|
hoja.color = (125, 200, 10)
|
||||||
|
app.msgbox(hoja.color)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **doc**
|
||||||
|
|
||||||
|
Devuelve al documento Calc donde esta la hoja.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
doc = hoja.doc
|
||||||
|
app.debug(doc.title)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **is_protected**
|
||||||
|
|
||||||
|
Devuelve verdadero (True) si la hoja esta protegida
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
esta_protegida = hoja.is_protected
|
||||||
|
app.debug(esta_protegida)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **name**
|
||||||
|
|
||||||
|
Nombre visible y editable por el usuario.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
app.debug(hoja.name)
|
||||||
|
hoja.name = 'Nuevo Nombre'
|
||||||
|
app.debug(hoja.name)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **password**
|
||||||
|
|
||||||
|
Establecer una contraseña.
|
||||||
|
|
||||||
|
!!! tip "Consejo"
|
||||||
|
|
||||||
|
Si la hoja ya esta protegida, aún sin contraseña, este método no tendrá ningún efecto.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
hoja.password = 'siscaloburropanzon'
|
||||||
|
app.debug(hoja.is_protected)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **used_area**
|
||||||
|
|
||||||
|
Referencia al área de usuario actual.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
rango = hoja.used_area
|
||||||
|
app.debug(rango)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **visible**
|
||||||
|
|
||||||
|
Muestra u oculta la hoja
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
app.msgbox(hoja.visible)
|
||||||
|
hoja.visible = not hoja.visible
|
||||||
|
app.msgbox(hoja.visible)
|
||||||
|
hoja.visible = not hoja.visible
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! tip "Cuidado"
|
||||||
|
|
||||||
|
Solo funcionará con dos o más hojas, por que debe haber al menos una visible. Siempre puedes trabajar con todo el documento oculto.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Métodos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **activate**
|
||||||
|
|
||||||
|
Pasar el foco a la hoja.
|
||||||
|
|
||||||
|
!!! tip inline end "Recuerde"
|
||||||
|
|
||||||
|
No es necesario activar una hoja para manipularse.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[-1]
|
||||||
|
hoja.activate()
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **copy**
|
||||||
|
|
||||||
|
!!! tip "Consejo"
|
||||||
|
|
||||||
|
Siempre valide que no exista el nuevo nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[0]
|
||||||
|
|
||||||
|
nuevo_nombre = f'{hoja.name}_2'
|
||||||
|
if not nuevo_nombre in doc:
|
||||||
|
hoja.copy(nuevo_nombre)
|
||||||
|
```
|
||||||
|
|
||||||
|
Si no se establece el nuevo nombre, se generá de forma automática: `nombre + índice`.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja.copy()
|
||||||
|
```
|
||||||
|
|
||||||
|
### **copy_to**
|
||||||
|
|
||||||
|
Copiar la hoja a otro documento. Se usa el mismo nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc.active
|
||||||
|
|
||||||
|
documento_nuevo = app.docs.new()
|
||||||
|
hoja.copy_to(documento_nuevo)
|
||||||
|
```
|
||||||
|
|
||||||
|
Usar un nuevo nombre.
|
||||||
|
|
||||||
|
```python
|
||||||
|
hoja.copy_to(documento_nuevo, 'Nuevo nombre')
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **move**
|
||||||
|
|
||||||
|
Mover a la última posición.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[0]
|
||||||
|
hoja.move()
|
||||||
|
```
|
||||||
|
|
||||||
|
Mover a una posición especifica.
|
||||||
|
|
||||||
|
```py
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc[0]
|
||||||
|
hoja.move(3)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **remove**
|
||||||
|
|
||||||
|
Remover hoja.
|
||||||
|
|
||||||
|
```py
|
||||||
|
sheet = app.active.active
|
||||||
|
sheet.remove()
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning "Cuidado"
|
||||||
|
|
||||||
|
Siempre debe existir al menos una hoja.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **unprotect**
|
||||||
|
|
||||||
|
Quitar contraseña.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
hoja.password = 'siscaloburropanzon'
|
||||||
|
app.msgbox(hoja.is_protected)
|
||||||
|
|
||||||
|
hoja.unprotect('siscaloburropanzon')
|
||||||
|
app.msgbox(hoja.is_protected)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Eventos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **names**
|
||||||
|
|
||||||
|
Obtener una tupla con los eventos soportados por la hoja.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
|
||||||
|
for nombre in hoja.events.names:
|
||||||
|
app.debug(nombre)
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
23/04/2023 16:59:26 - DEBUG - OnFocus
|
||||||
|
23/04/2023 16:59:26 - DEBUG - OnUnfocus
|
||||||
|
23/04/2023 16:59:26 - DEBUG - OnSelect
|
||||||
|
23/04/2023 16:59:26 - DEBUG - OnDoubleClick
|
||||||
|
23/04/2023 16:59:26 - DEBUG - OnRightClick
|
||||||
|
23/04/2023 16:59:26 - DEBUG - OnChange
|
||||||
|
23/04/2023 16:59:26 - DEBUG - OnCalculate
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### Asignar una macro a un evento.
|
||||||
|
|
||||||
|
```py
|
||||||
|
def on_select(source):
|
||||||
|
app.debug(source.AbsoluteName)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
doc = app.active
|
||||||
|
hoja = doc.active
|
||||||
|
|
||||||
|
if 'OnSelect' in hoja.events:
|
||||||
|
macro = {'library': 'test', 'name': 'on_select'}
|
||||||
|
hoja.events['OnSelect'] = macro
|
||||||
|
|
||||||
|
return
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### Eliminar la asignación del evento.
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja.events['OnSelect'] = {}
|
||||||
|
```
|
||||||
|
|
||||||
|
O
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja.events.remove('OnFocus')
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
|
@ -0,0 +1,109 @@
|
||||||
|
---
|
||||||
|
title: DrawPage
|
||||||
|
---
|
||||||
|
|
||||||
|
La página de dibujo es la capa gráfica donde se agregan las formas y las imágenes en los documentos. La forma de acceder es la misma, solo cambia el tipo de documento.
|
||||||
|
|
||||||
|
## Hoja de Calc
|
||||||
|
|
||||||
|
### **draw_page**
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
pagina_dibujo = hoja.draw_page
|
||||||
|
```
|
||||||
|
|
||||||
|
### **dp**
|
||||||
|
|
||||||
|
Alias de `draw_page`
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
pagina_dibujo = hoja.dp
|
||||||
|
```
|
||||||
|
|
||||||
|
### **shapes**
|
||||||
|
|
||||||
|
Alias de `draw_page`
|
||||||
|
|
||||||
|
```py
|
||||||
|
hoja = app.active.active
|
||||||
|
pagina_dibujo = hoja.shapes
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
Una vez referenciada, sus métodos y propiedades son las mismas.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Formas
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **index**
|
||||||
|
|
||||||
|
Acceso por índice
|
||||||
|
|
||||||
|
```py
|
||||||
|
forma = formas[0]
|
||||||
|
app.debug(forma)
|
||||||
|
```
|
||||||
|
|
||||||
|
Acceso por nombre
|
||||||
|
|
||||||
|
```py
|
||||||
|
forma = formas['Rectangulo1']
|
||||||
|
app.debug(forma)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **in**
|
||||||
|
|
||||||
|
Verificar si una forma esta en la colección por nombre.
|
||||||
|
|
||||||
|
```py
|
||||||
|
app.debug('Shape 1' in formas)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **iter**
|
||||||
|
|
||||||
|
Iterar los elementos gráficos de la página de dibujo.
|
||||||
|
|
||||||
|
```py
|
||||||
|
for f in formas:
|
||||||
|
app.debug(f)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
### **len**
|
||||||
|
|
||||||
|
Contar los elementos gráficos en la página de dibujo.
|
||||||
|
|
||||||
|
```py
|
||||||
|
app.debug(len(formas))
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Métodos
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **add**
|
||||||
|
|
||||||
|
Agrega una nueva forma (un rectángulo) y la devuelve.
|
||||||
|
|
||||||
|
```py
|
||||||
|
forma = formas.add('Rectangle')
|
||||||
|
app.debug(forma)
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
|
@ -0,0 +1,7 @@
|
||||||
|
## Propiedades
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Métodos
|
||||||
|
|
||||||
|
---
|
|
@ -24,6 +24,14 @@ nav:
|
||||||
- docs/index.md
|
- docs/index.md
|
||||||
- Propiedades: docs/properties.md
|
- Propiedades: docs/properties.md
|
||||||
- Métodos: docs/methods.md
|
- Métodos: docs/methods.md
|
||||||
|
- Calc:
|
||||||
|
- calc/index.md
|
||||||
|
- Hojas: calc/sheets.md
|
||||||
|
- Rangos: calc/ranges.md
|
||||||
|
- Celdas: calc/cells.md
|
||||||
|
- Página de dibujo:
|
||||||
|
- dp/drawpage.md
|
||||||
|
- Formas: dp/shapes.md
|
||||||
theme:
|
theme:
|
||||||
name: material
|
name: material
|
||||||
locale: es
|
locale: es
|
||||||
|
|
|
@ -11,6 +11,7 @@ from .easydrawpage import LOGalleries
|
||||||
def __getattr__(name):
|
def __getattr__(name):
|
||||||
classes = {
|
classes = {
|
||||||
'active': LODocuments().active,
|
'active': LODocuments().active,
|
||||||
|
'active_sheet': LODocuments().active.active,
|
||||||
'clipboard': ClipBoard,
|
'clipboard': ClipBoard,
|
||||||
'cmd': LOMain.commands,
|
'cmd': LOMain.commands,
|
||||||
'color': Color(),
|
'color': Color(),
|
||||||
|
|
|
@ -90,9 +90,10 @@ class LOCellStyles():
|
||||||
# ~ IsStartOfNewPage
|
# ~ IsStartOfNewPage
|
||||||
class LOSheetRows():
|
class LOSheetRows():
|
||||||
|
|
||||||
def __init__(self, sheet, obj):
|
def __init__(self, sheet, obj, range_address):
|
||||||
self._sheet = sheet
|
self._sheet = sheet
|
||||||
self._obj = obj
|
self._obj = obj
|
||||||
|
self._ra = range_address
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if isinstance(index, int):
|
if isinstance(index, int):
|
||||||
|
@ -106,7 +107,8 @@ class LOSheetRows():
|
||||||
return self.obj.Count
|
return self.obj.Count
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.obj.Name
|
name = f'Rows: {self._ra.StartRow} - {self._ra.EndRow}'
|
||||||
|
return name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def obj(self):
|
def obj(self):
|
||||||
|
@ -239,6 +241,7 @@ class LOCalcRange():
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
self._obj = obj
|
self._obj = obj
|
||||||
self._is_cell = obj.ImplementationName == self.CELL
|
self._is_cell = obj.ImplementationName == self.CELL
|
||||||
|
self._shape = None
|
||||||
|
|
||||||
def __contains__(self, rango):
|
def __contains__(self, rango):
|
||||||
if isinstance(rango, LOCalcRange):
|
if isinstance(rango, LOCalcRange):
|
||||||
|
@ -303,6 +306,7 @@ class LOCalcRange():
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_range(self):
|
def is_range(self):
|
||||||
|
"""True if range is not cell"""
|
||||||
return not self._is_cell
|
return not self._is_cell
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -523,6 +527,17 @@ class LOCalcRange():
|
||||||
col2 = ra.EndColumn + 1
|
col2 = ra.EndColumn + 1
|
||||||
return LOCalcRange(self.sheet[row1:row2, col1:col2].obj)
|
return LOCalcRange(self.sheet[row1:row2, col1:col2].obj)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def shape(self):
|
||||||
|
return self._shape
|
||||||
|
@shape.setter
|
||||||
|
def shape(self, shape):
|
||||||
|
shape.anchor = self
|
||||||
|
shape.resize_with_cell = True
|
||||||
|
shape.possize = self.possize
|
||||||
|
return
|
||||||
|
|
||||||
|
# ~ Fix
|
||||||
@property
|
@property
|
||||||
def array_formula(self):
|
def array_formula(self):
|
||||||
return self.obj.ArrayFormula
|
return self.obj.ArrayFormula
|
||||||
|
@ -535,12 +550,10 @@ class LOCalcRange():
|
||||||
cursor = self.obj.Spreadsheet.createCursorByRange(self.obj)
|
cursor = self.obj.Spreadsheet.createCursorByRange(self.obj)
|
||||||
return cursor
|
return cursor
|
||||||
|
|
||||||
# ~ To doc
|
|
||||||
@property
|
@property
|
||||||
def position(self):
|
def position(self):
|
||||||
return self.obj.Position
|
return self.obj.Position
|
||||||
|
|
||||||
# ~ To doc
|
|
||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
return self.obj.Size
|
return self.obj.Size
|
||||||
|
@ -561,20 +574,19 @@ class LOCalcRange():
|
||||||
def y(self):
|
def y(self):
|
||||||
return self.obj.Position.Y
|
return self.obj.Position.Y
|
||||||
|
|
||||||
# ~ To doc
|
|
||||||
@property
|
@property
|
||||||
def possize(self):
|
def possize(self):
|
||||||
data = {
|
data = {
|
||||||
'Width': self.size.Width,
|
'Width': self.width,
|
||||||
'Height': self.size.Height,
|
'Height': self.height,
|
||||||
'X': self.position.X,
|
'X': self.x,
|
||||||
'Y': self.position.Y,
|
'Y': self.y,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rows(self):
|
def rows(self):
|
||||||
return LOSheetRows(self.sheet, self.obj.Rows)
|
return LOSheetRows(self.sheet, self.obj.Rows, self.range_address)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def row(self):
|
def row(self):
|
||||||
|
@ -592,17 +604,26 @@ class LOCalcRange():
|
||||||
return
|
return
|
||||||
|
|
||||||
def offset(self, rows=0, cols=1):
|
def offset(self, rows=0, cols=1):
|
||||||
|
"""Get cell offset"""
|
||||||
ra = self.range_address
|
ra = self.range_address
|
||||||
col = ra.EndColumn + cols
|
col = ra.EndColumn + cols
|
||||||
row = ra.EndRow + rows
|
row = ra.EndRow + rows
|
||||||
return LOCalcRange(self.sheet[row, col].obj)
|
return LOCalcRange(self.sheet[row, col].obj)
|
||||||
|
|
||||||
def to_size(self, cols: int, rows: int):
|
def to_size(self, cols: int, rows: int):
|
||||||
|
"""Expande range to size"""
|
||||||
cursor = self.cursor
|
cursor = self.cursor
|
||||||
cursor.collapseToSize(cols, rows)
|
cursor.collapseToSize(cols, rows)
|
||||||
rango = self.obj.Spreadsheet[cursor.AbsoluteName]
|
rango = self.obj.Spreadsheet[cursor.AbsoluteName]
|
||||||
return LOCalcRange(rango)
|
return LOCalcRange(rango)
|
||||||
|
|
||||||
|
def len(self):
|
||||||
|
"""Get size of range in rows and columns"""
|
||||||
|
ra = self.range_address
|
||||||
|
rows = ra.EndRow - ra.StartRow + 1
|
||||||
|
cols = ra.EndColumn - ra.StartColumn + 1
|
||||||
|
return rows, cols
|
||||||
|
|
||||||
|
|
||||||
class LOCalcSheet(BaseObject):
|
class LOCalcSheet(BaseObject):
|
||||||
|
|
||||||
|
@ -623,10 +644,12 @@ class LOCalcSheet(BaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def doc(self):
|
def doc(self):
|
||||||
|
"""Get parent doc"""
|
||||||
return LOCalc(self.obj.DrawPage.Forms.Parent)
|
return LOCalc(self.obj.DrawPage.Forms.Parent)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
"""Get name sheet"""
|
||||||
return self._obj.Name
|
return self._obj.Name
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, value):
|
def name(self, value):
|
||||||
|
@ -634,6 +657,7 @@ class LOCalcSheet(BaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_name(self):
|
def code_name(self):
|
||||||
|
"""Get code name"""
|
||||||
return self._obj.CodeName
|
return self._obj.CodeName
|
||||||
@code_name.setter
|
@code_name.setter
|
||||||
def code_name(self, value):
|
def code_name(self, value):
|
||||||
|
@ -641,6 +665,7 @@ class LOCalcSheet(BaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def visible(self):
|
def visible(self):
|
||||||
|
"""Get visible"""
|
||||||
return self._obj.IsVisible
|
return self._obj.IsVisible
|
||||||
@visible.setter
|
@visible.setter
|
||||||
def visible(self, value):
|
def visible(self, value):
|
||||||
|
@ -648,6 +673,7 @@ class LOCalcSheet(BaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color(self):
|
def color(self):
|
||||||
|
"""Get color tab"""
|
||||||
return self._obj.TabColor
|
return self._obj.TabColor
|
||||||
@color.setter
|
@color.setter
|
||||||
def color(self, value):
|
def color(self, value):
|
||||||
|
@ -655,12 +681,14 @@ class LOCalcSheet(BaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def used_area(self):
|
def used_area(self):
|
||||||
|
"""Get used area"""
|
||||||
cursor = self.create_cursor()
|
cursor = self.create_cursor()
|
||||||
cursor.gotoEndOfUsedArea(True)
|
cursor.gotoEndOfUsedArea(True)
|
||||||
return self[cursor.AbsoluteName]
|
return self[cursor.AbsoluteName]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_protected(self):
|
def is_protected(self):
|
||||||
|
"""Get is protected"""
|
||||||
return self._obj.isProtected()
|
return self._obj.isProtected()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -668,10 +696,12 @@ class LOCalcSheet(BaseObject):
|
||||||
return ''
|
return ''
|
||||||
@password.setter
|
@password.setter
|
||||||
def password(self, value):
|
def password(self, value):
|
||||||
|
"""Set password protect"""
|
||||||
self.obj.protect(value)
|
self.obj.protect(value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def draw_page(self):
|
def draw_page(self):
|
||||||
|
"""Get draw page"""
|
||||||
return LODrawPage(self.obj.DrawPage)
|
return LODrawPage(self.obj.DrawPage)
|
||||||
@property
|
@property
|
||||||
def dp(self):
|
def dp(self):
|
||||||
|
@ -686,6 +716,7 @@ class LOCalcSheet(BaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def events(self):
|
def events(self):
|
||||||
|
"""Get events"""
|
||||||
return LOEvents(self.obj.Events)
|
return LOEvents(self.obj.Events)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -701,6 +732,7 @@ class LOCalcSheet(BaseObject):
|
||||||
return
|
return
|
||||||
|
|
||||||
def unprotect(self, value):
|
def unprotect(self, value):
|
||||||
|
"""Unproyect sheet"""
|
||||||
try:
|
try:
|
||||||
self.obj.unprotect(value)
|
self.obj.unprotect(value)
|
||||||
return True
|
return True
|
||||||
|
@ -709,6 +741,7 @@ class LOCalcSheet(BaseObject):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def move(self, pos: int=-1):
|
def move(self, pos: int=-1):
|
||||||
|
"""Move sheet"""
|
||||||
index = pos
|
index = pos
|
||||||
if pos < 0:
|
if pos < 0:
|
||||||
index = len(self.doc)
|
index = len(self.doc)
|
||||||
|
@ -716,10 +749,12 @@ class LOCalcSheet(BaseObject):
|
||||||
return
|
return
|
||||||
|
|
||||||
def remove(self):
|
def remove(self):
|
||||||
|
"""Auto remove"""
|
||||||
self.doc.remove(self.name)
|
self.doc.remove(self.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
def copy(self, new_name: str='', pos: int=-1):
|
def copy(self, new_name: str='', pos: int=-1):
|
||||||
|
"""Copy sheet"""
|
||||||
index = pos
|
index = pos
|
||||||
if pos < 0:
|
if pos < 0:
|
||||||
index = len(self.doc)
|
index = len(self.doc)
|
||||||
|
@ -727,8 +762,7 @@ class LOCalcSheet(BaseObject):
|
||||||
return new_sheet
|
return new_sheet
|
||||||
|
|
||||||
def copy_to(self, doc: Any, target: str='', pos: int=-1):
|
def copy_to(self, doc: Any, target: str='', pos: int=-1):
|
||||||
"""Copy sheet to other document.
|
"""Copy sheet to other document."""
|
||||||
"""
|
|
||||||
index = pos
|
index = pos
|
||||||
if pos < 0:
|
if pos < 0:
|
||||||
index = len(doc)
|
index = len(doc)
|
||||||
|
@ -909,7 +943,6 @@ class LOCalc(LODocument):
|
||||||
self._cc.select(obj)
|
self._cc.select(obj)
|
||||||
return
|
return
|
||||||
|
|
||||||
@run_in_thread
|
|
||||||
def start_range_selection(self, controllers: Any, args: dict={}):
|
def start_range_selection(self, controllers: Any, args: dict={}):
|
||||||
"""Start select range selection by user
|
"""Start select range selection by user
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,10 @@ class LODrawPage(BaseObject):
|
||||||
break
|
break
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
"""Count shapes"""
|
||||||
|
return self.count
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.obj.Name
|
return self.obj.Name
|
||||||
|
@ -201,7 +205,6 @@ class LODrawPage(BaseObject):
|
||||||
if properties:
|
if properties:
|
||||||
set_properties(shape, properties)
|
set_properties(shape, properties)
|
||||||
|
|
||||||
# ~ return LOShape(self.obj[index], index)
|
|
||||||
return LOShape(self.obj[index])
|
return LOShape(self.obj[index])
|
||||||
|
|
||||||
def remove(self, shape):
|
def remove(self, shape):
|
||||||
|
|
|
@ -80,15 +80,12 @@ class EventsRangeSelectionListener(EventsListenerBase, XRangeSelectionListener):
|
||||||
super().__init__(controller, '')
|
super().__init__(controller, '')
|
||||||
|
|
||||||
def done(self, event):
|
def done(self, event):
|
||||||
range_selection = event.RangeDescriptor
|
|
||||||
print(event)
|
|
||||||
event_name = 'range_selection_done'
|
event_name = 'range_selection_done'
|
||||||
if hasattr(self._controller, event_name):
|
if hasattr(self._controller, event_name):
|
||||||
getattr(self._controller, event_name)(range_selection)
|
getattr(self._controller, event_name)(event.RangeDescriptor)
|
||||||
return
|
return
|
||||||
|
|
||||||
def aborted(self, event):
|
def aborted(self, event):
|
||||||
range_selection = event.RangeDescriptor
|
|
||||||
event_name = 'range_selection_aborted'
|
event_name = 'range_selection_aborted'
|
||||||
if hasattr(self._controller, event_name):
|
if hasattr(self._controller, event_name):
|
||||||
getattr(self._controller, event_name)()
|
getattr(self._controller, event_name)()
|
||||||
|
|
|
@ -54,6 +54,24 @@ class LOShape(BaseObject):
|
||||||
def obj(self):
|
def obj(self):
|
||||||
return self._obj
|
return self._obj
|
||||||
|
|
||||||
|
@property
|
||||||
|
def anchor(self):
|
||||||
|
return self.obj.Anchor
|
||||||
|
@anchor.setter
|
||||||
|
def anchor(self, obj):
|
||||||
|
if hasattr(obj, 'obj'):
|
||||||
|
obj = obj.obj
|
||||||
|
self.obj.Anchor = obj
|
||||||
|
return
|
||||||
|
|
||||||
|
@property
|
||||||
|
def resize_with_cell(self):
|
||||||
|
return self.obj.ResizeWithCell
|
||||||
|
@resize_with_cell.setter
|
||||||
|
def resize_with_cell(self, value):
|
||||||
|
self.obj.ResizeWithCell = value
|
||||||
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def properties(self):
|
def properties(self):
|
||||||
# ~ properties = self.obj.PropertySetInfo.Properties
|
# ~ properties = self.obj.PropertySetInfo.Properties
|
||||||
|
|
Loading…
Reference in New Issue