text-console 2.0.5__tar.gz → 2.0.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: text_console
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: ('A customizable Tkinter-based text console widget, in which a user types in commands to be sent to the Python interpreter.',)
5
5
  Home-page: https://github.com/Ircama/text_console
6
6
  Author: Ircama
@@ -1,4 +1,4 @@
1
- from .text_console import TextConsole
1
+ from .text_console import TextConsole, BaseTextConsole
2
2
  from .history import History
3
3
  from .__version__ import __version__
4
4
 
@@ -0,0 +1 @@
1
+ __version__ = "2.0.7"
@@ -103,6 +103,9 @@ class BaseTextConsole(tk.Text):
103
103
  self.mark_gravity('input', 'left')
104
104
  self.focus_set()
105
105
 
106
+ # Add this attribute in your __init__ method if not present
107
+ self.history_panel = None
108
+
106
109
  def setup_tags(self):
107
110
  """Set up text tags for styling"""
108
111
  font_obj = tkfont.nametofont(self.cget("font"))
@@ -848,7 +851,21 @@ class BaseTextConsole(tk.Text):
848
851
  return 'break'
849
852
 
850
853
  def show_command_history_panel(self):
851
- CommandHistoryPanel(self, self.history, self.insert_cmd, [self._hist_item])
854
+ # If already open and not destroyed, bring to front and focus
855
+ if self.history_panel is not None and self.history_panel.winfo_exists():
856
+ self.history_panel.lift()
857
+ self.history_panel.focus_force()
858
+ self.history_panel.search_entry.focus_set()
859
+ return
860
+
861
+ # Otherwise, create a new panel
862
+ self.history_panel = CommandHistoryPanel(self, self.history, self.insert_cmd, [self._hist_item])
863
+
864
+ # When the panel is closed, clear the reference
865
+ def on_panel_close():
866
+ self.history_panel.destroy()
867
+ self.history_panel = None
868
+ self.history_panel.protocol("WM_DELETE_WINDOW", on_panel_close)
852
869
 
853
870
  def insert_line(self, event=None):
854
871
  """Handle Ctrl+Return key press"""
@@ -898,6 +915,12 @@ class BaseTextConsole(tk.Text):
898
915
 
899
916
  def eval_current(self, auto_indent=False):
900
917
  """Evaluate code"""
918
+ # Close history panel if open
919
+ try:
920
+ self.history_panel.destroy()
921
+ except Exception:
922
+ pass
923
+
901
924
  index = self.index('input')
902
925
  lines = self.get('input', 'insert lineend').splitlines() # commands to execute
903
926
  self.mark_set('insert', 'insert lineend')
@@ -978,14 +1001,6 @@ class BaseTextConsole(tk.Text):
978
1001
  self.insert('insert', '\n', "output")
979
1002
  self.prompt()
980
1003
 
981
- # Close history panel if open
982
- if hasattr(self, '_history_window') and self._history_window is not None:
983
- try:
984
- self._history_window.destroy()
985
- except Exception:
986
- pass
987
- self._history_window = None
988
-
989
1004
  def on_key_press(self, event):
990
1005
  """
991
1006
  Prevent character insertion if the cursor is over a character with any tag (e.g., prompt).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: text_console
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: ('A customizable Tkinter-based text console widget, in which a user types in commands to be sent to the Python interpreter.',)
5
5
  Home-page: https://github.com/Ircama/text_console
6
6
  Author: Ircama
@@ -1 +0,0 @@
1
- __version__ = "2.0.5"
File without changes
File without changes
File without changes
File without changes