Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions pglet/barchart.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
from typing import Optional, Union, Literal
from typing import Optional, Union
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal

from beartype import beartype

from pglet.control import Control


DATA_MODE = Literal["default", "fraction", "percentage", None]
DataMode = Literal["default", "fraction", "percentage", None]


class BarChart(Control):
def __init__(
self,
id=None,
tooltips=None,
data_mode: DATA_MODE = None,
data_mode: DataMode = None,
points=None,
width=None,
height=None,
Expand Down Expand Up @@ -65,7 +71,7 @@ def data_mode(self):

@data_mode.setter
@beartype
def data_mode(self, value: DATA_MODE):
def data_mode(self, value: DataMode):
self._set_attr("dataMode", value)

def _get_children(self):
Expand Down
14 changes: 10 additions & 4 deletions pglet/callout.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from typing import Literal, Optional
from typing import Optional
try:
from typing import Literal
except:
from typing_extensions import Literal

from beartype import beartype

from pglet.control import Control

POSITION = Literal[
Position = Literal[
None,
"topLeft",
"topCenter",
Expand All @@ -26,7 +32,7 @@ def __init__(
self,
id=None,
target=None,
position: POSITION = None,
position: Position = None,
gap=None,
beak=None,
beak_width=None,
Expand Down Expand Up @@ -105,7 +111,7 @@ def position(self):

@position.setter
@beartype
def position(self, value: POSITION):
def position(self, value: Position):
self._set_attr("position", value)

# gap
Expand Down
14 changes: 10 additions & 4 deletions pglet/checkbox.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from typing import Literal, Optional
from typing import Optional
try:
from typing import Literal
except:
from typing_extensions import Literal

from beartype import beartype

from pglet.control import Control

BOX_SIDE = Literal[None, "start", "end"]
BoxSide = Literal[None, "start", "end"]


class Checkbox(Control):
Expand All @@ -12,7 +18,7 @@ def __init__(
id=None,
value=None,
value_field=None,
box_side: BOX_SIDE = None,
box_side: BoxSide = None,
focused=None,
data=None,
width=None,
Expand Down Expand Up @@ -89,7 +95,7 @@ def box_side(self):

@box_side.setter
@beartype
def box_side(self, value: BOX_SIDE):
def box_side(self, value: BoxSide):
self._set_attr("boxSide", value)

# focused
Expand Down
12 changes: 8 additions & 4 deletions pglet/combobox.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from typing import List, Literal, Optional
from typing import List, Optional
try:
from typing import Literal
except:
from typing_extensions import Literal

from beartype import beartype

from pglet.control import Control

ITEM_TYPE = Literal[None, "normal", "divider", "header", "selectAll", "select_all"]
ItemType = Literal[None, "normal", "divider", "header", "selectAll", "select_all"]


class ComboBox(Control):
Expand Down Expand Up @@ -183,7 +187,7 @@ def on_blur(self, handler):


class Option(Control):
def __init__(self, key=None, text=None, item_type: ITEM_TYPE = None, disabled=None):
def __init__(self, key=None, text=None, item_type: ItemType = None, disabled=None):
Control.__init__(self)
assert key != None or text != None, "key or text must be specified"
self.key = key
Expand Down Expand Up @@ -219,7 +223,7 @@ def item_type(self):

@item_type.setter
@beartype
def item_type(self, value: ITEM_TYPE):
def item_type(self, value: ItemType):
self._set_attr("itemtype", value)

# disabled
Expand Down
1 change: 0 additions & 1 deletion pglet/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import threading
import uuid

from pglet.event import Event
from pglet.protocol import *
from pglet.reconnecting_websocket import ReconnectingWebSocket

Expand Down
16 changes: 11 additions & 5 deletions pglet/control.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import datetime as dt
import threading
from typing import Literal, Optional
from beartype import beartype
from typing import Optional
from difflib import SequenceMatcher

try:
from typing import Literal
except:
from typing_extensions import Literal

from beartype import beartype

from pglet.protocol import Command

BORDER_STYLE = Literal[
BorderStyle = Literal[
None, "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"
]

TEXT_SIZE = Literal[
TextSize = Literal[
None,
"tiny",
"xSmall",
Expand All @@ -25,7 +31,7 @@
"mega",
]

TEXT_ALIGN = Literal[None, "left", "right", "center", "justify"]
TextAlign = Literal[None, "left", "right", "center", "justify"]


class Control:
Expand Down
14 changes: 10 additions & 4 deletions pglet/dialog.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from typing import Literal, Optional
from typing import Optional
try:
from typing import Literal
except:
from typing_extensions import Literal

from beartype import beartype

from pglet.control import Control

TYPE = Literal[None, "normal", "largeHeader", "close"]
DialogType = Literal[None, "normal", "largeHeader", "close"]


class Dialog(Control):
Expand All @@ -12,7 +18,7 @@ def __init__(
open=None,
title=None,
sub_text=None,
type: TYPE = None,
type: DialogType = None,
auto_dismiss=None,
width=None,
max_width=None,
Expand Down Expand Up @@ -117,7 +123,7 @@ def type(self):

@type.setter
@beartype
def type(self, value: TYPE):
def type(self, value: DialogType):
self._set_attr("type", value)

# auto_dismiss
Expand Down
12 changes: 8 additions & 4 deletions pglet/dropdown.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from typing import Literal, Optional
from typing import Optional
try:
from typing import Literal
except:
from typing_extensions import Literal

from beartype import beartype

from pglet.control import Control

ITEM_TYPE = Literal[None, "normal", "divider", "header"]
ItemType = Literal[None, "normal", "divider", "header"]


class Dropdown(Control):
Expand Down Expand Up @@ -142,7 +146,7 @@ def on_blur(self, handler):


class Option(Control):
def __init__(self, key=None, text=None, item_type: ITEM_TYPE = None, disabled=None):
def __init__(self, key=None, text=None, item_type: ItemType = None, disabled=None):
Control.__init__(self)
assert key != None or text != None, "key or text must be specified"
self.key = key
Expand Down Expand Up @@ -178,7 +182,7 @@ def item_type(self):

@item_type.setter
@beartype
def item_type(self, value: ITEM_TYPE):
def item_type(self, value: ItemType):
self._set_attr("itemtype", value)

# disabled
Expand Down
25 changes: 15 additions & 10 deletions pglet/grid.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
from __future__ import annotations

from typing import Literal, Optional
from typing import Optional
try:
from typing import Literal
except:
from typing_extensions import Literal

from beartype import beartype

from pglet.control import Control

SELECTION_MODE = Literal[None, "single", "multiple"]
SORTABLE = Literal[None, "string", "number", False]
SORTED = Literal[None, False, "asc", "desc"]
SelectionMode = Literal[None, "single", "multiple"]
Sortable = Literal[None, "string", "number", False]
Sorted = Literal[None, False, "asc", "desc"]


class Grid(Control):
def __init__(
self,
id=None,
selection_mode: SELECTION_MODE = None,
selection_mode: SelectionMode = None,
compact=None,
header_visible=None,
shimmer_lines=None,
Expand Down Expand Up @@ -116,7 +121,7 @@ def selection_mode(self):

@selection_mode.setter
@beartype
def selection_mode(self, value: SELECTION_MODE):
def selection_mode(self, value: SelectionMode):
self._set_attr("selection", value)

# compact
Expand Down Expand Up @@ -228,9 +233,9 @@ def __init__(
icon=None,
icon_only=None,
field_name=None,
sortable: SORTABLE = None,
sortable: Sortable = None,
sort_field=None,
sorted: SORTED = None,
sorted: Sorted = None,
resizable=None,
min_width=None,
max_width=None,
Expand Down Expand Up @@ -300,7 +305,7 @@ def sortable(self):

@sortable.setter
@beartype
def sortable(self, value: SORTABLE):
def sortable(self, value: Sortable):
self._set_attr("sortable", value)

# sort_field
Expand All @@ -319,7 +324,7 @@ def sorted(self):

@sorted.setter
@beartype
def sorted(self, value: SORTED):
def sorted(self, value: Sorted):
self._set_attr("sorted", value)

# resizable
Expand Down
Loading