Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # basic_level_python_roadmap.py ZZZ
- import tkinter as tk
- from tkinter import ttk
- # import autoimport
- def create_code_block(parent, code, options):
- frame = ttk.Frame(parent)
- frame.pack(fill=tk.X, padx=5, pady=5)
- code_label = ttk.Label(frame, text=code)
- code_label.pack(side=tk.LEFT, padx=5)
- option_var = tk.StringVar()
- option_menu = ttk.OptionMenu(frame, option_var, *options)
- option_menu.pack(side=tk.RIGHT, padx=5)
- # Create the main window
- root = tk.Tk()
- root.title("Title")
- root = Tk()
- top = Toplevel(root, width=200, height=200)
- frame = Frame(root, width=200, height=200)
- label = Label(root, text="Hello", font=("Verdana", 16, "bold italic"), fg="blue", bg="yellow", width=10, height=2)
- button = Button(root, text="Click", font=("Arial", 12), fg="white", bg="black", width=10, height=2)
- entry = Entry(root, font=("Courier", 14), fg="green", bg="white", width=20)
- text = Text(root, font=("Times New Roman", 12), fg="red", bg="lightgray", width=30, height=10)
- canvas = Canvas(root, width=300, height=200, bg="lightblue", highlightthickness=2, highlightbackground="black")
- menu = Menu(root, tearoff=0)
- menubutton = Menubutton(root, text="Menu", font=("Helvetica", 14), fg="purple", bg="lightgreen")
- optionmenu = OptionMenu(root, entry, "Option1", "Option2", font=("Georgia", 12), fg="orange", bg="lightyellow")
- checkbutton = Checkbutton(root, text="Check", font=("Comic Sans MS", 14), fg="brown", bg="lightpink")
- radiobutton = Radiobutton(root, text="Radio", font=("Impact", 16), fg="darkblue", bg="lightcyan")
- scale = Scale(root, from_=0, to=100, orient="horizontal", length=200, width=20, sliderlength=30, tickinterval=20)
- scrollbar = Scrollbar(root, orient="vertical", width=15)
- listbox = Listbox(root, font=("Courier", 12), fg="darkgreen", bg="lightgray", width=20, height=10)
- message = Message(root, text="Message", font=("Verdana", 14), fg="darkred", bg="lightyellow", width=200)
- spinbox = Spinbox(root, from_=0, to=10, font=("Arial", 14), fg="darkmagenta", bg="lightgray", width=10)
- panedwindow = PanedWindow(root, orient="horizontal", sashwidth=5, sashrelief="raised")
- labelframe = LabelFrame(root, text="LabelFrame", font=("Times New Roman", 16), fg="darkcyan", bg="lightgray", width=200, height=150)
- bitmapimage = BitmapImage(file="bitmap.xbm")
- photoimage = PhotoImage(file="photo.png")
- # PIL Image Operations with Additional Options
- img = Image.new('RGB', (100, 100), color='#FFFFFF')
- draw = ImageDraw.Draw(img)
- font = ImageFont.truetype('arial.ttf', 16)
- img = img.filter(ImageFilter.BLUR)
- enhancer = ImageEnhance.Brightness(img)
- img = ImageOps.flip(img)
- img = ImageChops.add(img, img)
- stat = ImageStat.Stat(img)
- color = ImageColor.getrgb('red')
- img = ImageGrab.grab()
- seq = ImageSequence.Iterator(img)
- file = ImageFile.Parser()
- img = Image.new('RGB', (100, 100), color='#FFFFFF')
- img = Image.blend(img, img, 0.5)
- img = Image.composite(img, img, img)
- img = Image.merge('RGB', (img, img, img))
- img = Image.frombytes('RGB', (100, 100), b'abc')
- img = Image.fromstring('RGB', (100, 100), b'abc')
- img = Image.frombuffer('RGB', (100, 100), b'abc')
- img = Image.fromarray(np.zeros((100, 100)))
- img = Image.fromqimage(qimage)
- img = Image.fromqpixmap(qpixmap)
- img.save('image.png')
- img.show()
- img = img.convert('L')
- img = img.copy()
- img = img.crop((0, 0, 50, 50))
- img = img.draft('RGB', (100, 100))
- img = img.effect_spread(10)
- bands = img.getbands()
- bbox = img.getbbox()
- channel = img.getchannel('R')
- colors = img.getcolors()
- data = img.getdata()
- extrema = img.getextrema()
- im = img.getim()
- palette = img.getpalette()
- pixel = img.getpixel((0, 0))
- projection = img.getprojection()
- sampling = img.getsampling()
- histogram = img.histogram()
- img = img.offset(10)
- img.paste(img, (0, 0))
- img = img.point(lambda x: x * 2)
- img.putalpha(img)
- img.putdata(data)
- img.putpalette(palette)
- img = img.quantize(256)
- img = img.remap_palette(palette)
- img = img.resize((50, 50))
- img = img.rotate(45)
- img.save_all('image.gif')
- img.seek(0)
- img.split()
- pos = img.tell()
- img.thumbnail((50, 50))
- bitmap = img.tobitmap()
- bytes = img.tobytes()
- string = img.tostring()
- img = img.transform((100, 100), Image.AFFINE, (1, 0, 0, 0, 1, 0))
- img = img.transpose(Image.FLIP_LEFT_RIGHT)
- img.verify()
- # Built-in Functions
- abs(-1)
- dict(a=1, b=2)
- help(dict)
- min([1, 2, 3])
- set([1, 2, 3])
- all([True, True, False])
- dir(dict)
- hex(255)
- next(iter([1, 2, 3]))
- slice(1, 5)
- any([False, False, True])
- divmod(5, 2)
- id(dict)
- object()
- sorted([3, 1, 2])
- ascii('รค')
- enumerate(['a', 'b', 'c'])
- input("Enter: ")
- oct(255)
- staticmethod(lambda: None)
- bin(255)
- eval('1 + 1')
- int('10')
- open('file.txt', 'r')
- str(10)
- bool(1)
- isinstance(1, int)
- ord('a')
- sum([1, 2, 3])
- bytearray(b'abc')
- filter(lambda x: x > 1, [1, 2, 3])
- issubclass(int, object)
- pow(2, 3)
- super()
- bytes(b'abc')
- float('1.2')
- iter([1, 2, 3])
- print('Hello')
- tuple([1, 2, 3])
- callable(print)
- format(1.2345, '.2f')
- len([1, 2, 3])
- property()
- type(1)
- chr(97)
- frozenset([1, 2, 3])
- list([1, 2, 3])
- range(1, 5)
- vars()
- classmethod(lambda: None)
- getattr(dict, 'keys')
- locals()
- repr(dict)
- zip([1, 2], [3, 4])
- globals()
- map(lambda x: x * 2, [1, 2, 3])
- reversed([1, 2, 3])
- complex(1, 2)
- hasattr(dict, 'keys')
- max([1, 2, 3])
- round(1.2345, 2)
- delattr(dict, 'a')
- hash(dict)
- memoryview(bytes(b'abc'))
- setattr(dict, 'a', 1)
- # Control Flow
- if True:
- pass
- elif False:
- pass
- else:
- pass
- for i in range(3):
- pass
- while True:
- pass
- try:
- pass
- except:
- pass
- else:
- pass
- finally:
- pass
- with open('file.txt', 'r') as f:
- pass
- assert True
- break
- continue
- return
- raise Exception
- yield
- # Operators
- and
- or
- not
- in
- is
- # Tkinter Root Methods with Additional Options
- root.mainloop()
- root.quit()
- root.update()
- root.update_idletasks()
- root.after(1000, lambda: None)
- root.after_idle(lambda: None)
- root.after_cancel(lambda: None)
- root.bind("<Button-1>", lambda e: None)
- root.unbind("<Button-1>")
- root.bind_all("<Button-1>", lambda e: None)
- root.unbind_all("<Button-1>")
- root.bind_class("Button", "<Button-1>", lambda e: None)
- root.unbind_class("Button", "<Button-1>")
- root.event_generate("<Button-1>")
- root.focus_set()
- root.focus_get()
- root.focus_force()
- root.focus_lastfor()
- root.focus_displayof()
- root.grab_set()
- root.grab_release()
- root.grab_current()
- root.grab_status()
- root.clipboard_get()
- root.clipboard_clear()
- root.clipboard_append("text")
- root.selection_get()
- root.selection_clear()
- root.selection_handle(lambda x: None)
- root.selection_own()
- root.selection_own_get()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement