class PunisherGUI(tk.Tk, object): def __init__(self, *args, **kwargs): super(PunisherGUI, self).__init__(*args, **kwargs) self._punisher = None self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.title('The Punisher') self._image = Image.open(punisher.utils.abspath(__file__, 'banner.png')) self._photo = ImageTk.PhotoImage(self._image, master=self) self._banner = tk.Label(master = self, image=self._photo) self._banner.grid(row=0, column=0, padx=5, pady=5) self._frame = _StartFrame(master=self, on_start=self._on_start) self._frame.grid(row=1, column=0, padx=5, pady=5) def _on_punish(self): self.destroy() def _on_start(self): punish_datetime = self._frame.punish_datetime self._punisher = Punisher(self._frame.username) self._punisher.user.settings_save() self._punisher.safe_mode = self._frame.safe_mode self._punisher.activate(self._frame.punish_datetime, self._frame.password) self.title('The Punisher' + (' [Safe Mode]' if self._punisher.safe_mode else '')) self._frame.destroy() self._frame = _RunFrame(master=self, on_punish=self._on_punish, on_stopped=self._on_stopped, punish_at=punish_datetime) self._frame.grid(row=1, column=0, padx=5, pady=5) self.protocol('WM_DELETE_WINDOW', lambda:None) def _on_stopped(self): try: self._punisher.deactivate(self._frame.password) except PunisherError: return self.destroy() def destroy(self): if self._punisher is not None: self._punisher._timer.join() super(PunisherGUI, self).destroy()
def _on_start(self): punish_datetime = self._frame.punish_datetime self._punisher = Punisher(self._frame.username) self._punisher.user.settings_save() self._punisher.safe_mode = self._frame.safe_mode self._punisher.activate(self._frame.punish_datetime, self._frame.password) self.title('The Punisher' + (' [Safe Mode]' if self._punisher.safe_mode else '')) self._frame.destroy() self._frame = _RunFrame(master=self, on_punish=self._on_punish, on_stopped=self._on_stopped, punish_at=punish_datetime) self._frame.grid(row=1, column=0, padx=5, pady=5) self.protocol('WM_DELETE_WINDOW', lambda:None)