-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.py
More file actions
43 lines (37 loc) · 1.49 KB
/
editor.py
File metadata and controls
43 lines (37 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
try:
from tkinter import *
except:
from Tkinter import *
import textarea
import linenumbers
import highlight
class Editor(Frame):
def __init__(self, parent, fpathname):
Frame.__init__(self, parent)
self.parent = parent
self.mainframe = parent.mainframe
self.root = parent.root
self.open(fpathname)
from os import path
self.fname = path.basename(fpathname) if fpathname else 'new'
self.scrollbarY = Scrollbar(self)
self.textarea = textarea.TextArea(self)
self.linenumbers = linenumbers.LineNumbers(self, self.textarea)
self.highlight = highlight.HighLight(self, self.textarea)
self.linenumbers.pack(side=LEFT, fill=Y)
self.textarea.pack(side=LEFT, fill=BOTH, expand=True)
self.scrollbarY.pack(side=RIGHT, fill=Y)
self.scrollbarY.config(command=self.textarea.scrollY)
#self.bind('<Button-3>', self.on_rclick)
#print( self.mainframe.f )
#self.textarea.delete(1.0, END)
if self.f:
self.textarea.insert(1.0, self.f.read())
# set textarea to not modified after original insertion
self.textarea.edit_modified(False)
# clear the undo stack not to be able to undo to empty textarea
self.textarea.edit_reset()
self.textarea.on_key_release()
def open(self, fpathname):
self.f = self.mainframe.filemenu.open( fpathname ) if fpathname else None
self.fpathname = fpathname