def __init__(self, master, id, avisynth): super(FrameViewer.FrameTab, self).__init__(master) self.id = id self.avisynth = avisynth _toolbar = Frame(self) self._combo_chooser = Combobox(_toolbar, state="readonly") self._combo_chooser["values"] = ["original"] + list(Tester.testers.keys()) self._combo_chooser.bind("<<ComboboxSelected>>", self._cb_set) self._combo_chooser.set("original") self._combo_chooser.pack(side="left") @self.register def isint(S): if self._combo_chooser.get() == "original": return True try: val = int(S) except ValueError: return False return val > 0 self._height_val = IntVar() self._height_val.trace("w", self.setheight) self._height = Entry(_toolbar, state="disabled", validate="key", validatecommand=(isint, "%P"), textvariable=self._height_val) self._height.pack(side="left") self.image = ImageViewer(self, panner=self.master.panner) _toolbar.pack(fill="x", side="top") self.image.pack(fill="both", expand=1) self.master._update_single_frame(self) self._in_update = False
def __init__(self, master, avisynth): super(FrameViewer, self).__init__(master) self.frames = {} self.panner = ImageViewer._Panner() self.avisynth = avisynth self.clip = None self.frameno = None self.insert("end", Frame(self), text="+") self.enable_traversal() self.bind("<<NotebookTabChanged>>", self._settab) self.bind("<Double-Button-1>", self._delete)
class FrameTab(Frame, object): def __init__(self, master, id, avisynth): super(FrameViewer.FrameTab, self).__init__(master) self.id = id self.avisynth = avisynth _toolbar = Frame(self) self._combo_chooser = Combobox(_toolbar, state="readonly") self._combo_chooser["values"] = ["original"] + list(Tester.testers.keys()) self._combo_chooser.bind("<<ComboboxSelected>>", self._cb_set) self._combo_chooser.set("original") self._combo_chooser.pack(side="left") @self.register def isint(S): if self._combo_chooser.get() == "original": return True try: val = int(S) except ValueError: return False return val > 0 self._height_val = IntVar() self._height_val.trace("w", self.setheight) self._height = Entry(_toolbar, state="disabled", validate="key", validatecommand=(isint, "%P"), textvariable=self._height_val) self._height.pack(side="left") self.image = ImageViewer(self, panner=self.master.panner) _toolbar.pack(fill="x", side="top") self.image.pack(fill="both", expand=1) self.master._update_single_frame(self) self._in_update = False def set(self, tester, height=None): if self._in_update: return self._in_update = True self._combo_chooser.set(tester) if height is not None: self._height_val.set(height) self._in_update = False if tester == "original": self.master.tab(self.master.index(self), text="original") self._height["state"] = "disabled" else: self.master.tab(self.master.index(self), text="%d@%s" % (int(height), tester)) self._height["state"] = "enabled" self.master._update_single_frame(self) def setheight(self, *args): if self._combo_chooser.get() == "original": return self._cb_set() def _cb_set(self, event=None): type = self._combo_chooser.get() if type == "original": self.set("original") else: value = self._height_val.get() if not value: self._height_val.set(100) return if value % 2 == 1: return self.set(type, value) def update_frame(self, clip, frame): fut = self._update_frame(clip, frame) fut.set_lowlevel() @Task def _update_frame(self, clip, frame): if clip is None: return type = self._combo_chooser.get() height = self._height_val.get() if type != "original": self.image.image = yield self.avisynth.get_tester_frame(clip, type, height, frame) else: self.image.image = yield self.avisynth.get_frame(clip, frame)
def __init__(self, master, filename, framecb): super(Autodetector, self).__init__(master) self.filename = filename self.framecb = framecb self.title("Resolution Autodetector") self.iconbitmap("data/br.ico") self.executor = None _data = Frame(self) _settings = Frame(_data) try: cCpu = multiprocessing.cpu_count() except NotImplementedError: cCpu = 1 Label(_settings, text="Processes").grid(row=0, column=0) self.cpu_count = cCpu if cCpu > 1: self.cpu_sel = Combobox(_settings, state="readonly") self.cpu_sel["values"] = tuple(str(i + 1) for i in range(cCpu)) self.cpu_sel.set(self.cpu_count) self.cpu_sel.grid(row=0, column=1) else: self.cpu_sel = IntVar(value=1) Label(_settings, text="1").grid(row=0, column=0, sticky="nesw") Label(_settings, text="Aspect Ratio").grid(row=1, column=0) self.ar = StringVar(value="16:9") Entry(_settings, textvariable=self.ar).grid(row=1, column=1, sticky="nesw") self.from_ = IntVar(value="400") self.to = IntVar(value="1080") Label(_settings, text="From").grid(row=2, column=0) Label(_settings, text="To").grid(row=3, column=0) Entry(_settings, textvariable=self.from_).grid(row=2, column=1, sticky="news") Entry(_settings, textvariable=self.to).grid(row=3, column=1, sticky="news") self.proc = Button(_settings, text="Detect", command=self.start_detect) self.proc.grid(row=4, column=0, columnspan=2) self.progress = Progressbar(_settings) self.progress.grid(row=5, column=0, columnspan=2, sticky="news") _settings.grid_columnconfigure(1, weight=1) _settings.pack(side="top", padx=5, pady=5, fill="y") _vals = Frame(_data) self.values = Listbox(_data, selectmode='multiple') _sel = Frame(_vals) _sel.pack(side="top", fill="x") self.values.pack(fill="both", expand=1) self.thresh = StringVar() Entry(_sel, textvariable=self.thresh).pack(side="left") Button(_sel, text="Find", command=self.find).pack(side="left") Button(_sel, text="Open", command=self.open).pack(side="right") _vals.pack(side="bottom", fill="x") _data.pack(side="left", fill="y") nb = Notebook(self) nb.pack(fill="both", expand=1) self.viewer = ImageViewer(nb) fig = Frame(nb) self.figure = Figure() self.derivative_data = self.figure.add_subplot(211) self.normal_data = self.figure.add_subplot(212) self.reset_plots() self.figure.suptitle("Similarity...", fontsize=20) self.figure.subplots_adjust(hspace=.5) self.stats = FigureCanvasTkAgg(self.figure, fig) nav = NavigationToolbar2TkAgg(self.stats, fig) nav.update() self.ani = animation.FuncAnimation(self.figure, self._update_lines, interval=100, blit=False) self.stats.get_tk_widget().pack(fill="both", expand=1) self.stats._tkcanvas.pack(fill="both", expand=1) nb.add(fig, text="Statistics") nb.add(self.viewer, text="Preview") self.reset_data()