Beispiel #1
0
    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()  #文件编码类型
        self.codeType.set("utf-8")  #设置文件编码类默认为utf-8

        self.topFrame = Frame(self.root)
        self.topFrame.pack(fill="x")
        self.leftFrame = Frame(self.root)
        self.leftFrame.pack(side="left", fill="y")
        self.rightFrame = Frame(self.root, )
        self.rightFrame.pack(expand="yes", fill="both")

        self.__createMenu()
        self.__createListBox()
        self.__createConsole()
        self.__createShowArea()
Beispiel #2
0
class Menu:
    def __init__(self):
        self.NoteBook = NoteBook()
        self.choices = {
            "1": self.displayMenu,
            "2": self.showNotes,
            "3": self.addNote,
            "4": self.deleteNote,
            "5": self.updateMemo,
            "6": self.addTag,
            "7": self.deleteTag,
        }

    def Menu(self):
        return " 1: Display Menu\n" \
               " 2: Show Notes\n" \
               " 3: Add Note\n" \
               " 4: Delete Note\n" \
               " 5: Update Memo\n" \
               " 6: Add Tag\n" \
               " 7: Delete Tag\n" \

    def displayMenu(self):
        while True:
            print(self.Menu())
            choice = input("Enter Your Input: ")
            action = self.choices.get(choice)
            if action:
                action()

    def showNotes(self):
        for note in self.NoteBook.notes:
            print(note)

    def addNote(self):
        memo = input("Enter your Note: ")
        tags_raw = input("Enter tags: ")
        tags = tags_raw.split()
        self.NoteBook.addNote(memo, tags)

    def deleteNote(self):
        Id = int(input("Enter Note Id: "))
        self.NoteBook.deleteNote(Id)

    def updateMemo(self):
        Id = int(input("Enter Note Id: "))
        updatedMemo = input("Enter New memo: ")
        self.NoteBook.updateMemo(Id, updatedMemo)

    def addTag(self):
        Id = int(input("Enter Note Id: "))
        newTag = input("Enter New Tag: ")
        self.NoteBook.addTag(Id, newTag)

    def deleteTag(self):
        Id = int(input("Enter Note Id: "))
        deleteTag = input("Enter Tag to be deleted: ")
        self.NoteBook.deleteTag(Id, deleteTag)
Beispiel #3
0
 def __init__(self):
     self.NoteBook = NoteBook()
     self.choices = {
         "1": self.displayMenu,
         "2": self.showNotes,
         "3": self.addNote,
         "4": self.deleteNote,
         "5": self.updateMemo,
         "6": self.addTag,
         "7": self.deleteTag,
     }
	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()#文件编码类型
		self.codeType.set("utf-8")#设置文件编码类默认为utf-8

		self.topFrame = Frame(self.root)
		self.topFrame.pack(fill="x")
		self.leftFrame = Frame(self.root)
		self.leftFrame.pack(side="left",fill="y")
		self.rightFrame = Frame(self.root,)
		self.rightFrame.pack(expand="yes",fill="both")

		self.__createMenu()
		self.__createListBox()
		self.__createConsole()
		self.__createShowArea()
Beispiel #5
0
def Main():
        
    """
        order of creation of objects matters. initFrame should be called last
        so that is can assert itself above or below other frames
        depending on the presence of a password file
        
    """
    
    root = Tk()
    root.title('QR Ticket Generator')
    
    mainStyle = GUIStyle()
    
    noteBook = NoteBook("notebook", root)

    mainFrame = GeneratorFrame("Main", noteBook)
    contextFrame = ContextFrame("ChangePass", noteBook)
    optionsFrame = OptionsFrame("Options", noteBook)

    noteBook.add(mainFrame.frame, text="Ticket Generator", state="normal")
    noteBook.add(contextFrame.frame, text="Context", state="normal")
    noteBook.add(optionsFrame.frame, text="Options", state="normal")
    noteBook.grid(column=0, row=0, sticky=("nwes"))
    
    initFrame = InitFrame("Init", root)
    
    for child in root.children.values():
        child.columnconfigure=1
        child.rowconfigure=1

    root.mainloop()
