def __init__(self, parent, model, style): super().__init__(parent) self._model = model util.stretchy_rows_cols(self, [3], [0]) if style == "normal": self._text = richtext.RichText(self, height=12, scroll="v") self._text.grid(sticky=tk.NSEW, row=0, column=0) if gpd is None: self._error_case() return self._text.add_text(_text["main"]) subframe = ttk.Frame(self) subframe.grid(row=1, column=0, padx=2, pady=3, sticky=tk.NW) ttk.Button(subframe, text=_text["load"], command=self._load).grid(row=0, column=0, padx=2) self._filename_label = ttk.Label(subframe) self._filename_label.grid(row=0, column=1, padx=2) tooltips.ToolTipYellow(self._filename_label, _text["filett"]) self._projectors_widget = projectors_view.GeoFrameProjectorWidget( self, self._model._projector, self._update) self._projectors_widget.grid(row=2, column=0, padx=2, pady=3, sticky=tk.NW) subframe = ttk.Frame(self) subframe.grid(row=3, column=0, padx=2, pady=3, sticky=tk.NSEW) util.stretchy_rows_cols(subframe, [0], [0, 1]) self._preview_frame = ttk.LabelFrame(subframe, text=_text["preview"]) self._preview_frame.grid(row=0, column=0, sticky=tk.NSEW, padx=2) util.stretchy_rows_cols(self._preview_frame, [0], [0]) self._preview_canvas = mtp.CanvasFigure(self._preview_frame) self._preview_canvas.grid(sticky=tk.NSEW, padx=1, pady=1) self._preview_frame_tt = tooltips.ToolTipYellow( self._preview_frame, _text["previewnonett"]) with_coords_frame = ttk.LabelFrame(subframe, text=_text["preview2"]) with_coords_frame.grid(row=0, column=1, sticky=tk.NSEW, padx=2) util.stretchy_rows_cols(with_coords_frame, [0], [0]) self._with_coords_canvas = mtp.CanvasFigure(with_coords_frame) self._with_coords_canvas.grid(sticky=tk.NSEW, padx=1, pady=1) self._with_coords_frame_tt = tooltips.ToolTipYellow( with_coords_frame, _text["previewnonett"]) self._update()
def __init__(self, parent, model): self._model = model super().__init__(parent) self._plot = mtp.CanvasFigure(self) self._plot.grid(padx=2, pady=2, sticky=tk.NSEW, row=0, column=0) self._plot.set_figure_task(self._plot_task) util.stretchy_rows_cols(self, [0], [0])
def __init__(self, parent, model, parent_model): self._model = model self._parent_model = parent_model super().__init__(parent) subframe = ttk.Frame(self) subframe.grid(row=0, column=0, sticky=tk.W) label = ttk.Label(subframe, text=_text["spbw"]) label.grid(row=0, column=0, padx=2, pady=2) tooltips.ToolTipYellow(label, _text["spbw_tt"]) self._space_bandwidth = tk.StringVar() entry = ttk.Entry(subframe, textvariable=self._space_bandwidth, width=5) entry.grid(row=0, column=1, padx=2) util.IntValidator(entry, self._space_bandwidth, callback=self._space_bw_changed) ttk.Label(subframe, text=_text["spbw1"]).grid(row=0, column=2, padx=2) subframe = ttk.Frame(self) subframe.grid(row=1, column=0, sticky=tk.W) label = ttk.Label(subframe, text=_text["tbw"]) label.grid(row=0, column=0, padx=2, pady=2) tooltips.ToolTipYellow(label, _text["tbw_tt"]) self._time_bandwidth = tk.StringVar() entry = ttk.Entry(subframe, textvariable=self._time_bandwidth, width=5) entry.grid(row=0, column=1, padx=2) util.IntValidator(entry, self._time_bandwidth, callback=self._time_bw_changed) self._plot = mtp.CanvasFigure(self) self._plot.grid(padx=2, pady=2, sticky=tk.NSEW, row=2, column=0) util.stretchy_rows_cols(self, [2], [0]) self._update()
def update_prediction(self, level=-1, adjust_task=None): """Change the plotted prediction. :param level: The % of "coverage" to display, or -1 to mean plot all the relative risk. """ def make_fig(): fig = mtp.new_figure((20, 20)) ax = fig.add_subplot(1, 1, 1) prediction = self.model.current_prediction if level == -1: plot_risk(prediction, ax, adjust_task) else: plot_coverage(prediction, level, ax, adjust_task) ax.set_aspect(1) fig.set_tight_layout(True) return fig if not hasattr(self, "_plot") or self._plot is None: frame = ttk.LabelFrame(self, text=_text["graph_name"]) frame.grid(row=10, column=0, columnspan=2, padx=2, pady=2, sticky=tk.NSEW) util.stretchy_rows_cols(frame, [0], [0]) util.stretchy_rows(self, [10]) util.stretchy_columns(self, [0, 1]) self._plot = mtp.CanvasFigure(frame) self._plot.grid(padx=2, pady=2, sticky=tk.NSEW) self._plot.set_figure_task(make_fig, dpi=50)
def _plot_grid(self): coords = self._controller._projected_coords() if coords is None: return self._no_proj() if self._inline: return def make_fig(): xmin, xmax = _np.min(coords[0]), _np.max(coords[0]) xd = (xmax - xmin) / 100 * 3 xmin, xmax = xmin - xd, xmax + xd ymin, ymax = _np.min(coords[1]), _np.max(coords[1]) yd = (ymax - ymin) / 100 * 3 ymin, ymax = ymin - yd, ymax + yd width = xmax - xmin height = ymax - ymin if width == 0 or height == 0: size = (10, 10) else: height = height / width * 10.0 width = 10.0 if height > 10.0: width = 100.0 / height height = 10.0 size = (width, height) fig = mtp.new_figure(size) ax = fig.add_subplot(1, 1, 1) ax.scatter(coords[0], coords[1], marker="x", color="black", alpha=0.5) lc = open_cp.plot.lines_from_regular_grid( self._controller.get_grid()) ax.add_collection( mtp.matplotlib.collections.LineCollection(lc, color="black", linewidth=0.5)) ax.set(xlim=[xmin, xmax], ylim=[ymin, ymax]) ax.set_aspect(1.0) fig.set_tight_layout(True) return fig if self._plot is None: frame = ttk.LabelFrame(self, text=_text["vp"]) frame.grid(row=0, column=2, rowspan=4, padx=2, pady=2, sticky=tk.NSEW) util.stretchy_rows_cols(frame, [0], [0]) self._plot = mtp.CanvasFigure(frame) self._plot.grid(padx=2, pady=2, sticky=tk.NSEW) self._plot.set_figure_task(make_fig, dpi=150)
def __init__(self, model, parent): super().__init__(parent) self.model = model util.stretchy_rows_cols(self, [2], [0]) text = richtext.RichText(self, height=3, scroll="v") text.grid(row=0, column=0, sticky=tk.NSEW) text.add_text(_text["scipy_main"]) self._plot = mtp.CanvasFigure(self) self._plot.grid(row=2, column=0, sticky=tk.NSEW) tooltips.ToolTipYellow(self._plot, _text["kdeplot"]) coords = self.model.main_model.test_coords() if coords is None: return kernel_provider = self.model.make_kernel() task = self.make_plot_task(kernel_provider, coords) self._plot.set_figure_task(task)
def __init__(self, model, parent): super().__init__(parent) self.model = model util.stretchy_rows_cols(self, [2], [0]) text = richtext.RichText(self, height=3, scroll="v") text.grid(row=0, column=0, sticky=tk.NSEW) text.add_text(_text["nkde_main"]) frame = ttk.Frame(self) frame.grid(row=1, column=0, sticky=tk.W) label = ttk.Label(frame, text=_text["nkde_k"]) label.grid(row=0, column=0, padx=2, pady=2) tooltips.ToolTipYellow(label, _text["nkde_k_tt"]) self._k_value = tk.StringVar() entry = ttk.Entry(frame, textvariable=self._k_value) entry.grid(row=0, column=1, padx=2, pady=2) util.IntValidator(entry, self._k_value, callback=self._k_changed) self._plot = mtp.CanvasFigure(self) self._plot.grid(row=2, column=0, sticky=tk.NSEW) tooltips.ToolTipYellow(self._plot, _text["kdeplot"]) self.update()
def _add_widgets(self): subframe = ttk.Frame(self) subframe.grid(row=0, column=0, sticky=tk.W) label = ttk.Label(subframe, text=_text["q_bandwidth"]) label.grid(row=0, column=0, padx=2, pady=2) tooltips.ToolTipYellow(label, _text["q_bandwidth_tt"]) self._quartic_bandwidth_var = tk.StringVar() entry = ttk.Entry(subframe, textvariable=self._quartic_bandwidth_var, width=7) entry.grid(row=0, column=1, padx=2) util.IntValidator(entry, self._quartic_bandwidth_var, callback=self._quartic_bandwidth_changed) ttk.Label(subframe, text=_text["q_bandwidth1"]).grid(row=0, column=2) self._quartic_plot = mtp.CanvasFigure(self) self._quartic_plot.grid(padx=2, pady=2, sticky=tk.NSEW, row=1, column=0) util.stretchy_rows_cols(self, [1], [0])