Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec73dc6

Browse files
committed
Support for Moshe's status bar.
1 parent 17752f7 commit ec73dc6

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

Tools/idle/EditorWindow.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class EditorWindow:
8585
from IOBinding import IOBinding
8686
import Bindings
8787
from Tkinter import Toplevel
88+
from MultiStatusBar import MultiStatusBar
8889

8990
about_title = about_title
9091
about_text = about_text
@@ -101,7 +102,8 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
101102
self.menubar = Menu(root)
102103
self.top = top = self.Toplevel(root, menu=self.menubar)
103104
self.vbar = vbar = Scrollbar(top, name='vbar')
104-
self.text = text = Text(top, name='text', padx=5,
105+
self.text_frame = text_frame = Frame(top)
106+
self.text = text = Text(text_frame, name='text', padx=5,
105107
foreground=cprefs.CNormal[0],
106108
background=cprefs.CNormal[1],
107109
highlightcolor=cprefs.CHilite[0],
@@ -139,7 +141,8 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
139141
if sys.platform[:3] == 'win':
140142
text['font'] = ("lucida console", 8)
141143
# text['font'] = ("courier new", 10)
142-
text.pack(side=LEFT, fill=BOTH, expand=1)
144+
text_frame.pack(side=LEFT, fill=BOTH, expand=1)
145+
text.pack(side=TOP, fill=BOTH, expand=1)
143146
text.focus_set()
144147

145148
self.per = per = self.Percolator(text)
@@ -186,6 +189,21 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
186189
if self.extensions.has_key('AutoIndent'):
187190
self.extensions['AutoIndent'].set_indentation_params(
188191
self.ispythonsource(filename))
192+
self.set_status_bar()
193+
194+
def set_status_bar(self):
195+
self.status_bar = self.MultiStatusBar(self.text_frame)
196+
self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
197+
self.status_bar.set_label('line', 'Ln: ?', side=RIGHT)
198+
self.status_bar.pack(side=BOTTOM, fill=X)
199+
self.text.bind('<KeyRelease>', self.set_line_and_column)
200+
self.text.bind('<ButtonRelease>', self.set_line_and_column)
201+
self.text.after_idle(self.set_line_and_column)
202+
203+
def set_line_and_column(self, event=None):
204+
line, column = string.split(self.text.index(INSERT), '.')
205+
self.status_bar.set_label('column', 'Col: %s' % column)
206+
self.status_bar.set_label('line', 'Ln: %s' % line)
189207

190208
def wakeup(self):
191209
if self.top.wm_state() == "iconic":

0 commit comments

Comments
 (0)