MCPcopy Index your code
hub / github.com/Akascape/CTkCodeBox / __init__

Method __init__

CTkCodeBox/ctk_code_box.py:59–127  ·  view source on GitHub ↗
(self,
                 master,
                 language,
                 height=200,
                 theme:str="solarized-light",
                 line_numbering:bool=True,
                 numbering_color:str=None,
                 undo:bool=True,
                 menu:bool=True,
                 menu_fg_color:str=None,
                 menu_text_color:str=None,
                 menu_hover_color:str=None,
                 wrap:bool=True,
                 select_color:str=None,
                 cursor_color:str=None,
                 **kwargs)

Source from the content-addressed store, hash-verified

57 Widget for displaying code in CTk
58 """
59 def __init__(self,
60 master,
61 language,
62 height=200,
63 theme:str="solarized-light",
64 line_numbering:bool=True,
65 numbering_color:str=None,
66 undo:bool=True,
67 menu:bool=True,
68 menu_fg_color:str=None,
69 menu_text_color:str=None,
70 menu_hover_color:str=None,
71 wrap:bool=True,
72 select_color:str=None,
73 cursor_color:str=None,
74 **kwargs):
75
76 super().__init__(master, undo=undo, height=height, **kwargs)
77
78 if wrap:
79 self.configure(wrap="word")
80 if line_numbering:
81 AddLineNums(self, text_color=numbering_color)
82 if menu:
83 TextMenu(self, fg_color=menu_fg_color, text_color=menu_text_color, hover_color=menu_hover_color)
84
85 self.select_color = select_color
86 if select_color:
87 self._textbox.config(selectbackground=self.select_color)
88 self.cursor_color = cursor_color
89
90 if self.cursor_color:
91 self._textbox.config(insertbackground=self.cursor_color)
92
93 self.bind('<KeyRelease>', self.update_code) # When a key is released, update the code
94 self.bind('<<ContentChanged>>', self.update_code)
95 self.bind("<Control-a>", lambda e: self.after(200, self._select_all), add=True)
96
97 self.theme_name = theme
98 self.all_themes = list(get_all_styles())
99
100 self.common_langs = {
101 "python": python.PythonLexer,
102 "c": c_cpp.CLexer,
103 "cpp": c_cpp.CppLexer,
104 "c++": c_cpp.CppLexer,
105 "c#": dotnet.CSharpLexer,
106 "html": html.HtmlLexer,
107 "javascript": javascript.JavascriptLexer,
108 "xml": html.XmlLexer,
109 "css": css.CssLexer,
110 "json": data.JsonLexer,
111 "yaml": data.YamlLexer,
112 "go": go.GoLexer,
113 "typescript": javascript.TypeScriptLexer,
114 "kotlin": jvm.KotlinLexer,
115 "php": php.PhpLexer,
116 "ruby": ruby.RubyLexer,

Callers 1

__init__Method · 0.45

Calls 5

configureMethod · 0.95
check_lexerMethod · 0.95
configure_tagsMethod · 0.95
AddLineNumsClass · 0.85
TextMenuClass · 0.85

Tested by

no test coverage detected