Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2
- # -*- coding: utf-8 -*-
- from Tkinter import Tk, Canvas
- class App:
- def __init__(self, master):
- self.master = master
- self.width = {"start": 0, "end": 640}
- self.height = {"start": 0, "end": 480}
- self.canvas = Canvas(master)
- self.canvas.configure({"bg": "white"})
- self.canvas.pack({"fill": "both", "expand": True})
- # Tk bindings
- self.__bindings(master)
- def __update_coords(self, event):
- # bind event, to update coordinates
- self.width['end'] = event.width
- self.height['end'] = event.height
- self.canvas.update_idletasks()
- self.__draw()
- def __draw(self, event=None):
- self.canvas.delete("diagonal")
- self.canvas.create_line(
- self.width['start'],
- self.height['start'],
- self.width['end'],
- self.height['end'],
- tags="diagonal")
- def __bindings(self, master):
- # binding master window resize
- master.bind("<Configure>", self.__update_coords)
- # master.bind("<Configure>", self.__draw)
- root = Tk()
- root.title("MachineGraphics. Lab2. Variant 2")
- root.geometry("640x480-0+100")
- app = App(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement