Skip to content

Miscellaneous George functions

All George values as enum and functions which are not specific to any TVPaint element.

GrgErrorValue

Common George error values.

Attributes:

Name Type Description
EMPTY str

See tv_clipinfo for example

NONE str

See tv_clipenumid for example

ERROR str

See tv_setapen for example

GrgBoolState

Bases: enum.Enum

George booleans.

Attributes:

Name Type Description
ON
OFF

FieldOrder

Bases: enum.Enum

Field order of the camera.

Attributes:

Name Type Description
NONE
LOWER
UPPER

MarkType

Bases: enum.Enum

The mark command.

Attributes:

Name Type Description
MARKIN
MARKOUT

MarkReference

Bases: enum.Enum

The object to mark.

Attributes:

Name Type Description
PROJECT
CLIP

MarkAction

Bases: enum.Enum

The mark action.

Attributes:

Name Type Description
SET
CLEAR

RectButton

Bases: enum.Enum

The rect button when drawing.

Attributes:

Name Type Description
LEFT
RIGHT

TVPShape

Bases: enum.Enum

The shape tools.

Attributes:

Name Type Description
B_SPLINE
BEZIER
BEZIER_FILL
CAMERA
CIRCLE
CIRCLE_2PTS
CIRCLE_3PTS
CIRCLE_FILL
CIRCLE_2PTS_FILL
CIRCLE_3PTS_FILL
CROP
CUT_RECT
CUT_POLY
CUT_FREE_HAND
CUT_FLOOD
DOT
FLOOD
FREE_HAND_LINE
FREE_HAND_FILL
ELLIPSE
ELLIPSE_FILL
ELLIPSE_2PTS
ELLIPSE_2PTS_FILL
LINE
LINE_FILL
PLANNING
POSITION
RECTANGLE
RECTANGLE_FILL
SELECT_RECTANGLE
SELECT_ELLIPSE
SELECT_2PTS
SELECT_3PTS
SELECT_POLY
SELECT_FREE_HAND
SELECT_FLOOD
SELECT_COLOR
SELECT_BEZIER
SELECT_B_SPLINE
SINGLE_DOT
SPLIT_3PTS
SPLINE_FILL
WARP
WRAP
ZOOM_IN
ZOOM_OUT
ZOOM_HAND
ZOOM_RECT

ResizeOption

Bases: enum.Enum

Resize options for projects.

Attributes:

Name Type Description
EMPTY
CROP
STRETCH

SpriteLayout

Bases: enum.Enum

Sprite layout when exporting as sprites.

Attributes:

Name Type Description
RECTANGLE
HORIZONTAL
VERTICAL
DIAGONAL
ANTI_DIAGONAL

AlphaMode

Bases: enum.Enum

The alpha load mode.

Attributes:

Name Type Description
PREMULTIPLY
NO_PREMULTIPLY
NO_ALPHA
ALPHA_ONLY
GUESS

AlphaSaveMode

Bases: enum.Enum

The alpha save mode.

Attributes:

Name Type Description
PREMULTIPLY
NO_PREMULTIPLY
NO_ALPHA
ALPHA_ONLY
GUESS
ALPHA_BINARY

SaveFormat

Bases: enum.Enum

All save formats.

Attributes:

Name Type Description
AVI
BMP
CINEON
DEEP
DPX
FLI
GIF
ILBM
JPG

jpeg

MKV

Mode=1017

MOV

Mode=1015

MP4

Mode=1016

PCX
PDF
PNG
PSD
SGI

Mode=16

SOFTIMAGE

Mode=10

SUNRASTER

sun

TGA

tga

TIFF

Mode=15

VPB
WEBM

Mode=1018

from_extension(extension: str) -> SaveFormat classmethod

Returns the correct tvpaint format value from a string extension.

Source code in pytvpaint/george/grg_base.py
340
341
342
343
344
345
346
347
348
@classmethod
def from_extension(cls, extension: str) -> SaveFormat:
    """Returns the correct tvpaint format value from a string extension."""
    extension = extension.replace(".", "").upper()
    if not hasattr(SaveFormat, extension):
        raise ValueError(
            f"Could not find format ({extension}) in accepted formats ({SaveFormat})"
        )
    return cast(SaveFormat, getattr(cls, extension.upper()))

is_image(extension: str) -> bool classmethod

Returns True if the extension correspond to an image format.

Source code in pytvpaint/george/grg_base.py
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
@classmethod
def is_image(cls, extension: str) -> bool:
    """Returns True if the extension correspond to an image format."""
    extension = extension.replace(".", "").lower()
    image_formats = [
        "bmp",
        "cin",
        "deep",
        "dpx",
        "ilbm",
        "jpg",
        "jpeg",
        "pcx",
        "png",
        "psd",
        "sgi",
        "pic",
        "ras",
        "sun",
        "tga",
        "tiff",
    ]
    return extension in image_formats

RGBColor(r: int, g: int, b: int) dataclass

RGB color with 0-255 range values.

HSLColor(h: int, s: int, l: int) dataclass

HSL color. Maximum values are (360, 100, 100) for h, s, l.

BlendingMode

Bases: enum.Enum

All the blending modes.

Attributes:

Name Type Description
COLOR
BEHIND
ERASE
SHADE
LIGHT
COLORIZE
HUE
SATURATION
VALUE
ADD
SUB
MULTIPLY
SCREEN
REPLACE
COPY
DIFFERENCE
DIVIDE
OVERLAY
OVERLAY2
LIGHT2
SHADE2
HARDLIGHT
SOFTLIGHT
GRAIN_EXTRACT
GRAIN_MERGE
SUB2
DARKEN
LIGHTEN

DrawingMode

Bases: enum.Enum

All the drawing modes.

Attributes:

Name Type Description
COLOR
BEHIND
ERASE
PANTO
MERGE
SHADE
LIGHT
COLORIZE
TINT
GRAIN
BLUR
NOISE
NEGATIVE
SHARP
EMBOSS
SOLARIZE
SATURATE
UNSATURATE
ADD
SUB
MULTIPLY
SCREEN
DIFF
HEALING
BURN
DODGE
DARKEN
LIGHTEN

MenuElement

Bases: enum.Enum

All the TVPaint menu elements.

Attributes:

Name Type Description
SHOW_UI
HIDE_UI
RESIZE_UI
CENTER_DISPLAY
FIT_DISPLAY
FRONT
BACK
ASPECT_RATIO
CLIP
PROJECT
XSHEET
NOTES

FileMode

Bases: enum.Enum

File mode save or load.

Attributes:

Name Type Description
SAVE
LOAD

TVPPenBrush(mode: DrawingMode, size: float, power: int, opacity: int, dry: bool, aaliasing: bool, gradient: bool, csize: str, cpower: str) dataclass

A TVPaint brush.

TVPSound(offset: float, volume: float, mute: bool, fade_in_start: float, fade_in_stop: float, fade_out_start: float, fade_out_stop: float, path: Path, sound_in: float, sound_out: float, color_index: int) dataclass

A TVPaint sound (clip and project).

undoable(func: T) -> T

Decorator to register actions in the TVPaint undo stack.

Source code in pytvpaint/george/grg_base.py
600
601
602
603
604
605
606
607
608
609
def undoable(func: T) -> T:
    """Decorator to register actions in the TVPaint undo stack."""

    def wrapper(*args: Any, **kwargs: Any) -> T:
        tv_undo_open_stack()
        res = func(*args, **kwargs)
        tv_undo_close_stack(func.__name__)
        return cast(T, res)

    return cast(T, wrapper)

undoable_stack() -> Generator[None, None, None]

Context manager that creates an undo stack. Useful to undo a sequence of George actions.

Source code in pytvpaint/george/grg_base.py
612
613
614
615
616
617
@contextlib.contextmanager
def undoable_stack() -> Generator[None, None, None]:
    """Context manager that creates an undo stack. Useful to undo a sequence of George actions."""
    tv_undo_open_stack()
    yield
    tv_undo_close_stack()

tv_warn(msg: str) -> None

Display a warning message.

Source code in pytvpaint/george/grg_base.py
620
621
622
def tv_warn(msg: str) -> None:
    """Display a warning message."""
    send_cmd("tv_Warn", msg)

tv_version() -> tuple[str, str, str]

Returns the software name, version and language.

Source code in pytvpaint/george/grg_base.py
625
626
627
628
629
630
631
632
633
634
def tv_version() -> tuple[str, str, str]:
    """Returns the software name, version and language."""
    cmd_fields = [
        ("software_name", str),
        ("version", str),
        ("language", str),
    ]
    res = tv_parse_list(send_cmd("tv_Version"), with_fields=cmd_fields)
    software_name, version, language = res.values()
    return software_name, version, language

tv_quit() -> None

Closes the TVPaint instance.

Source code in pytvpaint/george/grg_base.py
637
638
639
def tv_quit() -> None:
    """Closes the TVPaint instance."""
    send_cmd("tv_Quit")

tv_host2back() -> None

Minimize the TVPaint window.

Source code in pytvpaint/george/grg_base.py
642
643
644
def tv_host2back() -> None:
    """Minimize the TVPaint window."""
    send_cmd("tv_Host2Back")

tv_host2front() -> None

Restore the TVPaint window after being minimized.

Source code in pytvpaint/george/grg_base.py
647
648
649
def tv_host2front() -> None:
    """Restore the TVPaint window after being minimized."""
    send_cmd("tv_Host2Front")

tv_menu_hide() -> None

Switch to inlay view and hide all non-docking panels.

Source code in pytvpaint/george/grg_base.py
652
653
654
def tv_menu_hide() -> None:
    """Switch to inlay view and hide all non-docking panels."""
    send_cmd("tv_MenuHide")

add_some_magic(i_am_a_badass: bool = False, magic_number: int | None = None) -> None

Don't use ! Will change your life forever...

Source code in pytvpaint/george/grg_base.py
657
658
659
660
661
662
663
664
665
666
def add_some_magic(
    i_am_a_badass: bool = False, magic_number: int | None = None
) -> None:
    """Don't use ! Will change your life forever..."""
    if not i_am_a_badass:
        log.warning("Sorry, you're not enough of a badass for this function...")

    magic_number = magic_number or 14
    send_cmd("tv_MagicNumber", magic_number)
    log.info("Totally worth it, right ? ^^")

tv_menu_show(menu_element: MenuElement | None = None, *menu_options: Any, current: bool = False) -> None

For the complete documentation, see: https://www.tvpaint.com/doc/tvpaint-animation-11/george-commands#tv_menushow.

Source code in pytvpaint/george/grg_base.py
669
670
671
672
673
674
675
676
677
678
679
680
681
def tv_menu_show(
    menu_element: MenuElement | None = None, *menu_options: Any, current: bool = False
) -> None:
    """For the complete documentation, see: https://www.tvpaint.com/doc/tvpaint-animation-11/george-commands#tv_menushow."""
    cmd_args: list[str] = []

    if current:
        cmd_args.append("current")

    if menu_element:
        cmd_args.append(menu_element.value)

    send_cmd("tv_MenuShow", *cmd_args, *menu_options)

tv_request(msg: str, confirm_text: str = 'Yes', cancel_text: str = 'No') -> bool

Open a confirmation prompt with a message.

Parameters:

Name Type Description Default
msg str

the message to display

required
confirm_text str

the confirm button text. Defaults to "Yes".

'Yes'
cancel_text str

the cancel button text. Defaults to "No".

'No'

Returns:

Name Type Description
bool bool

True if clicked on "Yes"

Source code in pytvpaint/george/grg_base.py
684
685
686
687
688
689
690
691
692
693
694
695
def tv_request(msg: str, confirm_text: str = "Yes", cancel_text: str = "No") -> bool:
    """Open a confirmation prompt with a message.

    Args:
        msg: the message to display
        confirm_text: the confirm button text. Defaults to "Yes".
        cancel_text: the cancel button text. Defaults to "No".

    Returns:
        bool: True if clicked on "Yes"
    """
    return bool(int(send_cmd("tv_Request", msg, confirm_text, cancel_text)))

tv_req_num(value: int, min: int, max: int, title: str = 'Enter Value') -> int | None

Open a prompt to request an integer (within a range).

Parameters:

Name Type Description Default
value int

the initial value

required
min int

the minimum value

required
max int

the maximum value

required
title str

title of the prompt dialog. Defaults to "Enter Value".

'Enter Value'

Returns:

