def main(): from filestorage import FileStorage testGUI = Tk() testGUI.fileStorage = FileStorage() processor = Processor(testGUI) processor.grid() testGUI.mainloop()
def __init__(self, storageType="memory"): if storageType == "memory": self.realStorage = MemoryStorage() elif storageType == "file": self.realStorage = FileStorage() elif storageType == "json": self.realStorage = JsonStorage() else: raise TypeError('Wrong storage type!')
class Indexer: def __init__(self, directoryToBeIndexed, indexStorageDirectory): self._directory = directoryToBeIndexed self._indexStorageDirectory = indexStorageDirectory self._filestorage = FileStorage() self._fileNameToDocIdMapper = FileNameToDocIdMapper() self._tokenizer = Tokenizer() def iterateThroughFilesInDirectory(self): docId = 1 for subdir, dirs, files in os.walk(self._directory): for file in files: filepath = subdir + os.sep + file self._tokenizer.tokenizeFiles(filepath, docId) self._fileNameToDocIdMapper.storeFileNameToDictId( filepath, docId) docId += 1 self._filestorage.pickleIndexFile(self._indexStorageDirectory) self._fileNameToDocIdMapper.pickleFileNameToDocMapper( self._indexStorageDirectory)
def main(): "most probably does not work" from filestorage import FileStorage import os.path import os testGUI = Tk() testGUI.fileStorage = FileStorage() testingDir = os.path.join(os.getcwd(), "TestingFiles") from filestorage import recognizeFiles testGUI.fileStorage.addFiles(recognizeFiles([os.path.join(testingDir, file) for file in os.listdir(testingDir)])) controller = Controller(testGUI) controller.grid() controller.controlFun() controller.saveToFrame.saveToVar.set(os.path.join(os.getcwd(), "Results.txt")) controller.saveFun() testGUI.mainloop()
def main(): import os.path import os from filestorage import FileStorage, recognizeFiles testGUI = Tk() testGUI.fileStorage = FileStorage() testGUI.timeFrame = TimeFrame(testGUI) testingDir = os.path.join(os.getcwd(), "TestingFiles") files = recognizeFiles( [os.path.join(testingDir, file) for file in os.listdir(testingDir)]) testGUI.fileStorage.addFiles(files) testGUI.fileStorage.tag(files[1][1]) testGUI.showtracks = ShowTracks(testGUI, files[1], files[1][1]) testGUI.showtracks.grid() testGUI.showtracks.controlled = True testGUI.wm_withdraw() testGUI.mainloop()
def changedTask(self): """called when mode is changed changes names in Options menu exchanges Process, Explore, Control notepages calls m.changeMode puts old filestorage in m.fs[m.mode] and the self.root.[...].fileStorage is reassigned saves old slaves of GUI's notebook and loads new renames GUI and saves the mode selection to options """ if self.task.get() != m.mode: if m.mode: oldname = m.fullname[m.mode] newname = m.fullname[self.task.get()] self.menu_options.entryconfigure( "Parameter settings (" + oldname + ")", label="Parameter settings (" + newname + ")") self.menu_options.entryconfigure(oldname + " options", label=newname + " options") if m.mode in m.slaves: m.slaves[m.mode][1] = self.root.selectFunction.select() m.changeMode(self.task.get()) if m.mode not in m.fs: m.fs[m.mode] = FileStorage() self.root.selectFunction.fileStorage = m.fs[m.mode] if m.mode not in m.slaves: m.slaves[m.mode] = [ m.Slaves(Processor(self.root.selectFunction), Explorer(self.root.selectFunction), Controller(self.root.selectFunction)), None ] self.root.processor = m.slaves[m.mode][0].processor self.root.explorer = m.slaves[m.mode][0].explorer self.root.controller = m.slaves[m.mode][0].controller self.root.changeSlaves() if m.slaves[m.mode][1]: self.root.selectFunction.select(m.slaves[m.mode][1]) self.root.changeTitle(m.name) optionWrite("DefaultTask", "'" + self.task.get() + "'", general=True)
def __init__(self): super().__init__() self.title("CM Manager " + ".".join(version())) self.option_add("*tearOff", FALSE) self.resizable(FALSE, FALSE) ''' used when size of the window is changed for placeWindow arguments self.after(50, lambda: print(self.winfo_width())) self.after(50, lambda: print(self.winfo_height())) ''' placeWindow(self, 1010, 786) # notebook self.selectFunction = ttk.Notebook(self) self.selectFunction.grid() # FileStorage is associated with the Notebook self.selectFunction.fileStorage = FileStorage() self.processor = Processor(self.selectFunction) self.explorer = Explorer(self.selectFunction) self.controller = Controller(self.selectFunction) notepageWidth = 20 self.selectFunction.add(self.processor, text="{:^{}}".format("Process", notepageWidth)) self.selectFunction.add(self.explorer, text="{:^{}}".format("Explore", notepageWidth)) self.selectFunction.add(self.controller, text="{:^{}}".format("Control", notepageWidth)) self.selectFunction.bind("<<NotebookTabChanged>>", lambda e: self.checkProcessing(e)) # menu self["menu"] = MenuCM(self) # checks for new messages and versions on the web if optionGet("CheckMessages", True, "bool"): self.onStart() self.mainloop()
def createWidgets(self): self.selectLabel = ttk.Label(self, text = "Select:") self.selectLabel.grid(column = 0, row = 0, padx = 10, pady = 5) self.select = Select(self, textvariable = self.selectVar) self.select.grid(column = 1, row = 0, sticky = (E, W)) self.searchLabel = ttk.Label(self, text = "Search:") self.searchLabel.grid(column = 2, row = 0, padx = 10, pady = 5) self.search = Search(self, textvariable = self.searchVar) self.search.grid(column = 3, row = 0, sticky = (E, W)) self.filestorage = FileStorage(self) self.filetree = FileTree(self) self.filetree.grid(column = 0, row = 1, rowspan = 4, sticky = (N, S, E, W), columnspan = 4) self.scrollbar = ttk.Scrollbar(self, orient = VERTICAL, command = self.filetree.yview) self.scrollbar.grid(column = 4, row = 1, rowspan = 4, sticky = (N, S, E)) self.filetree.configure(yscrollcommand = self.scrollbar.set) self.tags = Tags(self) self.tags.grid(column = 5, row = 2, sticky = (E, W), padx = 5) self.tagsLab = ttk.Label(text = "Tags") self.tagsLab.grid(column = 5, row = 1, padx = 5, pady = 2) self.notes = Notes(self) self.notes.grid(column = 5, row = 4, sticky = (N, S, E, W), padx = 5) self.notesLab = ttk.Label(text = "Notes") self.notesLab.grid(column = 5, row = 3, padx = 5, pady = 2) self.scrollNotes = ttk.Scrollbar(self, orient = VERTICAL, command = self.notes.yview) self.scrollNotes.grid(column = 6, row = 4, sticky = (N, S, W)) self.notes.configure(yscrollcommand = self.scrollNotes.set) self.buttons = Buttons(self) self.buttons.grid(row = 5, column = 0, columnspan = 5, pady = 5, sticky = (E, W)) self.statusBar = StatusBar(self) self.statusBar.grid(row = 6, column = 0, columnspan = 5, padx = 5, pady = 5, sticky = (E, W))
def __init__(self, directoryToBeIndexed, indexStorageDirectory): self._directory = directoryToBeIndexed self._indexStorageDirectory = indexStorageDirectory self._filestorage = FileStorage() self._fileNameToDocIdMapper = FileNameToDocIdMapper() self._tokenizer = Tokenizer()
class GUI(Tk): "represents GUI" def __init__(self): super().__init__() self.option_add("*tearOff", FALSE) self.initialized = False self.title("Papyer") x, y = 1500, 500 self.minsize(x, y) placeWindow(self, x, y) self.options = Options(self) self["menu"] = TopMenu(self) self.protocol("WM_DELETE_WINDOW", self.closeFun) self.base = os.getcwd() self.selectVar = StringVar() self.searchVar = StringVar() self.createWidgets() self.columnconfigure(1, weight = 1) self.columnconfigure(3, weight = 1) self.columnconfigure(5, weight = 1) self.rowconfigure(4, weight = 1) self.bind("<Control-d>", lambda e: self.filetree.keepDuplicates()) self.bind("<Control-a>", lambda e: self.filetree.selectAll()) self.mainloop() def refresh(self): # do in a smarter way - check changes in the files self.filestorage.save() self.filetree.saveSettings() selected = self.filetree.selection() self.createWidgets() self.filetree.selection_set(selected) def createWidgets(self): self.selectLabel = ttk.Label(self, text = "Select:") self.selectLabel.grid(column = 0, row = 0, padx = 10, pady = 5) self.select = Select(self, textvariable = self.selectVar) self.select.grid(column = 1, row = 0, sticky = (E, W)) self.searchLabel = ttk.Label(self, text = "Search:") self.searchLabel.grid(column = 2, row = 0, padx = 10, pady = 5) self.search = Search(self, textvariable = self.searchVar) self.search.grid(column = 3, row = 0, sticky = (E, W)) self.filestorage = FileStorage(self) self.filetree = FileTree(self) self.filetree.grid(column = 0, row = 1, rowspan = 4, sticky = (N, S, E, W), columnspan = 4) self.scrollbar = ttk.Scrollbar(self, orient = VERTICAL, command = self.filetree.yview) self.scrollbar.grid(column = 4, row = 1, rowspan = 4, sticky = (N, S, E)) self.filetree.configure(yscrollcommand = self.scrollbar.set) self.tags = Tags(self) self.tags.grid(column = 5, row = 2, sticky = (E, W), padx = 5) self.tagsLab = ttk.Label(text = "Tags") self.tagsLab.grid(column = 5, row = 1, padx = 5, pady = 2) self.notes = Notes(self) self.notes.grid(column = 5, row = 4, sticky = (N, S, E, W), padx = 5) self.notesLab = ttk.Label(text = "Notes") self.notesLab.grid(column = 5, row = 3, padx = 5, pady = 2) self.scrollNotes = ttk.Scrollbar(self, orient = VERTICAL, command = self.notes.yview) self.scrollNotes.grid(column = 6, row = 4, sticky = (N, S, W)) self.notes.configure(yscrollcommand = self.scrollNotes.set) self.buttons = Buttons(self) self.buttons.grid(row = 5, column = 0, columnspan = 5, pady = 5, sticky = (E, W)) self.statusBar = StatusBar(self) self.statusBar.grid(row = 6, column = 0, columnspan = 5, padx = 5, pady = 5, sticky = (E, W)) def closeFun(self): "ask for saving files on exit" self.filetree.saveSettings() self.filestorage.save() self.options.save() self.destroy()