Python 去除代码前行号,python去除代码前行,# -*- coding
文章由Byrx.net分享于2019-03-23 09:03:58
Python 去除代码前行号,python去除代码前行,# -*- coding
# -*- coding: utf-8 -*-import wxclass MainWindow(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, u'去除代码前行号的Python小工具 - wxPython版 - Develop by Yanxy') self.textBox = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE,size=(600,600)) self.butOK = wx.Button(self, label=u"去除行号") self.butLeft = wx.Button(self, label=u"去除左侧一个字符") self.Bind(wx.EVT_BUTTON, self.CutLineNum, self.butOK) self.Bind(wx.EVT_BUTTON, self.CutLeftChar, self.butLeft) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(self.textBox,1,wx.EXPAND) self.sizer.Add(self.butOK) self.sizer.Add(self.butLeft) self.SetSizer(self.sizer) self.SetAutoLayout(1) self.sizer.Fit(self) self.Show(True) def OnCloseWindow(self, event): self.Destroy() def CutLineNum(self, event): multiStr = unicode(self.textBox.GetValue()).splitlines(1) outStr = u'' for singleStr in multiStr: singleStr = singleStr.lstrip() i=0 for charStr in singleStr: if charStr.isdigit(): i += 1 elif i>0: singleStr = singleStr[i:] break else: break outStr += singleStr self.textBox.SetValue(outStr) def CutLeftChar(self, event): outStr = u'' multiStr = unicode(self.textBox.GetValue()).splitlines(1) for singleStr in multiStr: singleStr = singleStr[1:] outStr += singleStr self.textBox.SetValue(outStr)if __name__ == '__main__': app = wx.PySimpleApp() frame = MainWindow(parent=None, id=-1) app.MainLoop()del app#该片段来自于http://byrx.net
相关内容
- Python Daemon(守护进程),pythondaemon,def createDa
- Python 创建xml,python创建xml,from xml.dom
- 在python3.2中使用pickle,python3.2pickle,import pickl
- Python 截屏函数,python截屏函数,python截屏函数.1
- Python 下载器,python下载器,# coding=UTF
- Python 格式化css文件,,import strin
- Python threading模块,pythonthreading,python是支持多线程
- Python quopri模块,pythonquopri模块,quopri模块和bas
- Python MySQLdb模块,pythonmysqldb模块,mysql是一个优秀的开
- Randomized Select,randomizedselect,import rando
评论关闭