There are several things wrong with your code.
First, you need to call mainloop after you call main, not before.
Second, sizevar= StringVar needs to be sizevar= StringVar().
Third -- and this is the line that is throwing the error -- you are trying to call self.tk.Checkbutton but your crop object hasn't defined an attribute named tk. I'm not entirely sure what you are trying to accomplish, but my guess is that you are just trying to call the tk checkbutton which means the code should be tk.Checkbutton(...)
The next problem is with self.pack() - self is the crop object. It is not a widget so it doesn't have a pack method. It appears that your intention is to pack the checkbutton, so you need to save a reference to the checkbutton and then call pack on it (eg: self.cb = tk.Checkbutton(...); self.cb.pack())
Another problem is that you're importing tkinter twice. You should only do it once. You need to remove both from tkinter import * and from tkinter.ttk import *. Then, use tk. or ttk. as a prefix when referring to tkinter and ttk objects.
A final issue is that you're not following PEP8 guidelines, making your code harder for other programmers to understand. Specifically, crop needs to be Crop.
Putting that all together, your code should1 look like this:
import tkinter as tk
from tkinter import ttk
screen = tk.Tk()
class Crop:
def __init__(self,sizename,sizevar,onvar):
sizevar= tk.StringVar()
self.cb = tk.Checkbutton(screen, text=sizename, variable=sizevar, onvalue=onvar, offvalue='no')
self.cb.pack()
def main():
first = Crop('2.5','twofive','twofiveon')
second = Crop('3','three','threeon')
main()
screen.mainloop()
1 I say should because it's not 100% clear what you want to do. Because of the way you originally did the imports it's unclear if you're intending to use the ttk version of the Checkbutton widget or the tk version. This is one of the reasons why wildcard imports are bad when importing tkinter. If you want to use the ttk checkbutton, you need to change that one line to this:
self.cb = ttk.Checkbutton