def __init__(self, title, url, width, height, resizable, fullscreen, min_size, webview_ready): self.Text = title self.AutoScaleBaseSize = Size(5, 13) self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) # Application icon try: # Try loading an icon embedded in the exe file. This will crash when frozen with PyInstaller handler = windll.kernel32.GetModuleHandleW(None) icon_handler = windll.user32.LoadIconW(handler, 1) self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handler))) except: pass self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if fullscreen: self.toggle_fullscreen()
def __init__(self, API_key): self.API_key = API_key self.token = '' if API_key: self.target_url = self.token_url.format( API_key, self.name, self.expiry, self.scope) else: self.target_url = self.login_url self.Text = 'Authorization' self.ClientSize = Size(800, 800) self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = True self.web_browser.IsWebBrowserContextMenuEnabled = False self.web_browser.WebBrowserShortcutsEnabled = False self.web_browser.DocumentCompleted += self.on_document_completed self.web_browser.DocumentCompleted += self.check_token if not API_key: self.web_browser.Navigated += self.on_navigated self.web_browser.DocumentCompleted += self.check_API_key self.web_browser.Visible = True self.web_browser.Navigate(self.target_url) self.Controls.Add(self.web_browser)
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, background_color, debug, webview_ready): self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) self.BackColor = ColorTranslator.FromHtml(background_color) if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = True self.web_browser.IsWebBrowserContextMenuEnabled = False self.web_browser.WebBrowserShortcutsEnabled = False # HACK. Hiding the WebBrowser is needed in order to show a non-default background color. Tweaking the Visible property # results in showing a non-responsive control, until it is loaded fully. To avoid this, we need to disable this behaviour # for the default background color. if background_color != '#FFFFFF': self.web_browser.Visible = False self.first_load = True else: self.first_load = False self.cancel_back = False self.web_browser.PreviewKeyDown += self.on_preview_keydown self.web_browser.Navigating += self.on_navigating self.web_browser.DocumentCompleted += self.on_document_completed if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if confirm_quit: self.FormClosing += self.on_closing if fullscreen: self.toggle_fullscreen()
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, webview_ready): self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = True self.web_browser.IsWebBrowserContextMenuEnabled = False self.cancel_back = False self.web_browser.PreviewKeyDown += self.on_preview_keydown self.web_browser.Navigating += self.on_navigating if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if confirm_quit: self.FormClosing += self.on_closing if fullscreen: self.toggle_fullscreen()
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, webview_ready): self.Text = title self.AutoScaleBaseSize = Size(5, 13) self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if fullscreen: self.toggle_fullscreen()
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, webview_ready): self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) self.AutoScaleDimensions = SizeF(96.0, 96.0) self.AutoScaleMode = WinForms.AutoScaleMode.Dpi if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon try: # Try loading an icon embedded in the exe file. This will crash when frozen with PyInstaller handler = windll.kernel32.GetModuleHandleW(None) icon_handler = windll.user32.LoadIconW(handler, 1) self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handler))) except: pass self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = True self.web_browser.IsWebBrowserContextMenuEnabled = False if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if confirm_quit: self.FormClosing += self.on_closing if fullscreen: self.toggle_fullscreen()