CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 07:33:01 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=68279cf2fc0c12849bb394e19da40ecc8f2aa93745fac7fefa461ad887f42798a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22pKWxywKHwYcSz5iopO2mdtffdsYcU3eZ%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ccaabb78369ac4-BLR
# tk_canvas_zoom.py - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_canvas_zoom.py
- import tkinter as tk
- def create_xcanvas(rootwin, **opt):
- width = opt.get("width", 1000)
- height = opt.get("height", 600)
- bg = opt.get("bg", "white")
- scrollbars = opt.get("scrollbars", True)
- scalewidget = opt.get("scalewidget", True)
- x_axis = opt.get("x_axis", 7)
- y_axis = opt.get("y_axis", 7)
- region = (-50, -50, width, height)
- rootframe = tk.Frame(rootwin, width=width, height=height, bg=bg)
- rootframe.pack(expand=True, fill=tk.BOTH)
- canvas = tk.Canvas(rootframe, width=width, height=height, bg=bg, scrollregion=region)
- canvas.config(highlightthickness=0)
- if scrollbars:
- setup_scrollbars(canvas, rootframe)
- canvas.pack(side=tk.LEFT, expand=True, fill=tk.BOTH)
- scalewidget_obj = tk.Scale(rootframe, from_=1, to=3000, length=500,
- orient=tk.VERTICAL, font="Consolas 6",
- command=lambda p: resize_canvas(canvas, region, p))
- scalewidget_obj.set(100)
- if scalewidget:
- scalewidget_obj.pack(side=tk.TOP, fill=tk.Y, expand=False)
- else:
- scalewidget_obj.place(x=100000, y=100000)
- canvas.xview_moveto(0)
- canvas.yview_moveto(0)
- if x_axis or y_axis:
- draw_axis(canvas, x_axis, y_axis)
- setup_bindings(canvas, rootwin, scalewidget_obj)
- canvas.region = region
- canvas.rootwin = rootwin
- canvas.scalewidget = scalewidget_obj
- return canvas
- def setup_scrollbars(canvas, rootframe):
- sbarV = tk.Scrollbar(rootframe, orient=tk.VERTICAL)
- sbarH = tk.Scrollbar(rootframe, orient=tk.HORIZONTAL)
- sbarV.config(command=canvas.yview)
- sbarH.config(command=canvas.xview)
- canvas.config(yscrollcommand=sbarV.set)
- canvas.config(xscrollcommand=sbarH.set)
- sbarV.pack(side=tk.RIGHT, fill=tk.Y)
- sbarH.pack(side=tk.BOTTOM, fill=tk.X)
- def setup_bindings(canvas, rootwin, scalewidget):
- canvas.bind("<Control-MouseWheel>", lambda e: on_ctrl_mousewheel(e, scalewidget))
- canvas.bind("<Alt-MouseWheel>", lambda e: on_alt_mousewheel(e, scalewidget))
- canvas.bind("<MouseWheel>", lambda e: canvas.yview_scroll(int(-1*(e.delta/120)), "units"))
- canvas.bind("<Shift-MouseWheel>", lambda e: canvas.xview_scroll(int(-1*(e.delta/120)), "units"))
- canvas.bind("f", lambda e: scalewidget.set(100))
- canvas.bind("<Home>", lambda e: scalewidget.set(100))
- canvas.bind("<Up>", lambda e: canvas.yview_scroll(-1, "units"))
- canvas.bind("<Down>", lambda e: canvas.yview_scroll(1, "units"))
- canvas.bind("<Left>", lambda e: canvas.xview_scroll(-1, "units"))
- canvas.bind("<Right>", lambda e: canvas.xview_scroll(1, "units"))
- canvas.bind("<Prior>", lambda e: canvas.yview_scroll(-1, "pages"))
- canvas.bind("<Next>", lambda e: canvas.yview_scroll(1, "pages"))
- canvas.bind("<Shift-Prior>", lambda e: canvas.xview_scroll(1, "pages"))
- canvas.bind("<Shift-Next>", lambda e: canvas.xview_scroll(-1, "pages"))
- def on_ctrl_mousewheel(event, scalewidget):
- s = scalewidget.get()
- s += 15 if event.delta > 0 else -15
- scalewidget.set(s)
- def on_alt_mousewheel(event, scalewidget):
- s = scalewidget.get()
- s += 5 if event.delta > 0 else -5
- scalewidget.set(s)
- def resize_canvas(canvas, region, percent):
- x1, y1, x2, y2 = region
- canvas_breadth = max(x2-x1, y2-y1)
- _region = canvas.config('scrollregion')[4].split()
- region_vals = tuple(float(x) for x in _region)
- x1, y1, x2, y2 = region_vals
- breadth = max(x2-x1, y2-y1)
- if breadth == 0:
- return
- r = float(percent) / 100
- if r < 0.01 or r > 30:
- return
- s = r / (float(breadth) / canvas_breadth)
- canvas.scale('all', 0, 0, s, s)
- nregion = tuple(x*r for x in region)
- canvas.config(scrollregion=nregion)
- def draw_axis(canvas, m, n):
- canvas.create_line(-40, 0, 100*m, 0, width=1, fill='black', arrow='last')
- canvas.create_line(0, -40, 0, 100*n, width=1, fill='black', arrow='last')
- for i in range(1, m):
- canvas.create_line(100*i, -5, 100*i, 0, width=1, fill='black')
- canvas.create_text(100*i, -5, text=str(100*i), font='Consolas 8', anchor='s')
- for i in range(1, n):
- canvas.create_line(-5, 100*i, 0, 100*i, width=1, fill='black')
- canvas.create_text(-7, 100*i, text=str(100*i), font='Consolas 8', anchor='e')
- def show_canvas(canvas, force=False):
- if force or not canvas.winfo_ismapped():
- canvas.rootwin.iconify()
- canvas.rootwin.update()
- canvas.rootwin.deiconify()
- canvas.rootwin.lift()
- def hide_canvas(canvas):
- canvas.rootwin.iconify()
- def xcanvas_test():
- rootwin1 = tk.Tk()
- c1 = create_xcanvas(rootwin1, width=1000, height=800, bg="white")
- c1.create_rectangle(100, 120, 400, 230, width=2, outline='blue', fill='yellow')
- c1.create_rectangle(400, 320, 600, 530, width=2, outline='blue', fill='yellow')
- c1.create_oval(400, 320, 600, 530, width=2, outline='blue', fill='cyan')
- c1.create_line(200, 50, 500, 430, width=3, fill='blue')
- rootwin2 = tk.Tk()
- c2 = create_xcanvas(rootwin2, scrollbars=False, scalewidget=False, x_axis=0, y_axis=0, width=1000, height=800, bg="cornsilk")
- c2.create_rectangle(100, 120, 400, 230, width=2, outline='red', fill='yellow')
- c2.create_oval(100, 120, 400, 230, width=2, outline='red', fill='cyan')
- c2.create_rectangle(400, 320, 600, 530, width=2, outline='red', fill='yellow')
- c2.create_line(200, 50, 500, 430, width=3, fill='red')
- tk.mainloop()
- xcanvas_test()
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐Exchange Exploit⭐⭐ 4
JavaScript | 2 sec ago | 0.24 KB
-
⭐✅ Jack's Profit Method ✅ NEVER SEEN BEF...
JavaScript | 9 sec ago | 0.24 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 11 sec ago | 0.10 KB
-
✅⭐ Make huge profits on trading ⭐⭐ 8
JavaScript | 13 sec ago | 0.24 KB
-
⭐✅ Online Marketplace Exploit ✅ NEVER SEEN BE...
JavaScript | 20 sec ago | 0.24 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 24 sec ago | 0.10 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ K
JavaScript | 24 sec ago | 0.24 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 29 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand