예제 #1
0
 def save_state(self):
     state_manager.update({
         "x": self.capture_x,
         "y": self.capture_y,
         "size": self.capture_size,
         "rotation": self.capture_rotation
     })
예제 #2
0
    def mouse_1_up(self, event):

        capture_x = self.selection_frame.winfo_x()
        capture_y = self.selection_frame.winfo_y()
        box_size = self.selection_frame.winfo_width()
        self.root.withdraw()

        source_img_pil = pyautogui.screenshot(region=(capture_x, capture_y,
                                                      box_size, box_size))

        Utils.send_toast(f"Screenshot taken at: {capture_x}, {capture_y}",
                         f"Size: {box_size} x {box_size}",
                         duration=2)
        print(
            f"Initial screenshot taken at: {capture_x}, {capture_y}\n  Size: {box_size} x {box_size}"
        )

        self.back_frame.destroy()
        self.root.deiconify()

        options_menu = OptionsMenu(self.root, self.source, source_img_pil)
        if options_menu.cancelled:
            return None

        source_img_path = path.join(Env.appdata_path,
                                    f"images/{self.source}_source.png")
        Path(path.join(Env.appdata_path, "images")).mkdir(parents=True,
                                                          exist_ok=True)
        source_img_pil.save(source_img_path)

        state_manager.update({
            "x": int((Env.res_x / 2) - (box_size / 2)),
            "y": int((Env.res_y / 2) - (box_size / 2)),
            "size": box_size,
            "rotation": 0
        })

        Utils.send_toast("Capture complete",
                         "You can now align the image",
                         duration=2)
예제 #3
0
 def on_back_destroy(self):
     state_manager.update({"water_company": self.water_company.get()})
예제 #4
0
 def save_state(self):
     state_manager.update({
         "x": self.capture_x,
         "y": self.capture_y,
         "size": self.capture_size
     })
예제 #5
0
  def __init__(self, root = None, source = None, initial_img_pil = None):

    super().__init__(root)

    if not [ "dw", "map" ].__contains__(source):
      return

    self.source = source
    self.source_name = { "dw": "DW", "map": "Map" }[source]

    self.cancelled = False

    self.reference = StringVar()
    state_manager.update({ "reference": "" })

    self.generate_frames()
    self.generate_header()
    self.generate_title("Current Image")

    self.resize(450, 625)

    self.root.bind("<Key>", self.key_press)

    self.initial_img_pil = initial_img_pil
    if self.initial_img_pil is None:
      self.initial_img_pil = Image.open(
        path.join(Env.appdata_path, f"images/{source}.png")
      )

    self.source_img_tk = ImageTk.PhotoImage(self.initial_img_pil)

    self.img_frame = Frame(
      self.front_frame,
      highlightthickness=1,
      highlightcolor="#fff"
    )
    self.img_frame.pack(side=TOP, pady=(10))

    self.image_label = Label(
      self.img_frame,
      image=self.source_img_tk,
      bg="#212121",
      borderwidth=0,
      width=300, height=300
    )
    self.image_label.image = self.source_img_tk
    self.image_label.pack()

    self.generate_title("Input a Reference")


    self.reference_entry = Entry(
      self.front_frame,
      font=("Courier", 12),
      textvariable=self.reference,
      bg="#212121",
      fg="white",
      insertbackground="white",
      justify=CENTER,
      highlightthickness=1,
      relief=FLAT
    )
    self.reference_entry.pack(side=TOP, pady=10)

    self.button_frame = Label(
      self.front_frame,
      bg="#212121"
    )
    self.button_frame.pack(side=TOP)

    self.generate_button("Submit", self.submit, self.button_frame)
    self.generate_button("Cancel", self.cancel, self.button_frame)

    self.root.after(1, self.reference_entry.focus)

    self.root.mainloop()
예제 #6
0
def save_ref(ref):
  state_manager.update({ "reference": ref })