Type Description
int | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
def tv_req_num(
    value: int, min: int, max: int, title: str = "Enter Value"
) -> int | None:
    """Open a prompt to request an integer (within a range).

    Args:
        value: the initial value
        min: the minimum value
        max: the maximum value
        title: title of the prompt dialog. Defaults to "Enter Value".

    Returns:
        the value or None if cancelled
    """
    res = send_cmd("tv_ReqNum", value, min, max, title, handle_string=False)
    return None if res.lower() == "cancel" else int(res)

tv_req_angle(value: float, min: float, max: float, title: str = 'Enter Value') -> float | None

Open a prompt to request an angle (in degree).

Parameters:

Name Type Description Default
value float

the initial value

required
min float

the minimum value

required
max float

the maximum value

required
title str

title of the prompt. Defaults to "Enter Value".

'Enter Value'

Returns:

Type Description
float | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
def tv_req_angle(
    value: float, min: float, max: float, title: str = "Enter Value"
) -> float | None:
    """Open a prompt to request an angle (in degree).

    Args:
        value: the initial value
        min: the minimum value
        max: the maximum value
        title: title of the prompt. Defaults to "Enter Value".

    Returns:
        the value or None if cancelled
    """
    res = send_cmd("tv_ReqAngle", value, min, max, title, handle_string=False)
    return None if res.lower() == "cancel" else float(res)

tv_req_float(value: float, min: float, max: float, title: str = 'Enter value') -> float | None

Open a prompt to request a float.

Parameters:

Name Type Description Default
value float

the initial value

required
min float

the minimum value

required
max float

the maximum value

required
title str

title of the prompt. Defaults to "Enter Value".

'Enter value'

Returns:

Type Description
float | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
def tv_req_float(
    value: float, min: float, max: float, title: str = "Enter value"
) -> float | None:
    """Open a prompt to request a float.

    Args:
        value: the initial value
        min: the minimum value
        max: the maximum value
        title: title of the prompt. Defaults to "Enter Value".

    Returns:
        the value or None if cancelled
    """
    res = send_cmd("tv_ReqFloat", value, min, max, title, handle_string=False)
    return None if res.lower() == "cancel" else float(res)

tv_req_string(title: str, text: str) -> str | None

Open a prompt to request a string.

Parameters:

Name Type Description Default
title str

title of the requester. Defaults to "Enter Value".

required
text str

the initial value

required

Returns:

Type Description
str | None

the value or None if cancelled

Source code in pytvpaint/george/grg_base.py
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
def tv_req_string(title: str, text: str) -> str | None:
    """Open a prompt to request a string.

    Args:
        title: title of the requester. Defaults to "Enter Value".
        text: the initial value

    Returns:
        the value or None if cancelled
    """
    cmd_args = ["|".join([title, text])]
    if "\n" in text:
        cmd_args.insert(0, "multiline")
    res = send_cmd("tv_ReqString", *cmd_args, handle_string=False)
    return None if res.lower() == "cancel" else res

tv_list_request(entries: list[Entry]) -> tuple[int, str]

Open a prompt to request a selection in a list.

Parameters:

Name Type Description Default
entries list[pytvpaint.george.grg_base.Entry]

the list of entries (either a single entry or sub entries)

required

Returns:

Type Description
tuple[int, str]

the position, the entry

Source code in pytvpaint/george/grg_base.py
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
def tv_list_request(entries: list[Entry]) -> tuple[int, str]:
    """Open a prompt to request a selection in a list.

    Args:
        entries: the list of entries (either a single entry or sub entries)

    Returns:
        the position, the entry
    """
    entries_str = "|".join(map(_entry_to_str, entries))
    res = send_cmd("tv_ListRequest", entries_str, error_values=["-1 Cancel"])
    res_obj = tv_parse_list(
        res,
        with_fields=[
            ("index", int),
            ("entry", str),
        ],
    )
    index, entry = tuple(res_obj.values())
    return int(index), entry

tv_req_file(mode: FileMode, title: str = '', working_dir: Path | str | None = None, default_name: str | None = None, extension_filter: str | None = None) -> Path | None

Open a prompt to request a file.

Parameters:

Name Type Description Default
mode pytvpaint.george.grg_base.FileMode

save or load

required
title str

