Advertisement
here2share

# basic_level_python_roadmap.py

Sep 14th, 2024 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.51 KB | None | 0 0
  1. # basic_level_python_roadmap.py ZZZ
  2.  
  3. import tkinter as tk
  4. from tkinter import ttk
  5. # import autoimport
  6.  
  7. def create_code_block(parent, code, options):
  8.     frame = ttk.Frame(parent)
  9.     frame.pack(fill=tk.X, padx=5, pady=5)
  10.    
  11.     code_label = ttk.Label(frame, text=code)
  12.     code_label.pack(side=tk.LEFT, padx=5)
  13.    
  14.     option_var = tk.StringVar()
  15.     option_menu = ttk.OptionMenu(frame, option_var, *options)
  16.     option_menu.pack(side=tk.RIGHT, padx=5)
  17.  
  18. # Create the main window
  19. root = tk.Tk()
  20. root.title("Title")
  21.  
  22. root = Tk()
  23. top = Toplevel(root, width=200, height=200)
  24. frame = Frame(root, width=200, height=200)
  25. label = Label(root, text="Hello", font=("Verdana", 16, "bold italic"), fg="blue", bg="yellow", width=10, height=2)
  26. button = Button(root, text="Click", font=("Arial", 12), fg="white", bg="black", width=10, height=2)
  27. entry = Entry(root, font=("Courier", 14), fg="green", bg="white", width=20)
  28. text = Text(root, font=("Times New Roman", 12), fg="red", bg="lightgray", width=30, height=10)
  29. canvas = Canvas(root, width=300, height=200, bg="lightblue", highlightthickness=2, highlightbackground="black")
  30. menu = Menu(root, tearoff=0)
  31. menubutton = Menubutton(root, text="Menu", font=("Helvetica", 14), fg="purple", bg="lightgreen")
  32. optionmenu = OptionMenu(root, entry, "Option1", "Option2", font=("Georgia", 12), fg="orange", bg="lightyellow")
  33. checkbutton = Checkbutton(root, text="Check", font=("Comic Sans MS", 14), fg="brown", bg="lightpink")
  34. radiobutton = Radiobutton(root, text="Radio", font=("Impact", 16), fg="darkblue", bg="lightcyan")
  35. scale = Scale(root, from_=0, to=100, orient="horizontal", length=200, width=20, sliderlength=30, tickinterval=20)
  36. scrollbar = Scrollbar(root, orient="vertical", width=15)
  37. listbox = Listbox(root, font=("Courier", 12), fg="darkgreen", bg="lightgray", width=20, height=10)
  38. message = Message(root, text="Message", font=("Verdana", 14), fg="darkred", bg="lightyellow", width=200)
  39. spinbox = Spinbox(root, from_=0, to=10, font=("Arial", 14), fg="darkmagenta", bg="lightgray", width=10)
  40. panedwindow = PanedWindow(root, orient="horizontal", sashwidth=5, sashrelief="raised")
  41. labelframe = LabelFrame(root, text="LabelFrame", font=("Times New Roman", 16), fg="darkcyan", bg="lightgray", width=200, height=150)
  42. bitmapimage = BitmapImage(file="bitmap.xbm")
  43. photoimage = PhotoImage(file="photo.png")
  44.  
  45. # PIL Image Operations with Additional Options
  46. img = Image.new('RGB', (100, 100), color='#FFFFFF')
  47. draw = ImageDraw.Draw(img)
  48. font = ImageFont.truetype('arial.ttf', 16)
  49. img = img.filter(ImageFilter.BLUR)
  50. enhancer = ImageEnhance.Brightness(img)
  51. img = ImageOps.flip(img)
  52. img = ImageChops.add(img, img)
  53. stat = ImageStat.Stat(img)
  54. color = ImageColor.getrgb('red')
  55. img = ImageGrab.grab()
  56. seq = ImageSequence.Iterator(img)
  57. file = ImageFile.Parser()
  58. img = Image.new('RGB', (100, 100), color='#FFFFFF')
  59. img = Image.blend(img, img, 0.5)
  60. img = Image.composite(img, img, img)
  61. img = Image.merge('RGB', (img, img, img))
  62. img = Image.frombytes('RGB', (100, 100), b'abc')
  63. img = Image.fromstring('RGB', (100, 100), b'abc')
  64. img = Image.frombuffer('RGB', (100, 100), b'abc')
  65. img = Image.fromarray(np.zeros((100, 100)))
  66. img = Image.fromqimage(qimage)
  67. img = Image.fromqpixmap(qpixmap)
  68. img.save('image.png')
  69. img.show()
  70. img = img.convert('L')
  71. img = img.copy()
  72. img = img.crop((0, 0, 50, 50))
  73. img = img.draft('RGB', (100, 100))
  74. img = img.effect_spread(10)
  75. bands = img.getbands()
  76. bbox = img.getbbox()
  77. channel = img.getchannel('R')
  78. colors = img.getcolors()
  79. data = img.getdata()
  80. extrema = img.getextrema()
  81. im = img.getim()
  82. palette = img.getpalette()
  83. pixel = img.getpixel((0, 0))
  84. projection = img.getprojection()
  85. sampling = img.getsampling()
  86. histogram = img.histogram()
  87. img = img.offset(10)
  88. img.paste(img, (0, 0))
  89. img = img.point(lambda x: x * 2)
  90. img.putalpha(img)
  91. img.putdata(data)
  92. img.putpalette(palette)
  93. img = img.quantize(256)
  94. img = img.remap_palette(palette)
  95. img = img.resize((50, 50))
  96. img = img.rotate(45)
  97. img.save_all('image.gif')
  98. img.seek(0)
  99. img.split()
  100. pos = img.tell()
  101. img.thumbnail((50, 50))
  102. bitmap = img.tobitmap()
  103. bytes = img.tobytes()
  104. string = img.tostring()
  105. img = img.transform((100, 100), Image.AFFINE, (1, 0, 0, 0, 1, 0))
  106. img = img.transpose(Image.FLIP_LEFT_RIGHT)
  107. img.verify()
  108.  
  109. # Built-in Functions
  110. abs(-1)
  111. dict(a=1, b=2)
  112. help(dict)
  113. min([1, 2, 3])
  114. set([1, 2, 3])
  115. all([True, True, False])
  116. dir(dict)
  117. hex(255)
  118. next(iter([1, 2, 3]))
  119. slice(1, 5)
  120. any([False, False, True])
  121. divmod(5, 2)
  122. id(dict)
  123. object()
  124. sorted([3, 1, 2])
  125. ascii('รค')
  126. enumerate(['a', 'b', 'c'])
  127. input("Enter: ")
  128. oct(255)
  129. staticmethod(lambda: None)
  130. bin(255)
  131. eval('1 + 1')
  132. int('10')
  133. open('file.txt', 'r')
  134. str(10)
  135. bool(1)
  136. isinstance(1, int)
  137. ord('a')
  138. sum([1, 2, 3])
  139. bytearray(b'abc')
  140. filter(lambda x: x > 1, [1, 2, 3])
  141. issubclass(int, object)
  142. pow(2, 3)
  143. super()
  144. bytes(b'abc')
  145. float('1.2')
  146. iter([1, 2, 3])
  147. print('Hello')
  148. tuple([1, 2, 3])
  149. callable(print)
  150. format(1.2345, '.2f')
  151. len([1, 2, 3])
  152. property()
  153. type(1)
  154. chr(97)
  155. frozenset([1, 2, 3])
  156. list([1, 2, 3])
  157. range(1, 5)
  158. vars()
  159. classmethod(lambda: None)
  160. getattr(dict, 'keys')
  161. locals()
  162. repr(dict)
  163. zip([1, 2], [3, 4])
  164. globals()
  165. map(lambda x: x * 2, [1, 2, 3])
  166. reversed([1, 2, 3])
  167. complex(1, 2)
  168. hasattr(dict, 'keys')
  169. max([1, 2, 3])
  170. round(1.2345, 2)
  171. delattr(dict, 'a')
  172. hash(dict)
  173. memoryview(bytes(b'abc'))
  174. setattr(dict, 'a', 1)
  175.  
  176. # Control Flow
  177. if True:
  178.     pass
  179. elif False:
  180.     pass
  181. else:
  182.     pass
  183.  
  184. for i in range(3):
  185.     pass
  186.  
  187. while True:
  188.     pass
  189.  
  190. try:
  191.     pass
  192. except:
  193.     pass
  194. else:
  195.     pass
  196. finally:
  197.     pass
  198.  
  199. with open('file.txt', 'r') as f:
  200.     pass
  201.  
  202. assert True
  203. break
  204. continue
  205. return
  206. raise Exception
  207. yield
  208.  
  209. # Operators
  210. and
  211. or
  212. not
  213. in
  214. is
  215.  
  216. # Tkinter Root Methods with Additional Options
  217. root.mainloop()
  218. root.quit()
  219. root.update()
  220. root.update_idletasks()
  221. root.after(1000, lambda: None)
  222. root.after_idle(lambda: None)
  223. root.after_cancel(lambda: None)
  224. root.bind("<Button-1>", lambda e: None)
  225. root.unbind("<Button-1>")
  226. root.bind_all("<Button-1>", lambda e: None)
  227. root.unbind_all("<Button-1>")
  228. root.bind_class("Button", "<Button-1>", lambda e: None)
  229. root.unbind_class("Button", "<Button-1>")
  230. root.event_generate("<Button-1>")
  231. root.focus_set()
  232. root.focus_get()
  233. root.focus_force()
  234. root.focus_lastfor()
  235. root.focus_displayof()
  236. root.grab_set()
  237. root.grab_release()
  238. root.grab_current()
  239. root.grab_status()
  240. root.clipboard_get()
  241. root.clipboard_clear()
  242. root.clipboard_append("text")
  243. root.selection_get()
  244. root.selection_clear()
  245. root.selection_handle(lambda x: None)
  246. root.selection_own()
  247. root.selection_own_get()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement