Skip to content

Commit

Permalink
Cell
Browse files Browse the repository at this point in the history
  • Loading branch information
daizutabi committed Jul 7, 2024
1 parent fef2c74 commit 055611f
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 172 deletions.
12 changes: 8 additions & 4 deletions src/pptxlib/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
from win32com.client import DispatchBaseClass

from pptxlib.app import Slide
from pptxlib.tables import Cell


class Shape(Element):
parent: Shapes
parent: Shapes | Cell

@property
def text_range(self) -> DispatchBaseClass:
Expand All @@ -31,7 +32,10 @@ def text(self, text: str) -> None:

@property
def slide(self) -> Slide:
return self.parent.parent
if isinstance(self.parent, Shapes):
return self.parent.parent

raise NotImplementedError

@property
def left(self) -> float:
Expand All @@ -51,7 +55,7 @@ def height(self) -> float:

@left.setter
def left(self, value: float | Literal["center"]) -> float:
slide = self.parent.parent
slide = self.slide

if value == "center":
value = (slide.width - self.width) / 2
Expand All @@ -63,7 +67,7 @@ def left(self, value: float | Literal["center"]) -> float:

@top.setter
def top(self, value: float | Literal["center"]) -> float:
slide = self.parent.parent
slide = self.slide

if value == "center":
value = (slide.height - self.height) / 2
Expand Down
Loading

0 comments on commit 055611f

Please sign in to comment.