Beispiel #6
0
    def create_main_windows_notebook(self):
        """
            The function creates the main windows tabs and the main windows themselves..
        """

        # Create the notebook and main windows panel.
        self.notebook_panel = wx.Panel(self)

        # Set up the notebook of the main windows.
        self.notebook = NoteBook(self.notebook_panel, self)

        sizer = wx.BoxSizer(wx.HORIZONTAL)

        sizer.Add(self.notebook, 1, wx.EXPAND)

        self.notebook_panel.SetSizer(sizer)

        self.sizer.Add(self.notebook_panel, pos=(0, 0), span=(97, 193), flag=wx.EXPAND)
	def clearFilesList(self):
		self.notebook = NoteBook()
		self.fileListBox.delete(0,self.fileListBox.size()-1)
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()#文件编码类型
		self.codeType.set("utf-8")#设置文件编码类默认为utf-8

		self.topFrame = Frame(self.root)
		self.topFrame.pack(fill="x")
		self.leftFrame = Frame(self.root)
		self.leftFrame.pack(side="left",fill="y")
		self.rightFrame = Frame(self.root,)
		self.rightFrame.pack(expand="yes",fill="both")

		self.__createMenu()
		self.__createListBox()
		self.__createConsole()
		self.__createShowArea()
	
	def __createMenu(self):
		""" 创建菜单 """

		self.menu = Menu(self.root)
		self.root.config(menu=self.menu);

		filemenu = Menu(self.menu)
		self.menu.add_cascade(label="File", menu=filemenu)
		filemenu.add_command(label="Open", command=self.__chooseFiles)
		#filemenu.add_separator()
		filemenu.add_command(label="Clear",command=self.clearFilesList)
		filemenu.add_command(label="Exit",command=self.root.quit)

		helpmenu = Menu(self.menu)
		self.menu.add_cascade(label="Help", menu=helpmenu)
		helpmenu.add_command(label="About",command=self.__about)

	def __about(self):
		tkMessageBox.showwarning("About","author:vince su\ncontact me:[email protected]")

	def __createListBox(self):
		""" 创建文件显示列表"""
		self.fileListBox = Listbox(self.topFrame,height=5)
		self.fileListBox.pack(fill="x",padx=10,pady=10)

	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()) ) 

	def __createShowArea(self):
		""" 创建显示区域 """
		self.showArea = Text(self.rightFrame)
		self.showArea.pack(fill="both",expand="yes")
	
	def __chooseFiles(self):
		""" 选择文件并写入notebook """
		filenames = tkFileDialog.askopenfilenames().split()
		try:
			for s in filenames:
				if self.notebook.add(s):
					self.fileListBox.insert(END,s)
		except:
			tkMessageBox.showerror("error","can't read file.please change code.");

	def showMsg(self,string,flag=1):
		if flag:
			self.showArea.insert(END,"error:%s\n" % string)
		else:
			self.showArea.insert(END,"msg:%s\n" % string)

	def find(self):
		""" 查找下一处 """
		self.isComingSoonDialog()

	def clearFilesList(self):
		self.notebook = NoteBook()
		self.fileListBox.delete(0,self.fileListBox.size()-1)

	def replace(self):
		""" 替换,根据选项可实现单处替换,单一文件替换,所有文件替换 """
		self.showMsg(
				"begin at: %s" % (
				time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())),
			),
			0)
		if self.searchString.get() == "":
			self.showMsg("search string is empty")
			tkMessageBox.showwarning("message", "search string is empty")
			return None
		if self.replaceString.get() == "":
			self.showMsg("replace string is empty")
			tkMessageBox.showwarning("message", "replace string is empty")
			return None
		if self.searchAllFiles.get():
			try:
				self.notebook.reset()
				self.notebook.setSerachStr(self.searchString.get())
				self.notebook.replaceAll(self.replaceString.get())
			except:
				self.showMsg("can non't replace files")
				tkMessageBox.showerror( "message", "can non't replace files")
				return None
			try:
				self.notebook.update()
				tkMessageBox.showwarning( "message", "replace completed")
				self.showMsg("replace completed",0)
			except NoteBookException, e:
				string = None
				for s in e.errorfiles:
					self.showMsg(
						"file:%s --- can not update,the backup files maybe exist." % (s,))
				if len(e.errorfiles) != len(self.notebook.files):
					self.showMsg("other files update completed.",0)
				if len(e.errorfiles) == 1:
					string = "1 file can't update"
				else:
					string = "%d files can't update" % (len(e.errorfiles),)
				tkMessageBox.showerror( "message", string)
				return None
			except Exception:
				self.showMsg("can not update files!")
				tkMessageBox.showerror( "message", "can not update files!")
Beispiel #9
0
from NoteBook import NoteBook
from NoteBook import Note

quote_book = NoteBook("The Quote Book")

new_note = Note()
new_note.write_content("abcdefg")
quote_book.add_note(new_note)

print(quote_book.get_number_of_pages())

