How to use on_dialog method in Playwright Python

Best Python code snippet using playwright-python

casino-setup-gui.py

Source:casino-setup-gui.py Github

copy

Full Screen

1#!/usr/bin/python22# CASINO Setup GUI written by Synge Todo3import sys4import os5import shutil6import subprocess7import wx8import config9class Frame(wx.Frame):10 def __init__(self, prefix, scriptdir):11 self.prefix = prefix12 self.scriptdir = scriptdir13 self.process_download = None14 self.process_compile = None15 self.process_kill = False16 self.on_dialog = False17 wx.Frame.__init__(self, None, -1, "CASINO Setup", size = (420,500))18 self.panel = wx.Panel(self, -1)19 layout = wx.BoxSizer(wx.VERTICAL)20 self.radio_download_pw = wx.RadioButton(self.panel, -1, "Download source with username and password")21 self.radio_download_pw.Bind(wx.EVT_RADIOBUTTON, self.OnChooseRadioDownloadPw)22 self.radio_download_pw.SetValue(True)23 layout.Add(self.radio_download_pw, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)24 grid_1 = wx.FlexGridSizer(2, 3)25 self.text_username = wx.TextCtrl(self.panel, -1, size = (285, -1))26 self.text_username.Bind(wx.EVT_TEXT, self.OnTextUsername)27 self.text_password = wx.TextCtrl(self.panel, -1, style = wx.TE_PASSWORD)28 self.text_password.SetMaxLength(8)29 self.text_password.Bind(wx.EVT_TEXT, self.OnTextPassword)30 grid_1.Add(wx.StaticText(self.panel, -1, ' '), 0)31 grid_1.Add(wx.StaticText(self.panel, -1, "Username:"), 0, wx.RIGHT, 4)32 grid_1.Add(self.text_username, 1, wx.EXPAND, 4)33 grid_1.Add(wx.StaticText(self.panel, -1, ' '), 0)34 grid_1.Add(wx.StaticText(self.panel, -1, "Password:"), 0, wx.RIGHT | wx.TOP, 4)35 grid_1.Add(self.text_password, 1, wx.EXPAND | wx.TOP, 4)36 layout.Add(grid_1, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)37 self.radio_download_url = wx.RadioButton(self.panel, -1, "Download source from temporary URL")38 self.radio_download_url.Bind(wx.EVT_RADIOBUTTON, self.OnChooseRadioDownloadUrl)39 layout.Add(self.radio_download_url, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)40 grid_2 = wx.FlexGridSizer(2, 3)41 self.text_url = wx.TextCtrl(self.panel, -1, size = (285, -1))42 self.text_url.Bind(wx.EVT_TEXT, self.OnTextUrl)43 grid_2.Add(wx.StaticText(self.panel, -1, ' '), 0)44 grid_2.Add(wx.StaticText(self.panel, -1, "URL:"), 0, wx.RIGHT, 4)45 grid_2.Add(self.text_url, 1, wx.EXPAND, 4)46 layout.Add(grid_2, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)47 self.radio_local = wx.RadioButton(self.panel, -1, "Use a source tarball on local storage")48 self.radio_local.Bind(wx.EVT_RADIOBUTTON, self.OnChooseRadioLocal)49 layout.Add(self.radio_local, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)50 grid_3 = wx.FlexGridSizer(2, 3)51 self.text_file = wx.TextCtrl(self.panel, -1, size = (325, -1), style = wx.TE_READONLY)52 self.button_choose = wx.Button(self.panel, -1, "Choose")53 self.button_choose.Bind(wx.EVT_BUTTON, self.OnChoose)54 grid_3.Add(wx.StaticText(self.panel, -1, ' '), 0)55 grid_3.Add(wx.StaticText(self.panel, -1, "File:"), 0, wx.RIGHT | wx.TOP, 4)56 grid_3.Add(self.text_file, 1, wx.EXPAND | wx.TOP, 4)57 grid_3.Add(wx.StaticText(self.panel, -1, ''), 0)58 grid_3.Add(wx.StaticText(self.panel, -1, ''), 0)59 grid_3.Add(self.button_choose, 0, wx.TOP, 4)60 layout.Add(grid_3, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)61 box_1 = wx.BoxSizer(wx.HORIZONTAL)62 self.button_help = wx.Button(self.panel, -1, "Help", size=(70,30))63 self.button_help.Bind(wx.EVT_BUTTON, self.OnHelp)64 self.button_cancel = wx.Button(self.panel, -1, "Cancel", size=(70,30))65 self.button_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)66 self.button_install = wx.Button(self.panel, -1, "Install", size=(70,30))67 self.button_install.Bind(wx.EVT_BUTTON, self.OnInstall)68 box_1.Add(self.button_help, 0, wx.LEFT | wx.BOTTOM, 5)69 box_1.Add(self.button_cancel, 0, wx.LEFT | wx.BOTTOM, 5)70 box_1.Add(self.button_install, 0, wx.LEFT | wx.BOTTOM, 5)71 layout.Add(box_1, 0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP, 10)72 self.text_log = wx.TextCtrl(self.panel, -1, style=wx.TE_MULTILINE | wx.TE_READONLY, size=(50,10))73 layout.Add(self.text_log, 1, wx.LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM | wx.EXPAND, 10)74 75 self.panel.SetSizer(layout)76 77 self.Bind(wx.EVT_CLOSE, self.OnClose)78 self.Bind (wx.EVT_IDLE, self.OnIdle)79 self.UpdateState()80 def OnCancel(self, event):81 if (self.process_download):82 self.on_dialog = True83 dialog = wx.MessageDialog(None, 'Downloading is now proceeding. Stop download?', 'CASINO Setup', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)84 if dialog.ShowModal() == wx.ID_YES:85 self.process_kill = True86 dialog.Destroy()87 self.on_dialog = False88 elif (self.process_compile):89 self.on_dialog = True90 dialog = wx.MessageDialog(None, 'Compilation is now proceeding. Stop compilation?', 'CASINO Setup', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)91 if dialog.ShowModal() == wx.ID_YES:92 self.process_kill = True93 dialog.Destroy()94 self.on_dialog = False95 else:96 self.Destroy()97 self.UpdateState()98 def OnChoose(self, event):99 self.OpenFileDialog()100 self.UpdateState()101 def OnChooseRadioDownloadPw(self, event):102 self.UpdateState()103 def OnChooseRadioDownloadUrl(self, event):104 self.UpdateState()105 def OnChooseRadioLocal(self, event):106 if (not self.text_file.GetValue()):107 self.OpenFileDialog()108 self.UpdateState()109 def OnClose(self, event):110 if (self.process_download or self.process_compile):111 self.OnCancel(event)112 if (not (self.process_download or self.process_compile)):113 self.Destroy()114 self.UpdateState()115 def OnHelp(self, event):116 wx.BeginBusyCursor() 117 import webbrowser118 webbrowser.open('file://' + scriptdir + '/help.html') 119 wx.EndBusyCursor() 120 121 def OnIdle(self, event):122 if (self.on_dialog): return123 if (self.process_download):124 ret = self.process_download.poll()125 if (ret == None):126 if (self.process_kill):127 self.process_kill = False128 self.process_download.kill()129 self.process_download = None130 self.text_log.AppendText('Killed.')131 self.UpdateState()132 else:133 line = self.process_download.stdout.readline()134 self.text_log.AppendText(line)135 else:136 self.process_download = None137 if (ret != 0):138 dialog = wx.MessageDialog(None, 'Invalid username and/or password', 'Error', wx.OK | wx.ICON_ERROR)139 dialog.ShowModal()140 dialog.Destroy()141 else:142 self.StartCompile(os.path.join(self.prefix, 'source', config.file))143 self.UpdateState()144 elif (self.process_compile):145 ret = self.process_compile.poll()146 if (ret == None):147 if (self.process_kill):148 self.process_kill = False149 self.process_compile.kill()150 self.process_compile = None151 self.text_log.AppendText('Killed.')152 self.UpdateState()153 else:154 line = self.process_compile.stdout.readline()155 self.text_log.AppendText(line)156 else:157 self.process_compile = None158 if (ret != 0):159 dialog = wx.MessageDialog(None, 'Error occured during compilation', 'Error', wx.OK | wx.ICON_ERROR)160 dialog.ShowModal()161 dialog.Destroy()162 else:163 dialog = wx.MessageBox('Installation completed', 'CASINO Setup')164 self.Destroy()165 self.UpdateState()166 def OnInstall(self, event):167 if (self.radio_download_pw.GetValue()):168 target = os.path.join(self.prefix, 'source')169 tarball = os.path.join(target, config.file)170 username = self.text_username.GetValue()171 password = self.text_password.GetValue()172 if (os.path.exists(tarball)):173 dialog = wx.MessageDialog(None, tarball + ' already exists. Remove it and continue download?', 'CASINO Setup', wx.OK | wx.CANCEL | wx.ICON_QUESTION)174 if dialog.ShowModal() == wx.ID_OK:175 dialog.Destroy()176 os.remove(tarball)177 else:178 dialog.Destroy()179 self.text_file.SetValue(tarball)180 self.radio_local.SetValue(True)181 self.UpdateState()182 return183 self.StartDownloadPw(username, password, target)184 elif (self.radio_download_url.GetValue()):185 target = os.path.join(self.prefix, 'source')186 tarball = os.path.join(target, config.file)187 url = self.text_url.GetValue()188 if (os.path.exists(tarball)):189 dialog = wx.MessageDialog(None, tarball + ' already exists. Remove it and continue download?', 'CASINO Setup', wx.OK | wx.CANCEL | wx.ICON_QUESTION)190 if dialog.ShowModal() == wx.ID_OK:191 dialog.Destroy()192 os.remove(tarball)193 else:194 dialog.Destroy()195 self.text_file.SetValue(tarball)196 self.radio_local.SetValue(True)197 self.UpdateState()198 return199 self.StartDownloadUrl(url, target)200 else:201 file = self.text_file.GetValue()202 if (file):203 self.StartCompile(file)204 else:205 dialog = wx.MessageDialog(None, 'Please specify source archive', 'Error',206 wx.OK | wx.ICON_ERROR)207 dialog.ShowModal()208 dialog.Destroy()209 self.UpdateState()210 def OnTextUsername(self, event):211 self.UpdateState()212 def OnTextPassword(self, event):213 self.UpdateState()214 def OnTextUrl(self, event):215 self.UpdateState()216 def OpenFileDialog(self):217 wildCard = "tar.gz file (*.tar.gz)|*.tar.gz|All files (*.*)|*.*"218 if (self.text_file.GetValue()):219 path = os.path.dirname(self.text_file.GetValue())220 else:221 path = os.environ['HOME']222 dialog = wx.FileDialog(self, "Choose a source archive", path, '', wildCard, wx.OPEN)223 if dialog.ShowModal() == wx.ID_OK:224 self.text_file.SetValue(dialog.GetPath())225 self.radio_local.SetValue(True)226 dialog.Destroy()227 def StartCompile(self, file):228 casinodir = os.path.join(self.prefix, 'share', 'casino')229 if (os.path.exists(casinodir)):230 dialog = wx.MessageDialog(None, casinodir + ' already exists. Clean up and install CASINO anyway?', 'CASINO Setup', wx.OK | wx.CANCEL | wx.ICON_QUESTION)231 if dialog.ShowModal() == wx.ID_OK:232 shutil.rmtree(casinodir)233 dialog.Destroy()234 else:235 dialog.Destroy()236 return 237 cmd = ['/bin/sh', os.path.join(self.scriptdir, 'compile.sh'), file, self.prefix]238 self.process_compile = subprocess.Popen(cmd, stdout=subprocess.PIPE,239 stderr=subprocess.STDOUT,240 stdin=subprocess.PIPE)241 self.text_log.AppendText('Start compilation of CASINO\n')242 def StartDownloadPw(self, username, password, target):243 cmd = ['python2', os.path.join(self.scriptdir, 'download_pw.py'), username, password, target]244 self.process_download = subprocess.Popen(cmd, stdout=subprocess.PIPE,245 stderr=subprocess.STDOUT,246 stdin=subprocess.PIPE)247 self.text_log.AppendText('Start download of CASINO\n')248 249 def StartDownloadUrl(self, url, target):250 cmd = ['python2', os.path.join(self.scriptdir, 'download_url.py'), url, target]251 self.process_download = subprocess.Popen(cmd, stdout=subprocess.PIPE,252 stderr=subprocess.STDOUT,253 stdin=subprocess.PIPE)254 self.text_log.AppendText('Start download of CASINO\n')255 256 def UpdateState(self):257 if (self.process_download or self.process_compile):258 self.radio_download_pw.Disable()259 self.radio_download_url.Disable()260 self.radio_local.Disable()261 self.text_username.Disable()262 self.text_password.Disable()263 self.text_url.Disable()264 self.text_file.Disable()265 self.button_choose.Disable()266 self.button_help.Disable()267 self.button_install.Disable()268 else:269 self.radio_download_pw.Enable()270 self.radio_download_url.Enable()271 self.radio_local.Enable()272 self.button_choose.Enable()273 self.button_help.Enable()274 if (self.radio_download_pw.GetValue()):275 self.text_username.Enable()276 self.text_password.Enable()277 self.text_url.Disable()278 self.text_file.Disable()279 if (self.text_username.GetValue() and self.text_password.GetValue()):280 self.button_install.Enable()281 else:282 self.button_install.Disable()283 elif (self.radio_download_url.GetValue()):284 self.text_username.Disable()285 self.text_password.Disable()286 self.text_url.Enable()287 self.text_file.Disable()288 if (self.text_url.GetValue()):289 self.button_install.Enable()290 else:291 self.button_install.Disable()292 else:293 self.text_username.Disable()294 self.text_password.Disable()295 self.text_url.Disable()296 self.text_file.Enable()297 if (self.text_file.GetValue()):298 self.button_install.Enable()299 else:300 self.button_install.Disable()301if __name__ == '__main__':302 if (len(sys.argv) < 2):303 print "Usage:", sys.argv[0], "prefix"304 sys.exit(127)305 scriptdir = os.path.abspath(os.path.dirname(sys.argv[0]))306 prefix = sys.argv[1]307 app = wx.App()308 frame = Frame(prefix, scriptdir)309 frame.Show()310 app.MainLoop()...

Full Screen

Full Screen

gamess-setup-gui.py

Source:gamess-setup-gui.py Github

copy

Full Screen

1#!/usr/bin/python22# GAMESS Setup GUI written by Synge Todo3import sys4import os5import shutil6import subprocess7import wx8import config9class Frame(wx.Frame):10 def __init__(self, prefix, scriptdir):11 self.prefix = prefix12 self.scriptdir = scriptdir13 self.process_download = None14 self.process_compile = None15 self.process_kill = False16 self.on_dialog = False17 wx.Frame.__init__(self, None, -1, "GAMESS Setup", size = (420,500))18 self.panel = wx.Panel(self, -1)19 layout = wx.BoxSizer(wx.VERTICAL)20 self.radio_download = wx.RadioButton(self.panel, -1, "Download source tarball from official website")21 self.radio_download.Bind(wx.EVT_RADIOBUTTON, self.OnChooseRadioDownload)22 self.radio_download.SetValue(True)23 layout.Add(self.radio_download, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)24 grid_1 = wx.FlexGridSizer(2, 3)25 self.text_username = wx.TextCtrl(self.panel, -1, value = 'source', size = (285, -1))26 self.text_username.Disable()27 self.text_password = wx.TextCtrl(self.panel, -1) # style = wx.TE_PASSWORD28 self.text_password.SetMaxLength(8)29 self.text_password.Bind(wx.EVT_TEXT, self.OnTextPassword)30 grid_1.Add(wx.StaticText(self.panel, -1, ' '), 0)31 grid_1.Add(wx.StaticText(self.panel, -1, "Username:"), 0, wx.RIGHT, 4)32 grid_1.Add(self.text_username, 1, wx.EXPAND, 4)33 grid_1.Add(wx.StaticText(self.panel, -1, ' '), 0)34 grid_1.Add(wx.StaticText(self.panel, -1, "Password:"), 0, wx.RIGHT | wx.TOP, 4)35 grid_1.Add(self.text_password, 1, wx.EXPAND | wx.TOP, 4)36 layout.Add(grid_1, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)37 self.radio_local = wx.RadioButton(self.panel, -1, "Use a source tarball on local storage")38 self.radio_local.Bind(wx.EVT_RADIOBUTTON, self.OnChooseRadioLocal)39 layout.Add(self.radio_local, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)40 grid_2 = wx.FlexGridSizer(2, 3)41 self.text_file = wx.TextCtrl(self.panel, -1, size = (325, -1), style = wx.TE_READONLY)42 self.button_choose = wx.Button(self.panel, -1, "Choose")43 self.button_choose.Bind(wx.EVT_BUTTON, self.OnChoose)44 grid_2.Add(wx.StaticText(self.panel, -1, ' '), 0)45 grid_2.Add(wx.StaticText(self.panel, -1, "File:"), 0, wx.RIGHT | wx.TOP, 4)46 grid_2.Add(self.text_file, 1, wx.EXPAND | wx.TOP, 4)47 grid_2.Add(wx.StaticText(self.panel, -1, ''), 0)48 grid_2.Add(wx.StaticText(self.panel, -1, ''), 0)49 grid_2.Add(self.button_choose, 0, wx.TOP, 4)50 layout.Add(grid_2, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)51 box_1 = wx.BoxSizer(wx.HORIZONTAL)52 self.button_help = wx.Button(self.panel, -1, "Help", size=(70,30))53 self.button_help.Bind(wx.EVT_BUTTON, self.OnHelp)54 self.button_cancel = wx.Button(self.panel, -1, "Cancel", size=(70,30))55 self.button_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)56 self.button_install = wx.Button(self.panel, -1, "Install", size=(70,30))57 self.button_install.Bind(wx.EVT_BUTTON, self.OnInstall)58 box_1.Add(self.button_help, 0, wx.LEFT | wx.BOTTOM, 5)59 box_1.Add(self.button_cancel, 0, wx.LEFT | wx.BOTTOM, 5)60 box_1.Add(self.button_install, 0, wx.LEFT | wx.BOTTOM, 5)61 layout.Add(box_1, 0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP, 10)62 self.text_log = wx.TextCtrl(self.panel, -1, style=wx.TE_MULTILINE | wx.TE_READONLY, size=(50,10))63 layout.Add(self.text_log, 1, wx.LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM | wx.EXPAND, 10)64 65 self.panel.SetSizer(layout)66 67 self.Bind(wx.EVT_CLOSE, self.OnClose)68 self.Bind (wx.EVT_IDLE, self.OnIdle)69 self.UpdateState()70 def OnCancel(self, event):71 if (self.process_download):72 self.on_dialog = True73 dialog = wx.MessageDialog(None, 'Downloading is now proceeding. Stop download?', 'GAMESS Setup', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)74 if dialog.ShowModal() == wx.ID_YES:75 self.process_kill = True76 dialog.Destroy()77 self.on_dialog = False78 elif (self.process_compile):79 self.on_dialog = True80 dialog = wx.MessageDialog(None, 'Compilation is now proceeding. Stop compilation?', 'GAMESS Setup', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)81 if dialog.ShowModal() == wx.ID_YES:82 self.process_kill = True83 dialog.Destroy()84 self.on_dialog = False85 else:86 self.Destroy()87 self.UpdateState()88 def OnChoose(self, event):89 self.OpenFileDialog()90 self.UpdateState()91 def OnChooseRadioDownload(self, event):92 self.UpdateState()93 def OnChooseRadioLocal(self, event):94 if (not self.text_file.GetValue()):95 self.OpenFileDialog()96 self.UpdateState()97 def OnClose(self, event):98 if (self.process_download or self.process_compile):99 self.OnCancel(event)100 if (not (self.process_download or self.process_compile)):101 self.Destroy()102 self.UpdateState()103 def OnHelp(self, event):104 wx.BeginBusyCursor() 105 import webbrowser 106 webbrowser.open('file://' + scriptdir + '/help.html') 107 wx.EndBusyCursor() 108 109 def OnIdle(self, event):110 if (self.on_dialog): return111 if (self.process_download):112 ret = self.process_download.poll()113 if (ret == None):114 if (self.process_kill):115 self.process_kill = False116 self.process_download.kill()117 self.process_download = None118 self.text_log.AppendText('Killed.')119 self.UpdateState()120 else:121 line = self.process_download.stdout.readline()122 self.text_log.AppendText(line)123 else:124 self.process_download = None125 if (ret != 0):126 dialog = wx.MessageDialog(None, 'Invalid username and/or password', 'Error', wx.OK | wx.ICON_ERROR)127 dialog.ShowModal()128 dialog.Destroy()129 else:130 self.StartCompile(os.path.join(self.prefix, 'source', "gamess-current.tar.gz"))131 self.UpdateState()132 elif (self.process_compile):133 ret = self.process_compile.poll()134 if (ret == None):135 if (self.process_kill):136 self.process_kill = False137 self.process_compile.kill()138 self.process_compile = None139 self.text_log.AppendText('Killed.')140 self.UpdateState()141 else:142 line = self.process_compile.stdout.readline()143 self.text_log.AppendText(line)144 else:145 self.process_compile = None146 if (ret != 0):147 dialog = wx.MessageDialog(None, 'Error occured during compilation', 'Error', wx.OK | wx.ICON_ERROR)148 dialog.ShowModal()149 dialog.Destroy()150 else:151 dialog = wx.MessageBox('Installation completed', 'GAMESS Setup')152 self.Destroy()153 self.UpdateState()154 def OnInstall(self, event):155 if (self.radio_download.GetValue()):156 target = os.path.join(self.prefix, 'source')157 tarball = os.path.join(target, "gamess-current.tar.gz")158 username = self.text_username.GetValue()159 password = self.text_password.GetValue()160 if (os.path.exists(tarball)):161 dialog = wx.MessageDialog(None, tarball + ' already exists. Remove it and continue download?', 'GAMESS Setup', wx.OK | wx.CANCEL | wx.ICON_QUESTION)162 if dialog.ShowModal() == wx.ID_OK:163 dialog.Destroy()164 os.remove(tarball)165 else:166 dialog.Destroy()167 self.text_file.SetValue(tarball)168 self.radio_local.SetValue(True)169 self.UpdateState()170 return171 if (password == ''):172 dialog = wx.MessageDialog(None, 'Please input password', 'Error', wx.OK | wx.ICON_ERROR)173 dialog.ShowModal()174 dialog.Destroy()175 else:176 self.StartDownload(username, password, target)177 else:178 file = self.text_file.GetValue()179 if (file):180 self.StartCompile(file)181 else:182 dialog = wx.MessageDialog(None, 'Please specify source archive', 'Error',183 wx.OK | wx.ICON_ERROR)184 dialog.ShowModal()185 dialog.Destroy()186 self.UpdateState()187 def OnTextPassword(self, event):188 self.UpdateState()189 def OpenFileDialog(self):190 wildCard = "tar.gz file (*.tar.gz)|*.tar.gz|All files (*.*)|*.*"191 if (self.text_file.GetValue()):192 path = os.path.dirname(self.text_file.GetValue())193 else:194 path = os.environ['HOME']195 dialog = wx.FileDialog(self, "Choose a source archive", path, '', wildCard, wx.OPEN)196 if dialog.ShowModal() == wx.ID_OK:197 self.text_file.SetValue(dialog.GetPath())198 self.radio_local.SetValue(True)199 dialog.Destroy()200 def StartCompile(self, file):201 gamessdir = os.path.join(self.prefix, 'share', 'gamess')202 if (os.path.exists(gamessdir)):203 dialog = wx.MessageDialog(None, gamessdir + ' already exists. Clean up and install GAMESS anyway?', 'GAMESS Setup', wx.OK | wx.CANCEL | wx.ICON_QUESTION)204 if dialog.ShowModal() == wx.ID_OK:205 shutil.rmtree(gamessdir)206 dialog.Destroy()207 else:208 dialog.Destroy()209 return 210 cmd = ['/bin/sh', os.path.join(self.scriptdir, 'compile.sh'), file, self.prefix]211 self.process_compile = subprocess.Popen(cmd, stdout=subprocess.PIPE,212 stderr=subprocess.STDOUT,213 stdin=subprocess.PIPE)214 self.text_log.AppendText('Start compilation of GAMESS\n')215 def StartDownload(self, username, password, target):216 cmd = ['python2', os.path.join(self.scriptdir, 'download.py'), username, password, target]217 self.process_download = subprocess.Popen(cmd, stdout=subprocess.PIPE,218 stderr=subprocess.STDOUT,219 stdin=subprocess.PIPE)220 self.text_log.AppendText('Start download of GAMESS\n')221 222 def UpdateState(self):223 if (self.process_download or self.process_compile):224 self.radio_download.Disable()225 self.radio_local.Disable()226 self.text_password.Disable()227 self.text_file.Disable()228 self.button_choose.Disable()229 self.button_help.Disable()230 self.button_install.Disable()231 else:232 self.radio_download.Enable()233 self.radio_local.Enable()234 self.button_choose.Enable()235 self.button_help.Enable()236 if (self.radio_download.GetValue()):237 self.text_password.Enable()238 self.text_file.Disable()239 if (self.text_username.GetValue() and len(self.text_password.GetValue()) == 8):240 self.button_install.Enable()241 else:242 self.button_install.Disable()243 else:244 self.text_password.Disable()245 self.text_file.Enable()246 if (self.text_file.GetValue()):247 self.button_install.Enable()248 else:249 self.button_install.Disable()250if __name__ == '__main__':251 if (len(sys.argv) < 2):252 print("Usage:", sys.argv[0], "prefix")253 sys.exit(127)254 scriptdir = os.path.dirname(sys.argv[0])255 prefix = sys.argv[1]256 app = wx.App()257 frame = Frame(prefix, scriptdir)258 frame.Show()259 app.MainLoop()...