the title of the request

''
working_dir pathlib.Path | str | None

the default folder to go. Defaults to None.

None
default_name str | None

the default name. Defaults to None.

None
extension_filter str | None

display the files with this extension. Defaults to None.

None

Returns:

Type Description
pathlib.Path | None

the choosen path or None if cancelled

Source code in pytvpaint/george/grg_base.py
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
def tv_req_file(
    mode: FileMode,
    title: str = "",
    working_dir: Path | str | None = None,
    default_name: str | None = None,
    extension_filter: str | None = None,
) -> Path | None:
    """Open a prompt to request a file.

    Args:
        mode: save or load
        title: the title of the request
        working_dir: the default folder to go. Defaults to None.
        default_name: the default name. Defaults to None.
        extension_filter: display the files with this extension. Defaults to None.

    Returns:
        the choosen path or None if cancelled
    """
    cmd_args = [
        title,
        Path(working_dir).as_posix() if working_dir else None,
        default_name,
        extension_filter,
    ]

    arg_str = "|".join([v if v is not None else "" for v in cmd_args])
    res = send_cmd("tv_ReqFile", f"{mode.value} {arg_str}", handle_string=False)

    return None if res.lower() == "cancel" else Path(res)

tv_undo() -> None

Do an undo.

Source code in pytvpaint/george/grg_base.py
835
836
837
def tv_undo() -> None:
    """Do an undo."""
    send_cmd("tv_Undo")

tv_update_undo() -> None

Copies the contents of the current image in the current layer into the buffer undo memory.

None of the draw commands described in this section updates this buffer memory. If you click on the Undo button after executing a George program, everything that the program has drawn in your image will be deleted. With this function you can update the undo buffer memory whenever you wish (for example at the beginning of the program).

Source code in pytvpaint/george/grg_base.py
840
841
842
843
844
845
846
847
def tv_update_undo() -> None:
    """Copies the contents of the current image in the current layer into the buffer undo memory.

    None of the draw commands described in this section updates this buffer memory.
    If you click on the Undo button after executing a George program, everything that the program has drawn in your image will be deleted.
    With this function you can update the undo buffer memory whenever you wish (for example at the beginning of the program).
    """
    send_cmd("tv_UpdateUndo")

tv_undo_open_stack() -> None

Open an 'undo' stack.

Surround a piece of code with tv_undoopenstack ... tv_undoclosestack, then multiple undo will be added to this stack, and closing this stack will undo everything inside. (To be sure the script returns to the expected result use tv_updateundo before tv_undoopenstack)

Source code in pytvpaint/george/grg_base.py
850
851
852
853
854
855
856
def tv_undo_open_stack() -> None:
    """Open an 'undo' stack.

    Surround a piece of code with tv_undoopenstack ... tv_undoclosestack, then multiple undo will be added to this stack, and closing this stack will undo everything inside.
    (To be sure the script returns to the expected result use tv_updateundo before tv_undoopenstack)
    """
    send_cmd("tv_UndoOpenStack")

tv_undo_close_stack(name: str = '') -> None

Close an 'undo' stack (See tv_undo_open_stack).

Source code in pytvpaint/george/grg_base.py
859
860
861
def tv_undo_close_stack(name: str = "") -> None:
    """Close an 'undo' stack (See tv_undo_open_stack)."""
    send_cmd("tv_UndoCloseStack", name)

tv_save_mode_get() -> tuple[SaveFormat, list[str]]

Get the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
864
865
866
867
868
869
def tv_save_mode_get() -> tuple[SaveFormat, list[str]]:
    """Get the saving alpha mode."""
    res = send_cmd("tv_SaveMode")
    res_split = res.split()
    save_format = tv_cast_to_type(res_split.pop(0), SaveFormat)
    return save_format, res_split

tv_save_mode_set(save_format: SaveFormat, *format_options: str | int | float) -> None

Set the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
872
873
874
875
876
def tv_save_mode_set(
    save_format: SaveFormat, *format_options: str | int | float
) -> None:
    """Set the saving alpha mode."""
    send_cmd("tv_SaveMode", save_format.value, *format_options)

tv_alpha_load_mode_get() -> AlphaMode

Set the loading alpha mode.

Source code in pytvpaint/george/grg_base.py
879
880
881
882
def tv_alpha_load_mode_get() -> AlphaMode:
    """Set the loading alpha mode."""
    res = send_cmd("tv_AlphaLoadMode")
    return tv_cast_to_type(res, AlphaMode)

tv_alpha_load_mode_set(mode: AlphaMode) -> None

Get the loading alpha mode.

Source code in pytvpaint/george/grg_base.py
885
886
887
def tv_alpha_load_mode_set(mode: AlphaMode) -> None:
    """Get the loading alpha mode."""
    send_cmd("tv_AlphaLoadMode", mode.value)

tv_alpha_save_mode_get() -> AlphaSaveMode

Get the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
890
891
892
893
def tv_alpha_save_mode_get() -> AlphaSaveMode:
    """Get the saving alpha mode."""
    res = send_cmd("tv_AlphaSaveMode")
    return tv_cast_to_type(res, AlphaSaveMode)

tv_alpha_save_mode_set(mode: AlphaSaveMode) -> None

Set the saving alpha mode.

Source code in pytvpaint/george/grg_base.py
896
897
898
def tv_alpha_save_mode_set(mode: AlphaSaveMode) -> None:
    """Set the saving alpha mode."""
    send_cmd("tv_AlphaSaveMode", mode.value)

tv_mark_in_get(reference: MarkReference) -> tuple[int, MarkAction]

Get markin of the project / clip.

Source code in pytvpaint/george/grg_base.py
901
902
903
904
905
def tv_mark_in_get(
    reference: MarkReference,
) -> tuple[int, MarkAction]:
    """Get markin of the project / clip."""
    return _tv_mark(MarkType.MARKIN, reference)

tv_mark_in_set(reference: MarkReference, frame: int | None, action: MarkAction) -> tuple[int, MarkAction]

Set markin of the project / clip.

Source code in pytvpaint/george/grg_base.py
908
909
910
911
912
913
914
def tv_mark_in_set(
    reference: MarkReference,
    frame: int | None,
    action: MarkAction,
) -> tuple[int, MarkAction]:
    """Set markin of the project / clip."""
    return _tv_mark(MarkType.MARKIN, reference, frame, action)

tv_mark_out_get(reference: MarkReference) -> tuple[int, MarkAction]

Get markout of the project / clip.

Source code in pytvpaint/george/grg_base.py
917
918
919
920
921
def tv_mark_out_get(
    reference: MarkReference,
) -> tuple[int, MarkAction]:
    """Get markout of the project / clip."""
    return _tv_mark(MarkType.MARKOUT, reference)

tv_mark_out_set(reference: MarkReference, frame: int | None, action: MarkAction) -> tuple[int, MarkAction]

Set markout of the project / clip.

Source code in pytvpaint/george/grg_base.py
924
925
926
927
928
def tv_mark_out_set(
    reference: MarkReference, frame: int | None, action: MarkAction
) -> tuple[int, MarkAction]:
    """Set markout of the project / clip."""
    return _tv_mark(MarkType.MARKOUT, reference, frame, action)

tv_get_active_shape() -> TVPShape

Get the current shape.

Source code in pytvpaint/george/grg_base.py
965
966
967
def tv_get_active_shape() -> TVPShape:
    """Get the current shape."""
    return tv_cast_to_type(send_cmd("tv_GetActiveShape"), TVPShape)

tv_set_active_shape(shape: TVPShape, **shape_kwargs: Any) -> None

Set the current shape and its tool parameters.

Parameters:

Name Type Description Default
shape pytvpaint.george.grg_base.TVPShape

the shape to set

required
**shape_kwargs typing.Any

the shape specific parameters as keyword arguments

{}
Source code in pytvpaint/george/grg_base.py
970
971
972
973
974
975
976
977
def tv_set_active_shape(shape: TVPShape, **shape_kwargs: Any) -> None:
    """Set the current shape and its tool parameters.

    Args:
        shape: the shape to set
        **shape_kwargs: the shape specific parameters as keyword arguments
    """
    send_cmd("tv_SetActiveShape", shape.value, *args_dict_to_list(shape_kwargs))

tv_set_a_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor

Set the APen RGBA color.

Source code in pytvpaint/george/grg_base.py
1027
1028
1029
def tv_set_a_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor:
    """Set the APen RGBA color."""
    return _tv_set_ab_pen("a", color.r, color.g, color.b, "rgb", a=alpha)

tv_set_a_pen_hsl(color: HSLColor) -> HSLColor

Set the A Pen HSL color.

Source code in pytvpaint/george/grg_base.py
1032
1033
1034
def tv_set_a_pen_hsl(color: HSLColor) -> HSLColor:
    """Set the A Pen HSL color."""
    return _tv_set_ab_pen("a", color.h, color.s, color.l, color_format="hsl")

tv_set_b_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor

Set the B Pen RGBA color.

Source code in pytvpaint/george/grg_base.py
1037
1038
1039
def tv_set_b_pen_rgba(color: RGBColor, alpha: int | None = None) -> RGBColor:
    """Set the B Pen RGBA color."""
    return _tv_set_ab_pen("b", color.r, color.g, color.b, color_format="rgb", a=alpha)

tv_set_b_pen_hsl(color: HSLColor) -> HSLColor

Set the B Pen HSL color.

Source code in pytvpaint/george/grg_base.py
1042
1043
1044
def tv_set_b_pen_hsl(color: HSLColor) -> HSLColor:
    """Set the B Pen HSL color."""
    return _tv_set_ab_pen("b", color.h, color.s, color.l, color_format="hsl")

tv_pen(size: float) -> float

Change current pen tool size. This function is most likely deprecated it is undocumented in the George reference but still works.

Source code in pytvpaint/george/grg_base.py
1047
1048
1049
1050
def tv_pen(size: float) -> float:
    """Change current pen tool size. This function is most likely deprecated it is undocumented in the George reference but still works."""
    res = tv_parse_dict(send_cmd("tv_Pen", size), with_fields=[("size", float)])
    return cast(float, res["size"])

tv_pen_brush_get(tool_mode: bool = False) -> TVPPenBrush

Get pen brush parameters.

Source code in pytvpaint/george/grg_base.py
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
def tv_pen_brush_get(tool_mode: bool = False) -> TVPPenBrush:
    """Get pen brush parameters."""
    args = ("toolmode", "backup") if tool_mode else ("backup",)
    result = send_cmd("tv_PenBrush", *args)

    # Remove the first value which is tv_penbrush
    result = result[len("tv_penbrush") + 1 :]

    res = tv_parse_dict(result, with_fields=TVPPenBrush)
    return TVPPenBrush(**res)

tv_pen_brush_set(mode: DrawingMode | None = None, size: int | None = None, opacity: int | None = None, tool_mode: bool = False, reset: bool = False) -> TVPPenBrush

Manage pen brush.

Source code in pytvpaint/george/grg_base.py
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
def tv_pen_brush_set(
    mode: DrawingMode | None = None,
    size: int | None = None,
    opacity: int | None = None,
    tool_mode: bool = False,
    reset: bool = False,
) -> TVPPenBrush:
    """Manage pen brush."""
    args = {
        "mode": mode.value if mode else None,
        "size": size,
        "opacity": opacity,
    }

    args_list = args_dict_to_list(args)

    if tool_mode:
        args_list.append("toolmode")
    if reset:
        args_list.append("reset")

    send_cmd("tv_PenBrush", *args_list)

    # Since TVPaint is returning only the values that were modified
    # this is almost impossible to parse so we call get
    return tv_pen_brush_get()

tv_line(xy1: tuple[int, int], xy2: tuple[int, int], right_click: bool = False, dry: bool = False) -> None

Draw a line (with the current brush).

Parameters:

Name Type Description Default
xy1 tuple[int, int]

start position as (x, y)

required
xy2 tuple[int, int]

end position as (x, y)

required
right_click bool

True to emulate right click, False to emulate left click. Default is False

False
dry bool

True for dry mode

False
Source code in pytvpaint/george/grg_base.py
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
def tv_line(
    xy1: tuple[int, int],
    xy2: tuple[int, int],
    right_click: bool = False,
    dry: bool = False,
) -> None:
    """Draw a line (with the current brush).

    Args:
        xy1: start position as (x, y)
        xy2: end position as (x, y)
        right_click: True to emulate right click, False to emulate left click. Default is False
        dry: True for dry mode
    """
    args = [
        *xy1,
        *xy2,
        bool(right_click),
        bool(dry),
    ]
    send_cmd("tv_Line", *args)

