Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmee.py
More file actions
Latest commit
executable file
·98 lines (84 loc) · 3.77 KB
/
Copy pathmee.py
File metadata and controls
executable file
·98 lines (84 loc) · 3.77 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
94
95
96
97
98
#!/usr/bin/python3
# -*- coding: utf-8 -*-
cr=""" mee.py
Michaels einfacher Editor - Version 0.1.2
Copyright 2014 Michael Stehmann <info@rechtsanwalt-stehmann.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.\n
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.\n
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA."""
fromtkinterimport*
importos, tkinter.filedialog, tkinter.scrolledtext, tkinter.messagebox
classEditor(object):
def__init__(self):
self.content, self.endflag, self.newflag="", False, False
ifnothasattr(self, 'fs'): self.fs=10
self.master=Tk()
self.master.title("Editor")
self.master.geometry("+100+100")
self.menu()
self.st=tkinter.scrolledtext.ScrolledText(self.master, font="SansSerif, "+str(self.fs))
self.st.pack(fill="both", expand="yes")
self.master.mainloop()
defmenu(self):
menu=Menu(self.master, font="SansSerif, "+str(self.fs))
self.master.config(menu=menu)
filemenu=Menu(menu)
menu.add_cascade(label="Datei", menu=filemenu, font="SansSerif, "+str(self.fs))
filemenu.add_command(label="Neu", command=self.makenew, font="SansSerif, "+str(self.fs))
filemenu.add_command(label="Öffnen ...", command=self.opener, font="SansSerif, "+str(self.fs))
filemenu.add_command(label="Speichern ...", command=self.saver, font="SansSerif, "+str(self.fs))
filemenu.add_separator()
filemenu.add_command(label="Beenden", command=self.ende, font="SansSerif, "+str(self.fs))
viewmenu=Menu(menu)
menu.add_cascade(label="Anzeige", menu=viewmenu, font="SansSerif, "+str(self.fs))
viewmenu.add_command(label="Schrift vergrößern", command=self.enlargefont, font="SansSerif, "+str(self.fs))
viewmenu.add_command(label="Schrift verkleinern", command=self.reducefont, font="SansSerif, "+str(self.fs))
menu.add_command(label="Informationen", command=self.minfo, font="SansSerif, "+str(self.fs))
defmakenew(self):
self.newflag=True
self.ende()
self.__init__()
defenlargefont(self):
self.fs=self.fs+1
self.st["font"] ="SansSerif, "+str(self.fs)
self.menu()
defreducefont(self):
ifself.fs>6:
self.fs=self.fs-1
self.st["font"] ="SansSerif, "+str(self.fs)
self.menu()
else: tkinter.messagebox.showwarning("Kleiner geht nicht!", "Noch kleiner ist nicht vorgesehen.", type="ok")
defende(self):
ifself.st.get("0.0", "end") !="\n"andself.st.get("0.0", "end") !=self.content:
iftkinter.messagebox.askyesno("Speichern?", "Vorher speichern?",icon="question"):
ifnotself.newflag:
self.endflag=True
self.saver()
else: self.master.destroy()
else: self.master.destroy()
defminfo(self):
sb=tkinter.messagebox.showinfo("Informationen", cr, type="ok")
defopener(self):
try:
fo=tkinter.filedialog.askopenfile(initialdir=os.getenv('HOME'))
self.st.insert(INSERT,fo.read())
except: return# Faengt Abbruch des Dateiladendialoges ab
defsaver(self):
try:
nfo=tkinter.filedialog.asksaveasfile(initialdir=os.getenv('HOME'))
nfo.write(self.st.get("0.0", "end"))
self.content=self.st.get("0.0", "end")
ifself.endflag==True: self.ende()
ifself.newflag==True: self.newdia()
except: tkinter.messagebox.showwarning("Achtung!", "Es wurde nichts gespeichert!", type="ok")
if__name__=='__main__':
mee=Editor()