-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvpy.py
More file actions
93 lines (73 loc) · 2.54 KB
/
vpy.py
File metadata and controls
93 lines (73 loc) · 2.54 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Known bugs (TODO):
- visualizing tabs need to differ from spaces in color
- if scroll down to hide top content, then resize window down and then maximize top content into view, it doesn't get highlighted
- highlight.whitspace (line 74), string index out of range if i <= ... content[i+1]
Next features (todo):
- create new file
- if editor is too slow with multiple tabs, try to only have one mainframe.textarea, and make editors keep text contents only
"""
try:
from tkinter import *
except:
from Tkinter import *
import filemenu
import notebook
import texthelper
class MainFrame(Frame):
"The main container (Frame) of the program."
def __init__(self, parent):
Frame.__init__(self, parent, background="white")
self.root = parent
self.root.title("Visual Python")
self.pack(fill=BOTH, expand=1)
self.maximize()
self.mainframe = self
self.texthelper = texthelper
self.menu = Menu(self)
self.root.config(menu=self.menu)
self.filemenu = filemenu.FileMenu(self)
self.notebook = notebook.NoteBook(self)
self.notebook.pack(side=LEFT, fill=BOTH, expand=True)
self.root.protocol("WM_DELETE_WINDOW", self.filemenu.before_exit)
import sys
if len( sys.argv ) > 1:
# auto-open file at startup (after inits)
# something is not ready when auto-opening, resulting in for example multiline-counter being messed up
# though fixed with update
self.root.update()
self.notebook.new_editor( sys.argv[1] )
else:
self.notebook.new_editor()
#self.root.wait_visibility(self.textarea) # FREEZES
#self.root.wait_window(self.textarea) # never happens
#self.root.update_idletasks()
def maximize(self):
try:
# windows only? at least not lubuntu
self.root.state('zoomed')
except:
pass
def print_exception(e):
import sys
import traceback
import os
ex_type, ex, tb = sys.exc_info()
traceback.print_tb(tb)
print( '%s %s %s' % (str(ex_type),str(ex),str(traceback.extract_stack())) )
print()
def main():
root = Tk()
root.geometry("250x150+300+300")
app = MainFrame(root)
root.mainloop()
if __name__ == '__main__':
try:
main()
except Exception as e:
print_exception(e)
import os
os.system("pause")
# http://www.alandmoore.com/blog/2013/07/25/tkinter-not-dead-yet/