Best Python code snippet using avocado_python
__init__.py
Source:__init__.py  
...64    @property65    def logs_icon(self):66        return self._icon_data('logs_icon.svg')67    @property68    def whiteboard_icon(self):69        return self._icon_data('whiteboard_icon.svg')70    @property71    def tests(self):72        mapping = {"SKIP": "warning",73                   "ERROR": "danger",74                   "FAIL": "danger",75                   "WARN": "warning",76                   "PASS": "success",77                   "INTERRUPTED": "danger",78                   "CANCEL": "warning"}79        test_info = []80        results_dir = self.results_dir(False)81        for tst in self.result.tests:82            formatted = {}...whiteboard.pyw
Source:whiteboard.pyw  
1from tkinter import *2from tkinter import colorchooser3# Create select color function to select an extra color from color menu4def select_color():5    add_color = colorchooser.askcolor(title="Select Color")6    global color7    color = add_color[1]8# Create locate_xy function9def locate_xy(work):10    global current_x, current_y11    current_x = work.x12    current_y = work.y13# Create addLine function for drawing a line14def addLine(work):15    global current_x, current_y16    canvas.create_line((current_x, current_y, work.x, work.y), width=get_current_value(), fill=color, capstyle=ROUND, smooth=True)17    current_x, current_y = work.x, work.y18# Create show_color function for choose a color19def show_color(new_color):20    global color21    color = new_color22# Creare erase_all function for erase all drawing23def erase_all():24    canvas.delete('all')25    display_pallete()26# create display_pallete function for displaying color palletes27def display_pallete():28    id = colors.create_rectangle((10, 10, 30, 30), fill='Black')29    colors.tag_bind(id, '<Button-1>', lambda x: show_color('Black'))30    id = colors.create_rectangle((40, 10, 60, 30), fill='#6D351A')31    colors.tag_bind(id, '<Button-1>', lambda x: show_color('#6D351A'))32    id = colors.create_rectangle((70, 10, 90, 30), fill='gray')33    colors.tag_bind(id, '<Button-1>', lambda x: show_color('gray'))34    id = colors.create_rectangle((100, 10, 120, 30), fill='orange')35    colors.tag_bind(id, '<Button-1>', lambda x: show_color('orange'))36    id = colors.create_rectangle((130, 10, 150, 30), fill='#FF0800')37    colors.tag_bind(id, '<Button-1>', lambda x: show_color('#FF0800'))38    id = colors.create_rectangle((160, 10, 180, 30), fill='#8F00FF')39    colors.tag_bind(id, '<Button-1>', lambda x: show_color('#8F00FF'))40    id = colors.create_rectangle((190, 10, 210, 30), fill='#08E8DE')41    colors.tag_bind(id, '<Button-1>', lambda x: show_color('#08E8DE'))42    id = colors.create_rectangle((220, 10, 240, 30), fill='yellow')43    colors.tag_bind(id, '<Button-1>', lambda x: show_color('yellow'))44    id = colors.create_rectangle((250, 10, 270, 30), fill='green')45    colors.tag_bind(id, '<Button-1>', lambda x: show_color('green'))46    id = colors.create_rectangle((280, 10, 300, 30), fill='#DFFF00')47    colors.tag_bind(id, '<Button-1>', lambda x: show_color('#DFFF00'))48    id = colors.create_rectangle((310, 10, 330, 30), fill='blue')49    colors.tag_bind(id, '<Button-1>', lambda x: show_color('blue'))50    id = colors.create_rectangle((340, 10, 360, 30), fill='#F0F8FF')51    colors.tag_bind(id, '<Button-1>', lambda x: show_color('#F0F8FF'))52# create get_current_value function for getting the current thickness of brush53def get_current_value():54    return '{: .2f}'.format(current_value.get())55# create slider_changed function for change the color thickness56def slider_changed(event):57    value_label.config(text=get_current_value())58# Start execution of program from here59if __name__ == '__main__':60    root = Tk()61    root.title("White Board")62    root.geometry("1050x600+100+20")63    root.attributes('-alpha', 0.97)  # Transparant 3% or 0.03%64    root.config(bg="#f2f3f5")65    root.resizable(False, False)66    current_x = 067    current_y = 068    color = 'black'69    # Set Icon70    root.wm_iconbitmap("A:\\My Projects\\Android Subsystem for Windows (Python)\\White board\\whiteboard_icon.ico")71    # Create color boxes area72    color_boxes = PhotoImage(file="A:\\My Projects\\Android Subsystem for Windows (Python)\\White board\\color section.png")73    Label(root, image=color_boxes, bg="#f2f3f5").place(x=270, y=520)74    # create eraser75    eraser = PhotoImage(file='A:\\My Projects\\Android Subsystem for Windows (Python)\\White board\\eraser.png')76    Button(root, image=eraser, bg='white', bd=0, activebackground='white', command=erase_all, cursor='hand2').place(x=680, y=536)77    # create a add more color button78    add_color_image = PhotoImage(file='A:\\My Projects\\Android Subsystem for Windows (Python)\\White board\\Add-colorpng.png')79    Button(root, image=add_color_image, command=select_color, bd=0, bg='#f2f3f5', cursor='hand2').place(x=850, y=525)80    # Create a canvas for putting the color boxes in it81    colors = Canvas(root, bg="#ffffff", width=368, height=37, bd=0, cursor='hand2')82    colors.place(x=300, y=540)83    # calling display_pallete function84    display_pallete()85    # create working area86    canvas = Canvas(root, width=1026, height=510, background='white')87    canvas.place(x=10, y=10)88    # Bind working area with mouse left click and mouse motion89    canvas.bind("<Button-1>", locate_xy)90    canvas.bind("<B1-Motion>",addLine )91    # _______________ Create Slider ______________92    current_value = DoubleVar()93    slider = Scale(root, from_=1, to=100, orient=HORIZONTAL, command=slider_changed, variable=current_value, length=200, width=10, troughcolor='#FAF0BE', fg='red', activebackground='orange', digits=True, cursor='hand2', bg='#f2f3f5', relief=FLAT, bd=1, sliderrelief=RIDGE, sliderlength=10)94    slider.set(5)95    slider.place(x=50, y=530)96    # value label97    value_label = Label(root, text=get_current_value(), bg='#f2f3f5')98    value_label.place(x=5, y=546)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
