python - Is it possible to create a canvas inside of a class -


i working on project have have grid made of points... seems code of class ok because there no error message. can't create canvas inside of class? helping me. here code:

from tkinter import *  root = tk()  class grid():      def createcanvas(self, master, width, height):         self.canvas = canvas(master, width=width, height=height)         return(self.canvas)      def createlabel(self, master, textu):         self.l = label(self.c, text=textu)         self.l.pack()      def createpoints(self, master, gridsize): # gridsize format '8x8'         gridsize = gridsize.split('x')          in range(len(gridsize)):             gridsize[i] = int(gridsize[i]) #[8,8] example --> x,y coordinates         spx = 0         spy = int(canvas['height'])         in range(gridsize[1]):             j in range(gridsize[0]):                 master.create_oval(spx, spy, spx+5, spy+5)                 spx = spx + (int(canvas['height'])/gridsize[0])             spx = 0             spy = spy - (int(canvas['height'])/gridsize[1])    canvas = grid() canvas = canvas.createcanvas(root, 600, 600) = grid() a.createpoints(canvas, '16x16')  root.mainloop() 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -