Merge pull request #391 from MikeTheWatchGuy/Dev-latest

New Error Element
This commit is contained in:
MikeTheWatchGuy 2018-09-30 19:21:22 -04:00 committed by GitHub
commit 800f5721b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 2 deletions

View File

@ -204,6 +204,7 @@ ELEM_TYPE_MENUBAR = 600
ELEM_TYPE_PROGRESS_BAR = 200
ELEM_TYPE_BLANK = 100
ELEM_TYPE_TABLE = 700
ELEM_TYPE_ERROR = 666
# ------------------------- Popup Buttons Types ------------------------- #
POPUP_BUTTONS_YES_NO = 1
@ -1989,7 +1990,7 @@ class TKCalendar(ttk.Frame):
# ---------------------------------------------------------------------- #
# Canvas #
# Menu #
# ---------------------------------------------------------------------- #
class Menu(Element):
def __init__(self, menu_definition, background_color=None, size=(None, None), tearoff=True, pad=None, key=None):
@ -2043,6 +2044,35 @@ class Table(Element):
# ---------------------------------------------------------------------- #
# Error Element #
# ---------------------------------------------------------------------- #
class ErrorElement(Element):
def __init__(self, key=None):
self.Key = key
super().__init__(ELEM_TYPE_ERROR, key=key)
return
def Update(self, *args, **kwargs):
Popup('Keyword error', self.Key, 'Hey duffus, you gave me a bad key and now you\'re trying to do an update.', 'You need to stop this madness and check your spelling')
return
def MenuItemChosenCallback(self, item_chosen):
# print('IN MENU ITEM CALLBACK', item_chosen)
self.ParentForm.LastButtonClicked = item_chosen
self.ParentForm.FormRemainedOpen = True
self.ParentForm.TKroot.quit() # kick the users out of the mainloop
def __del__(self):
super().__del__()
# ------------------------------------------------------------------------- #
# Window CLASS #
@ -2188,6 +2218,7 @@ class Window:
except:
pass
def Read(self):
self.NonBlocking = False
if self.TKrootDestroyed:
@ -2208,6 +2239,7 @@ class Window:
else:
return self.ReturnValues
def ReadNonBlocking(self, Message=''):
if self.TKrootDestroyed:
return None, None
@ -2238,7 +2270,6 @@ class Window:
return self
def Refresh(self):
if self.TKrootDestroyed:
return
@ -2256,6 +2287,7 @@ class Window:
element = _FindElementFromKeyInSubForm(self, key)
if element is None:
print('*** WARNING = FindElement did not find the key. Please check your key\'s spelling ***')
return ErrorElement(key=key)
return element
def SaveToDisk(self, filename):