Full Screen

Full Screen

selectpath.py

Source:selectpath.py Github

copy

Full Screen

...76 generate_pieces = False77 fail=False78 if (self.txtpathphotos.get_text_length() >0 and self.txtpathwork.get_text_length() > 0 and79 self.txtpathwork.get_text()== self.txtpathphotos.get_text()):80 mosaic.on_dialog(self.wdselectpaths,81 _("Please select differents paths"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)82 fail=True83 else:84 if self.txtpathphotos.get_text_length() <= 0:85 generate_pieces = False86 if self.txtpathwork.get_text_length() <= 0:87 mosaic.on_dialog(self.wdselectpaths,88 _("Please select a work path"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)89 fail=True90 else: 91 if self.check_path_index(self.txtpathwork.get_text()):92 generate_pieces = False93 94 else:95 mosaic.on_dialog(self.wdselectpaths,96 _("Please select a work path that contains pieces of mosaic"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)97 fail=True98 else:99 generate_pieces = True100 if self.txtpathwork.get_text_length() <= 0:101 mosaic.on_dialog(self.wdselectpaths,102 _("Please select a work path"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)103 fail=True104 else: 105 if self.check_path_index(self.txtpathwork.get_text()):106 if self.question_generate():107 generate_pieces = True108 else:109 generate_pieces = False110 else:111 generate_pieces = True112 113 self.mosaic.txtphotos = self.txtpathphotos.get_text()114 self.mosaic.txtwork = self.txtpathwork.get_text()115 self.mosaic.recursive = self.chbtrecursive.get_active()...

Full Screen

Full Screen

mosaic.py

Source:mosaic.py Github

copy

Full Screen

...102 if splitpath[len(splitpath)-1] == "mxt":103 boolmxt=True104 105 if not boolmxt:106 on_dialog(self.wdmosaic, 107 _("Please select a directory that contains pieces of an earlier generation")108 , gtk.MESSAGE_ERROR, gtk.BUTTONS_CANCEL)109 110 else:111 cmosaic=createmosaic.CreateMosaic(self) 112 def on_btabout_clicked(self, widget, data=None):113 vbabout=about.About()114 115 def loadconfig(self):116 if os.path.exists(self.fileOptions):117 cfg = ConfigParser.SafeConfigParser()118 cfg.readfp(file(self.fileOptions))119 try:120 self.txtphotos = cfg.get("SelectPath", "txtphotos")121 self.txtwork = cfg.get("SelectPath", "txtwork")122 if cfg.get("SelectPath", "recursive")=="True":123 self.recursive = True124 else:125 self.recursive = False126 self.width = int(cfg.get("SelectPath", "width"))127 self.height = int(cfg.get("SelectPath", "height"))128 self.scale = int(cfg.get("CreateMosaic", "scale"))129 self.distance = int(cfg.get("CreateMosaic", "distance"))130 self.cheat = int(cfg.get("CreateMosaic", "cheat"))131 self.orig=cfg.get("CreateMosaic", "orig")132 return False133 except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):134 on_dialog(self.wdmosaic, 135 _("Config file is wrong, default config file will be used"),136 gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE)137 138 return True139 else:140 self.loaddefault()141 return False142 143def on_dialog(parent, text, type, buttons):144 md = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT,145 type, buttons, text)146 if type==gtk.MESSAGE_ERROR:147 md.set_title("Getapixel - Error")148 md.set_icon_from_file("/usr/share/icons/gnome/16x16/actions/gtk-stop.png")149 elif type==gtk.MESSAGE_INFO:150 md.set_title("Getapixel - Info")151 md.set_icon_from_file(PATH_ICON+"getapixel_46x46.png")152 md.run()153 md.destroy() 154if __name__ == "__main__":155 mosaic=Mosaic()156 mosaic.main()157

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python 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