..So jetzt habe ich nun die Linux Version vorerst mal fertig gestellt,Dieser Editor ist zwar vom Design anders aufgebaut aber funktioniert bei mir unter Ubuntu einwandfrei,man bedenke das code leider nicht per copy und paste unter dem Run Button funktioniert sondern nur über den Öffnen Dialog in den Editor geladenen Code (Tkinter- ,GTK -programme)lassen sich über den Run Button ausführen.Könnte man sicher noch verbessern... ich habe diese Version Chameleo Version genannt wegen den verschieden Farbmöglichkeiten wo man den Editor nach seinen Bedürfnissen anpassen kann.Viel spass...
Code: Alles auswählen
#! /usr/bin/env python
# -*- coding: cp1252 -*-
from Tkinter import*
import tkFileDialog
import sys
import os
import thread
class Editor:
def __init__ (self,master):
self.master = master
self.master.geometry('600x450+300+150')
master.title("MyPy IDE ------ *Chameleo Version*")
scrollbar = Scrollbar(master)
scrollbar.pack(side=RIGHT,fill=Y)
self.file=None
self.s=StringVar()
# create a menu
self.menu = Menu(master,bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.master.config(menu=self.menu)
self.filemenu = Menu(self.menu,tearoff=0,bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.menu.add_cascade(label="File", menu=self.filemenu)
self.filemenu.add_command(label="New", command=self.new)
self.filemenu.add_command(label="Open", command=self.laden)
self.filemenu.add_command(label="Save as", command=self.speichern_unter)
self.filemenu.add_separator()
self.filemenu.add_command(label="Exit", command=self.quit)
self.optionsmenu = Menu(self.menu,tearoff=0,bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.menu.add_cascade(label="Options", menu=self.optionsmenu)
self.optionsmenu.add_command(label="Select colors...", command=self.farben)
self.optionsmenu.add_command(label="Blue", command=self.blue)
self.optionsmenu.add_command(label="Yellow", command=self.yellow)
self.optionsmenu.add_command(label="Green", command=self.green)
self.optionsmenu.add_command(label="Black", command=self.black)
self.optionsmenu.add_command(label="White", command=self.white)
self.optionsmenu.add_command(label="Arial 18", command=self.arial)
self.optionsmenu.add_command(label="Verdana 12", command=self.verdana)
self.optionsmenu.add_command(label="Courier 14", command=self.courier)
self.optionsmenu.add_command(label="Font", command=self.couriernew)
self.Runmenu = Menu(self.menu,tearoff=0,bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.menu.add_cascade(label="Run", menu=self.Runmenu)
self.Runmenu.add_command(label="Script...", command=self.run)
self.Runmenu.add_command(label="Python Shell", command=self.shell)
self.helpmenu = Menu(self.menu,tearoff=0,bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.menu.add_cascade(label="Help", menu=self.helpmenu)
self.helpmenu.add_command(label="About...", command=self.about)
self.text=Text(master,bg="#ECEEE9",fg="#3F4929",width=600,height=400,font=("Courier new",12),
yscrollcommand=scrollbar.set)
scrollbar.config(command=self.text.yview)
self.text.pack()
def farben(self,event=None):
main = Tk()
main.geometry("200x114+80+200")
main.title("Select color...")
frame=Frame(main,width=100,height=6,bg="black")
frame.place(x=0,y=0)
button=Button(frame,text="",bg="blue",width=32,activebackground="#B4C0EB",command=self.blue)
button.pack(side=TOP,expand=TRUE)
button2=Button(frame,text="",bg="green",width=32,activebackground="#D2ECAB",command=self.green)
button2.pack(side=TOP)
button3=Button(frame,text="",bg="yellow",width=32,activebackground="#EAEAB7",command=self.yellow)
button3.pack(side=TOP)
button4=Button(frame,text="",bg="black",width=32,activebackground="#6D6F77",command=self.black)
button4.pack(side=TOP)
button5=Button(frame,text="",bg="white",width=32,activebackground="#F7EBEB",command=self.white)
button5.pack(side=TOP)
main.resizable(0,0)
main.mainloop()
def blue(self,event=None):
self.text.config(bg="#E9ECF7",fg="#273156")
self.menu.config(bg="black",fg="cyan",activebackground="#B4C0EB",activeforeground="#273156")
self.filemenu.config(bg="black",fg="cyan",activebackground="#B4C0EB",activeforeground="#273156")
self.optionsmenu.config(bg="black",fg="cyan",activebackground="#B4C0EB",activeforeground="#273156")
self.helpmenu.config(bg="black",fg="cyan",activebackground="#B4C0EB",activeforeground="#273156")
self.Runmenu.config(bg="black",fg="cyan",activebackground="#B4C0EB",activeforeground="#273156")
def yellow(self,event=None):
self.text.config(bg="#F8F8DD",fg="#55552F")
self.menu.config(bg="black",fg="yellow",activebackground="#EAEAB7",activeforeground="#71713C")
self.filemenu.config(bg="black",fg="yellow",activebackground="#EAEAB7",activeforeground="#71713C")
self.optionsmenu.config(bg="black",fg="yellow",activebackground="#EAEAB7",activeforeground="#71713C")
self.helpmenu.config(bg="black",fg="yellow",activebackground="#EAEAB7",activeforeground="#71713C")
self.Runmenu.config(bg="black",fg="yellow",activebackground="#EAEAB7",activeforeground="#71713C")
def green(self,event=None):
self.text.config(bg="#ECEEE9",fg="#3F4929")
self.menu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.filemenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.optionsmenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.helpmenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.Runmenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
def black(self,event=None):
self.text.config(bg="black",fg="green")
self.menu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.filemenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.optionsmenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.helpmenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
self.Runmenu.config(bg="black",fg="green",activebackground="#D2ECAB",activeforeground="#3F4929")
def white(self,event=None):
self.text.config(bg="white",fg="black")
self.menu.config(bg="black",fg="white",activebackground="#D2ECAB",activeforeground="#3F4929")
self.filemenu.config(bg="black",fg="white",activebackground="#D2ECAB",activeforeground="#3F4929")
self.optionsmenu.config(bg="black",fg="white",activebackground="#D2ECAB",activeforeground="#3F4929")
self.helpmenu.config(bg="black",fg="white",activebackground="#D2ECAB",activeforeground="#3F4929")
self.Runmenu.config(bg="black",fg="white",activebackground="#D2ECAB",activeforeground="#3F4929")
def arial(self,event=None):
self.text.config(font=("Arial new",18))
def verdana(self,event=None):
self.text.config(font=("Verdana",12))
def courier(self,event=None):
self.text.config(font=("Courier new",14))
def couriernew(self,event=None):
self.text.config(font=("Courier new",12))
def quit(self,event=None):
self.master.destroy()
def run(self,event=None):
thread.start_new_thread(os.system,(("C:\Python24\python "+self.datei.name),))
def shell(self,event=None):
os.system('"C:\Python24\python"')
def laden (self,event=None):
self.datei = tkFileDialog.askopenfile()
self.text.delete(1.0,END)
if self.datei:
self.text.insert(1.0,self.datei.read())
def new (self,event=None):
self.text.delete(1.0,END)
def speichern_unter (self,event=None):
self.datei=tkFileDialog.asksaveasfile()
if self.datei:
self.datei.write(self.text.get(1.0,END))
def about(self,event=None):
window = Tk()
window.geometry("200x220")
info=Label(window,width="200",height="220",bg="black",
fg="green",
text="MyPy IDE Chameleo Version is written \nby yabuti 2006 \n in Python \n---------- \n\nthis version is for Linux \na code Editor \nfor run codesnippets \nor Tkinter programs \nthis is version 1.0").pack()
window.title("About")
window.resizable(0,0)
window.mainloop()
root=Tk()
editor=Editor(root)
root.mainloop()
P.S. vielleicht weiß jemand eine Lösung wie man codesnippets oder Programme mit copy und paste in den Editor dann ausführen kann....