Merge pull request #441 from MikeTheWatchGuy/Dev-latest

NEW PopupQuick call - a non-blocking, self-closing popup
This commit is contained in:
MikeTheWatchGuy 2018-10-07 15:32:10 -04:00 committed by GitHub
commit 5aa2565651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 10 deletions

View File

@ -619,7 +619,6 @@ class Listbox(Element):
self.Values = values self.Values = values
def SetValue(self, values): def SetValue(self, values):
for index, item in enumerate(self.Values): for index, item in enumerate(self.Values):
try: try:
@ -630,6 +629,9 @@ class Listbox(Element):
except: pass except: pass
self.DefaultValues = values self.DefaultValues = values
def GetListValues(self):
return self.Values
def __del__(self): def __del__(self):
try: try:
self.TKListBox.__del__() self.TKListBox.__del__()
@ -2088,11 +2090,9 @@ class ErrorElement(Element):
return self return self
def MenuItemChosenCallback(self, item_chosen): def Get(self):
# print('IN MENU ITEM CALLBACK', item_chosen) return 'This is NOT a valid Element!\nSTOP trying to do things with it or I will have to crash at some point!'
self.ParentForm.LastButtonClicked = item_chosen
self.ParentForm.FormRemainedOpen = True
self.ParentForm.TKroot.quit() # kick the users out of the mainloop
def __del__(self): def __del__(self):
super().__del__() super().__del__()
@ -2237,6 +2237,9 @@ class Window:
else: else:
window = self window = self
if window: if window:
if window.NonBlocking:
self.CloseNonBlockingForm()
else:
window._Close() window._Close()
self.TKroot.quit() self.TKroot.quit()
self.RootNeedsDestroying = True self.RootNeedsDestroying = True
@ -2482,6 +2485,14 @@ class UberForm():
def __del__(self): def __del__(self):
return return
# ################################################################################
# ################################################################################
# END OF ELEMENT DEFINITIONS
# ################################################################################
# ################################################################################
# =========================================================================== # # =========================================================================== #
# Button Lazy Functions so the caller doesn't have to define a bunch of stuff # # Button Lazy Functions so the caller doesn't have to define a bunch of stuff #
# =========================================================================== # # =========================================================================== #
@ -3170,7 +3181,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TooltipObject = ToolTip(element.TKOptionMenu, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME) element.TooltipObject = ToolTip(element.TKOptionMenu, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
# ------------------------- LISTBOX element ------------------------- # # ------------------------- LISTBOX element ------------------------- #
elif element_type == ELEM_TYPE_INPUT_LISTBOX: elif element_type == ELEM_TYPE_INPUT_LISTBOX:
max_line_len = max([len(str(l)) for l in element.Values]) max_line_len = max([len(str(l)) for l in element.Values]) if len(element.Values) != 0 else 0
if auto_size_text is False: width=element_size[0] if auto_size_text is False: width=element_size[0]
else: width = max_line_len else: width = max_line_len
listbox_frame = tk.Frame(tk_row_frame) listbox_frame = tk.Frame(tk_row_frame)
@ -4664,6 +4675,33 @@ def PopupNonBlocking(*args, button_type=POPUP_BUTTONS_OK, button_color=None, bac
PopupNoWait = PopupNonBlocking PopupNoWait = PopupNonBlocking
# --------------------------- PopupQuick - a NonBlocking, Self-closing Popup ---------------------------
def PopupQuick(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None, auto_close=True, auto_close_duration=1, non_blocking=True, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None,None)):
"""
Show Popup box that doesn't block and closes itself
:param args:
:param button_type:
:param button_color:
:param background_color:
:param text_color:
:param auto_close:
:param auto_close_duration:
:param non_blocking:
:param icon:
:param line_width:
:param font:
:param no_titlebar:
:param grab_anywhere:
:param keep_on_top:
:param location:
:return:
"""
Popup(*args, button_color=button_color, background_color=background_color, text_color=text_color, button_type=button_type,
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon, line_width=line_width,
font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
# --------------------------- PopupNoTitlebar --------------------------- # --------------------------- PopupNoTitlebar ---------------------------
def PopupNoTitlebar(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None, auto_close=False, auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None, grab_anywhere=True, keep_on_top=False, location=(None,None)): def PopupNoTitlebar(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None, auto_close=False, auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None, grab_anywhere=True, keep_on_top=False, location=(None,None)):
""" """