pycharmers.utils.tkinter_utils module¶
-
class
pycharmers.utils.tkinter_utils.PortionSelector(resize_ratio=2.0)[source]¶ Bases:
object- Args:
resize_ratio (float) : How much to resize the screenshot. (∵ The default screenshot is too big)
-
root¶ Toplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.
- Type
Tk
-
canvas¶ Canvas widget to display graphical elements like lines or text.
- Type
Canvas
-
ss¶ A ScreenShot. You can retake using
retake_screenshotmethod.- Type
Image
-
sstk¶ A Screenshot converted for display on
tkinter.- Type
PhotoImage
-
portion¶ Selected Portion.
- Type
list
Examples
>>> from pycharmers.utils import PortionSelector >>> ps = PortionSelector() >>> ps.run() >>> portion = ps.portion
-
retake_screenshot(sec=3)[source]¶ Retake the screenshot after
secseconds.- Parameters
sec (int) – Retake a screenshot in
secseconds.- Returns
Taken screenshot.
- Return type
Image
-
property
ssSize¶ The size of ScreenShot.
-
ssResize(dsize)[source]¶ Resize both screenshots (
self.ss,self.sstk).- Parameters
dsize (tuple) – Resized screenshot size.
-
get_start_point(evt)[source]¶ Get the start point.
- Parameters
evt (Event) – Container for the properties of an event.
Examples
>>> from pycharmers.utils import PortionSelector >>> ps = PortionSelector() >>> ps.canvas.pack() >>> ps.canvas.bind("<ButtonPress-1>", ps.get_start_point) >>> ps.canvas.bind("<Button1-Motion>", "Action executed when Mouse is moving") >>> ps.canvas.bind("<ButtonRelease-1>", "Action executed when Button released") >>> ps.root.mainloop()
-
draw_curt_rect(evt)[source]¶ Drawing the current Rectangle.
- Parameters
evt (Event) – Container for the properties of an event.
Examples
>>> from pycharmers.utils import PortionSelector >>> ps = PortionSelector() >>> ps.canvas.pack() >>> ps.canvas.bind("<ButtonPress-1>", "Action executed when Button Pressed") >>> ps.canvas.bind("<Button1-Motion>", ps.draw_curt_rect) >>> ps.canvas.bind("<ButtonRelease-1>", "Action executed when Button released") >>> ps.root.mainloop()
-
release_action(evt)[source]¶ Drawing the current Rectangle.
- Parameters
evt (Event) – Container for the properties of an event.
Examples
>>> from pycharmers.utils import PortionSelector >>> ps = PortionSelector() >>> ps.canvas.pack() >>> ps.canvas.bind("<ButtonPress-1>", "Action executed when Button Pressed") >>> ps.canvas.bind("<Button1-Motion>", "Action executed when Mouse is moving") >>> ps.canvas.bind("<ButtonRelease-1>", ps.release_action) >>> ps.root.mainloop()