How to use get_window_width method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

application.py

Source:application.py Github

copy

Full Screen

...263 def screen_main(self):264 if not self.bi.uname:265 self.bi.uname = 'Stranger'266 imgui.columns(3, border=False)267 imgui.set_column_width(0, imgui.get_window_width() * 0.20)268 imgui.set_column_width(1, imgui.get_window_width() * 0.60)269 imgui.set_column_width(2, imgui.get_window_width() * 0.20)270 imgui.next_column()271 imgui.text(' '*(int(25*imgui.get_window_width()/640-len(self.bi.uname)*1.3)) + 'Welcome ' + self.bi.uname + '!')272 imgui.text('')273 if imgui.button('Start questionnaire', imgui.get_window_width() * 0.60, 75):274 self.cur_tab = "qa"275 self.sceen_qa()276 imgui.text('')277 if imgui.button('Check evaluation', imgui.get_window_width() * 0.60, 50):278 self.cur_tab = "eval"279 self.screen_eval()280 imgui.text('')281 if imgui.button('Quit application', imgui.get_window_width() * 0.60, 50):282 self.saveUserData()283 quit()284 imgui.next_column()285 286 def loadUserData(self):287 if os.path.exists('userdata.json'):288 results = Json.fromJSON('userdata.json', questions.BasicInfo)289 if len(results) != 1:290 print('Valami elromlott a user datával')291 self.bi = questions.BasicInfo()292 else:293 print('User data betöltve')294 self.bi = results[0]295 else:296 print('Új user data létrehozva')297 self.bi = questions.BasicInfo() # Load default data298 299 def saveUserData(self):300 Json.toJSON(self.bi, 'userdata.json')301 if not os.path.exists('userdata.json'):302 print('Nem sikerült user datát írni')303 def screen_firstlogin(self):304 # TODO : ide sok animációt kérek305 imgui.columns(3, border=False)306 imgui.set_column_width(0, imgui.get_window_width() * 0.20)307 imgui.set_column_width(1, imgui.get_window_width() * 0.60)308 imgui.set_column_width(2, imgui.get_window_width() * 0.20)309 imgui.next_column()310 imgui.text("Choose your username:")311 changed, text_val = imgui.input_text(' ', self.bi.uname, 30)312 if changed:313 self.bi.uname = text_val314 imgui.text("")315 imgui.text("Advanced mode: ")316 imgui.same_line()317 _, self.bi.advanced = imgui.checkbox("", self.bi.advanced)318 imgui.text("")319 if imgui.button("Confirm"):320 if self.bi.uname.strip():321 self.cur_tab = "Main menu"322 self.anim.draw(self.n)...

Full Screen

Full Screen

AppCreator.py

Source:AppCreator.py Github

copy

Full Screen

