text-console 1.0.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,134 @@
1
+ Copyright (c) 2024-2025 Ircama, EUPL-1.1
2
+
3
+ Corresponding SPDX licence: European Union Public License 1.1
4
+
5
+ Licence ID: EUPL-1.1
6
+
7
+ See also:
8
+ https://joinup.ec.europa.eu/sites/default/files/custom-page/attachment/eupl1.1…
9
+ https://opensource.org/licenses/EUPL-1.1
10
+ https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
11
+
12
+ Licence text
13
+
14
+ European Union Public Licence V. 1.1
15
+
16
+ EUPL (c) the European Community 2007
17
+
18
+ This European Union Public Licence (the "EUPL") applies to the Work or Software (as defined below) which is provided under the terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such use is covered by a right of the copyright holder of the Work).
19
+
20
+ The Original Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following notice immediately following the copyright notice for the Original Work:
21
+
22
+ Licensed under the EUPL V.1.1
23
+
24
+ or has expressed by any other mean his willingness to license under the EUPL.
25
+
26
+ 1. Definitions
27
+ In this Licence, the following terms have the following meaning:
28
+
29
+ - The Licence: this Licence.
30
+ - The Original Work or the Software: the software distributed and/or communicated by the Licensor under this Licence, available as Source Code and also as Executable Code as the case may be.
31
+ - Derivative Works: the works or software that could be created by the Licensee, based upon the Original Work or modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in the country mentioned in Article 15.
32
+ - The Work: the Original Work and/or its Derivative Works.
33
+ - The Source Code: the human-readable form of the Work which is the most convenient for people to study and modify.
34
+ - The Executable Code: any code which has generally been compiled and which is meant to be interpreted by a computer as a program.
35
+ - The Licensor: the natural or legal person that distributes and/or communicates the Work under the Licence.
36
+ - Contributor(s): any natural or legal person who modifies the Work under the Licence, or otherwise contributes to the creation of a Derivative Work.
37
+ - The Licensee or "You": any natural or legal person who makes any usage of the Software under the terms of the Licence.
38
+ - Distribution and/or Communication: any act of selling, giving, lending, renting, distributing, communicating, transmitting, or otherwise making available, on-line or off-line, copies of the Work or providing access to its essential functionalities at the disposal of any other natural or legal person.
39
+ 2. Scope of the rights granted by the Licence
40
+ The Licensor hereby grants You a world-wide, royalty-free, non-exclusive, sublicensable licence to do the following, for the duration of copyright vested in the Original Work:
41
+
42
+ - use the Work in any circumstance and for all usage,
43
+ - reproduce the Work,
44
+ - modify the Original Work, and make Derivative Works based upon the Work,
45
+ - communicate to the public, including the right to make available or display the Work or copies thereof to the public and perform publicly, as the case may be, the Work,
46
+ - distribute the Work or copies thereof,
47
+ - lend and rent the Work or copies thereof,
48
+ - sub-license rights in the Work or copies thereof.
49
+ Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the applicable law permits so.
50
+
51
+ In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed by law in order to make effective the licence of the economic rights here above listed.
52
+
53
+ The Licensor grants to the Licensee royalty-free, non exclusive usage rights to any patents held by the Licensor, to the extent necessary to make use of the rights granted on the Work under this Licence.
54
+
55
+ 3. Communication of the Source Code
56
+ The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to distribute and/or communicate the Work.
57
+
58
+ 4. Limitations on copyright
59
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the exclusive rights of the rights owners in the Original Work or Software, of the exhaustion of those rights or of other applicable limitations thereto.
60
+
61
+ 5. Obligations of the Licensee
62
+ The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those obligations are the following:
63
+
64
+ Attribution right: the Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the Licence with every copy of the Work he/she distributes and/or communicates. The Licensee must cause any Derivative Work to carry prominent notices stating that the Work has been modified and the date of modification.
65
+
66
+ Copyleft clause: If the Licensee distributes and/or communicates copies of the Original Works or Derivative Works based upon the Original Work, this Distribution and/or Communication will be done under the terms of this Licence or of a later version of this Licence unless the Original Work is expressly distributed only under this version of the Licence. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the Work or Derivative Work that alter or restrict the terms of the Licence.
67
+
68
+ Compatibility clause: If the Licensee Distributes and/or Communicates Derivative Works or copies thereof based upon both the Original Work and another work licensed under a Compatible Licence, this Distribution and/or Communication can be done under the terms of this Compatible Licence. For the sake of this clause, "Compatible Licence," refers to the licences listed in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
69
+
70
+ Provision of Source Code: When distributing and/or communicating copies of the Work, the Licensee will provide a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available for as long as the Licensee continues to distribute and/or communicate the Work.
71
+
72
+ Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the copyright notice.
73
+
74
+ 6. Chain of Authorship
75
+ The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence.
76
+
77
+ Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence.
78
+
79
+ Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions to the Work, under the terms of this Licence.
80
+
81
+ 7. Disclaimer of Warranty
82
+ The Work is a work in progress, which is continuously improved by numerous contributors. It is not a finished work and may therefore contain defects or "bugs" inherent to this type of software development.
83
+
84
+ For the above reason, the Work is provided under the Licence on an "as is" basis and without warranties of any kind concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this Licence.
85
+
86
+ This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
87
+
88
+ 8. Disclaimer of Liability
89
+ Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
90
+
91
+ 9. Additional agreements
92
+ While distributing the Original Work or Derivative Works, You may choose to conclude an additional agreement to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or services consistent with this Licence. However, in accepting such obligations, You may act only on your own behalf and on your sole responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by the fact You have accepted any such warranty or additional liability.
93
+
94
+ 10. Acceptance of the Licence
95
+ The provisions of this Licence can be accepted by clicking on an icon "I agree" placed under the bottom of a window displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms and conditions.
96
+
97
+ Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution and/or Communication by You of the Work or copies thereof.
98
+
99
+ 11. Information to the public
100
+ In case of any Distribution and/or Communication of the Work by means of electronic communication by You (for example, by offering to download the Work from a remote location) the distribution channel or media (for example, a website) must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence and the way it may be accessible, concluded, stored and reproduced by the Licensee.
101
+
102
+ 12. Termination of the Licence
103
+ The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms of the Licence. Such a termination will not terminate the licences of any person who has received the Work from the Licensee under the Licence, provided such persons remain in full compliance with the Licence.
104
+
105
+ 13. Miscellaneous
106
+ Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the Work licensed hereunder.
107
+
108
+ If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or enforceability of the Licence as a whole. Such provision will be construed and/or reformed so as necessary to make it valid and enforceable.
109
+
110
+ The European Commission may publish other linguistic versions and/or new versions of this Licence, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. New versions of the Licence will be published with a unique version number.
111
+
112
+ All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take advantage of the linguistic version of their choice.
113
+
114
+ 14. Jurisdiction
115
+ Any litigation resulting from the interpretation of this License, arising between the European Commission, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice of the European Communities, as laid down in article 238 of the Treaty establishing the European Community.
116
+
117
+ Any litigation arising between Parties, other than the European Commission, and resulting from the interpretation of this License, will be subject to the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
118
+
119
+ 15. Applicable Law
120
+ This Licence shall be governed by the law of the European Union country where the Licensor resides or has his registered office.
121
+
122
+ This licence shall be governed by the Belgian law if:
123
+
124
+ - a litigation arises between the European Commission, as a Licensor, and any Licensee;
125
+ - the Licensor, other than the European Commission, has no residence or registered office inside a European Union country.
126
+ Appendix
127
+
128
+ "Compatible Licences" according to article 5 EUPL are:
129
+
130
+ - GNU General Public License (GNU GPL) v. 2
131
+ - Open Software License (OSL) v. 2.1, v. 3.0
132
+ - Common Public License v. 1.0
133
+ - Eclipse Public License v. 1.0
134
+ - Cecill v. 2.0
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.1
2
+ Name: text_console
3
+ Version: 1.0.13
4
+ Summary: ('A customizable Tkinter-based text console widget, in which a user types in commands to be sent to the Python interpreter.',)
5
+ Home-page: https://github.com/Ircama/text_console
6
+ Author: Ircama
7
+ License: EUPL-1.2
8
+ Keywords: shell console tkinter
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Developers
16
+ Requires-Python: >3.6
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+
20
+ # text_console
21
+
22
+ A customizable Tkinter-based text console widget with support for command history and interactive execution, in which a user types in commands to be sent to the Python interpreter.
23
+
24
+ It includes options for overriding specific variables through subclassing, by extending the `TextConsole` class.
25
+
26
+ The package is installable via pip.
27
+
28
+ ## Features
29
+
30
+ - Tkinter-based package
31
+ - Customizable history file.
32
+ - Context menu with options for Cut, Copy, Paste, and Clear.
33
+ - Extendable for additional functionality.
34
+
35
+ The package provides flexibility to customize:
36
+
37
+ - `history_file`: Change the location of the history file
38
+ - `console_locals`: Add custom variables and functions to the console's namespace
39
+ - `context_menu_items`: Modify the right-click context menu
40
+ - `show_about_message`: Customize the about dialog content
41
+ - `show_help_content`: Customize the help window content
42
+ - `create_menu`: Override to completely customize the menu bar
43
+
44
+ Each of these can be customized by subclassing TextConsole and overriding the appropriate attributes or methods.
45
+
46
+
47
+ Full information and usage details at the [text_console GitHub repository](https://github.com/Ircama/text_console).
@@ -0,0 +1,203 @@
1
+ # text_console
2
+
3
+ A customizable Tkinter-based text console widget with support for command history and interactive execution, in which a user types in commands to be sent to the Python interpreter.
4
+
5
+ It includes options for overriding specific variables through subclassing, by extending the `TextConsole` class.
6
+
7
+ The package is installable via pip.
8
+
9
+ ## Features
10
+
11
+ - Tkinter-based package
12
+ - Customizable history file.
13
+ - Context menu with options for Cut, Copy, Paste, and Clear.
14
+ - Extendable for additional functionality.
15
+
16
+ The package provides flexibility to customize:
17
+
18
+ - `history_file`: Change the location of the history file
19
+ - `console_locals`: Add custom variables and functions to the console's namespace
20
+ - `context_menu_items`: Modify the right-click context menu
21
+ - `show_about_message`: Customize the about dialog content
22
+ - `show_help_content`: Customize the help window content
23
+ - `create_menu`: Override to completely customize the menu bar
24
+
25
+ Each of these can be customized by subclassing TextConsole and overriding the appropriate attributes or methods.
26
+
27
+ ## Installation
28
+
29
+ ### From pypi
30
+
31
+ ```bash
32
+ pip install text-console
33
+ ```
34
+
35
+ ### From sources
36
+
37
+ Navigate to the directory containing *setup.py*. Run:
38
+
39
+ ```
40
+ pip install .
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ ### Basic usage with default settings
46
+
47
+ ```python
48
+ import tkinter as tk
49
+ from text_console import TextConsole
50
+
51
+ class TkConsole(tk.Tk):
52
+ def __init__(self):
53
+ super().__init__()
54
+ self.title("Python Console")
55
+ self.geometry("800x400")
56
+
57
+ # Initialize the TextConsole widget
58
+ console = TextConsole(self, self)
59
+ console.pack(fill='both', expand=True)
60
+
61
+ # Configure grid resizing for the main window
62
+ self.grid_rowconfigure(0, weight=1)
63
+ self.grid_columnconfigure(0, weight=1)
64
+
65
+
66
+ app = TkConsole()
67
+ app.mainloop()
68
+ ```
69
+
70
+ ### Invoking TextConsole from a Master widget
71
+
72
+ ```python
73
+ import tkinter as tk
74
+ from text_console import TextConsole
75
+
76
+ class TkConsole(tk.Tk):
77
+ def __init__(self):
78
+ super().__init__()
79
+ self.title("Python Console")
80
+ self.geometry("100x70")
81
+
82
+ # Add a button to launch the TextConsole
83
+ run_console_button = tk.Button(
84
+ self,
85
+ text="Debug Console",
86
+ command=self.run_text_console
87
+ )
88
+ run_console_button.pack(pady=20) # Add some spacing around the button
89
+
90
+ # Configure grid resizing for the main window
91
+ self.grid_rowconfigure(0, weight=1)
92
+ self.grid_columnconfigure(0, weight=1)
93
+
94
+ def run_text_console(self):
95
+ """Launches the TextConsole in a new Toplevel window."""
96
+ console_window = tk.Toplevel(self)
97
+ console_window.title("Debug Console")
98
+ console_window.geometry("800x400")
99
+
100
+ # Initialize the TextConsole widget
101
+ console = TextConsole(self, console_window)
102
+ console.pack(fill='both', expand=True)
103
+
104
+ app = TkConsole()
105
+ app.mainloop()
106
+ ```
107
+
108
+ ### Customized console through subclassing
109
+
110
+ ```python
111
+ from text_console import TextConsole
112
+
113
+ class MyCustomConsole(TextConsole):
114
+
115
+ # Override class attributes
116
+ history_file = "my_custom_history.txt"
117
+
118
+ console_locals = {
119
+ "my_var": 42,
120
+ "my_function": lambda x: x * 2
121
+ }
122
+
123
+ context_menu_items = [
124
+ ("Custom Action", "custom_action"),
125
+ "-", # separator
126
+ ("Clear", "clear")
127
+ ]
128
+
129
+ show_about_message = "My Custom Console v1.0"
130
+ show_help_content = "This is my custom console help content"
131
+
132
+ def custom_action(self):
133
+ print("Custom action executed!")
134
+
135
+ def create_menu(self, master):
136
+ # Override to create a custom menu
137
+ super().create_menu(main, master)
138
+
139
+ # Add "Web Site" to the Help menu
140
+ menu_bar = master.nametowidget(master.cget('menu')) # Get the menu widget
141
+ help_menu = list(menu_bar.children.values())[2] # Access the Help menu (third = 2)
142
+ help_menu.insert_command(
143
+ help_menu.index("end"),
144
+ label="Web Site",
145
+ command=self.new_action
146
+ )
147
+
148
+ # Override to create a custom menu
149
+ menu_bar = Menu(master)
150
+ master.config(menu=menu_bar)
151
+
152
+ # Custom menu items
153
+ custom_menu = Menu(menu_bar, tearoff=0)
154
+ custom_menu.add_command(label="My Action", command=self.custom_action)
155
+ menu_bar.add_cascade(label="Custom", menu=custom_menu)
156
+
157
+ def new_action(self):
158
+ pass
159
+
160
+ """ Alternatively, override create_menu:
161
+ def create_menu(self, master):
162
+ # Override to create a custom menu
163
+ menu_bar = Menu(master)
164
+ master.config(menu=menu_bar)
165
+
166
+ # Custom menu items
167
+ custom_menu = Menu(menu_bar, tearoff=0)
168
+ custom_menu.add_command(label="My Action", command=self.custom_action)
169
+ menu_bar.add_cascade(label="Custom", menu=custom_menu)
170
+ """
171
+
172
+
173
+ # Use the custom console
174
+ text_console = MyCustomConsole(main, master)
175
+ ```
176
+
177
+ ## Key bindings
178
+
179
+ The text_console module provides the following key bindings for efficient navigation and interaction:
180
+
181
+ - `Ctrl + Enter (<Control-Return>)`
182
+
183
+ Submit a command while keeping the current context open.
184
+
185
+ - `Shift + Enter (<Shift-Return>)`
186
+
187
+ Insert a newline without triggering a default submission action.
188
+
189
+ - `Tab (<Tab>)`
190
+
191
+ Indent input.
192
+
193
+ - `Down Arrow (<Down>)`
194
+
195
+ Next command from the history.
196
+
197
+ - `Up Arrow (<Up>)`
198
+
199
+ Previous command from the history.
200
+
201
+ - `Right-Click (<Button-3>)`
202
+
203
+ Displays the context menu.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from setuptools import setup, find_packages
5
+ import re
6
+ import os
7
+ import sys
8
+
9
+ import json
10
+ from urllib import request
11
+ from pkg_resources import parse_version
12
+
13
+ ###########################################################################
14
+
15
+ END_OF_INTRODUCTION = '## Installation'
16
+
17
+ EPILOGUE = '''
18
+ Full information and usage details at the [text_console GitHub repository](https://github.com/Ircama/text_console).
19
+ '''
20
+
21
+ DESCRIPTION = (
22
+ "A customizable Tkinter-based text console widget,"
23
+ " in which a user types in commands"
24
+ " to be sent to the Python interpreter."
25
+ ),
26
+
27
+ PACKAGE_NAME = "text_console"
28
+
29
+ VERSIONFILE = "text_console/__version__.py"
30
+
31
+ ###########################################################################
32
+
33
+ def versions(pkg_name, site):
34
+ url = 'https://' + site + '.python.org/pypi/' + pkg_name + '/json'
35
+ try:
36
+ releases = json.loads(request.urlopen(url).read())['releases']
37
+ except Exception as e:
38
+ print("Error while getting data from URL '" + url + "': " + e)
39
+ return []
40
+ return sorted(releases, key=parse_version, reverse=True)
41
+
42
+ with open("README.md", "r") as readme:
43
+ long_description = readme.read()
44
+
45
+ build = ''
46
+ verstrline = open(VERSIONFILE, "rt").read()
47
+ VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
48
+ mo = re.search(VSRE, verstrline, re.M)
49
+ if mo:
50
+ verstr = mo.group(1)
51
+ else:
52
+ raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
53
+
54
+ if os.environ.get('GITHUB_RUN_NUMBER') is not None:
55
+ try:
56
+ version_list_pypi = [
57
+ a for a in versions(PACKAGE_NAME, 'pypi') if a.startswith(verstr)]
58
+ version_list_testpypi = [
59
+ a for a in versions(PACKAGE_NAME, 'testpypi') if a.startswith(verstr)]
60
+ if (version_list_pypi or
61
+ version_list_testpypi or
62
+ os.environ.get('GITHUB_FORCE_RUN_NUMBER') is not None):
63
+ print('---------------------------------'
64
+ '---------------------------------')
65
+ print("Using build number " + os.environ['GITHUB_RUN_NUMBER'])
66
+ if version_list_pypi:
67
+ print(
68
+ "Version list available in pypi: " +
69
+ ', '.join(version_list_pypi))
70
+ if version_list_testpypi:
71
+ print(
72
+ "Version list available in testpypi: " +
73
+ ', '.join(version_list_testpypi))
74
+ print('---------------------------------'
75
+ '---------------------------------')
76
+ verstr += '-' + os.environ['GITHUB_RUN_NUMBER']
77
+ except Exception as e:
78
+ print("Cannot use pypi or testpypi for getting the version:", e)
79
+
80
+
81
+ setup(
82
+ name=PACKAGE_NAME,
83
+ version=verstr,
84
+ description=(DESCRIPTION),
85
+ long_description=long_description[
86
+ :long_description.find(END_OF_INTRODUCTION)] + EPILOGUE,
87
+ long_description_content_type="text/markdown",
88
+ classifiers=[
89
+ "Programming Language :: Python :: 3",
90
+ "License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
91
+ "Topic :: Software Development :: Libraries :: Python Modules",
92
+ 'Programming Language :: Python :: 3 :: Only',
93
+ "Development Status :: 5 - Production/Stable",
94
+ "Operating System :: OS Independent",
95
+ "Intended Audience :: Developers",
96
+ ],
97
+ keywords=("shell console tkinter"),
98
+ author="Ircama",
99
+ url="https://github.com/Ircama/text_console",
100
+ license='EUPL-1.2',
101
+ packages=find_packages(),
102
+ entry_points={
103
+ 'console_scripts': [
104
+ 'text_console = text_console.__main__:main',
105
+ ]},
106
+ python_requires='>3.6'
107
+ )
@@ -0,0 +1,5 @@
1
+ from .text_console import TextConsole
2
+ from .history import History
3
+ from .__version__ import __version__
4
+
5
+ __all__ = ["TextConsole", "History"]
@@ -0,0 +1,73 @@
1
+ import sys
2
+ import argparse
3
+ import tkinter as tk
4
+ import webbrowser
5
+
6
+ from . import TextConsole
7
+ from .__version__ import __version__
8
+
9
+
10
+ class TkTextConsole(TextConsole):
11
+
12
+ """Subclass that adds the second element to the Help menu."""
13
+ def create_menu(self, main, master):
14
+ """Extend the menu creation logic."""
15
+ # Call the parent class implementation
16
+ super().create_menu(main, master)
17
+
18
+ # Add "Web Site" to the Help menu
19
+ menu_bar = master.nametowidget(master.cget('menu')) # Get the menu widget
20
+ help_menu = list(menu_bar.children.values())[2] # Access the Help menu (third = 2)
21
+ help_menu.insert_command(
22
+ help_menu.index("end"),
23
+ label="Web Site",
24
+ command=self.open_help_browser
25
+ )
26
+
27
+ def open_help_browser(self):
28
+ # Opens a web browser to a help URL
29
+ url = "https://ircama.github.io/text_console"
30
+ try:
31
+ ret = webbrowser.open(url)
32
+ except Exception as e:
33
+ pass
34
+
35
+
36
+ class TkConsole(tk.Tk):
37
+ """Main application class for the Tkinter console."""
38
+ def __init__(self):
39
+ super().__init__()
40
+ self.title("Python Console v" + __version__)
41
+ self.geometry("800x400")
42
+
43
+ # Initialize the TkTextConsole widget
44
+ console = TkTextConsole(self, self)
45
+ console.pack(fill='both', expand=True)
46
+
47
+ # Configure grid resizing for the main window
48
+ self.grid_rowconfigure(0, weight=1)
49
+ self.grid_columnconfigure(0, weight=1)
50
+
51
+
52
+ def main():
53
+ parser = argparse.ArgumentParser(
54
+ prog='Python Console',
55
+ epilog='A customizable Tkinter-based text console widget.')
56
+ parser.add_argument(
57
+ '-V',
58
+ "--version",
59
+ dest='version',
60
+ action='store_true',
61
+ help="Print version and exit")
62
+
63
+ args, unknown = parser.parse_known_args()
64
+ if args.version:
65
+ print(f'Python Console version {__version__}')
66
+ sys.exit(0)
67
+
68
+ app = TkConsole()
69
+ app.mainloop()
70
+
71
+
72
+ if __name__ == "__main__":
73
+ main()
@@ -0,0 +1 @@
1
+ __version__ = "1.0.13"
@@ -0,0 +1,28 @@
1
+ import os
2
+
3
+ class History(list):
4
+ def __init__(self, history_file=".console_history"):
5
+ super().__init__()
6
+ self.history_file = history_file
7
+
8
+ # Load history from the file
9
+ if os.path.exists(self.history_file):
10
+ with open(self.history_file, "r", encoding="utf-8") as file:
11
+ self.extend(line.strip() for line in file if line.strip())
12
+
13
+ def __getitem__(self, index):
14
+ try:
15
+ return super().__getitem__(index)
16
+ except IndexError:
17
+ return None
18
+
19
+ def append(self, item):
20
+ # Ensure only strings are added
21
+ if isinstance(item, list):
22
+ item = " ".join(item) # Convert list to string
23
+ super().append(item)
24
+
25
+ def save(self):
26
+ # Save history back to the file
27
+ with open(self.history_file, "w", encoding="utf-8") as file:
28
+ file.writelines(item + "\n" for item in self)
@@ -0,0 +1,529 @@
1
+ import sys
2
+ import re
3
+ import tkinter as tk
4
+ from tkinter import Menu, messagebox
5
+ import tkinter.font as tkfont
6
+ from code import InteractiveConsole
7
+ from io import StringIO
8
+ from contextlib import redirect_stdout, redirect_stderr
9
+
10
+ from .history import History
11
+ from .__version__ import __version__
12
+
13
+
14
+ class BaseTextConsole(tk.Text):
15
+ """Base class for the text console with customizable attributes"""
16
+
17
+ # Class attributes that can be overridden by subclasses
18
+ history_file = ".console_history"
19
+ console_locals = {}
20
+ context_menu_items = [
21
+ ("Cut", "cut"),
22
+ ("Copy", "copy"),
23
+ ("Paste", "paste"),
24
+ ("Clear", "clear")
25
+ ]
26
+ show_about_message = "Python Console v" + __version__
27
+ show_help_content = "Welcome to the Python Console"
28
+
29
+ def __init__(self, main, master, **kw):
30
+ kw.setdefault('width', 50)
31
+ kw.setdefault('wrap', 'word')
32
+ kw.setdefault('prompt1', '>>> ')
33
+ kw.setdefault('prompt2', '... ')
34
+ self._prompt1 = kw.pop('prompt1')
35
+ self._prompt2 = kw.pop('prompt2')
36
+ banner = kw.pop('banner', 'Python %s\n' % sys.version)
37
+
38
+ super().__init__(master, **kw)
39
+
40
+ # Initialize console with merged locals
41
+ merged_locals = {
42
+ "self": main,
43
+ "master": master,
44
+ "kw": kw,
45
+ "local": self
46
+ }
47
+ merged_locals.update(self.console_locals)
48
+ self._console = InteractiveConsole(locals=merged_locals)
49
+
50
+ # Initialize history
51
+ self.history = History(self.history_file)
52
+ self._hist_item = 0
53
+ self._hist_match = ''
54
+
55
+ self.setup_tags()
56
+ self.setup_bindings()
57
+ self.setup_context_menu()
58
+ self.create_menu(main, master)
59
+
60
+ # Initialize console display
61
+ self.insert('end', banner, 'banner')
62
+ self.prompt()
63
+ self.mark_set('input', 'insert')
64
+ self.mark_gravity('input', 'left')
65
+
66
+ def setup_tags(self):
67
+ """Set up text tags for styling"""
68
+ font_obj = tkfont.nametofont(self.cget("font"))
69
+ font_size = font_obj.actual("size")
70
+
71
+ self.tag_configure(
72
+ "errors",
73
+ foreground="red",
74
+ font=("Courier", font_size - 2)
75
+ )
76
+ self.tag_configure(
77
+ "banner",
78
+ foreground="darkred",
79
+ font=("Courier", font_size - 2)
80
+ )
81
+ self.tag_configure(
82
+ "prompt",
83
+ foreground="green",
84
+ font=("Courier", font_size - 2)
85
+ )
86
+ self.tag_configure("input_color", foreground="blue")
87
+
88
+ def setup_bindings(self):
89
+ """Set up key bindings"""
90
+ self.bind('<Control-Return>', self.on_ctrl_return)
91
+ self.bind('<Shift-Return>', self.on_shift_return)
92
+ self.bind('<KeyPress>', self.on_key_press)
93
+ self.bind('<KeyRelease>', self.on_key_release)
94
+ self.bind('<Tab>', self.on_tab)
95
+ self.bind('<Down>', self.on_down)
96
+ self.bind('<Up>', self.on_up)
97
+ self.bind('<Return>', self.on_return)
98
+ self.bind('<BackSpace>', self.on_backspace)
99
+ self.bind('<Control-c>', self.on_ctrl_c)
100
+ self.bind('<<Paste>>', self.on_paste)
101
+ self.bind("<Button-3>", self.show_context_menu)
102
+
103
+ def setup_context_menu(self):
104
+ """Set up the context menu"""
105
+ self.context_menu = Menu(self, tearoff=0)
106
+ for label, command in self.context_menu_items:
107
+ if label == "-":
108
+ self.context_menu.add_separator()
109
+ else:
110
+ self.context_menu.add_command(
111
+ label=label, command=getattr(self, command)
112
+ )
113
+
114
+ def create_menu(self, main, master):
115
+ """Create the menu bar - can be overridden by subclasses"""
116
+ menu_bar = Menu(master)
117
+ master.config(menu=menu_bar)
118
+
119
+ # File menu
120
+ file_menu = Menu(menu_bar, tearoff=0)
121
+ file_menu.add_command(label="Clear Console", command=self.clear_console)
122
+ file_menu.add_command(label="History", command=self.dump_history)
123
+ if master != main:
124
+ file_menu.add_command(label="Close Window", command=master.destroy)
125
+ file_menu.add_command(label="Quit Application", command=self.quit)
126
+ menu_bar.add_cascade(label="File", menu=file_menu)
127
+
128
+ # Edit menu
129
+ edit_menu = Menu(menu_bar, tearoff=0)
130
+ edit_menu.add_command(label="Cut", command=self.cut)
131
+ edit_menu.add_command(label="Copy", command=self.copy)
132
+ edit_menu.add_command(label="Paste", command=self.paste)
133
+ menu_bar.add_cascade(label="Edit", menu=edit_menu)
134
+
135
+ # Help menu
136
+ help_menu = Menu(menu_bar, tearoff=0)
137
+ help_menu.add_command(label="Help", command=self.show_help)
138
+ help_menu.add_command(label="About", command=self.show_about)
139
+ menu_bar.add_cascade(label="Help", menu=help_menu)
140
+
141
+ def show_about(self):
142
+ """Show about dialog - can be overridden by subclasses"""
143
+ messagebox.showinfo("About", self.show_about_message)
144
+
145
+ def show_help(self):
146
+ """Show help window - can be overridden by subclasses"""
147
+ help_window = tk.Toplevel(self)
148
+ help_window.title("Help")
149
+ help_window.geometry("600x400")
150
+
151
+ # Add a scrollbar and text widget
152
+ scrollbar = tk.Scrollbar(help_window)
153
+ scrollbar.pack(side="right", fill="y")
154
+
155
+ help_text = tk.Text(
156
+ help_window,
157
+ wrap="word",
158
+ yscrollcommand=scrollbar.set
159
+ )
160
+ help_text.tag_configure("title", foreground="purple")
161
+ help_text.tag_configure("section", foreground="blue")
162
+
163
+ help_text.insert(
164
+ tk.END,
165
+ self.show_help_content + '\n\n',
166
+ "title"
167
+ )
168
+ help_text.insert(
169
+ tk.END,
170
+ 'Features:\n\n',
171
+ "section"
172
+ )
173
+ help_text.insert(
174
+ tk.END,
175
+ (
176
+ "- Clear Console: Clears all text in the console.\n"
177
+ "- Context Menu: Right-click for cut, copy, paste, or clear.\n"
178
+ "- Help: Provides this text.\n\n"
179
+ )
180
+ )
181
+ help_text.insert(
182
+ tk.END,
183
+ 'Tokens:\n\n',
184
+ "section"
185
+ )
186
+ help_text.insert(
187
+ tk.END,
188
+ (
189
+ "self: Master self\n"
190
+ "master: TextConsole widget\n"
191
+ "kw: kw dictionary ({'width': 50, 'wrap': 'word'})\n"
192
+ "local: TextConsole self\n\n"
193
+ )
194
+ )
195
+ help_text.config(state="disabled") # Make the text read-only
196
+ help_text.pack(fill="both", expand=True)
197
+ scrollbar.config(command=help_text.yview)
198
+
199
+ def clear_console(self):
200
+ """Clear the text in the console."""
201
+ self.clear()
202
+
203
+ def show_context_menu(self, event):
204
+ """Show the context menu at the cursor position."""
205
+ self.context_menu.post(event.x_root, event.y_root)
206
+
207
+ def cut(self):
208
+ """Cut the selected text to the clipboard."""
209
+ try:
210
+ self.event_generate("<<Cut>>")
211
+ except tk.TclError:
212
+ pass
213
+
214
+ def copy(self):
215
+ """Copy the selected text to the clipboard."""
216
+ try:
217
+ self.event_generate("<<Copy>>")
218
+ except tk.TclError:
219
+ pass
220
+
221
+ def paste(self):
222
+ """Paste text from the clipboard."""
223
+ try:
224
+ self.event_generate("<<Paste>>")
225
+ except tk.TclError:
226
+ pass
227
+
228
+ def clear(self):
229
+ """Clear all text from the console."""
230
+ self.delete("1.0", "end")
231
+ self.insert("1.0", self._prompt1) # Reinsert the prompt
232
+ self.delete('input', 'insert lineend')
233
+
234
+ def dump_history(self):
235
+ """Open a separate window with the output of the history."""
236
+ history_window = tk.Toplevel(self)
237
+ history_window.title("History")
238
+ history_window.geometry("1000x400")
239
+
240
+ # Add a scrollbar and text widget
241
+ scrollbar = tk.Scrollbar(history_window)
242
+ scrollbar.pack(side="right", fill="y")
243
+
244
+ history_txt = tk.Text(
245
+ history_window, wrap="word", yscrollcommand=scrollbar.set
246
+ )
247
+ history_txt.tag_configure("title", foreground="red")
248
+ history_txt.tag_configure("counter", foreground="blue")
249
+ for i, command in enumerate(self.history):
250
+ history_txt.insert('end', f"{i + 1}\t| ", "counter")
251
+ history_txt.insert('end', f"{command}\n")
252
+ history_txt.config(state="disabled") # Make the text read-only
253
+ history_txt.pack(fill="both", expand=True)
254
+ scrollbar.config(command=history_txt.yview)
255
+
256
+ def on_ctrl_c(self, event):
257
+ """Copy selected code, removing prompts first"""
258
+ sel = self.tag_ranges('sel')
259
+ if sel:
260
+ txt = self.get('sel.first', 'sel.last').splitlines()
261
+ lines = []
262
+ for i, line in enumerate(txt):
263
+ if line.startswith(self._prompt1):
264
+ lines.append(line[len(self._prompt1):])
265
+ elif line.startswith(self._prompt2):
266
+ lines.append(line[len(self._prompt2):])
267
+ else:
268
+ lines.append(line)
269
+ self.clipboard_clear()
270
+ self.clipboard_append('\n'.join(lines))
271
+ return 'break'
272
+
273
+ def on_paste(self, event):
274
+ """Paste commands"""
275
+ if self.compare('insert', '<', 'input'):
276
+ return "break"
277
+ sel = self.tag_ranges('sel')
278
+ if sel:
279
+ self.delete('sel.first', 'sel.last')
280
+ txt = self.clipboard_get()
281
+ self.insert("insert", txt)
282
+ self.insert_cmd(self.get("input", "end"))
283
+ return 'break'
284
+
285
+ def prompt(self, result=False):
286
+ """Insert a prompt"""
287
+ if result:
288
+ self.insert('end', self._prompt2, 'prompt')
289
+ else:
290
+ self.insert('end', self._prompt1, 'prompt')
291
+ self.mark_set('input', 'end-1c')
292
+
293
+ def on_key_press(self, event):
294
+ """Prevent text insertion in command history"""
295
+ if self.compare('insert', '<', 'input') and event.keysym not in ['Left', 'Right']:
296
+ self._hist_item = len(self.history)
297
+ if not event.char.isalnum():
298
+ return 'break'
299
+ else:
300
+ if event.keysym not in ['Return']:
301
+ self.tag_add("input_color", "input", "insert lineend")
302
+
303
+ def on_key_release(self, event):
304
+ """Reset history scrolling"""
305
+ if self.compare('insert', '<', 'input') and event.keysym not in ['Left', 'Right']:
306
+ self._hist_item = len(self.history)
307
+ return 'break'
308
+ else:
309
+ if event.keysym not in ['Return']:
310
+ self.tag_add("input_color", "input", "insert lineend")
311
+
312
+ def on_up(self, event):
313
+ """Handle up arrow key press"""
314
+ # Handle cursor position outside the input area
315
+ if self.compare('insert', '<', 'input'):
316
+ self.mark_set('insert', 'end')
317
+ return 'break'
318
+
319
+ # Check if at the start of the input line
320
+ elif self.index('input linestart') == self.index('insert linestart'):
321
+ # Get the current input line for partial matching
322
+ line = self.get('input', 'insert')
323
+ self._hist_match = line
324
+
325
+ # Save the current history index and move one step back
326
+ hist_item = self._hist_item
327
+ self._hist_item -= 1
328
+
329
+ # Search for a matching history entry
330
+ while self._hist_item >= 0:
331
+ # Convert the current history item to a string
332
+ item = self.history[self._hist_item]
333
+ if item.startswith(line): # Match the current input
334
+ break
335
+ self._hist_item -= 1
336
+
337
+ if self._hist_item >= 0:
338
+ # Found a match: insert the command
339
+ index = self.index('insert')
340
+ self.insert_cmd(item) # Update input with the matched command
341
+ self.mark_set('insert', index)
342
+ else:
343
+ # No match: use the last history item
344
+ self._hist_item = len(self.history) - 1
345
+ if self._hist_item >= 0:
346
+ item = self.history[self._hist_item]
347
+ index = self.index('insert')
348
+ self.insert_cmd(item) # Update input with the last command
349
+ self.mark_set('insert', index)
350
+ else:
351
+ # No history at all, do nothing
352
+ self._hist_item = hist_item
353
+
354
+ return 'break'
355
+
356
+ def on_down(self, event):
357
+ """Handle down arrow key press"""
358
+ # Handle cursor position outside the input area
359
+ if self.compare('insert', '<', 'input'):
360
+ self.mark_set('insert', 'end')
361
+ return 'break'
362
+
363
+ # Check if at the end of the last input line
364
+ elif self.compare('insert lineend', '==', 'end-1c'):
365
+ # Get the prefix to match (from the previous navigation step)
366
+ line = self._hist_match
367
+
368
+ # Move one step forward in history
369
+ self._hist_item += 1
370
+
371
+ # Search for a matching history entry
372
+ while self._hist_item < len(self.history):
373
+ # Convert the current history item to a string
374
+ item = self.history[self._hist_item]
375
+ if item.startswith(line): # Match the prefix
376
+ break
377
+ self._hist_item += 1
378
+
379
+ if self._hist_item < len(self.history):
380
+ # Found a match: insert the command
381
+ self.insert_cmd(item)
382
+ self.mark_set('insert', 'input+%ic' % len(self._hist_match))
383
+ else:
384
+ # No match: reset to the end of the history
385
+ self._hist_item = len(self.history)
386
+ self.delete('input', 'end')
387
+ self.insert('insert', line)
388
+
389
+ return 'break'
390
+
391
+ def on_tab(self, event):
392
+ """Handle tab key press"""
393
+ if self.compare('insert', '<', 'input'):
394
+ self.mark_set('insert', 'input lineend')
395
+ return "break"
396
+ # indent code
397
+ sel = self.tag_ranges('sel')
398
+ if sel:
399
+ start = str(self.index('sel.first'))
400
+ end = str(self.index('sel.last'))
401
+ start_line = int(start.split('.')[0])
402
+ end_line = int(end.split('.')[0]) + 1
403
+ for line in range(start_line, end_line):
404
+ self.insert('%i.0' % line, ' ')
405
+ else:
406
+ txt = self.get('insert-1c')
407
+ if not txt.isalnum() and txt != '.':
408
+ self.insert('insert', ' ')
409
+ return "break"
410
+
411
+ def on_shift_return(self, event):
412
+ """Handle Shift+Return key press"""
413
+ if self.compare('insert', '<', 'input'):
414
+ self.mark_set('insert', 'input lineend')
415
+ return 'break'
416
+ else: # execute commands
417
+ self.mark_set('insert', 'end')
418
+ self.insert('insert', '\n')
419
+ self.insert('insert', self._prompt2, 'prompt')
420
+ self.eval_current(True)
421
+
422
+ def on_return(self, event=None):
423
+ """Handle Return key press"""
424
+ if self.compare('insert', '<', 'input'):
425
+ self.mark_set('insert', 'input lineend')
426
+ return 'break'
427
+ else:
428
+ self.eval_current(True)
429
+ self.see('end')
430
+ self.history.save()
431
+ return 'break'
432
+
433
+ def on_ctrl_return(self, event=None):
434
+ """Handle Ctrl+Return key press"""
435
+ self.insert('insert', '\n' + self._prompt2, 'prompt')
436
+ return 'break'
437
+
438
+ def on_backspace(self, event):
439
+ """Handle delete key press"""
440
+ if self.compare('insert', '<=', 'input'):
441
+ self.mark_set('insert', 'input lineend')
442
+ return 'break'
443
+ sel = self.tag_ranges('sel')
444
+ if sel:
445
+ self.delete('sel.first', 'sel.last')
446
+ else:
447
+ linestart = self.get('insert linestart', 'insert')
448
+ if re.search(r' $', linestart):
449
+ self.delete('insert-4c', 'insert')
450
+ else:
451
+ self.delete('insert-1c')
452
+ return 'break'
453
+
454
+ def insert_cmd(self, cmd):
455
+ """Insert lines of code, adding prompts"""
456
+ input_index = self.index('input')
457
+ self.delete('input', 'end')
458
+ lines = cmd.splitlines()
459
+ if lines:
460
+ indent = len(re.search(r'^( )*', lines[0]).group())
461
+ self.insert('insert', lines[0][indent:])
462
+ for line in lines[1:]:
463
+ line = line[indent:]
464
+ self.insert('insert', '\n')
465
+ self.prompt(True)
466
+ self.insert('insert', line)
467
+ self.mark_set('input', input_index)
468
+ self.see('end')
469
+
470
+ def eval_current(self, auto_indent=False):
471
+ """Evaluate code"""
472
+ index = self.index('input')
473
+ lines = self.get('input', 'insert lineend').splitlines() # commands to execute
474
+ self.mark_set('insert', 'insert lineend')
475
+ #self.tag_add("input_color", "input", "insert lineend")
476
+ if lines: # there is code to execute
477
+ # remove prompts
478
+ lines = [lines[0].rstrip()] + [line[len(self._prompt2):].rstrip() for line in lines[1:]]
479
+ for i, l in enumerate(lines):
480
+ if l.endswith('?'):
481
+ lines[i] = 'help(%s)' % l[:-1]
482
+ cmds = '\n'.join(lines)
483
+ self.insert('insert', '\n')
484
+ out = StringIO() # command output
485
+ err = StringIO() # command error traceback
486
+ with redirect_stderr(err): # redirect error traceback to err
487
+ with redirect_stdout(out): # redirect command output
488
+ # execute commands in interactive console
489
+ res = self._console.push(cmds)
490
+ # if res is True, this is a partial command, e.g. 'def test():' and we need to wait for the rest of the code
491
+ errors = err.getvalue()
492
+ if errors: # there were errors during the execution
493
+ self.insert('end', errors, 'errors') # display the traceback
494
+ self.mark_set('input', 'end')
495
+ self.see('end')
496
+ self.prompt() # insert new prompt
497
+ else:
498
+ output = out.getvalue() # get output
499
+ if output:
500
+ self.insert('end', output, 'output')
501
+ self.mark_set('input', 'end')
502
+ self.see('end')
503
+ if not res and self.compare('insert linestart', '>', 'insert'):
504
+ self.insert('insert', '\n')
505
+ self.prompt(res)
506
+ if auto_indent and lines:
507
+ # insert indentation similar to previous lines
508
+ indent = re.search(r'^( )*', lines[-1]).group()
509
+ line = lines[-1].strip()
510
+ if line and line[-1] == ':':
511
+ indent = indent + ' '
512
+ self.insert('insert', indent)
513
+ self.see('end')
514
+ if res:
515
+ self.mark_set('input', index)
516
+ self._console.resetbuffer() # clear buffer since the whole command will be retrieved from the text widget
517
+ elif lines:
518
+ if not self.history or [self.history[-1]] != lines:
519
+ self.history.append(lines) # Add commands to history
520
+ self._hist_item = len(self.history)
521
+ out.close()
522
+ err.close()
523
+ else:
524
+ self.insert('insert', '\n')
525
+ self.prompt()
526
+
527
+ class TextConsole(BaseTextConsole):
528
+ """Default implementation of the console"""
529
+ pass
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.1
2
+ Name: text_console
3
+ Version: 1.0.13
4
+ Summary: ('A customizable Tkinter-based text console widget, in which a user types in commands to be sent to the Python interpreter.',)
5
+ Home-page: https://github.com/Ircama/text_console
6
+ Author: Ircama
7
+ License: EUPL-1.2
8
+ Keywords: shell console tkinter
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Developers
16
+ Requires-Python: >3.6
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+
20
+ # text_console
21
+
22
+ A customizable Tkinter-based text console widget with support for command history and interactive execution, in which a user types in commands to be sent to the Python interpreter.
23
+
24
+ It includes options for overriding specific variables through subclassing, by extending the `TextConsole` class.
25
+
26
+ The package is installable via pip.
27
+
28
+ ## Features
29
+
30
+ - Tkinter-based package
31
+ - Customizable history file.
32
+ - Context menu with options for Cut, Copy, Paste, and Clear.
33
+ - Extendable for additional functionality.
34
+
35
+ The package provides flexibility to customize:
36
+
37
+ - `history_file`: Change the location of the history file
38
+ - `console_locals`: Add custom variables and functions to the console's namespace
39
+ - `context_menu_items`: Modify the right-click context menu
40
+ - `show_about_message`: Customize the about dialog content
41
+ - `show_help_content`: Customize the help window content
42
+ - `create_menu`: Override to completely customize the menu bar
43
+
44
+ Each of these can be customized by subclassing TextConsole and overriding the appropriate attributes or methods.
45
+
46
+
47
+ Full information and usage details at the [text_console GitHub repository](https://github.com/Ircama/text_console).
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ text_console/__init__.py
5
+ text_console/__main__.py
6
+ text_console/__version__.py
7
+ text_console/history.py
8
+ text_console/text_console.py
9
+ text_console.egg-info/PKG-INFO
10
+ text_console.egg-info/SOURCES.txt
11
+ text_console.egg-info/dependency_links.txt
12
+ text_console.egg-info/entry_points.txt
13
+ text_console.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ text_console = text_console.__main__:main
@@ -0,0 +1 @@
1
+ text_console