MCPcopy Index your code
hub / github.com/python/cpython / create_new

Method create_new

Lib/idlelib/configdialog.py:914–952  ·  view source on GitHub ↗

Create a new custom theme with the given name. Create the new theme based on the previously active theme with the current changes applied. Once it is saved, then activate the new theme. Attributes accessed: builtin_name custom_name

(self, new_theme_name)

Source from the content-addressed store, hash-verified

912 self.create_new(new_theme_name)
913
914 def create_new(self, new_theme_name):
915 """Create a new custom theme with the given name.
916
917 Create the new theme based on the previously active theme
918 with the current changes applied. Once it is saved, then
919 activate the new theme.
920
921 Attributes accessed:
922 builtin_name
923 custom_name
924
925 Attributes updated:
926 customlist
927 theme_source
928
929 Method:
930 save_new
931 set_theme_type
932 """
933 if self.theme_source.get():
934 theme_type = 'default'
935 theme_name = self.builtin_name.get()
936 else:
937 theme_type = 'user'
938 theme_name = self.custom_name.get()
939 new_theme = idleConf.GetThemeDict(theme_type, theme_name)
940 # Apply any of the old theme's unsaved changes to the new theme.
941 if theme_name in changes['highlight']:
942 theme_changes = changes['highlight'][theme_name]
943 for element in theme_changes:
944 new_theme[element] = theme_changes[element]
945 # Save the new theme.
946 self.save_new(new_theme_name, new_theme)
947 # Change GUI over to the new theme.
948 custom_theme_list = idleConf.GetSectionList('user', 'highlight')
949 custom_theme_list.sort()
950 self.customlist.SetMenu(custom_theme_list, new_theme_name)
951 self.theme_source.set(0)
952 self.set_theme_type()
953
954 def set_highlight_target(self):
955 """Set fg/bg toggle and color based on highlight tag target.

Callers 4

get_colorMethod · 0.95
save_as_new_themeMethod · 0.95

Calls 8

save_newMethod · 0.95
set_theme_typeMethod · 0.95
GetThemeDictMethod · 0.80
GetSectionListMethod · 0.80
SetMenuMethod · 0.80
getMethod · 0.45
sortMethod · 0.45
setMethod · 0.45

Tested by 2