def __init__(self, model, parent): super().__init__(parent) self.model = model util.stretchy_columns(self, [0]) text = richtext.RichText(self, height=3, scroll="v") text.grid(row=0, column=0, sticky=tk.NSEW) text.add_text(_text["to_main"])
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 __init__(self, parent, model): super().__init__(parent) self._model = model self._show = False util.stretchy_columns(self, range(7)) util.stretchy_rows(self, range(7)) self._add_widgets() self._make_square()
def add_widgets(self): self._text = richtext.RichText(self, height=12, scroll="v") util.stretchy_rows_cols(self, [0], [0]) self._text.grid(sticky=tk.NSEW) self._queue = queue.Queue() predictors.set_queue_logging(self._queue) self._bottom_frame = ttk.Frame(self) self._bottom_frame.grid(row=1, column=0, sticky=tk.EW) util.stretchy_columns(self._bottom_frame, [2]) self._okay_button = ttk.Button(self._bottom_frame, text=_text["okay"], command=self.cancel) self._okay_button.grid(row=0, column=0, padx=5, pady=3, ipadx=20) self._okay_button.state(["disabled"]) self._cancel_button = ttk.Button(self._bottom_frame, text=_text["cancel"], command=self._cancel) self._cancel_button.grid(row=0, column=1, padx=5, pady=3, ipadx=20) self._done = False self._poll_task()
def _add_widgets(self): frame = ttk.Frame(self) frame.grid(row=0, column=0, padx=2, pady=2, sticky=tk.W) la = ttk.Label(frame, text=_text["sf"].format( funcs.string_ellipse(self.model.settings_filename, 80))) la.grid(row=0, column=0) frame = ttk.LabelFrame(self, text=_text["config"]) frame.grid(row=10, column=0, padx=2, pady=2, sticky=tk.NSEW) self._add_config_box(frame) frame = ttk.LabelFrame(self, text=_text["info"]) frame.grid(row=11, column=0, padx=2, pady=2, sticky=tk.NSEW) tooltips.ToolTipYellow(frame, _text["info_tt"]) util.stretchy_rows(frame, [0]) self._add_info_box(frame) frame = ttk.Frame(self) frame.grid(row=20, column=0, padx=2, pady=2, sticky=tk.EW) util.stretchy_columns(frame, [0, 1]) b = ttk.Button(frame, text=_text["okay"], command=self._okay) b.grid(row=0, column=0, padx=2, pady=2, sticky=tk.NSEW) b = ttk.Button(frame, text=_text["cancel"], command=self._cancel) b.grid(row=0, column=1, padx=2, pady=2, sticky=tk.NSEW)
self._date = None date = self._source() self._dp_widget.date_picker.selected_date = date self._dp_widget.date_picker.month_year = (date.month, date.year) self._dp_widget.date_picker.command = self._cmd self._parent.wait_window(self._dp_widget) if self._date is not None: self._sink(self._date) # Seems that I need to do this to stop the keyboard focus being lost # forever to the now hidden top window! self._widget.focus_force() if __name__ == "__main__": root = tk.Tk() util.stretchy_columns(root, [0]) util.stretchy_rows(root, [0]) dp = DatePicker(root) dp.widget["borderwidth"] = 5 dp.widget["relief"] = "groove" dp.widget.grid(sticky=tk.NSEW) frame = tk.Frame(root) frame.grid() def sunday(): dp.first_day_of_week = "Sun" def monday(): dp.first_day_of_week = "Mon" def go_month():