UNIFIED CODE BASE! Back to a single PySimpleGUI file that GENERATES the PySimpleGUI27.py file
This commit is contained in:
parent
da5c8f5bc8
commit
9d08739c73
|
@ -15,6 +15,7 @@ else:
|
||||||
import tkFont
|
import tkFont
|
||||||
import ScrolledText
|
import ScrolledText
|
||||||
|
|
||||||
|
import types
|
||||||
import datetime
|
import datetime
|
||||||
import textwrap
|
import textwrap
|
||||||
import pickle
|
import pickle
|
||||||
|
@ -2813,33 +2814,72 @@ def _FindElementFromKeyInSubForm(form, key):
|
||||||
return element
|
return element
|
||||||
|
|
||||||
|
|
||||||
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
|
|
||||||
if type(sub_menu_info) is str:
|
if sys.version_info[0] >= 3:
|
||||||
if not is_sub_menu and not skip:
|
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
|
||||||
# print(f'Adding command {sub_menu_info}')
|
if type(sub_menu_info) is str:
|
||||||
pos = sub_menu_info.find('&')
|
if not is_sub_menu and not skip:
|
||||||
if pos != -1:
|
# print(f'Adding command {sub_menu_info}')
|
||||||
if pos == 0 or sub_menu_info[pos-1] != "\\":
|
pos = sub_menu_info.find('&')
|
||||||
sub_menu_info = sub_menu_info[:pos] + sub_menu_info[pos+1:]
|
if pos != -1:
|
||||||
if sub_menu_info == '---':
|
if pos == 0 or sub_menu_info[pos - 1] != "\\":
|
||||||
top_menu.add('separator')
|
sub_menu_info = sub_menu_info[:pos] + sub_menu_info[pos + 1:]
|
||||||
else:
|
if sub_menu_info == '---':
|
||||||
top_menu.add_command(label=sub_menu_info, underline=pos, command=lambda: Menu.MenuItemChosenCallback(element, sub_menu_info))
|
top_menu.add('separator')
|
||||||
else:
|
else:
|
||||||
i = 0
|
top_menu.add_command(label=sub_menu_info, underline=pos,
|
||||||
while i < (len(sub_menu_info)):
|
command=lambda: Menu.MenuItemChosenCallback(element, sub_menu_info))
|
||||||
item = sub_menu_info[i]
|
else:
|
||||||
if i != len(sub_menu_info) - 1:
|
i = 0
|
||||||
if type(sub_menu_info[i+1]) == list:
|
while i < (len(sub_menu_info)):
|
||||||
new_menu = tk.Menu(top_menu, tearoff=element.Tearoff)
|
item = sub_menu_info[i]
|
||||||
top_menu.add_cascade(label=sub_menu_info[i], menu=new_menu)
|
if i != len(sub_menu_info) - 1:
|
||||||
AddMenuItem(new_menu, sub_menu_info[i+1], element, is_sub_menu=True)
|
if type(sub_menu_info[i + 1]) == list:
|
||||||
i += 1 # skip the next one
|
new_menu = tk.Menu(top_menu, tearoff=element.Tearoff)
|
||||||
|
pos = sub_menu_info[i].find('&')
|
||||||
|
if pos != -1:
|
||||||
|
if pos == 0 or sub_menu_info[i][pos - 1] != "\\":
|
||||||
|
sub_menu_info[i] = sub_menu_info[i][:pos] + sub_menu_info[i][pos + 1:]
|
||||||
|
top_menu.add_cascade(label=sub_menu_info[i], menu=new_menu, underline=pos)
|
||||||
|
AddMenuItem(new_menu, sub_menu_info[i + 1], element, is_sub_menu=True)
|
||||||
|
i += 1 # skip the next one
|
||||||
|
else:
|
||||||
|
AddMenuItem(top_menu, item, element)
|
||||||
else:
|
else:
|
||||||
AddMenuItem(top_menu, item, element)
|
AddMenuItem(top_menu, item, element)
|
||||||
else:
|
i += 1
|
||||||
AddMenuItem(top_menu, item, element)
|
else:
|
||||||
i += 1
|
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
|
||||||
|
if isinstance(sub_menu_info, types.StringType):
|
||||||
|
if not is_sub_menu and not skip:
|
||||||
|
# print(f'Adding command {sub_menu_info}')
|
||||||
|
pos = sub_menu_info.find('&')
|
||||||
|
if pos != -1:
|
||||||
|
if pos == 0 or sub_menu_info[pos-1] != "\\":
|
||||||
|
sub_menu_info = sub_menu_info[:pos] + sub_menu_info[pos+1:]
|
||||||
|
if sub_menu_info == '---':
|
||||||
|
top_menu.add('separator')
|
||||||
|
else:
|
||||||
|
top_menu.add_command(label=sub_menu_info, underline=pos, command=lambda: Menu.MenuItemChosenCallback(element, sub_menu_info))
|
||||||
|
else:
|
||||||
|
i = 0
|
||||||
|
while i < (len(sub_menu_info)):
|
||||||
|
item = sub_menu_info[i]
|
||||||
|
if i != len(sub_menu_info) - 1:
|
||||||
|
if not isinstance(sub_menu_info[i+1], types.StringType):
|
||||||
|
new_menu = tk.Menu(top_menu, tearoff=element.Tearoff)
|
||||||
|
pos = sub_menu_info[i].find('&')
|
||||||
|
if pos != -1:
|
||||||
|
if pos == 0 or sub_menu_info[i][pos - 1] != "\\":
|
||||||
|
sub_menu_info[i] = sub_menu_info[i][:pos] + sub_menu_info[i][pos + 1:]
|
||||||
|
top_menu.add_cascade(label=sub_menu_info[i], menu=new_menu, underline=pos)
|
||||||
|
AddMenuItem(new_menu, sub_menu_info[i + 1], element, is_sub_menu=True)
|
||||||
|
i += 1 # skip the next one
|
||||||
|
else:
|
||||||
|
AddMenuItem(top_menu, item, element)
|
||||||
|
else:
|
||||||
|
AddMenuItem(top_menu, item, element)
|
||||||
|
i += 1
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------------------------------ #
|
# ------------------------------------------------------------------------------------------------------------------ #
|
||||||
# ===================================== TK CODE STARTS HERE ====================================================== #
|
# ===================================== TK CODE STARTS HERE ====================================================== #
|
||||||
|
@ -3365,13 +3405,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
|
|
||||||
PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form)
|
PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form)
|
||||||
|
|
||||||
# element.TKNotebook.pack(side=tk.LEFT)
|
|
||||||
# if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None:
|
|
||||||
# element.TKNotebook.configure(background=element.BackgroundColor,
|
|
||||||
# highlightbackground=element.BackgroundColor,
|
|
||||||
# highlightcolor=element.BackgroundColor)
|
|
||||||
# if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None:
|
|
||||||
# element.TKNotebook.configure(foreground=element.TextColor)
|
|
||||||
if element.ChangeSubmits:
|
if element.ChangeSubmits:
|
||||||
element.TKNotebook.bind('<<NotebookTabChanged>>', element.TabGroupSelectHandler)
|
element.TKNotebook.bind('<<NotebookTabChanged>>', element.TabGroupSelectHandler)
|
||||||
if element.BorderWidth is not None:
|
if element.BorderWidth is not None:
|
||||||
|
|
1462
PySimpleGUI27.py
1462
PySimpleGUI27.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue