예제 #1
0
    def __createConsole(self):
        """ 创建控制面板控件 """
        f1 = Frame(self.leftFrame)
        f2 = Frame(self.leftFrame)
        f3 = Frame(self.leftFrame)
        f4 = Frame(self.leftFrame)
        f5 = Frame(self.leftFrame)

        Label(f1, text="find:").grid(row=0)
        Label(f1, text="replace:").grid(row=1)

        self.entrySearch = Entry(f1,
                                 textvariable=self.searchString).grid(row=0,
                                                                      column=1)
        self.entryReplace = Entry(f1, textvariable=self.replaceString).grid(
            row=1, column=1)

        f1.pack(fill="x")

        self.buttonFind = Button(f2,text="Find",command=self.find)\
          .pack(side="left",padx=5,pady=5)
        self.buttonReplace = Button(f2,text="Replace",command=self.replace)\
          .pack(side="left",padx=5,pady=5)
        self.buttonReplace_Find = Button(f2,text="Replace/Find",command=self.r_f).\
        pack(side="left",padx=5,pady=5)
        f2.pack(fill="x")

        self.CK_replaceEntireFile = Checkbutton(f3,text="replace entire file",variable=self.searchEntireFile).\
         pack(side="left")
        f3.pack(fill="x")

        self.CK_replaceAllFile = Checkbutton(f4,text="replace all file",variable=self.searchAllFiles).\
         pack(side="left")
        f4.pack(fill="x")

        Label(f5, text="code:").grid(row=0)
        combobox = ttk.Combobox(f5,
                                textvariable=self.codeType,
                                values=["utf-8", "gbk", "gb2312"])
        combobox.grid(row=0, column=1)
        f5.pack(fill="x")
        combobox.bind("<<ComboboxSelected>>",
                      lambda e: util.setSysCoding(self.codeType.get()))
예제 #2
0
	def __createConsole(self):
		""" 创建控制面板控件 """
		f1 = Frame(self.leftFrame)
		f2 = Frame(self.leftFrame)
		f3 = Frame(self.leftFrame)
		f4 = Frame(self.leftFrame)
		f5 = Frame(self.leftFrame)

		Label(f1, text="find:").grid(row=0)
		Label(f1, text="replace:").grid(row=1)

		self.entrySearch = Entry(f1,textvariable=self.searchString).grid(row=0,column=1)
		self.entryReplace = Entry(f1,textvariable=self.replaceString).grid(row=1,column=1)

		f1.pack(fill="x")

		self.buttonFind = Button(f2,text="Find",command=self.find)\
				.pack(side="left",padx=5,pady=5)
		self.buttonReplace = Button(f2,text="Replace",command=self.replace)\
				.pack(side="left",padx=5,pady=5)
		self.buttonReplace_Find = Button(f2,text="Replace/Find",command=self.r_f).\
		pack(side="left",padx=5,pady=5)
		f2.pack(fill="x")

		self.CK_replaceEntireFile = Checkbutton(f3,text="replace entire file",variable=self.searchEntireFile).\
			pack(side="left")
		f3.pack(fill="x")

		self.CK_replaceAllFile = Checkbutton(f4,text="replace all file",variable=self.searchAllFiles).\
			pack(side="left")
		f4.pack(fill="x")

		Label(f5, text="code:").grid(row=0)
		combobox = ttk.Combobox(f5,textvariable=self.codeType,values=["utf-8","gbk","gb2312"])
		combobox.grid(row=0,column=1)
		f5.pack(fill="x")
		combobox.bind("<<ComboboxSelected>>",lambda e:util.setSysCoding(self.codeType.get()) ) 
예제 #3
0
    def GenerateFile(self, path):
        s = self.Generate()
        f = None
        try:
            f = open(path, "w")
            f.write(s)
        except:
            print "%s%s%s" % ("can not write file on path(", path, ")")
        finally:
            if f:
                f.close()


if __name__ == "__main__":

    util.setSysCoding()

    template = Template("test_data/d.txt")
    # 	lines = ["string1",
    # 			 "string2",
    # 			 "[r]1,1]",
    # 			 "aaaaa",
    # 			 "bbb",
    # 			 "[/r]",
    # 			 "stri[r]1,1]cccc[/r]ng3"]
    # 	template = Template(lines)
    print template.rules
    for r in template.rules:
        print r.lines

    print template.Generate()
예제 #4
0
#coding:utf-8
from Tkinter import *
import ttk
import tkFileDialog
import tkMessageBox
import time

from NoteBook import NoteBook
from NoteBook import NoteBookException
import util

util.setSysCoding()


class BulkEditingTool:
    def __init__(self, root):

        self.isComingSoonDialog = lambda: tkMessageBox.showwarning(
            "message", "this function is coming soon")

        self.root = root

        self.root.title("bulk editing tool")  #窗口标题

        self.notebook = NoteBook()  #笔记本

        self.searchEntireFile = IntVar()  #是否查找替换整个文件 1 是 0 否
        self.searchAllFiles = IntVar()  #是否查找替换所有文件 1 是 0 否
        self.searchString = StringVar()  #查找字符串
        self.replaceString = StringVar()  #替换字符串
        self.codeType = StringVar()  #文件编码类型