tv_text(text: str, x: int, y: int, use_b_pen: bool = False) -> None

Write text in a layer instance.

Parameters:

Name Type Description Default
text str

text to write

required
x int

text x position

required
y int

text y position

required
use_b_pen bool

True will use b pen, False will use A pen

False
Source code in pytvpaint/george/grg_base.py
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
def tv_text(text: str, x: int, y: int, use_b_pen: bool = False) -> None:
    """Write text in a layer instance.

    Args:
        text: text to write
        x: text x position
        y: text y position
        use_b_pen: True will use b pen, False will use A pen
    """
    send_cmd("tv_Text", x, y, int(use_b_pen), text)

tv_text_brush(text: str) -> None

Set the text for the text brush.

Parameters:

Name Type Description Default
text str

text to write

required
Source code in pytvpaint/george/grg_base.py
1128
1129
1130
1131
1132
1133
1134
def tv_text_brush(text: str) -> None:
    """Set the text for the text brush.

    Args:
        text: text to write
    """
    send_cmd("tv_TextBrush", text)

tv_rect(tlx: float, tly: float, brx: float, bry: float, button: RectButton | None = None) -> None

Draws an unfilled rectangle.

Parameters:

Name Type Description Default
tlx float

top left x coordinate

required
tly float

top left y coordinate

required
brx float

bottom right x coordinate

required
bry float

bottom right y coordinate

required
button pytvpaint.george.grg_base.RectButton | None

use left or right click button (left draws, right erases)

None
Source code in pytvpaint/george/grg_base.py
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
def tv_rect(
    tlx: float,
    tly: float,
    brx: float,
    bry: float,
    button: RectButton | None = None,
) -> None:
    """Draws an unfilled rectangle.

    Args:
        tlx: top left x coordinate
        tly: top left y coordinate
        brx: bottom right x coordinate
        bry: bottom right y coordinate
        button: use left or right click button (left draws, right erases)
    """
    args: list[float] = [tlx, tly, brx, bry]
    if button:
        args.append(button.value)
    send_cmd("tv_Rect", *args)

tv_rect_fill(tlx: float, tly: float, brx: float, bry: float, grx: float = 0, gry: float = 0, erase_mode: bool = False, tool_mode: bool = False) -> None

Draws a filled rectangle.

Parameters:

Name Type Description Default
tlx float

top left x coordinate

required
tly float

top left y coordinate

required
brx float

bottom right x coordinate

required
bry float

bottom right y coordinate

required
grx float

gradient vector x

0
gry float

gradient vector y

0
erase_mode bool

erase drawing mode

False
tool_mode bool

manage drawing mode

False
Source code in pytvpaint/george/grg_base.py
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
def tv_rect_fill(
    tlx: float,
    tly: float,
    brx: float,
    bry: float,
    grx: float = 0,
    gry: float = 0,
    erase_mode: bool = False,
    tool_mode: bool = False,
) -> None:
    """Draws a filled rectangle.

    Args:
        tlx: top left x coordinate
        tly: top left y coordinate
        brx: bottom right x coordinate
        bry: bottom right y coordinate
        grx: gradient vector x
        gry: gradient vector y
        erase_mode: erase drawing mode
        tool_mode: manage drawing mode
    """
    args: list[Any] = [tlx, tly, brx, bry, grx, gry, int(erase_mode)]
    if tool_mode:
        args.insert(0, "toolmode")
    send_cmd("tv_RectFill", *args)

tv_fast_line(x1: float, y1: float, x2: float, y2: float, r: int = 255, b: int = 255, g: int = 0, a: int = 255) -> None

Draw a line (1 pixel size and not antialiased).

Source code in pytvpaint/george/grg_base.py
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
def tv_fast_line(
    x1: float,
    y1: float,
    x2: float,
    y2: float,
    r: int = 255,
    b: int = 255,
    g: int = 0,
    a: int = 255,
) -> None:
    """Draw a line (1 pixel size and not antialiased)."""
    send_cmd("tv_fastline", x1, y1, x2, y2, r, g, b, a)