...11 12 if window_title:self.root = Tk(screenName=window_title)13 super().__init__(master=self.root)14 self.root.state('zoomed')15 self.widgetMargin = self.get_window_width() // 2 + 250 16 self.init_Ui()17 def init_Ui(self):18 self.pack(fill=tkinter.BOTH, expand=1)1920 self.canvas = tkinter.Canvas(self) 21 self.canvas.pack(fill=tkinter.BOTH, expand=1) 22 def createVerticalLine(self,x,startPointY,endPointY):23 ln = None24 def recreate():25 global ln26 try:27 self.canvas.delete(ln)28 except:29 pass30 ln = self.canvas.create_line(x, startPointY, x, endPointY)31 ln = self.canvas.create_line(x, startPointY, x, endPointY)32 tck = Tracker(self.root,lambda:recreate())33 tck.bind_config()34 def create_splitLine(self):35 self.createVerticalLine(self.widgetMargin,0,800) 36 def createHorizontalLine(self,y,startPointX,endPointX):37 ln = None38 def recreate():39 global ln40 self.canvas.delete(ln)41 self.canvas.create_line(startPointX, y, endPointX, y) 42 self.canvas.create_line(startPointX, y, endPointX, y)43 tck = Tracker(self.root,lambda:recreate())44 tck.bind_config()45 def return_canvas(self):46 return self.canvas 47 def return_root(self):48 return self.root 49 def useStyle(self,custom_theme="vista"):50 self.style = Style(self.root)51 self.style.theme_use(custom_theme) 52 def checkXandY(self,widget):53 x,y = get_x_pos(widget), get_y_pos(widget)54 width,height = get_width(widget), get_height(widget)55 56 window_width, window_height = get_width(self.root), get_height(self.root)57 58 59 60 def createLabel(self,master=None,text="",font="Consolas",fontsize=35,packORplace="pack",padx=None,pady=None,x=None,y=None):61 lbl = Label(master if master else self.root,text=text,font=(font,fontsize))62 if packORplace == "pack":63 lbl.pack(padx=padx,pady=pady)64 else:65 lbl.place(x=x,y=y) 66 def get_window_height(self):67 return self.root.winfo_height()68 def get_window_width(self):69 return self.root.winfo_width() 70 def focus_on(self,widget):71 tow = ""72 if get_x_pos(widget) < self.widgetMargin:73 pass74 else: 75 tow = str(type(widget)).replace("<class","").replace(">","").replace(" ","").replace("'","").replace("tkinter.ttk.","").lower().strip()76 if tow == "button":77 print("Focusing on a Button") 78 def bindRightClick(self,widget):79 m = tkinter.Menu(self.root, tearoff = 0)80 m.add_command(label ="Open Editor Tools",command=lambda:self.focus_on(widget))81 82 def do_popup(event):83 if get_x_pos(widget) > self.widgetMargin: 84 try:85 m.tk_popup(event.x_root, event.y_root)86 finally:87 m.grab_release() 8889 widget.bind("<Button-3>", do_popup) 90 91 def createNewItem(self,widget:str="button",text:str="widget",yposition:int=50,width:int=15,height:int=None,image=None):92 widget = widget.lower()93 current_win_height = None94 if self.get_window_height() == 1:95 current_win_height = monitor_height96 else:97 current_win_height = self.get_window_height()98 99 100 if widget == "button":101 if image!=None:102 img = tkinter.PhotoImage(file=image,name="image",master=self.root)103 img.configure(width=25,height=25)104 btn = Button(self.root,width=width,height=height,takefocus=False,text=text if text else None,image=img,compound="left")105 else:106 btn = Button(self.root,width=width,height=height,takefocus=False,text=text if text else None)107 btn.configure(command=lambda:self.focus_on(btn))108 dgm = DraggableWidgetMaker()109 btn.place(x=self.get_window_width() // 2 + 45, y = yposition)110 tck = Tracker(self.root,btn.place(x=self.get_window_width() // 2 + 45, y = yposition))111 tck.bind_config()112 dgm.create(btn,None,lambda:self.checkXandY(btn))113 self.bindRightClick(btn)114 return btn 115 elif widget == "input":116 inp = Entry(self.root,width=width+1,height=height,textvariable=text if text else None)117 dgm = DraggableWidgetMaker()118 inp.place(x=self.get_window_width() // 2 + 45, y = yposition)119 tck = Tracker(self.root,inp.place(x=self.get_window_width() // 2 + 45, y = yposition))120 tck.bind_config()121 dgm.create(inp,None,lambda:self.checkXandY(btn)) 122 return inp 123 124 125 def run(self):126 self.root.mainloop() ...

Full Screen

Full Screen

main_yt.pyw

Source:main_yt.pyw Github

copy

Full Screen