quote_book.add_note(Note("Hello, World"))
quote_book.add_note(Note("Hello, World"))
quote_book.add_note(Note("Hello, World"))
quote_book.add_note(Note("Hello, World"))
quote_book.add_note(Note("Hello, World"))

print(quote_book.get_number_of_pages())

my_note = quote_book.remove_note(1)
print(my_note)
my_note = quote_book.remove_note(2)
print(my_note)
my_note = quote_book.remove_note(1)
print(my_note)
Beispiel #10
0
 def clearFilesList(self):
     self.notebook = NoteBook()
     self.fileListBox.delete(0, self.fileListBox.size() - 1)
Beispiel #11
0
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()  #文件编码类型
        self.codeType.set("utf-8")  #设置文件编码类默认为utf-8

        self.topFrame = Frame(self.root)
        self.topFrame.pack(fill="x")
        self.leftFrame = Frame(self.root)
        self.leftFrame.pack(side="left", fill="y")
        self.rightFrame = Frame(self.root, )
        self.rightFrame.pack(expand="yes", fill="both")

        self.__createMenu()
        self.__createListBox()
        self.__createConsole()
        self.__createShowArea()

    def __createMenu(self):
        """ 创建菜单 """

        self.menu = Menu(self.root)
        self.root.config(menu=self.menu)

        filemenu = Menu(self.menu)
        self.menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Open", command=self.__chooseFiles)
        #filemenu.add_separator()
        filemenu.add_command(label="Clear", command=self.clearFilesList)
        filemenu.add_command(label="Exit", command=self.root.quit)

        helpmenu = Menu(self.menu)
        self.menu.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="About", command=self.__about)

    def __about(self):
        tkMessageBox.showwarning(
            "About", "author:vince su\ncontact me:[email protected]")

    def __createListBox(self):
        """ 创建文件显示列表"""
        self.fileListBox = Listbox(self.topFrame, height=5)
        self.fileListBox.pack(fill="x", padx=10, pady=10)

    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()))

    def __createShowArea(self):
        """ 创建显示区域 """
        self.showArea = Text(self.rightFrame)
        self.showArea.pack(fill="both", expand="yes")

    def __chooseFiles(self):
        """ 选择文件并写入notebook """
        filenames = tkFileDialog.askopenfilenames().split()
        try:
            for s in filenames:
                if self.notebook.add(s):
                    self.fileListBox.insert(END, s)
        except:
            tkMessageBox.showerror("error",
                                   "can't read file.please change code.")

    def showMsg(self, string, flag=1):
        if flag:
            self.showArea.insert(END, "error:%s\n" % string)
        else:
            self.showArea.insert(END, "msg:%s\n" % string)

    def find(self):
        """ 查找下一处 """
        self.isComingSoonDialog()

    def clearFilesList(self):
        self.notebook = NoteBook()
        self.fileListBox.delete(0, self.fileListBox.size() - 1)

    def replace(self):
        """ 替换,根据选项可实现单处替换,单一文件替换,所有文件替换 """
        self.showMsg(
            "begin at: %s" % (time.strftime('%Y-%m-%d %H:%M:%S',
                                            time.localtime(time.time())), ), 0)
        if self.searchString.get() == "":
            self.showMsg("search string is empty")
            tkMessageBox.showwarning("message", "search string is empty")
            return None
        if self.replaceString.get() == "":
            self.showMsg("replace string is empty")
            tkMessageBox.showwarning("message", "replace string is empty")
            return None
        if self.searchAllFiles.get():
            try:
                self.notebook.reset()
                self.notebook.setSerachStr(self.searchString.get())
                self.notebook.replaceAll(self.replaceString.get())
            except:
                self.showMsg("can non't replace files")
                tkMessageBox.showerror("message", "can non't replace files")
                return None
            try:
                self.notebook.update()
                tkMessageBox.showwarning("message", "replace completed")
                self.showMsg("replace completed", 0)
            except NoteBookException, e:
                string = None
                for s in e.errorfiles:
                    self.showMsg(
                        "file:%s --- can not update,the backup files maybe exist."
                        % (s, ))
                if len(e.errorfiles) != len(self.notebook.files):
                    self.showMsg("other files update completed.", 0)
                if len(e.errorfiles) == 1:
                    string = "1 file can't update"
                else:
                    string = "%d files can't update" % (len(e.errorfiles), )
                tkMessageBox.showerror("message", string)
                return None
            except Exception:
                self.showMsg("can not update files!")
                tkMessageBox.showerror("message", "can not update files!")