Browse Source

use Literal for input type

Falko Schindler 4 years ago
parent
commit
687dab470b
1 changed files with 6 additions and 2 deletions
  1. 6 2
      nice_gui/elements/input.py

+ 6 - 2
nice_gui/elements/input.py

@@ -1,11 +1,15 @@
 import justpy as jp
-from typing import Callable, Union
+from typing import Callable, Literal, Union
 from .element import Element
 from ..utils import handle_exceptions, provide_arguments
 
 class Input(Element):
 
-    def __init__(self, placeholder: str = None, value: Union[str, float] = None, type: str = 'text', on_change: Callable = None):
+    def __init__(self,
+                 placeholder: str = None,
+                 value: Union[str, float] = None,
+                 type: Literal['text', 'number'] = 'text',
+                 on_change: Callable = None):
 
         view = jp.QInput(placeholder=placeholder, type=type)