def __init__(self, root): super().__init__(root) self.root = root self.title(m.fullname[m.mode] + " options") self.grab_set() self.focus_set() self.resizable(FALSE, FALSE) placeWindow(self, 720, 350) self["padx"] = 10 self["pady"] = 10 self.parametersF = ParameterFrame(self, "Default parameters") # selection of directories self.fileDirectory = ChooseDirectoryFrame(self, "Default directory for file selection", "FileDirectory", r'{}'.format(os.getcwd()), False) # default time self.timeLabFrame = ttk.Labelframe(self, text = "Default time") self.timeFrame = TimeFrame(self.timeLabFrame, observe = False, loadtime = False) self.timeFrame.grid(row = 0, column = 0) # buttons self._createButtons() # grid of self contents self.parametersF.grid(row = 0, column = 0, columnspan = 2, sticky = (N, W), padx = 4, pady = 2) self.buttonFrame.grid(row = 3, column = 0, columnspan = 2, padx = 3, pady = 6, sticky = (E, W, N, S)) self.timeLabFrame.grid(row = 1, column = 1, padx = 6, pady = 4, sticky = (N, W, E)) self.fileDirectory.grid(row = 1, column = 0, pady = 2, padx = 2, sticky = (E, W))
def __init__(self, root, filename): super().__init__(root) self.root = root self.fileStorage = self.root.fileStorage placeWindow(self, 574, 190) self.title("Comment") self.grab_set() self.focus_set() self.file = filename self.comment = self.fileStorage.comments[self.file] self.name = ttk.Label(self, text = filename) self.okBut = ttk.Button(self, text = "Ok", command = self.okFun) self.closeBut = ttk.Button(self, text = "Close", command = self.destroy) self.text = Text(self, height = 8, wrap = "word", width = 70) self.okBut.grid(column = 2, row = 2, pady = 2, padx = 10) self.closeBut.grid(column = 1, row = 2, pady = 2, padx = 10) self.name.grid(column = 0, row = 0, columnspan = 4, pady = 3, padx = 5) self.text.grid(column = 0, row = 1, columnspan = 4, pady = 2, padx = 5, sticky = (N, S, E, W)) self.columnconfigure(0, weight = 1) self.columnconfigure(3, weight = 1) self.rowconfigure(1, weight = 1) self.text.insert("1.0", self.comment) self.text.bind("<3>", lambda e: self.popUp(e))
def __init__(self): super().__init__() self.option_add("*tearOff", FALSE) self.resizable(FALSE, FALSE) self.initialized = False ''' # used when size of the window is changed for placeWindow arguments self.after(250, lambda: print(self.winfo_width())) self.after(250, lambda: print(self.winfo_height())) ''' x, y = 1000, 770 placeWindow(self, x, y) self.selectFunction = ttk.Notebook(self) self.selectFunction.grid() self["menu"] = MenuCM(self) self.protocol("WM_DELETE_WINDOW", self.closeFun) self.initialized = True path = optionGet("SelectedFilesDirectory", os.path.join(os.getcwd(), "Stuff", "Selected files"), "str", True) loadFileStorage(self, os.path.join(path, "~last.files")) self.mainloop()
def __init__(self, root, logfile, results = None): super().__init__(root) self.root = root self.title("Warning") self.grab_set() self.focus_set() placeWindow(self, 350, 100) self.resizable(False, False) self.logfile = logfile self.minsize(350, 100) # buttons self.cancelBut = ttk.Button(self, text = "Cancel", command = self.cancelFun) self.cancelBut.grid(column = 2, row = 2, pady = 2) self.showBut = ttk.Button(self, text = "Open log", command = self.showFun) self.showBut.grid(column = 1, row = 2, pady = 2) self.resultsBut = ttk.Button(self, text = "Show results", command = self.resultsFun) self.resultsBut.grid(column = 0, row = 2, pady = 2) if not results or not os.path.exists(results): self.resultsBut.state(["disabled"]) # text self.label = ttk.Label(self, text = "Some problem occured during processing.\n" +\ "See log for details.", anchor = "center", justify = "center") self.label.grid(column = 0, columnspan = 3, row = 0, padx = 8, pady = 5, sticky = (N, S, E, W)) self.rowconfigure(0, weight = 1) self.columnconfigure(0, weight = 1) self.columnconfigure(1, weight = 2) self.columnconfigure(2, weight = 1)
def __init__(self, root, logfile): super().__init__(root) self.root = root self.title("Warning") self.grab_set() self.focus_set() placeWindow(self, 250, 100) self.resizable(False, False) self.logfile = logfile self.minsize(250, 100) # buttons self.cancelBut = ttk.Button(self, text = "Cancel", command = self.cancelFun) self.cancelBut.grid(column = 0, row = 2, pady = 2) self.showBut = ttk.Button(self, text = "Open log", command = self.showFun) self.showBut.grid(column = 1, row = 2, pady = 2) # text self.label = ttk.Label(self, text = "Some problem occured during processing.\n" +\ "See log for details.", justify = "center") self.label.grid(column = 0, columnspan = 2, row = 0, padx = 8, pady = 5, sticky = (N, S, E, W)) self.rowconfigure(0, weight = 1) self.columnconfigure(0, weight = 1) self.columnconfigure(1, weight = 1)
def __init__(self, root): super().__init__(root) self["padx"] = 4 self["pady"] = 4 self.version = version.version() self.title("Updates") self.resizable(FALSE, FALSE) placeWindow(self, 488, 127) try: newVersion = self.checkNewVersion() if newVersion: available = ("There is a new version ({}.{}.{}) available.\n".format(*newVersion) + "Restart CMM to install the update.") optionWrite("DontShowVersion", self.version) else: available = "There is no new version available." except Exception: available = "Unable to get information about the newest version." text = "Your current version is {1}.{2}.{3}.\n\n{0}".format(available, *self.version) self.text = Text(self, height = 4, width = 58, relief = "flat", background = self.cget("background")) self.text.grid(column = 0, row = 0, padx = 6, pady = 6) self.text.insert("end", text) self.close = ttk.Button(self, text = "Close", command = self.destroy) self.close.grid(column = 0, row = 1, pady = 7)
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 __init__(self, root, title, message, dontShowOption = "", optionValue = None, html = True): super().__init__(root) self.root = root self.title(title) self.grab_set() self.focus_set() self.lift(root) placeWindow(self, 300, 150) self.resizable(False, False) self.minsize(300, 150) self.dontshow = dontShowOption self.optionValue = optionValue # message if html: message = message.replace("<br>", "\n") try: width, height = message.split("\n")[0].split("x") width = int(width.strip()) height = int(height.strip()) except Exception: width, height = 60, 10 else: message = "\n".join(message.split("\n")[1:]) self.text = Text(self, width = width, height = height, wrap = "word") self.text.grid(column = 0, row = 0, pady = 2, sticky = (N, S, E, W)) for count, part in enumerate(message.split("\\n")): if count != 0: self.text.insert("end", "\n") self.text.insert("end", part) links = [word for word in message.split() if "www." in word] idx = "1.0" for link in links: idx = self.text.search(link, idx, "end") lastidx = "{}+{}c".format(idx, len(link)) self.text.tag_add("link", idx, lastidx) idx = lastidx self.text.tag_configure("link", foreground = "blue") self.text.tag_bind("link", "<1>", lambda e: self.link(e)) self.text.tag_bind("link", "<Enter>", lambda e: self._enter(e)) self.text.tag_bind("link", "<Leave>", lambda e: self._leave(e)) self.text["state"] = "disabled" # dont show again checkbutton if self.dontshow: self.dontShowVar = BooleanVar() self.dontShowVar.set(False) self.dontShowCheck = ttk.Checkbutton(self, text = "Don't show me this message again.", variable = self.dontShowVar) self.dontShowCheck.grid(column = 0, row = 1, pady = 6, sticky = W, padx = 4) # cancel button self.okBut = ttk.Button(self, text = "Ok", command = self.okFun) self.okBut.grid(column = 0, row = 2, pady = 2) self.columnconfigure(0, weight = 1) self.rowconfigure(0, weight = 1)
def __init__(self, root): super().__init__(root, "Add label") placeWindow(self, 598, 208) self.var = StringVar() tags = [tag for tag in tuple(sorted(self.root.filestorage.getAllTags())) if tag not in self.root.options["tags"]] self.combo = ttk.Combobox(self, textvariable = self.var, values = tags) self.combo.grid(column = 2, columnspan = 2, row = 1)
def __init__(self, root, file): super().__init__(root, "Rename file") placeWindow(self, 598, 208) self.file = file self.nameVar = StringVar() self.nameVar.set(os.path.splitext(os.path.basename(file))[0]) self.name = ttk.Entry(self, textvariable=self.nameVar, width=50) self.name.grid(column=2, columnspan=2, row=1, sticky=(E, W), pady=5)
def __init__(self, root): if not os.path.exists(os.path.join(os.getcwd(), "Stuff", "Help")): messagebox.showinfo(message = "Folder 'Help' doesn't exist in the " + "'Stuff' directory!", title = "Error", icon = "error") return super().__init__(root) self["padx"] = 7 self["pady"] = 7 self.title("Help") placeWindow(self, 806, 699) self.resizable(FALSE, FALSE) self.goneThrough = [[""], 0] # variable containing lists of items gone through and their # position (e.g. [["", 0], ["Parameters", 1], ["Shocks", 2]]) self.linkMapping = {} # variable containing texts and items that the texts refer to # widgets self.text = Text(self, width = 70, height = 40, wrap = "word", cursor = "") self.text.grid(column = 1, row = 1, pady = 4) self.scroll = ttk.Scrollbar(self, orient = VERTICAL, command = self.text.yview) self.scroll.grid(column = 2, row = 1, pady = 4, sticky = (N, S, W)) self.text.configure(yscrollcommand = self.scroll.set) self.buttonBar = ttk.Frame(self) self.buttonBar.grid(column = 1, row = 0, pady = 4, sticky = (N, S, E, W)) self.buttonBar.columnconfigure(2, weight = 1) self.searchBut = ttk.Button(self.buttonBar, text = "Search", command = self.searchFun) self.searchBut.grid(column = 4, row = 0) self.searchTerm = StringVar() self.searchEntry = ttk.Entry(self.buttonBar, width = 30, justify = "left", textvariable = self.searchTerm) self.searchEntry.grid(column = 3, row = 0, padx = 4) self.returnBut = ttk.Button(self.buttonBar, text = "Return", command = self.returnFun) self.returnBut.grid(column = 0, row = 0, padx = 4) self.forwardBut = ttk.Button(self.buttonBar, text = "Forward", command = self.forwardFun) self.forwardBut.grid(column = 1, row = 0, padx = 4) self.tree = ttk.Treeview(self, selectmode = "browse") self.tree.grid(column = 0, row = 0, rowspan = 2, pady = 4, padx = 4, sticky = (N, S, E, W)) self.makeTree() self.makeText("Help") # initial text is from file 'Help' self.tree.bind("<1>", self.treeSelect)
def __init__(self, root): super().__init__(root) self.root = root placeWindow(self, 598, 208) self.title("Images options") self.grab_set() self.focus_set() self.resizable(False, False) self.oFrame = ttk.Frame(self) self.oFrame.grid(column = 0, columnspan = 3, row = 0) options = (("Scale", ("LastImageScale", 1, ["int", "float"])), ("Main title ('default' for filename)", ("LastImageMain", "default", "str")), ("Horizontal gap", ("LastImageXgap", 10, ["int", "float"])), ("Vertical gap", ("LastImageYgap", 10, ["int", "float"])), ("x-axis title", ("LastImageXlab", "Time", "str")), ("y-axis title (smart 'default')", ("LastImageYlab", "default", "str")), ("x-axis ticks", ("LastImageXticks", True, "bool")), ("y-axis ticks", ("LastImageYticks", True, "bool"))) self.options = options self.opts = [] entryWidth = 10 for row, option in enumerate(options): self.opts.append({}) var = BooleanVar if option[1][2] == 'bool' else StringVar self.opts[row]["variable"] = var() current = optionGet(*option[1]) if type(current) == str: current = "'" + current + "'" self.opts[row]["variable"].set(current) self.opts[row]["label"] = ttk.Label(self.oFrame, text = option[0]) self.opts[row]["label"].grid(column = 0, row = row, pady = 2, sticky = E) if option[1][2] == 'bool': self.opts[row]["input"] = ttk.Checkbutton(self.oFrame, onvalue = True, offvalue = False, variable = self.opts[row]["variable"]) else: self.opts[row]["input"] = ttk.Entry(self.oFrame, width = entryWidth, justify = 'right', textvariable = self.opts[row]["variable"]) self.opts[row]["input"].grid(column = 1, row = row, padx = 2, pady = 2) self.okBut = ttk.Button(self, text = "Ok", command = self.okFun) self.okBut.grid(column = 2, row = 1, padx = 3, pady = 4) self.cancelBut = ttk.Button(self, text = "Cancel", command = self.cancelFun) self.cancelBut.grid(column = 1, row = 1, padx = 3, pady = 4) self.resetBut = ttk.Button(self, text = "Reset", command = self.resetFun) self.resetBut.grid(column = 0, row = 1, padx = 3, pady = 4)
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 __init__(self, root, number, text = "processed"): super().__init__(root) self.root = root self.number = number self.title("Progress") self.focus_set() self.grab_set() placeWindow(self, 404, 80) self.geometry("+500+300") self.text = text self.resizable(FALSE, FALSE) # progressbar self.progress = ttk.Progressbar(self, orient = HORIZONTAL, length = 400, mode = "determinate") self.progress.configure(maximum = number) self.progress.grid(column = 0, row = 1, columnspan = 2, pady = 3, padx = 2) # cancel button self.cancel = ttk.Button(self, text = "Cancel", command = self.close) self.cancel.grid(column = 0, columnspan = 2, row = 2, pady = 2) # number of files label self.numFiles = StringVar() self.processed = 0 self.processedFilesText = "{} out of {} files {}".format("{}", self.number, self.text) self.numFiles.set(self.processedFilesText.format(self.processed)) self.numFilesLab = ttk.Label(self, textvariable = self.numFiles) self.numFilesLab.grid(row = 0, column = 1, sticky = E, pady = 2, padx = 2) # expected time label self.begintime = time() self.timeText = "Remaining time: {}" self.timeVar = StringVar() self.timeLab = ttk.Label(self, textvariable = self.timeVar) self.timeLab.grid(row = 0, column = 0, sticky = W, pady = 2, padx = 2) self.protocol("WM_DELETE_WINDOW", lambda: self.close())
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(250, lambda: print(self.winfo_width())) self.after(250, lambda: print(self.winfo_height())) ''' placeWindow(self, 1010, 834) # 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) if not optionGet("Developer", False, 'bool'): self.protocol("WM_DELETE_WINDOW", self.closeFun) self.mainloop()
def __init__(self, root): super().__init__(root) self["padx"] = 4 self["pady"] = 4 self.version = ".".join(version.version()) self.title("About") self.resizable(FALSE, FALSE) placeWindow(self, 488, 303) line12 = "Carousel Maze Manager\nVersion " + self.version + "\n" + version.date() + "\n\n" line5 = "Copyright " + version.copyleft() + " Štěpán Bahník\[email protected]\n\n" line6 = "This program comes with ABSOLUTELY NO WARRANTY.\n" line8 = "This is free software, and you are welcome to redistribute\n" line9 = "it under certain conditions; click " line10 = "here" line11 = " for details.\n\n" self.aboutText = Text(self, height=15, width=58, relief="flat", background=self.cget("background")) self.aboutText.grid(column=0, row=0, padx=6, pady=6) text = line12 + line5 + line6 + line8 + line9 self.aboutText.insert("end", text) self.aboutText.insert("end", line10, "link") self.aboutText.insert("end", line11) self.aboutText.tag_configure("link", foreground="blue") self.aboutText.tag_bind("link", "<1>", lambda e: self.link(e)) self.aboutText.tag_bind("link", "<Enter>", lambda e: self._enter(e)) self.aboutText.tag_bind("link", "<Leave>", lambda e: self._leave(e)) filepath = os.path.join(os.getcwd(), "Stuff", "Modules", "GNUlogo.gif") self.logo = PhotoImage(file=filepath) self.aboutText.insert("end", " " * 21) self.aboutText.image_create("end", image=self.logo) self.aboutExit = ttk.Button(self, text="Close", command=self.aboutExit) self.aboutExit.grid(column=0, row=1, pady=7)
def __init__(self, root): super().__init__(root) self["padx"] = 4 self["pady"] = 4 self.title("Citation") self.resizable(FALSE, FALSE) placeWindow(self, 488, 135) v = version.version() year = version.date().split()[2] url = "https://github.com/bahniks/CM_Manager_{}_{}_{}".format(*v) text = ("Please cite this software as:\n\n" + "Bahník, Š. ({}). Carousel Maze Manager (Version {}.{}.{}) ".format(year, *v) + "[Software]. Available from {}".format(url)) self.text = Text(self, height = 5, width = 70, relief = "flat", wrap = "word", background = self.cget("background")) self.text.grid(column = 0, row = 0, padx = 6, pady = 6) self.text.insert("end", text) self.close = ttk.Button(self, text = "Close", command = self.destroy) self.close.grid(column = 0, row = 1, pady = 7)
def __init__(self, root): super().__init__(root) self["padx"] = 4 self["pady"] = 4 self.version = ".".join(version.version()) self.title("About") self.resizable(FALSE, FALSE) placeWindow(self, 488, 303) text = ("Carousel Maze Manager\nVersion " + self.version + "\n" + version.date() + "\n\n" "Copyright "+ version.copyleft() + " Štěpán Bahník\[email protected]\n\n" "This program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and " "you are welcome to redistribute\nit under certain conditions; click ") line10 = "here" line11 = " for details.\n\n" self.aboutText = Text(self, height = 15, width = 58, relief = "flat", background = self.cget("background")) self.aboutText.grid(column = 0, row = 0, padx = 6, pady = 6) self.aboutText.insert("end", text) self.aboutText.insert("end", line10, "link") self.aboutText.insert("end", line11) self.aboutText.tag_configure("link", foreground = "blue") self.aboutText.tag_bind("link", "<1>", lambda e: self.link(e)) self.aboutText.tag_bind("link", "<Enter>", lambda e: self._enter(e)) self.aboutText.tag_bind("link", "<Leave>", lambda e: self._leave(e)) filepath = os.path.join(os.getcwd(), "Stuff", "Modules", "GNUlogo.gif") self.logo = PhotoImage(file = filepath) self.aboutText.insert("end", " "*21) self.aboutText.image_create("end", image = self.logo) self.aboutExit = ttk.Button(self, text = "Close", command = self.aboutExit) self.aboutExit.grid(column = 0, row = 1, pady = 7)
def __init__(self, root): super().__init__(root) self.title("Parameter settings") self.grab_set() self.focus_set() self.resizable(FALSE, FALSE) placeWindow(self, 389, 682) self["padx"] = 10 self["pady"] = 10 self.saveBut = ttk.Button(self, text = "Save", command = self.saveFun) self.okBut = ttk.Button(self, text = "Ok", command = self.okFun) self.cancelBut = ttk.Button(self, text = "Cancel", command = self.cancelFun) self.saveBut.grid(column = 0, row = 3, padx = 3, pady = 2) self.okBut.grid(column = 1, row = 3, padx = 3, pady = 2) self.cancelBut.grid(column = 2, row = 3, padx = 3, pady = 2) # parameter settings self.parSettingsFrame = ttk.Frame(self) self.parSettingsFrame.grid(row = 1, column = 0, columnspan = 3, padx = 3, pady = 4, sticky = (N, W)) self.parSettingsFrame.columnconfigure(1, weight = 1) self.RlabelWidth = 8 self.EntryWidth = 10 # thigmotaxis - mozno nahradit pomoci ParameterOptionFrame ! self.thigmotaxisFrame = ttk.Labelframe(self.parSettingsFrame, text = "Thigmotaxis") self.thigmotaxisFrame.grid(column = 0, row = 2, columnspan = 3, pady = 3, padx = 3, sticky = (W, E)) self.thigmotaxisFrame.columnconfigure(0, weight = 1) self.thigmotaxisVar = StringVar() self.thigmotaxisVar.set(optionGet("ThigmotaxisPercentSize", 20, ["int", "float"])) self.thigmotaxisEntry = ttk.Entry(self.thigmotaxisFrame, textvariable = self.thigmotaxisVar, width = self.EntryWidth, justify = "right") self.thigmotaxisEntry.grid(column = 1, row = 1, padx = 1, pady = 2) self.thigmotaxisLab = ttk.Label(self.thigmotaxisFrame, text = "Annulus width:") self.thigmotaxisLab.grid(column = 0, row = 1, padx = 1, pady = 2, sticky = E) self.percentLab = ttk.Label(self.thigmotaxisFrame, text = "%", width = self.RlabelWidth) self.percentLab.grid(column = 2, row = 1, padx = 1, pady = 2, sticky = W) # setting of Time in chosen sector parameter self.TimeInChosenFrame = ttk.Labelframe(self.parSettingsFrame, text = "Time in chosen sector") self.TimeInChosenFrame.grid(column = 0, row = 0, columnspan = 3, pady = 3, padx = 3) self.TimeInChosenWidthVar = StringVar() self.TimeInChosenWidthVar.set(optionGet('WidthParTimeInChosen', 'default', ['int', 'float'])) self.TimeInChosenWidthEntry = ttk.Entry(self.TimeInChosenFrame, textvariable = self.TimeInChosenWidthVar, width = self.EntryWidth, justify = "right") self.TimeInChosenWidthEntry.grid(column = 1, row = 1, padx = 2, pady = 2) self.TimeInChosenWidthLab = ttk.Label(self.TimeInChosenFrame, text = "Width of sector ('default' if same as target):") self.TimeInChosenWidthLab.grid(column = 0, row = 1, pady = 2, sticky = (E)) self.DegreesLab = ttk.Label(self.TimeInChosenFrame, text = "°", width = self.RlabelWidth) self.DegreesLab.grid(column = 2, row = 1, pady = 2) self.TimeInChosenAngleVar = StringVar() self.TimeInChosenAngleVar.set(optionGet('AngleParTimeInChosen', 0, ['int', 'float'])) self.TimeInChosenAngleEntry = ttk.Entry(self.TimeInChosenFrame, textvariable = self.TimeInChosenAngleVar, width = self.EntryWidth, justify = "right") self.TimeInChosenAngleEntry.grid(column = 1, row = 0, padx = 2, pady = 2) self.TimeInChosenAngleLab = ttk.Label(self.TimeInChosenFrame, text = "Center of sector relative to the target:") self.TimeInChosenAngleLab.grid(column = 0, row = 0, pady = 2, sticky = (E)) self.DegreesLab2 = ttk.Label(self.TimeInChosenFrame, text = "°", width = self.RlabelWidth) self.DegreesLab2.grid(column = 2, row = 0, pady = 2) # setting of Time in sectors parameter self.TimeInSectorsFrame = ttk.Labelframe(self.parSettingsFrame, text = "Time in sectors") self.TimeInSectorsFrame.grid(column = 0, row = 1, columnspan = 3, pady = 3, padx = 3) self.TimeInSectorsWidthVar = StringVar() self.TimeInSectorsWidthVar.set(optionGet('WidthParTimeInSectors', 'default', ['int', 'float'])) self.TimeInSectorsWidthEntry = ttk.Entry(self.TimeInSectorsFrame, textvariable = self.TimeInSectorsWidthVar, width = self.EntryWidth, justify = "right") self.TimeInSectorsWidthEntry.grid(column = 1, row = 1, padx = 2, pady = 2) self.TimeInSectorsWidthLab = ttk.Label(self.TimeInSectorsFrame, text = "Width of sector ('default' if same as target):") self.TimeInSectorsWidthLab.grid(column = 0, row = 1, pady = 2, sticky = (E)) self.DegreesLab3 = ttk.Label(self.TimeInSectorsFrame, text = "°", width = self.RlabelWidth) self.DegreesLab3.grid(column = 2, row = 1, pady = 2) # setting of Total distance parameter self.totalDistance = ParameterOptionFrame(self.parSettingsFrame, "Total distance", (("Sampling after every:", ( 'StrideParTotalDistance', 25, 'int'), "rows"), ("Minimal distance counted:", ( 'MinDiffParTotalDistance', 0, ['int', 'float']), "pixels"))) self.totalDistance.grid(column = 0, row = 3, columnspan = 3, pady = 3, padx = 3, sticky = (W, E)) # setting of Maximum time of immobility parameter self.maximumTimeImmobility = ParameterOptionFrame(self.parSettingsFrame, "Maximum time of immobility", (("Minimum speed counted:", ( 'MinSpeedMaxTimeImmobility', 10, ['int', 'float']), "cm/s"), ("Computed from every:", ('SkipMaxTimeImmobility', 12, ['int']), "rows"), ("Averaged across:", ('SmoothMaxTimeImmobility', 2, ['int']), "intervals"))) self.maximumTimeImmobility.grid(column = 0, row = 4, columnspan = 3, pady = 3, padx = 3, sticky = (W, E)) # setting of Periodicity parameter self.periodicity = ParameterOptionFrame(self.parSettingsFrame, "Periodicity", (("Minimum speed counted:", ('MinSpeedPeriodicity', 10, ['int', 'float']), "cm/s"), ("Computed from every:", ('SkipPeriodicity', 12, ['int']), "rows"), ("Averaged across:", ('SmoothPeriodicity', 2, ['int']), "intervals"), ("Minimum time of interval:", ('MinTimePeriodicity', 9, ['int', 'float', 'list']), "seconds"))) self.periodicity.grid(column = 0, row = 5, columnspan = 3, pady = 3, padx = 3, sticky = (W, E)) # setting of Proportion of time moving parameter self.percentMobility = ParameterOptionFrame(self.parSettingsFrame, "Proportion of time moving", (("Minimum speed counted:", ('MinSpeedPercentMobility', 5, ['int', 'float']), "cm/s"), ("Computed from every:", ('SkipPercentMobility', 12, 'int'), "rows"), ("Averaged across:", ('SmoothPercentMobility', 2, 'int'), "intervals"))) self.percentMobility.grid(column = 0, row = 6, columnspan = 3, pady = 3, padx = 3, sticky = (W, E)) # setting of Proportion of time moving parameter self.speedAfterShock = ParameterOptionFrame(self.parSettingsFrame, "Median speed after shock", [("Computed from every:", ('SkipSpeedAfterShock', 25, 'int'), "rows")]) self.speedAfterShock.grid(column = 0, row = 7, columnspan = 3, pady = 3, padx = 3, sticky = (W, E))
def __init__(self, root, files): super().__init__(root) self.root = root self.fileStorage = self.root.root.root.fileStorage self["padx"] = 4 self["pady"] = 4 self.grab_set() self.focus_set() placeWindow(self, 758, 760) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) if files == "arenafiles": self.title("Matched files") self.initfiles = self.fileStorage.arenafiles elif files == "wrongfiles": self.title("Non-matched files") self.initfiles = self.fileStorage.wrongfiles self.shownFiles = files # frame with files self.filesFrame = ttk.Frame(self) self.filesFrame.grid(column=0, row=0, sticky=(N, S, E, W)) self.filesFrame.columnconfigure(1, weight=1) self.filesFrame.rowconfigure(0, weight=1) self.filesTree = ttk.Treeview(self.filesFrame, height=35) self.filesTree.grid(column=1, row=0, sticky=(N, S, E, W)) if files == "wrongfiles": self.filesTree["columns"] = ("directory") directoryWidth = 480 else: self.filesTree["columns"] = ("directory", "tag") self.filesTree.column("tag", width=30, anchor="center") self.filesTree.heading("tag", text="Tag", command=self.orderByTag) directoryWidth = 450 self.filesTree.column("#0", width=250, anchor="w") self.filesTree.heading("#0", text="Filename", command=self.orderByFilename) self.filesTree.column("directory", width=directoryWidth, anchor="w") self.filesTree.heading("directory", text="Directory", command=self.orderByDirectory) self.scrollbar = ttk.Scrollbar(self.filesFrame, orient=VERTICAL, command=self.filesTree.yview) self.scrollbar.grid(column=2, row=0, sticky=(N, S, E)) self.filesTree.configure(yscrollcommand=self.scrollbar.set) # button frame self.buttonFrame = ttk.Frame(self) self.buttonFrame.grid(column=0, row=1, sticky=(E, W)) self.buttonFrame.columnconfigure(3, weight=1) self.buttonFrame.columnconfigure(6, weight=1) self.removeBut = ttk.Button(self.buttonFrame, text="Remove Files", command=self.removeFun) self.removeBut.grid(column=0, row=0) self.cropBut = ttk.Button(self.buttonFrame, text="Crop Files", command=self.cropFun) self.cropBut.grid(column=1, row=0) self.selectAllBut = ttk.Button(self.buttonFrame, text="Select All", command=self.selectAllFun) self.selectAllBut.grid(column=2, row=0) self.closeBut = ttk.Button(self.buttonFrame, text="Close", command=self.closeFun) self.closeBut.grid(column=8, row=0) if files == "wrongfiles": self.pairSelectedBut = ttk.Button(self.buttonFrame, text="Pair Selected", command=self.pairSelectedFun) self.pairSelectedBut.grid(column=4, row=0) self.findPairsBut = ttk.Button(self.buttonFrame, text="Find Pairs", command=self.findPairsFun) self.findPairsBut.grid(column=5, row=0) self.showArenafilesBut = ttk.Button(self.buttonFrame, text="Show Matched Files", command=self.showArenafilesFun) self.showArenafilesBut.grid(column=7, row=0) else: self.tagFilesBut = ttk.Button(self.buttonFrame, text="Tag Files", command=self.tagFilesFun) self.tagFilesBut.grid(column=4, row=0) self.untagFilesBut = ttk.Button(self.buttonFrame, text="Untag Files", command=self.untagFilesFun) self.untagFilesBut.grid(column=5, row=0) self.showWrongfilesBut = ttk.Button(self.buttonFrame, text="Show Non-matched Files", command=self.showWrongfilesFun) self.showWrongfilesBut.grid(column=7, row=0) self.filesTree.bind("<3>", lambda e: self.popUp(e)) self.filesTree.bind("<Double-1>", lambda e: self.doubleClick(e)) self.protocol("WM_DELETE_WINDOW", lambda: self.closeFun()) self.initialize()
def __init__(self, root): super(OptionsCM, self).__init__(root) self.root = root self.title("General options") self.grab_set() self.focus_set() self.resizable(FALSE, FALSE) placeWindow(self, 554, 499) self["padx"] = 10 self["pady"] = 10 # default filetype of processor output self.fileTypeVar = StringVar() self.fileTypeVar.set(optionGet("DefProcessOutputFileType", ".txt", "str", True)) self.fileTypeFrame = ttk.Labelframe(self, text = "Default output filetype") self.txtRadioBut = ttk.Radiobutton(self.fileTypeFrame, text = ".txt", variable = self.fileTypeVar, value = ".txt") self.csvRadioBut = ttk.Radiobutton(self.fileTypeFrame, text = ".csv", variable = self.fileTypeVar, value = ".csv") self.txtRadioBut.grid(row = 1, column = 0, padx = 2, pady = 2, sticky = W) self.csvRadioBut.grid(row = 0, column = 0, padx = 2, pady = 2, sticky = W) # output separator self.separatorVar = StringVar() self.separatorVar.set(optionGet("ResultSeparator", ",", "str", True)) self.separatorFrame = ttk.Labelframe(self, text = "Result separator") self.commaRadioBut = ttk.Radiobutton(self.separatorFrame, text = "Comma", variable = self.separatorVar, value = ",") self.semicolonRadioBut = ttk.Radiobutton(self.separatorFrame, text = "Semicolon", variable = self.separatorVar, value = ";") self.tabRadioBut = ttk.Radiobutton(self.separatorFrame, text = "Tab", variable = self.separatorVar, value = "\t") self.commaRadioBut.grid(row = 0, padx = 2, pady = 2, sticky = W) self.semicolonRadioBut.grid(row = 1, padx = 2, pady = 2, sticky = W) self.tabRadioBut.grid(row = 2, padx = 2, pady = 2, sticky = W) # selection of directories self.directoriesFrame = ttk.Frame(self) self.directoriesFrame.columnconfigure(0, weight = 1) self.directoryOptions = [ ("Default directory for results", "ResultDirectory", os.getcwd(), True), ("Directory for saving of processing logs", "LogDirectory", os.path.join(os.getcwd(), "Stuff", "Logs"), True), ("Directory for images", "ImageDirectory", os.getcwd(), True), ("Directory for saving of selected files", "SelectedFilesDirectory", os.path.join(os.getcwd(), "Stuff", "Selected files"), True)] for count, option in enumerate(self.directoryOptions): exec("""self.{1} = ChooseDirectoryFrame(self.directoriesFrame, '{0}', '{1}', \ r'{2}', {3})""".format(*option)) exec("self.{}.grid(row = {}, column = 0, pady = 2, padx = 2, sticky = (E, W))".format( option[1], count)) # save filename as full path self.saveFilenameAs = RadioFrame(self, text = "Save (show) filename as:", optionName = "SaveFullPath", default = "Basename", options = ["Basename", "Full path", "Unique path"]) # processor options self.processorOptions = OptionFrame(self, text = "Default process options") self._createButtons() self.commentColor = ttk.Button(self, text = "Comment color", command = self.chooseCommentColor) self.commentColor.grid(column = 2, row = 0, padx = 2, pady = 2) self.fileTypeFrame.grid(row = 0, column = 0, padx = 3, pady = 4, sticky = (W, N, E, S)) self.buttonFrame.grid(row = 3, column = 0, columnspan = 3, padx = 3, pady = 6, sticky = (E, W, N, S)) self.separatorFrame.grid(row = 1, column = 0, padx = 3, pady = 4, sticky = (W, N, E)) self.saveFilenameAs.grid(row = 0, column = 1, padx = 3, pady = 4, sticky = (N, W, E)) self.processorOptions.grid(row = 1, column = 1, pady = 4, padx = 4, sticky = (N, W)) self.directoriesFrame.grid(row = 2, column = 0, columnspan = 3, padx = 3, pady = 4)
def __init__(self, root): super().__init__(root) self.title("Parameter settings (" + m.fullname[m.mode] + ")") self.grab_set() self.focus_set() self.resizable(FALSE, FALSE) self.minsize(410, 300) height = 382 if m.mode == "OF" else 800 placeWindow(self, 410, height) self.columnconfigure(0, weight = 3) self.columnconfigure(1, weight = 1) self.columnconfigure(2, weight = 1) self.columnconfigure(3, weight = 3) self["padx"] = 10 self["pady"] = 10 self.okBut = ttk.Button(self, text = "Ok", command = self.okFun) self.okBut.grid(column = 1, row = 1, padx = 3, pady = 4) self.cancelBut = ttk.Button(self, text = "Cancel", command = self.cancelFun) self.cancelBut.grid(column = 2, row = 1, padx = 3, pady = 4) self.settingsFrame = ttk.Frame(self) self.settingsFrame2 = ttk.Frame(self) self.optionFrames = [] mapping = {"degrees": "°", "seconds": "s", "percents": "%"} numFrames = sum([1 for par in m.parameters.values() if par.options]) split = numFrames > 7 count = 0 for name, par in sorted(m.parameters.items()): if not par.options: continue options = [] for option in sorted(par.options.values(), key = lambda opt: opt[0].types == "bool"): strings = option[1].split(" [in ") if len(strings) == 2: text, unit = strings unit = unit.rstrip("]") unit = mapping[unit] if unit in mapping else unit else: text, unit = strings[0], None text = text.strip() opt = option[0] options.append((text + ": ", (opt.name, opt.default, opt.types), unit)) if split and count >= (numFrames // 2): frame = self.settingsFrame2 else: frame = self.settingsFrame self.optionFrames.append(ParameterOptionFrame(frame, name, options)) count += 1 if numFrames > 7: self.settingsFrame.grid(row = 0, column = 0, columnspan = 2, padx = 3, pady = 4, sticky = (N, W, E)) self.settingsFrame2.grid(row = 0, column = 2, columnspan = 2, padx = 3, pady = 4, sticky = (N, W, E)) else: self.settingsFrame.grid(row = 0, column = 0, columnspan = 4, padx = 3, pady = 4, sticky = (N, W, E)) self.settingsFrame.columnconfigure(0, weight = 1) self.settingsFrame2.columnconfigure(0, weight = 1) for row, frame in enumerate(self.optionFrames): frame.grid(column = 0, row = row, pady = 3, padx = 3, sticky = (W, E))
def __init__(self, root, title, message, dontShowOption="", optionValue=None, html=True): super().__init__(root) self.root = root self.title(title) self.grab_set() self.focus_set() self.lift(root) placeWindow(self, 300, 150) self.resizable(False, False) self.minsize(300, 150) self.dontshow = dontShowOption self.optionValue = optionValue # message if html: message = message.replace("<br>", "\n") try: width, height = message.split("\n")[0].split("x") width = int(width.strip()) height = int(height.strip()) except Exception: width, height = 60, 10 else: message = "\n".join(message.split("\n")[1:]) self.text = Text(self, width=width, height=height, wrap="word") self.text.grid(column=0, row=0, pady=2, sticky=(N, S, E, W)) for count, part in enumerate(message.split("\\n")): if count != 0: self.text.insert("end", "\n") self.text.insert("end", part) links = [word for word in message.split() if "www." in word] idx = "1.0" for link in links: idx = self.text.search(link, idx, "end") lastidx = "{}+{}c".format(idx, len(link)) self.text.tag_add("link", idx, lastidx) idx = lastidx self.text.tag_configure("link", foreground="blue") self.text.tag_bind("link", "<1>", lambda e: self.link(e)) self.text.tag_bind("link", "<Enter>", lambda e: self._enter(e)) self.text.tag_bind("link", "<Leave>", lambda e: self._leave(e)) self.text["state"] = "disabled" # dont show again checkbutton if self.dontshow: self.dontShowVar = BooleanVar() self.dontShowVar.set(False) self.dontShowCheck = ttk.Checkbutton( self, text="Don't show me this message again.", variable=self.dontShowVar) self.dontShowCheck.grid(column=0, row=1, pady=6, sticky=W, padx=4) # cancel button self.okBut = ttk.Button(self, text="Ok", command=self.okFun) self.okBut.grid(column=0, row=2, pady=2) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1)
def __init__(self, root): super().__init__(root) self.title("Options") self.grab_set() self.focus_set() self.resizable(FALSE, FALSE) placeWindow(self, 824, 844) self["padx"] = 10 self["pady"] = 10 self.parametersF = ParameterFrame(self, "Default parameters") # default filetype of processor output self.fileTypeVar = StringVar() self.fileTypeVar.set( optionGet("DefProcessOutputFileType", ".txt", "str")) self.fileTypeFrame = ttk.Labelframe(self, text="Default output filetype") self.txtRadioBut = ttk.Radiobutton(self.fileTypeFrame, text=".txt", variable=self.fileTypeVar, value=".txt") self.csvRadioBut = ttk.Radiobutton(self.fileTypeFrame, text=".csv", variable=self.fileTypeVar, value=".csv") self.txtRadioBut.grid(row=1, column=0, padx=2, pady=2, sticky=W) self.csvRadioBut.grid(row=0, column=0, padx=2, pady=2, sticky=W) # output separator self.separatorVar = StringVar() self.separatorVar.set(optionGet("ResultSeparator", ",", "str")) self.separatorFrame = ttk.Labelframe(self, text="Result separator") self.commaRadioBut = ttk.Radiobutton(self.separatorFrame, text="Comma", variable=self.separatorVar, value=",") self.semicolonRadioBut = ttk.Radiobutton(self.separatorFrame, text="Semicolon", variable=self.separatorVar, value=";") self.tabRadioBut = ttk.Radiobutton(self.separatorFrame, text="Tab", variable=self.separatorVar, value="\t") self.commaRadioBut.grid(row=0, padx=2, pady=2, sticky=W) self.semicolonRadioBut.grid(row=1, padx=2, pady=2, sticky=W) self.tabRadioBut.grid(row=2, padx=2, pady=2, sticky=W) # save filename as full path self.saveFilenameAs = RadioFrame( self, text="Save (show) filename as:", optionName="SaveFullPath", default="Basename", options=["Basename", "Full path", "Unique path"]) # selection of directories self.directoriesFrame = ttk.Frame(self) self.directoriesFrame.columnconfigure(0, weight=1) self.directoryOptions = [ ("Default directory for file selection", "FileDirectory", os.getcwd()), ("Default directory for results", "ResultDirectory", os.getcwd()), ("Directory for saving of processing logs", "LogDirectory", os.path.join(os.getcwd(), "Stuff", "Logs")), ("Directory for images", "ImageDirectory", os.getcwd()), ("Directory for saving of selected files", "SelectedFilesDirectory", os.path.join(os.getcwd(), "Stuff", "Selected files")) ] for count, option in enumerate(self.directoryOptions): exec( """self.{1} = ChooseDirectoryFrame(self.directoriesFrame, '{0}', '{1}', \ r'{2}')""".format(*option)) exec( "self.{}.grid(row = {}, column = 0, pady = 2, padx = 2, sticky = (E, W))" .format(option[1], count)) # default time self.timeLabFrame = ttk.Labelframe(self, text="Default time") self.timeFrame = TimeFrame(self.timeLabFrame) self.timeFrame.grid(row=0, column=0) # processor options self.processorOptions = OptionFrame(self, text="Default process options") # checking messages self.messageCheckingFrame = ttk.Labelframe( self, text="Messages and new versions") self.messageCheckingVar = BooleanVar() self.messageCheckingVar.set(optionGet("CheckMessages", True, "bool")) self.messageCheckingChB = ttk.Checkbutton( self.messageCheckingFrame, variable=self.messageCheckingVar, onvalue=True, offvalue=False, text="Check messages and new versions") self.messageCheckingChB.grid(column=0, row=0) # buttons self.buttonFrame = ttk.Frame(self) self.buttonFrame.columnconfigure(1, weight=1) self.saveBut = ttk.Button(self.buttonFrame, text="Save", command=self.saveFun) self.okBut = ttk.Button(self.buttonFrame, text="Ok", command=self.okFun) self.cancelBut = ttk.Button(self.buttonFrame, text="Cancel", command=self.cancelFun) self.saveBut.grid(column=0, row=0, padx=3, pady=2, sticky=(W)) self.okBut.grid(column=1, row=0, padx=3, pady=2) self.cancelBut.grid(column=2, row=0, padx=3, pady=2, sticky=(E)) # grid of self contents self.parametersF.grid(row=0, column=0, columnspan=4, sticky=(N, W), padx=4, pady=2) self.fileTypeFrame.grid(row=2, column=0, columnspan=2, padx=3, pady=4, sticky=(W, N, E, S)) self.buttonFrame.grid(row = 8, column = 0, columnspan = 4, padx = 3, pady = 4,\ sticky = (E, W, N, S)) self.separatorFrame.grid(row=3, column=0, columnspan=2, padx=3, pady=4, sticky=(W, N, E)) self.saveFilenameAs.grid(row=2, column=2, padx=3, pady=4, sticky=(N, W, E)) self.directoriesFrame.grid(row=5, column=0, columnspan=5, padx=3, pady=8, sticky=(N, W, E)) self.timeLabFrame.grid(row=2, column=3, padx=3, pady=4, sticky=(N, W)) self.processorOptions.grid(row=3, column=2, pady=4, padx=4, sticky=(N, W), columnspan=2, rowspan=2) self.messageCheckingFrame.grid(row=4, column=0, columnspan=2, sticky=(N, W), pady=3, padx=3)
def __init__(self, root): super().__init__(root) self.title("Parameter settings") self.grab_set() self.focus_set() self.resizable(FALSE, FALSE) placeWindow(self, 389, 682) self["padx"] = 10 self["pady"] = 10 self.saveBut = ttk.Button(self, text="Save", command=self.saveFun) self.okBut = ttk.Button(self, text="Ok", command=self.okFun) self.cancelBut = ttk.Button(self, text="Cancel", command=self.cancelFun) self.saveBut.grid(column=0, row=3, padx=3, pady=2) self.okBut.grid(column=1, row=3, padx=3, pady=2) self.cancelBut.grid(column=2, row=3, padx=3, pady=2) # parameter settings self.parSettingsFrame = ttk.Frame(self) self.parSettingsFrame.grid(row=1, column=0, columnspan=3, padx=3, pady=4, sticky=(N, W)) self.parSettingsFrame.columnconfigure(1, weight=1) self.RlabelWidth = 8 self.EntryWidth = 10 # thigmotaxis - mozno nahradit pomoci ParameterOptionFrame ! self.thigmotaxisFrame = ttk.Labelframe(self.parSettingsFrame, text="Thigmotaxis") self.thigmotaxisFrame.grid(column=0, row=2, columnspan=3, pady=3, padx=3, sticky=(W, E)) self.thigmotaxisFrame.columnconfigure(0, weight=1) self.thigmotaxisVar = StringVar() self.thigmotaxisVar.set( optionGet("ThigmotaxisPercentSize", 20, ["int", "float"])) self.thigmotaxisEntry = ttk.Entry(self.thigmotaxisFrame, textvariable=self.thigmotaxisVar, width=self.EntryWidth, justify="right") self.thigmotaxisEntry.grid(column=1, row=1, padx=1, pady=2) self.thigmotaxisLab = ttk.Label(self.thigmotaxisFrame, text="Annulus width:") self.thigmotaxisLab.grid(column=0, row=1, padx=1, pady=2, sticky=E) self.percentLab = ttk.Label(self.thigmotaxisFrame, text="%", width=self.RlabelWidth) self.percentLab.grid(column=2, row=1, padx=1, pady=2, sticky=W) # setting of Time in chosen sector parameter self.TimeInChosenFrame = ttk.Labelframe(self.parSettingsFrame, text="Time in chosen sector") self.TimeInChosenFrame.grid(column=0, row=0, columnspan=3, pady=3, padx=3) self.TimeInChosenWidthVar = StringVar() self.TimeInChosenWidthVar.set( optionGet('WidthParTimeInChosen', 'default', ['int', 'float'])) self.TimeInChosenWidthEntry = ttk.Entry( self.TimeInChosenFrame, textvariable=self.TimeInChosenWidthVar, width=self.EntryWidth, justify="right") self.TimeInChosenWidthEntry.grid(column=1, row=1, padx=2, pady=2) self.TimeInChosenWidthLab = ttk.Label( self.TimeInChosenFrame, text="Width of sector ('default' if same as target):") self.TimeInChosenWidthLab.grid(column=0, row=1, pady=2, sticky=(E)) self.DegreesLab = ttk.Label(self.TimeInChosenFrame, text="°", width=self.RlabelWidth) self.DegreesLab.grid(column=2, row=1, pady=2) self.TimeInChosenAngleVar = StringVar() self.TimeInChosenAngleVar.set( optionGet('AngleParTimeInChosen', 0, ['int', 'float'])) self.TimeInChosenAngleEntry = ttk.Entry( self.TimeInChosenFrame, textvariable=self.TimeInChosenAngleVar, width=self.EntryWidth, justify="right") self.TimeInChosenAngleEntry.grid(column=1, row=0, padx=2, pady=2) self.TimeInChosenAngleLab = ttk.Label( self.TimeInChosenFrame, text="Center of sector relative to the target:") self.TimeInChosenAngleLab.grid(column=0, row=0, pady=2, sticky=(E)) self.DegreesLab2 = ttk.Label(self.TimeInChosenFrame, text="°", width=self.RlabelWidth) self.DegreesLab2.grid(column=2, row=0, pady=2) # setting of Time in sectors parameter self.TimeInSectorsFrame = ttk.Labelframe(self.parSettingsFrame, text="Time in sectors") self.TimeInSectorsFrame.grid(column=0, row=1, columnspan=3, pady=3, padx=3) self.TimeInSectorsWidthVar = StringVar() self.TimeInSectorsWidthVar.set( optionGet('WidthParTimeInSectors', 'default', ['int', 'float'])) self.TimeInSectorsWidthEntry = ttk.Entry( self.TimeInSectorsFrame, textvariable=self.TimeInSectorsWidthVar, width=self.EntryWidth, justify="right") self.TimeInSectorsWidthEntry.grid(column=1, row=1, padx=2, pady=2) self.TimeInSectorsWidthLab = ttk.Label( self.TimeInSectorsFrame, text="Width of sector ('default' if same as target):") self.TimeInSectorsWidthLab.grid(column=0, row=1, pady=2, sticky=(E)) self.DegreesLab3 = ttk.Label(self.TimeInSectorsFrame, text="°", width=self.RlabelWidth) self.DegreesLab3.grid(column=2, row=1, pady=2) # setting of Total distance parameter self.totalDistance = ParameterOptionFrame( self.parSettingsFrame, "Total distance", (("Sampling after every:", ('StrideParTotalDistance', 25, 'int'), "rows"), ("Minimal distance counted:", ('MinDiffParTotalDistance', 0, ['int', 'float']), "pixels"))) self.totalDistance.grid(column=0, row=3, columnspan=3, pady=3, padx=3, sticky=(W, E)) # setting of Maximum time of immobility parameter self.maximumTimeImmobility = ParameterOptionFrame( self.parSettingsFrame, "Maximum time of immobility", (("Minimum speed counted:", ('MinSpeedMaxTimeImmobility', 10, ['int', 'float']), "cm/s"), ("Computed from every:", ('SkipMaxTimeImmobility', 12, ['int']), "rows"), ("Averaged across:", ('SmoothMaxTimeImmobility', 2, ['int']), "intervals"))) self.maximumTimeImmobility.grid(column=0, row=4, columnspan=3, pady=3, padx=3, sticky=(W, E)) # setting of Periodicity parameter self.periodicity = ParameterOptionFrame( self.parSettingsFrame, "Periodicity", (("Minimum speed counted:", ('MinSpeedPeriodicity', 10, ['int', 'float']), "cm/s"), ("Computed from every:", ('SkipPeriodicity', 12, ['int']), "rows"), ("Averaged across:", ('SmoothPeriodicity', 2, ['int']), "intervals"), ("Minimum time of interval:", ('MinTimePeriodicity', 9, ['int', 'float', 'list']), "seconds"))) self.periodicity.grid(column=0, row=5, columnspan=3, pady=3, padx=3, sticky=(W, E)) # setting of Proportion of time moving parameter self.percentMobility = ParameterOptionFrame( self.parSettingsFrame, "Proportion of time moving", (("Minimum speed counted:", ('MinSpeedPercentMobility', 5, ['int', 'float']), "cm/s"), ("Computed from every:", ('SkipPercentMobility', 12, 'int'), "rows"), ("Averaged across:", ('SmoothPercentMobility', 2, 'int'), "intervals"))) self.percentMobility.grid(column=0, row=6, columnspan=3, pady=3, padx=3, sticky=(W, E)) # setting of Proportion of time moving parameter self.speedAfterShock = ParameterOptionFrame( self.parSettingsFrame, "Median speed after shock", [("Computed from every:", ('SkipSpeedAfterShock', 25, 'int'), "rows")]) self.speedAfterShock.grid(column=0, row=7, columnspan=3, pady=3, padx=3, sticky=(W, E))
def __init__(self, root, files): super().__init__(root) self.root = root self.fileStorage = self.root.root.root.fileStorage self["padx"] = 4 self["pady"] = 4 self.grab_set() self.focus_set() placeWindow(self, 758, 760) self.columnconfigure(0, weight = 1) self.rowconfigure(0, weight = 1) if files == "arenafiles": self.title("Matched files") self.initfiles = self.fileStorage.arenafiles elif files == "wrongfiles": self.title("Non-matched files") self.initfiles = self.fileStorage.wrongfiles self.shownFiles = files # frame with files self.filesFrame = ttk.Frame(self) self.filesFrame.grid(column = 0, row = 0, sticky = (N, S, E, W)) self.filesFrame.columnconfigure(1, weight = 1) self.filesFrame.rowconfigure(0, weight = 1) self.filesTree = ttk.Treeview(self.filesFrame, height = 35) self.filesTree.grid(column = 1, row = 0, sticky = (N, S, E, W)) if files == "wrongfiles": self.filesTree["columns"] = ("directory") directoryWidth = 480 else: self.filesTree["columns"] = ("directory", "tag") self.filesTree.column("tag", width = 30, anchor = "center") self.filesTree.heading("tag", text = "Tag", command = self.orderByTag) directoryWidth = 450 self.filesTree.column("#0", width = 250, anchor = "w") self.filesTree.heading("#0", text = "Filename", command = self.orderByFilename) self.filesTree.column("directory", width = directoryWidth, anchor = "w") self.filesTree.heading("directory", text = "Directory", command = self.orderByDirectory) self.scrollbar = ttk.Scrollbar(self.filesFrame, orient = VERTICAL, command = self.filesTree.yview) self.scrollbar.grid(column = 2, row = 0, sticky = (N, S, E)) self.filesTree.configure(yscrollcommand = self.scrollbar.set) # button frame self.buttonFrame = ttk.Frame(self) self.buttonFrame.grid(column = 0, row = 1, sticky = (E, W)) self.buttonFrame.columnconfigure(3, weight = 1) self.buttonFrame.columnconfigure(6, weight = 1) self.removeBut = ttk.Button(self.buttonFrame, text = "Remove Files", command = self.removeFun) self.removeBut.grid(column = 0, row = 0) self.cropBut = ttk.Button(self.buttonFrame, text = "Crop Files", command = self.cropFun) self.cropBut.grid(column = 1, row = 0) self.selectAllBut = ttk.Button(self.buttonFrame, text = "Select All", command = self.selectAllFun) self.selectAllBut.grid(column = 2, row = 0) self.closeBut = ttk.Button(self.buttonFrame, text = "Close", command = self.closeFun) self.closeBut.grid(column = 8, row = 0) if files == "wrongfiles": self.pairSelectedBut = ttk.Button(self.buttonFrame, text = "Pair Selected", command = self.pairSelectedFun) self.pairSelectedBut.grid(column = 4, row = 0) self.findPairsBut = ttk.Button(self.buttonFrame, text = "Find Pairs", command = self.findPairsFun) self.findPairsBut.grid(column = 5, row = 0) self.showArenafilesBut = ttk.Button(self.buttonFrame, text = "Show Matched Files", command = self.showArenafilesFun) self.showArenafilesBut.grid(column = 7, row = 0) else: self.tagFilesBut = ttk.Button(self.buttonFrame, text = "Tag Files", command = self.tagFilesFun) self.tagFilesBut.grid(column = 4, row = 0) self.untagFilesBut = ttk.Button(self.buttonFrame, text = "Untag Files", command = self.untagFilesFun) self.untagFilesBut.grid(column = 5, row = 0) self.showWrongfilesBut = ttk.Button(self.buttonFrame, text = "Show Non-matched Files", command = self.showWrongfilesFun) self.showWrongfilesBut.grid(column = 7, row = 0) self.filesTree.bind("<3>", lambda e: self.popUp(e)) self.filesTree.bind("<Double-1>", lambda e: self.doubleClick(e)) self.protocol("WM_DELETE_WINDOW", lambda: self.closeFun()) self.initialize()
def __init__(self, root): super().__init__(root) self.root = root placeWindow(self, 598, 208) self.title = "Set batch time" self.grab_set() self.focus_set() self.resizable(False, False) self.batchTime = optionGet("LastBatchTime", "[(0, 20)]", "list") self.developer = optionGet("Developer", False, 'bool') self.manualChangeEnabled = self.developer # frames self.buttonFrame = ttk.Frame(self) self.removeFrame = ttk.Frame(self) self.timeFrame = TimeFrame(self, observe = False) # buttons self.okBut = ttk.Button(self, text = "Ok", command = self.okFun) self.closeBut = ttk.Button(self, text = "Close", command = self.destroy) self.addBut = ttk.Button(self.buttonFrame, text = "Add", command = self.addFun, width = 8) self.removeLastBut = ttk.Button(self.removeFrame , text = "Remove last", command = self.removeLastFun) self.resetBut = ttk.Button(self.removeFrame , text = "Reset", command = self.resetFun) self.clearBut = ttk.Button(self.removeFrame , text = "Clear", command = self.clearFun) # text self.text = Text(self, height = 5, wrap = "word", width = 73) self.text.insert("1.0", self.batchTime) self.text.bind("<3>", lambda e: self.popUp(e)) if not self.developer: self.text["state"] = "disabled" self.text["background"] = self._color() else: self.addBut["state"] = "disabled" self.removeLastBut["state"] = "disabled" # adding to grid self.buttonFrame.grid(column = 1, row = 0, sticky = W, pady = 2) self.removeFrame.grid(column = 3, row = 0, pady = 3) self.timeFrame.grid(column = 0, row = 0) self.okBut.grid(column = 3, row = 2, pady = 2) self.closeBut.grid(column = 2, row = 2, pady = 2) self.addBut.grid(column = 0, row = 2, columnspan = 2) self.removeLastBut.grid(column = 0, row = 0, pady = 0) self.resetBut.grid(column = 0, row = 1, pady = 2) self.clearBut.grid(column = 0, row = 2, pady = 0) self.text.grid(column = 0, row = 1, columnspan = 4, pady = 5, padx = 5) # +x buttons ttk.Button(self.buttonFrame, text = "+1", command = lambda: self.addTime(1), width = 3).grid(column = 0, row = 0) ttk.Button(self.buttonFrame, text = "+2", command = lambda: self.addTime(2), width = 3).grid(column = 1, row = 0) ttk.Button(self.buttonFrame, text = "+5", command = lambda: self.addTime(5), width = 3).grid(column = 0, row = 1) ttk.Button(self.buttonFrame, text = "+10", command = lambda: self.addTime(10), width = 3).grid(column = 1, row = 1)
def __init__(self, root): super().__init__(root) self.title("Options") self.grab_set() self.focus_set() self.resizable(FALSE, FALSE) placeWindow(self, 824, 844) self["padx"] = 10 self["pady"] = 10 self.parametersF = ParameterFrame(self, "Default parameters") # default filetype of processor output self.fileTypeVar = StringVar() self.fileTypeVar.set(optionGet("DefProcessOutputFileType", ".txt", "str")) self.fileTypeFrame = ttk.Labelframe(self, text = "Default output filetype") self.txtRadioBut = ttk.Radiobutton(self.fileTypeFrame, text = ".txt", variable = self.fileTypeVar, value = ".txt") self.csvRadioBut = ttk.Radiobutton(self.fileTypeFrame, text = ".csv", variable = self.fileTypeVar, value = ".csv") self.txtRadioBut.grid(row = 1, column = 0, padx = 2, pady = 2, sticky = W) self.csvRadioBut.grid(row = 0, column = 0, padx = 2, pady = 2, sticky = W) # output separator self.separatorVar = StringVar() self.separatorVar.set(optionGet("ResultSeparator", ",", "str")) self.separatorFrame = ttk.Labelframe(self, text = "Result separator") self.commaRadioBut = ttk.Radiobutton(self.separatorFrame, text = "Comma", variable = self.separatorVar, value = ",") self.semicolonRadioBut = ttk.Radiobutton(self.separatorFrame, text = "Semicolon", variable = self.separatorVar, value = ";") self.tabRadioBut = ttk.Radiobutton(self.separatorFrame, text = "Tab", variable = self.separatorVar, value = "\t") self.commaRadioBut.grid(row = 0, padx = 2, pady = 2, sticky = W) self.semicolonRadioBut.grid(row = 1, padx = 2, pady = 2, sticky = W) self.tabRadioBut.grid(row = 2, padx = 2, pady = 2, sticky = W) # save filename as full path self.saveFilenameAs = RadioFrame(self, text = "Save (show) filename as:", optionName = "SaveFullPath", default = "Basename", options = ["Basename", "Full path", "Unique path"]) # selection of directories self.directoriesFrame = ttk.Frame(self) self.directoriesFrame.columnconfigure(0, weight = 1) self.directoryOptions = [ ("Default directory for file selection", "FileDirectory", os.getcwd()), ("Default directory for results", "ResultDirectory", os.getcwd()), ("Directory for saving of processing logs", "LogDirectory", os.path.join(os.getcwd(), "Stuff", "Logs")), ("Directory for images", "ImageDirectory", os.getcwd()), ("Directory for saving of selected files", "SelectedFilesDirectory", os.path.join(os.getcwd(), "Stuff", "Selected files"))] for count, option in enumerate(self.directoryOptions): exec("""self.{1} = ChooseDirectoryFrame(self.directoriesFrame, '{0}', '{1}', \ r'{2}')""".format(*option)) exec("self.{}.grid(row = {}, column = 0, pady = 2, padx = 2, sticky = (E, W))".format( option[1], count)) # default time self.timeLabFrame = ttk.Labelframe(self, text = "Default time") self.timeFrame = TimeFrame(self.timeLabFrame) self.timeFrame.grid(row = 0, column = 0) # processor options self.processorOptions = OptionFrame(self, text = "Default process options") # checking messages self.messageCheckingFrame = ttk.Labelframe(self, text = "Messages and new versions") self.messageCheckingVar = BooleanVar() self.messageCheckingVar.set(optionGet("CheckMessages", True, "bool")) self.messageCheckingChB = ttk.Checkbutton(self.messageCheckingFrame, variable = self.messageCheckingVar, onvalue = True, offvalue = False, text = "Check messages and new versions") self.messageCheckingChB.grid(column = 0, row = 0) # buttons self.buttonFrame = ttk.Frame(self) self.buttonFrame.columnconfigure(1, weight = 1) self.saveBut = ttk.Button(self.buttonFrame, text = "Save", command = self.saveFun) self.okBut = ttk.Button(self.buttonFrame, text = "Ok", command = self.okFun) self.cancelBut = ttk.Button(self.buttonFrame, text = "Cancel", command = self.cancelFun) self.saveBut.grid(column = 0, row = 0, padx = 3, pady = 2, sticky = (W)) self.okBut.grid(column = 1, row = 0, padx = 3, pady = 2) self.cancelBut.grid(column = 2, row = 0, padx = 3, pady = 2, sticky = (E)) # grid of self contents self.parametersF.grid(row = 0, column = 0, columnspan = 4, sticky = (N, W), padx = 4, pady = 2) self.fileTypeFrame.grid(row = 2, column = 0, columnspan = 2, padx = 3, pady = 4, sticky = (W, N, E, S)) self.buttonFrame.grid(row = 8, column = 0, columnspan = 4, padx = 3, pady = 4,\ sticky = (E, W, N, S)) self.separatorFrame.grid(row = 3, column = 0, columnspan = 2, padx = 3, pady = 4, sticky = (W, N, E)) self.saveFilenameAs.grid(row = 2, column = 2, padx = 3, pady = 4, sticky = (N, W, E)) self.directoriesFrame.grid(row = 5, column = 0, columnspan = 5, padx = 3, pady = 8, sticky = (N, W, E)) self.timeLabFrame.grid(row = 2, column = 3, padx = 3, pady = 4, sticky = (N, W)) self.processorOptions.grid(row = 3, column = 2, pady = 4, padx = 4, sticky = (N, W), columnspan = 2, rowspan = 2) self.messageCheckingFrame.grid(row = 4, column = 0, columnspan = 2, sticky = (N, W), pady = 3, padx = 3)
def __init__(self, root): super().__init__(root) self.root = root placeWindow(self, 598, 208) self.title = "Set batch time" self.grab_set() self.focus_set() self.resizable(False, False) self.batchTime = optionGet("LastBatchTime", "[(0, 20)]", "list") self.developer = optionGet("Developer", False, 'bool') self.manualChangeEnabled = self.developer # frames self.buttonFrame = ttk.Frame(self) self.removeFrame = ttk.Frame(self) self.timeFrame = TimeFrame(self, observe=False) # buttons self.okBut = ttk.Button(self, text="Ok", command=self.okFun) self.closeBut = ttk.Button(self, text="Close", command=self.destroy) self.addBut = ttk.Button(self.buttonFrame, text="Add", command=self.addFun, width=8) self.removeLastBut = ttk.Button(self.removeFrame, text="Remove last", command=self.removeLastFun) self.resetBut = ttk.Button(self.removeFrame, text="Reset", command=self.resetFun) self.clearBut = ttk.Button(self.removeFrame, text="Clear", command=self.clearFun) # text self.text = Text(self, height=5, wrap="word", width=73) self.text.insert("1.0", self.batchTime) self.text.bind("<3>", lambda e: self.popUp(e)) if not self.developer: self.text["state"] = "disabled" self.text["background"] = self._color() else: self.addBut["state"] = "disabled" self.removeLastBut["state"] = "disabled" # adding to grid self.buttonFrame.grid(column=1, row=0, sticky=W, pady=2) self.removeFrame.grid(column=3, row=0, pady=3) self.timeFrame.grid(column=0, row=0) self.okBut.grid(column=3, row=2, pady=2) self.closeBut.grid(column=2, row=2, pady=2) self.addBut.grid(column=0, row=2, columnspan=2) self.removeLastBut.grid(column=0, row=0, pady=0) self.resetBut.grid(column=0, row=1, pady=2) self.clearBut.grid(column=0, row=2, pady=0) self.text.grid(column=0, row=1, columnspan=4, pady=5, padx=5) # +x buttons ttk.Button(self.buttonFrame, text="+1", command=lambda: self.addTime(1), width=3).grid(column=0, row=0) ttk.Button(self.buttonFrame, text="+2", command=lambda: self.addTime(2), width=3).grid(column=1, row=0) ttk.Button(self.buttonFrame, text="+5", command=lambda: self.addTime(5), width=3).grid(column=0, row=1) ttk.Button(self.buttonFrame, text="+10", command=lambda: self.addTime(10), width=3).grid(column=1, row=1)
def __init__(self, root): super().__init__(root) self.root = root placeWindow(self, 598, 208) self.title("Images options") self.grab_set() self.focus_set() self.resizable(False, False) self.oFrame = ttk.Frame(self) self.oFrame.grid(column=0, columnspan=3, row=0) options = (("Scale", ("LastImageScale", 1, ["int", "float"])), ("Main title ('default' for filename)", ("LastImageMain", "default", "str")), ("Horizontal gap", ("LastImageXgap", 10, ["int", "float"])), ("Vertical gap", ("LastImageYgap", 10, ["int", "float"])), ("x-axis title", ("LastImageXlab", "Time", "str")), ("y-axis title (smart 'default')", ("LastImageYlab", "default", "str")), ("x-axis ticks", ("LastImageXticks", True, "bool")), ("y-axis ticks", ("LastImageYticks", True, "bool"))) self.options = options self.opts = [] entryWidth = 10 for row, option in enumerate(options): self.opts.append({}) var = BooleanVar if option[1][2] == 'bool' else StringVar self.opts[row]["variable"] = var() current = optionGet(*option[1]) if type(current) == str: current = "'" + current + "'" self.opts[row]["variable"].set(current) self.opts[row]["label"] = ttk.Label(self.oFrame, text=option[0]) self.opts[row]["label"].grid(column=0, row=row, pady=2, sticky=E) if option[1][2] == 'bool': self.opts[row]["input"] = ttk.Checkbutton( self.oFrame, onvalue=True, offvalue=False, variable=self.opts[row]["variable"]) else: self.opts[row]["input"] = ttk.Entry( self.oFrame, width=entryWidth, justify='right', textvariable=self.opts[row]["variable"]) self.opts[row]["input"].grid(column=1, row=row, padx=2, pady=2) self.okBut = ttk.Button(self, text="Ok", command=self.okFun) self.okBut.grid(column=2, row=1, padx=3, pady=4) self.cancelBut = ttk.Button(self, text="Cancel", command=self.cancelFun) self.cancelBut.grid(column=1, row=1, padx=3, pady=4) self.resetBut = ttk.Button(self, text="Reset", command=self.resetFun) self.resetBut.grid(column=0, row=1, padx=3, pady=4)