pygui: updated canvas size and scale dialog to allow negative values for lon,lat,alt
This commit is contained in:
parent
12ed9c8422
commit
150db07497
2 changed files with 15 additions and 3 deletions
|
@ -183,7 +183,7 @@ class SizeAndScaleDialog(Dialog):
|
|||
frame,
|
||||
textvariable=self.lat,
|
||||
validate="key",
|
||||
validatecommand=(self.validation.positive_float, "%P"),
|
||||
validatecommand=(self.validation.float, "%P"),
|
||||
)
|
||||
entry.bind("<FocusOut>", lambda event: self.validation.focus_out(event, "0"))
|
||||
entry.grid(row=0, column=1, sticky="ew", padx=PADX)
|
||||
|
@ -194,7 +194,7 @@ class SizeAndScaleDialog(Dialog):
|
|||
frame,
|
||||
textvariable=self.lon,
|
||||
validate="key",
|
||||
validatecommand=(self.validation.positive_float, "%P"),
|
||||
validatecommand=(self.validation.float, "%P"),
|
||||
)
|
||||
entry.bind("<FocusOut>", lambda event: self.validation.focus_out(event, "0"))
|
||||
entry.grid(row=0, column=3, sticky="ew", padx=PADX)
|
||||
|
@ -205,7 +205,7 @@ class SizeAndScaleDialog(Dialog):
|
|||
frame,
|
||||
textvariable=self.alt,
|
||||
validate="key",
|
||||
validatecommand=(self.validation.positive_float, "%P"),
|
||||
validatecommand=(self.validation.float, "%P"),
|
||||
)
|
||||
entry.bind("<FocusOut>", lambda event: self.validation.focus_out(event, "0"))
|
||||
entry.grid(row=0, column=5, sticky="ew")
|
||||
|
|
|
@ -20,6 +20,7 @@ class InputValidation:
|
|||
self.master = app.master
|
||||
self.positive_int = None
|
||||
self.positive_float = None
|
||||
self.float = None
|
||||
self.app_scale = None
|
||||
self.name = None
|
||||
self.ip4 = None
|
||||
|
@ -30,6 +31,7 @@ class InputValidation:
|
|||
def register(self):
|
||||
self.positive_int = self.master.register(self.check_positive_int)
|
||||
self.positive_float = self.master.register(self.check_positive_float)
|
||||
self.float = self.master.register(self.check_float)
|
||||
self.app_scale = self.master.register(self.check_scale_value)
|
||||
self.name = self.master.register(self.check_node_name)
|
||||
self.ip4 = self.master.register(self.check_ip4)
|
||||
|
@ -63,6 +65,16 @@ class InputValidation:
|
|||
except ValueError:
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def check_float(cls, s: str) -> bool:
|
||||
if len(s) == 0:
|
||||
return True
|
||||
try:
|
||||
float(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def check_positive_float(cls, s: str) -> bool:
|
||||
if len(s) == 0:
|
||||
|
|
Loading…
Reference in a new issue