New DeleteFigure method for Graph Element, fix for 2.7 menus, Non-blocking Scrolled Popup
This commit is contained in:
parent
098de18d75
commit
69bd3a707e
|
@ -241,6 +241,7 @@ ELEM_TYPE_ERROR = 'error'
|
||||||
ELEM_TYPE_SEPARATOR = 'separator'
|
ELEM_TYPE_SEPARATOR = 'separator'
|
||||||
ELEM_TYPE_STATUSBAR = 'statusbar'
|
ELEM_TYPE_STATUSBAR = 'statusbar'
|
||||||
ELEM_TYPE_PANE = 'pane'
|
ELEM_TYPE_PANE = 'pane'
|
||||||
|
# STRETCH == ERROR ELEMENT as a filler
|
||||||
|
|
||||||
# ------------------------- Popup Buttons Types ------------------------- #
|
# ------------------------- Popup Buttons Types ------------------------- #
|
||||||
POPUP_BUTTONS_YES_NO = 1
|
POPUP_BUTTONS_YES_NO = 1
|
||||||
|
@ -1875,6 +1876,13 @@ class Graph(Element):
|
||||||
return None
|
return None
|
||||||
self._TKCanvas2.delete('all')
|
self._TKCanvas2.delete('all')
|
||||||
|
|
||||||
|
|
||||||
|
def DeleteFigure(self, id):
|
||||||
|
try:
|
||||||
|
self._TKCanvas2.delete(id)
|
||||||
|
except:
|
||||||
|
print('DeleteFigure - bad ID {}'.format(id))
|
||||||
|
|
||||||
def Update(self, background_color, visible=None):
|
def Update(self, background_color, visible=None):
|
||||||
if self._TKCanvas2 is None:
|
if self._TKCanvas2 is None:
|
||||||
print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
|
print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
|
||||||
|
@ -4274,7 +4282,7 @@ if sys.version_info[0] >= 3:
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
|
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
|
||||||
if isinstance(sub_menu_info, types.StringType):
|
if isinstance(sub_menu_info, (str,unicode)):
|
||||||
if not is_sub_menu and not skip:
|
if not is_sub_menu and not skip:
|
||||||
# print(f'Adding command {sub_menu_info}')
|
# print(f'Adding command {sub_menu_info}')
|
||||||
pos = sub_menu_info.find('&')
|
pos = sub_menu_info.find('&')
|
||||||
|
@ -4301,7 +4309,7 @@ else:
|
||||||
while i < (len(sub_menu_info)):
|
while i < (len(sub_menu_info)):
|
||||||
item = sub_menu_info[i]
|
item = sub_menu_info[i]
|
||||||
if i != len(sub_menu_info) - 1:
|
if i != len(sub_menu_info) - 1:
|
||||||
if not isinstance(sub_menu_info[i + 1], types.StringType):
|
if not isinstance(sub_menu_info[i + 1], (str, unicode)):
|
||||||
new_menu = tk.Menu(top_menu, tearoff=element.Tearoff)
|
new_menu = tk.Menu(top_menu, tearoff=element.Tearoff)
|
||||||
pos = sub_menu_info[i].find('&')
|
pos = sub_menu_info[i].find('&')
|
||||||
if pos != -1:
|
if pos != -1:
|
||||||
|
@ -5763,11 +5771,11 @@ def EasyPrintClose():
|
||||||
# ======================== Scrolled Text Box =====#
|
# ======================== Scrolled Text Box =====#
|
||||||
# ===================================================#
|
# ===================================================#
|
||||||
def PopupScrolled(*args, button_color=None, yes_no=False, auto_close=False, auto_close_duration=None,
|
def PopupScrolled(*args, button_color=None, yes_no=False, auto_close=False, auto_close_duration=None,
|
||||||
size=(None, None), location=(None, None)):
|
size=(None, None), location=(None, None), title=None, non_blocking=False):
|
||||||
if not args: return
|
if not args: return
|
||||||
width, height = size
|
width, height = size
|
||||||
width = width if width else MESSAGE_BOX_LINE_WIDTH
|
width = width if width else MESSAGE_BOX_LINE_WIDTH
|
||||||
form = Window(args[0], auto_size_text=True, button_color=button_color, auto_close=auto_close,
|
window = Window(title=title or args[0], auto_size_text=True, button_color=button_color, auto_close=auto_close,
|
||||||
auto_close_duration=auto_close_duration, location=location)
|
auto_close_duration=auto_close_duration, location=location)
|
||||||
max_line_total, max_line_width, total_lines, height_computed = 0, 0, 0, 0
|
max_line_total, max_line_width, total_lines, height_computed = 0, 0, 0, 0
|
||||||
complete_output = ''
|
complete_output = ''
|
||||||
|
@ -5786,18 +5794,19 @@ def PopupScrolled(*args, button_color=None, yes_no=False, auto_close=False, auto
|
||||||
height_computed = MAX_SCROLLED_TEXT_BOX_HEIGHT if height_computed > MAX_SCROLLED_TEXT_BOX_HEIGHT else height_computed
|
height_computed = MAX_SCROLLED_TEXT_BOX_HEIGHT if height_computed > MAX_SCROLLED_TEXT_BOX_HEIGHT else height_computed
|
||||||
if height:
|
if height:
|
||||||
height_computed = height
|
height_computed = height
|
||||||
form.AddRow(Multiline(complete_output, size=(max_line_width, height_computed)))
|
window.AddRow(Multiline(complete_output, size=(max_line_width, height_computed)))
|
||||||
pad = max_line_total - 15 if max_line_total > 15 else 1
|
pad = max_line_total - 15 if max_line_total > 15 else 1
|
||||||
# show either an OK or Yes/No depending on paramater
|
# show either an OK or Yes/No depending on paramater
|
||||||
|
button = DummyButton if non_blocking else Button
|
||||||
if yes_no:
|
if yes_no:
|
||||||
form.AddRow(Text('', size=(pad, 1), auto_size_text=False), Yes(), No())
|
window.AddRow(Text('', size=(pad, 1), auto_size_text=False), button('Yes'), button('No'))
|
||||||
button, values = form.Read()
|
|
||||||
form.Close()
|
|
||||||
return button
|
|
||||||
else:
|
else:
|
||||||
form.AddRow(Text('', size=(pad, 1), auto_size_text=False), Button('OK', size=(5, 1), button_color=button_color))
|
window.AddRow(Text('', size=(pad, 1), auto_size_text=False), button('OK', size=(5, 1), button_color=button_color))
|
||||||
button, values = form.Read()
|
|
||||||
form.Close()
|
if non_blocking:
|
||||||
|
button, values = window.Read(timeout=0)
|
||||||
|
else:
|
||||||
|
button, values = window.Read()
|
||||||
return button
|
return button
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue