Update Editor CP 27 for Coding version betha 0.0.10
Setelah mengoprek lagi editor cp27 kini memiliki fitur baru yaitu mode print dan pemanggilan editor khusus python yaitu PyShell bagi yang sudah menginstall akan bisa memanggilnya dengan mengklik saja dan fasilitas untuk mengprint document anda tanpa banyak basa - basi lagi ini adalah source codenya
#Copy Left 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 * from wx.py.shell import ShellFrame from wx.py.filling import FillingFrame 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 ID_SHELL = 110 ID_PRINT = 111 class TextDocPrintout(wx.Printout): def __init__(self, text, title, margins): wx.Printout.__init__(self, title) self.lines = text.split('\n') self.margins = margins def HasPage(self, page): return page <= self.numPages def GetPageInfo(self): return (1, self.numPages, 1, self.numPages) def CalculateScale(self, dc): ppiPrinterX, ppiPrinterY = self.GetPPIPrinter() ppiScreenX, ppiScreenY = self.GetPPIScreen() logScale = float(ppiPrinterX)/float(ppiScreenX) pw, ph = self.GetPageSizePixels() dw, dh = dc.GetSize() scale = logScale * float(dw)/float(pw) dc.SetUserScale(scale, scale) self.logUnitsMM = float(ppiPrinterX)/(logScale*25.4) def CalculateLayout(self, dc): topLeft, bottomRight = self.margins dw ,dh = dc.GetSize() self.x1 = topLeft.x * self.logUnitsMM self.y1 = topLeft.y * self.logUnitsMM self.x2 = (dc.DeviceToLogicalXRel(dw) - bottomRight.y * self.logUnitsMM) self.y2 = (dc.DeviceToLogicalYRel(dh) - bottomRight.y * self.logUnitsMM) self.pageHeight = self.y2 - self.y1 - 2 * self.logUnitsMM font = wx.Font(FONTSIZE, wx.TELETYPE, wx.NORMAL, wx.NORMAL) dc.SetFont(font) self.lineHeight = dc.GetCharHeight() self.linesPerPage = int(self.pageHeight/self.lineHeight) def OnPreparePrinting(self): dc = self.GetDC() self.CalculateScale(dc) self.CalculateLayout(dc) self.numPages = len(self.lines)/self.linesPerPage if len(self.lines)%self.linesPerPage !=0: self.numPages += 1 def OnPrintPage(self, page): dc = self.GetDC() self.CalculateScale(dc) self.CalculateLayout(dc) dc.SetPen(wx.TRANSPARENT_BRUSH) r = wx.RectPP((self.x1, self.y1), (self.x2, self.y2)) dc.DrawRectangleRect(r) dc.SetClippingRect(r) line = (page-1) * self.linesPerPage x = self.x1 + self.logUnitsMM y = self.y1 + self.logUnitsMM while line < (page * self.linesPerPage): dc.DrawText(self.lines[line], x, y) y += self.lineHeight line += 1 if line >= len(self.lines): break return True 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.Append(ID_PRINT, "Print", "Print you document") 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") menudebug = wxMenu() menudebug.Append(ID_SHELL, "&WxShell") menuhelp = wxMenu() menuhelp.Append(ID_ABOUT, "&About") menubar = wxMenuBar() menubar.Append(menufile,"&File") menubar.Append(menuedit,"&Edit") menubar.Append(menudebug,"&Debug") 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_SHELL, self.OnShell) EVT_MENU(self,ID_ABOUT,self.OnHelpAbout) EVT_MENU(self, ID_PRINT, self.OnPrint) self.pdata = wx.PrintData() self.pdata.SetPaperId(wx.PORTRAIT) self.margins = (wx.Point(15, 15), wx.Point(15, 15)) def OnPrint(self, evt): data = wx.PrintDialogData(self.pdata) printer = wx.Printer(data) text = self.textbox.GetValue() printout = TextDocPrintout(text, "title", self.margins) useSetupDialog = True if not printer.Print(self, printout, useSetupDialog) and printer.GetLastError() == wx.PRINTER_ERROR: wx.MessageBox("There was a problem printing.\n" "Perhaps tou current printer is not set corretly?", "Printing Error", wx.OK) else: data = printer.GetPrintDialogData() self.pdata = wx.PrintData(data.GetPrintData()) printout.Destroy() def OnShell(self, event): frame = ShellFrame(parent=self) frame.Show() 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|Python(*.py)|*.py|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()
Update Editor CP 27 for Coding version betha 0.0.10
Reviewed by Unknown
on
9:15 AM
Rating: