Simple Editor for C0ding betha 0.0.5 Cp 27


Untuk menutup hari saya sedikit membuat program editor sederhana dan bisa di modifikasi lagi sesuai dengan keperluannya masing - masing. Langsung saja di bawah ini adalah editornya

#Copy L3ft By Andhika Hirlanda Putra a.k.a 54v0y a.k.a computer_freak
#Thanks To :
# Allah SWT
# Para Rasull dan Sahabat2nya
# Typus dan DBD yang sempat menghinggapi tubuh ini
# Diandra (Lepy gw)
# Penghuni CP27 : dayax (high_anonymouse), XdhiX, jalunk, Phebe, Flash Lite, m1k3, jajang05, putri, krl, bletotz, and all
from wxPython.wx import *
import wx
import os
ID_NEW = 101
ID_OPEN = 102
ID_SAVE = 103
ID_SAVE_AS = 104
ID_EXIT = 105
ID_ABOUT = 106
ID_COPY = 107
ID_PASTE = 108
ID_PRINT = 109
class main_window(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent,-1,title)
self.filename=""
self.dirname=""
self.documentChanged=0
self.textbox = wxTextCtrl(self,5,"",style=wxTE_MULTILINE)
EVT_TEXT(self, 5,self.OnChange)
self.CreateStatusBar()
menufile=wxMenu()
menufile.Append(ID_NEW,"&New\tCtrl+N","Create new document")
menufile.Append(ID_OPEN,"&Open\tCtrl+O","Open a file")
menufile.Append(ID_SAVE,"&Save\tCtrl+S","Save a Document")
menufile.Append(ID_SAVE_AS,"Save &As","Save the current document with a different name")
menufile.AppendSeparator()
menufile.Append(ID_EXIT, "E&xit\tAlt+X", "Exit the program")
menuedit = wxMenu()
menuedit.Append(ID_COPY, "&Copy", "Copy your text")
menuedit.Append(ID_PASTE, "P&aste", "Paste your text")
menuhelp = wxMenu()
menuhelp.Append(ID_ABOUT, "&About")
menubar = wxMenuBar()
menubar.Append(menufile,"&File")
menubar.Append(menuedit,"&Edit")
menubar.Append(menuhelp,"&Help")
self.SetMenuBar(menubar)
EVT_MENU(self,ID_NEW,self.OnFileNew)
EVT_MENU(self,ID_OPEN,self.OnFileOpen)
EVT_MENU(self,ID_SAVE,self.OnFileSave)
EVT_MENU(self,ID_SAVE_AS,self.OnFileSaveAs)
EVT_MENU(self,ID_EXIT,self.OnFileExit)
EVT_MENU(self,ID_COPY,self.OnCopy)
EVT_MENU(self,ID_PASTE, self.OnPaste)
EVT_MENU(self,ID_ABOUT,self.OnHelpAbout)
def OnCopy(self, evt):
data = wx.TextDataObject()
data.SetText(self.textbox.GetValue())
if wx.TheClipboard.Open():
wx.TheClipboard.SetData(data)
wx.TheClipboard.Close()
else:
wx.MessageBox("Unable to Open the clipboard", "Error")
def OnPaste(self, evt):
success = False
data = wx.TextDataObject()
if wx.TheClipboard.Open():
success = wx.TheClipboard.GetData(data)
wx.TheClipboard.Close()
if success:
self.textbox.SetValue(data.GetText())
else:
wx.MessageBox("There is no data in the clipboard in the requered format", "Error")
def OnFileNew(self, evt):
if self.documentChanged:
save=self.saveChanges()
if save == wxID_CANCEL:
pass
elif save == wxID_NO:
self.newFile()
else:
if self.filename==""and self.dirname=="":
if self.OnFileSaveAs(None):
self.newFile()
else:
self.OnFileSave(None)
self.newFile()
else:
self.newFile()
def OnFileOpen(self, evt):
if self.documentChanged:
save=self.saveChanges()
if save == wxID_CANCEL:
return
elif save == wxID_NO:
self.openFile()
else:
if self.filename=="" and self.dirname=="":
if self.OnFileSaveAs(None):
self.openFile()
else:
return
else:
self.saveFile(self.dirname, self.filename)
self.openFile()
else:
self.openFile()
def OnChange(self, evt):
if self.filename=="":
filename="Untitled"
else:
filename = self.filename
msg = "The text in the %s file has changed.\n\nDo you want to save the change?"%filename
dlg = wxMessageDialog(self, msg,'Text Editor', wxICON_EXCLAMATION | wxYES_NO|wxCANCEL)
ret = dlg.ShowModal()
dlg.Destroy()
return ret
def newFile(self):
self.textbox.SetValue("")
self.documentChanged=0
self.filename=""
self.dirname=""
self.SetTitle("Untitle Text Editor")
def openFile(self):
dlg=wxFileDialog(self,"Open", self.dirname,self.filename,"TextFile(*.txt)|*.txt|All Files|*.*", wxOPEN)
if (dlg.ShowModal()==wxID_OK):
self.filename = dlg.GetFilename()
self.dirname=dlg.GetDirectory()
try:
f=file(os.path.join(self.dirname,self.filename),'r')
self.textbox.SetValue(f.read())
self.documentChanged=0
self.SetTitle(self.filename+'Text Editor')
self.PushStatusText(self.filename+'opened.')
f.close()
except:
pass
dlg.Destroy()
def saveFile(self, dirname,filename):
try:
path=os.path.join(dirname, filename)
f = open(path,'w')
f.write(self.textbox.GetValue())
f.close()
self.documentChanged=0
self.SetTitle(filename+"Text Editor")
self.PushStatusText(filename+" saved.")
except:
pass
def OnFileSave(self, evt):
if self.filename=="" and self.dirname=="":
self.OnFileSaveAs(None)
else:
self.saveFile(self.dirname,self.filename)
def OnFileSaveAs(self, evt):
dlg = wxFileDialog(self,"Save As...", self.dirname, self.filename,"Text Files(*.txt)|*.txt|All Files|*.*",wxSAVE)
if (dlg.ShowModal()==wxID_OK):
self.filename=dlg.GetFilename()
self.dirname=dlg.GetDirectory()
self.saveFile(self.dirname,self.filename)
self.SetTitle(self.filename+'Text Editor')
dlg.Destroy()
return 1
else:
dlg.Destroy()
return 0
def doExit(self):
if self.documentChanged:
save=self.saveChanges()
if save==wxID_CANCEL:
return 0
elif save == wxID_NO:
return 1
else:
if self.filename=="" and self.dirname=="":
return self.OnFileSaveAs(None)
else:
self.saveFile(self.dirname, self.filename)
return 1
else:
return 1
def OnClose(self, evt):
self.Close()
def OnFileExit(self, evt):
self.Close()
def OnHelpAbout(self, evt):
dlg = wxMessageDialog(self, "Ini Adalah Editor Seri Betha\n"
"Dan Bebas untuk di kembangkan sesuai dengan kebutuhan\n"
"Copy Left @ Nama Andhika Hirlanda Putra", "tentang saya", wxOK|wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()                
if __name__=='__main__':
app = wxPySimpleApp()
frame = main_window(None, -1, "Cempaka Putih 27 Editor")
frame.CenterOnScreen()
frame.Show()
app.MainLoop()
Simple Editor for C0ding betha 0.0.5 Cp 27 Simple Editor for C0ding betha 0.0.5 Cp 27 Reviewed by Unknown on 9:50 AM Rating: 5
Editor By 54v0y. Powered by Blogger.