...27#Get window size - 1/2 of screen resolution28width = root.winfo_screenwidth()29height = root.winfo_screenheight()3031def get_window_width():32 window_width = int(width * 0.5 * get_scale_mult())33 return window_width34def get_window_height():35 window_height = int(height * 0.5 * get_scale_mult())36 return window_height37def get_window_size():38 window_size = str(get_window_width()) + "x" + str(get_window_height())39 return window_size4041#Set up window42def setup_window(): 43 root.resizable(0,0)44 root.geometry(get_window_size())45 root.configure(background="#2b2929")46 root.title("YouTube Video Downloader")4748#Create place to insert link WITH LABEL49link = StringVar()50def place_pastelink_text(): 51 paste_link_label = Label(52 root,53 text = 'Paste Link Below',54 font = 'arial ' + str(int(round(30 * get_scale_mult()))) + ' bold underline',55 background = '#2b2929',56 foreground = '#bd433c'57 )58 paste_link_x = int((get_window_width() - (360 * get_scale_mult())) / 2)59 paste_link_y = int(get_window_height() * 0.25)60 paste_link_label.place(x=paste_link_x, y=paste_link_y)6162#Insert link63def place_enterlink_text():64 link_enter = Entry(65 root, 66 width = int((70 * get_scale_mult())), 67 textvariable = link,68 background = "#ffffff"69 )70 link_enter_x = int((get_window_width() - (get_window_width() * 0.7)) / 2)71 link_enter_y = int(get_window_height() / 2)72 link_enter.place(x=link_enter_x, y=link_enter_y)7374#Fullscreen function75def Fullscreen():76 if root.state == False: #If not in fullscreen, change to fullscreen, change indicator to True, increase scale, destroy and replace buttons/labels.77 root.attributes("-fullscreen", True)78 root.state = True79 for widget in root.winfo_children():80 widget.destroy()81 init_func()82 83 else: #If already in fullscreen, change back to normal size, change indicator to False, decrease scale, destroy and replace buttons/labels.84 root.attributes("-fullscreen", False)85 root.state = False86 for widget in root.winfo_children():87 widget.destroy()88 init_func()8990#Main download function91def Download(): 92 try: #Valid Link93 url = YouTube(str(link.get()))94 video = url.streams.get_highest_resolution()95 video.download(output_path=path)96 downloaded_label = Label(97 root,98 text = 'DOWNLOADED', 99 font = 'arial ' + str(int(round(15 * get_scale_mult()))),100 background = '#2b2929',101 foreground = '#bd433c'102 )103 downloaded_label_x = int((get_window_width() - (get_window_width() * 0.2)) / 2)104 downloaded_label_y = int(get_window_height() * 0.9)105 downloaded_label.place(x=downloaded_label_x, y=downloaded_label_y)106 except: #Invalid Link107 fail_label = Label(108 root,109 text = '<<INVALID>>',110 font = 'arial ' + str(int(round(15 * get_scale_mult()))),111 background = '#2b2929',112 foreground = '#bd433c'113 )114 fail_label_x = int((get_window_width() - (get_window_width() * 0.2)) / 2)115 fail_label_y = int(get_window_height() * 0.9)116 fail_label.place(x=fail_label_x, y=fail_label_y)117118#Create Download Button 119def place_download_button():120 download_button = Button(121 root,122 height = 2,123 width = 20,124 text = 'DOWNLOAD',125 font = 'arial ' + str(int(round(15 * get_scale_mult()))) + ' bold' ,126 bg = '#bd433c', 127 padx = 2, 128 command = Download129 )130 dbutton_x = int((get_window_width() - (get_window_width() * 0.4)) / 2)131 dbutton_y = int(get_window_height() * 0.7)132 download_button.place(x=dbutton_x, y=dbutton_y)133134#Create fullscreen button135def place_fullscreen_button():136 fullscreen_button = Button(137 root,138 height = 1,139 width = 15,140 text = 'Toggle Fullscreen',141 font = 'arial 10 bold',142 bg = '#bd433c',143 padx = 2,144 command = Fullscreen145 )146 fbutton_x = 0147 fbutton_y = 0148 fullscreen_button.place(x=fbutton_x, y=fbutton_y)149150#Initial function to get values & place buttons151def init_func():152 get_scale_mult()153 get_window_width()154 get_window_height()155 get_window_size()156 setup_window()157 place_pastelink_text()158 place_enterlink_text()159 place_download_button()160 place_fullscreen_button()161162#Run program163if __name__ == "__main__":164 init_func() ...

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:

YouTube

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

Run robotframework-appiumlibrary 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?

Helpful

NotHelpful