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

Method create_page_highlight

Lib/idlelib/configdialog.py:461–714  ·  view source on GitHub ↗

Return frame of widgets for Highlights tab. Enable users to provisionally change foreground and background colors applied to textual tags. Color mappings are stored in complete listings called themes. Built-in themes in idlelib/config-highlight.def are fixed as far

(self)

Source from the content-addressed store, hash-verified

459 self.load_theme_cfg()
460
461 def create_page_highlight(self):
462 """Return frame of widgets for Highlights tab.
463
464 Enable users to provisionally change foreground and background
465 colors applied to textual tags. Color mappings are stored in
466 complete listings called themes. Built-in themes in
467 idlelib/config-highlight.def are fixed as far as the dialog is
468 concerned. Any theme can be used as the base for a new custom
469 theme, stored in .idlerc/config-highlight.cfg.
470
471 Function load_theme_cfg() initializes tk variables and theme
472 lists and calls paint_theme_sample() and set_highlight_target()
473 for the current theme. Radiobuttons builtin_theme_on and
474 custom_theme_on toggle var theme_source, which controls if the
475 current set of colors are from a builtin or custom theme.
476 DynOptionMenus builtinlist and customlist contain lists of the
477 builtin and custom themes, respectively, and the current item
478 from each list is stored in vars builtin_name and custom_name.
479
480 Function paint_theme_sample() applies the colors from the theme
481 to the tags in text widget highlight_sample and then invokes
482 set_color_sample(). Function set_highlight_target() sets the state
483 of the radiobuttons fg_on and bg_on based on the tag and it also
484 invokes set_color_sample().
485
486 Function set_color_sample() sets the background color for the frame
487 holding the color selector. This provides a larger visual of the
488 color for the current tag and plane (foreground/background).
489
490 Note: set_color_sample() is called from many places and is often
491 called more than once when a change is made. It is invoked when
492 foreground or background is selected (radiobuttons), from
493 paint_theme_sample() (theme is changed or load_cfg is called), and
494 from set_highlight_target() (target tag is changed or load_cfg called).
495
496 Button delete_custom invokes delete_custom() to delete
497 a custom theme from idleConf.userCfg['highlight'] and changes.
498 Button save_custom invokes save_as_new_theme() which calls
499 get_new_theme_name() and create_new() to save a custom theme
500 and its colors to idleConf.userCfg['highlight'].
501
502 Radiobuttons fg_on and bg_on toggle var fg_bg_toggle to control
503 if the current selected color for a tag is for the foreground or
504 background.
505
506 DynOptionMenu targetlist contains a readable description of the
507 tags applied to Python source within IDLE. Selecting one of the
508 tags from this list populates highlight_target, which has a callback
509 function set_highlight_target().
510
511 Text widget highlight_sample displays a block of text (which is
512 mock Python code) in which is embedded the defined tags and reflects
513 the color attributes of the current theme and changes for those tags.
514 Mouse button 1 allows for selection of a tag and updates
515 highlight_target with that tag value.
516
517 Note: The font in highlight_sample is set through the config in
518 the fonts tab.

Callers 1

__init__Method · 0.95

Calls 15

StringVarClass · 0.90
BooleanVarClass · 0.90
ScrollableTextFrameClass · 0.90
FrameClass · 0.90
ButtonClass · 0.90
DynOptionMenuClass · 0.90
RadiobuttonClass · 0.90
LabelClass · 0.90
LabelFrameClass · 0.85
strFunction · 0.85
addMethod · 0.45
configureMethod · 0.45

Tested by

no test coverage detected