How to use _init_refresh method in ATX

Best Python code snippet using ATX Github


Full Screen

...59 self._attachfile_text = tk.StringVar()60 self._running = False # if background is running61 self._init_items()62 self._init_thread()63 self._init_refresh()64 self._lastx = 065 self._lasty = 066 self._bounds = None # crop area67 self._center = (0, 0) # center point68 self._offset = (0, 0) # offset to image center69 self._poffset = (0, 0)70 self._size = (90, 90)71 self._moved = False # click or click and move72 self._color = 'red' # draw color73 self._tkimage = None # keep reference74 self._image = None75 self._ratio = ratio76 self._uinodes = [] # ui dump77 self._selected_node = None78 self._hovered_node = None79 self._save_parent_dir = None80 self._init_vars()81 def _init_items(self):82 """83 .---------------.84 | Ctrl | Screen |85 |------| |86 | Code | |87 | | |88 """89 root = self._root90 root.resizable(0, 0)91 frm_control = tk.Frame(root, bg='#bbb')92 frm_control.grid(column=0, row=0, padx=5, sticky=tk.NW)93 frm_screen = tk.Frame(root, bg='#aaa')94 frm_screen.grid(column=1, row=0)95 frm_screenshot = tk.Frame(frm_control)96 frm_screenshot.grid(column=0, row=0, sticky=tk.W)97 tk.Label(frm_control, text='-'*30).grid(column=0, row=1, sticky=tk.EW)98 frm_code = tk.Frame(frm_control)99 frm_code.grid(column=0, row=2, sticky=tk.EW)100 self._btn_refresh = tk.Button(frm_screenshot, textvariable=self._refresh_text, command=self._refresh_screen)101 self._btn_refresh.grid(column=0, row=0, sticky=tk.W)102 # tk.Button(frm_screenshot, text="Wakeup", command=self._device.wakeup).grid(column=0, row=1, sticky=tk.W)103 tk.Button(frm_screenshot, text=u"保存选中区域", command=self._save_crop).grid(column=0, row=1, sticky=tk.W)104 105 # tk.Button(frm_screenshot, text="保存截屏", command=self._save_screenshot).grid(column=0, row=2, sticky=tk.W)106 frm_checkbtns = tk.Frame(frm_screenshot)107 frm_checkbtns.grid(column=0, row=3, sticky=(tk.W, tk.E))108 tk.Checkbutton(frm_checkbtns, text="Auto refresh", variable=self._auto_refresh_var, command=self._run_check_refresh).grid(column=0, row=0, sticky=tk.W)109 tk.Checkbutton(frm_checkbtns, text="UI detect", variable=self._uiauto_detect_var).grid(column=1, row=0, sticky=tk.W)110 frm_code_editor = tk.Frame(frm_code)111 frm_code_editor.grid(column=0, row=0, sticky=(tk.W, tk.E))112 tk.Label(frm_code_editor, text='Generated code').grid(column=0, row=0, sticky=tk.W)113 tk.Entry(frm_code_editor, textvariable=self._gencode_text, width=30).grid(column=0, row=1, sticky=tk.W)114 tk.Label(frm_code_editor, text='Save file name').grid(column=0, row=2, sticky=tk.W)115 tk.Entry(frm_code_editor, textvariable=self._genfile_name, width=30).grid(column=0, row=3, sticky=tk.W)116 tk.Label(frm_code_editor, text='Extention name').grid(column=0, row=4, sticky=tk.W)117 tk.Entry(frm_code_editor, textvariable=self._fileext_text, width=30).grid(column=0, row=5, sticky=tk.W)118 119 frm_code_btns = tk.Frame(frm_code)120 frm_code_btns.grid(column=0, row=2, sticky=(tk.W, tk.E))121 tk.Button(frm_code_btns, text='Run', command=self._run_code).grid(column=0, row=0, sticky=tk.W)122 self._btn_runedit = tk.Button(frm_code_btns, state=tk.DISABLED, text='Insert and Run', command=self._run_and_insert)123 self._btn_runedit.grid(column=1, row=0, sticky=tk.W)124 tk.Button(frm_code, text='Select File', command=self._run_selectfile).grid(column=0, row=4, sticky=tk.W)125 tk.Label(frm_code, textvariable=self._attachfile_text).grid(column=0, row=5, sticky=tk.W)126 tk.Button(frm_code, text='Reset', command=self._reset).grid(column=0, row=6, sticky=tk.W)127 self.canvas = tk.Canvas(frm_screen, bg="blue", bd=0, highlightthickness=0, relief='ridge')128 self.canvas.grid(column=0, row=0, padx=10, pady=10)129 self.canvas.bind("<Button-1>", self._stroke_start)130 self.canvas.bind("<B1-Motion>", self._stroke_move)131 self.canvas.bind("<B1-ButtonRelease>", self._stroke_done)132 self.canvas.bind("<Motion>", self._mouse_move)133 def _init_vars(self):134 self.draw_image(self._device.screenshot())135 if self._uiauto_detect_var.get():136 self._uinodes = self._device.dump_nodes()137 def _worker(self):138 que = self._queue139 while True:140 (func, args, kwargs) = que.get()141 try:142 func(*args, **kwargs)143 except Exception as e:144 print e145 finally:146 que.task_done()147 148 def _run_check_refresh(self):149 auto = self._auto_refresh_var.get()150 state = tk.DISABLED if auto else tk.NORMAL151 self._btn_refresh.config(state=state)152 def _run_async(self, func, args=(), kwargs={}):153 self._queue.put((func, args, kwargs))154 def _init_thread(self):155 th = threading.Thread(name='thread', target=self._worker)156 th.daemon = True157 th.start()158 def _init_refresh(self):159 if not self._running and self._auto_refresh_var.get():160 self._refresh_screen()161 self._root.after(200, self._init_refresh)162 def _fix_bounds(self, bounds):163 bounds = [x/self._ratio for x in bounds]164 (x0, y0, x1, y1) = bounds165 if x0 > x1:166 x0, y0, x1, y1 = x1, y1, x0, y0167 # in case of out of bounds168 w, h = self._size169 x0 = max(0, x0)170 y0 = max(0, y0)171 x1 = min(w, x1)172 y1 = min(h, y1)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?