Ejemplo n.º 1
0
        def __init__(self, window):
            self.uid = window.uid
            self.pywebview_window = window
            self.url = None
            self.Text = window.title
            self.Size = Size(window.initial_width, window.initial_height)
            self.MinimumSize = Size(window.min_size[0], window.min_size[1])
            self.BackColor = ColorTranslator.FromHtml(window.background_color)

            if window.initial_x is not None and window.initial_y is not None:
                self.move(window.initial_x, window.initial_y)
            else:
                self.StartPosition = WinForms.FormStartPosition.CenterScreen

            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not window.resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            if window.minimized:
                self.WindowState = WinForms.FormWindowState.Minimized

            # Application icon
            handle = windll.kernel32.GetModuleHandleW(None)
            icon_path = os.path.join(os.path.dirname(os.path.realpath(importlib.util.find_spec("bcml").origin)), "data", "bcml.ico")
            icon_handle = windll.shell32.ExtractIconW(handle, icon_path, 0)

            if icon_handle != 0:
                self.Icon = Icon.FromHandle(
                    IntPtr.op_Explicit(Int32(icon_handle))
                ).Clone()

            windll.user32.DestroyIcon(icon_handle)

            self.closed = window.closed
            self.closing = window.closing
            self.shown = window.shown
            self.loaded = window.loaded
            self.url = window.url
            self.text_select = window.text_select
            self.on_top = window.on_top

            self.is_fullscreen = False
            if window.fullscreen:
                self.toggle_fullscreen()

            if window.frameless:
                self.frameless = window.frameless
                self.FormBorderStyle = 0
            CEF.create_browser(window, self.Handle.ToInt32(), BrowserView.alert)

            self.Shown += self.on_shown
            self.FormClosed += self.on_close
            self.FormClosing += self.on_closing

            self.Resize += self.on_resize
Ejemplo n.º 2
0
        def __init__(self, window):
            self.uid = window.uid
            self.pywebview_window = window
            self.real_url = None
            self.Text = window.title
            self.ClientSize = Size(window.width, window.height)
            self.MinimumSize = Size(window.min_size[0], window.min_size[1])
            self.BackColor = ColorTranslator.FromHtml(window.background_color)

            if window.x is not None and window.y is not None:
                self.move(window.x, window.y)
            else:
                self.StartPosition = WinForms.FormStartPosition.CenterScreen

            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not window.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.shown = window.shown
            self.loaded = window.loaded
            self.url = window.url
            self.text_select = window.text_select

            self.is_fullscreen = False
            if window.fullscreen:
                self.toggle_fullscreen()

            if window.frameless:
                self.frameless = window.frameless
                self.FormBorderStyle = 0

            if is_cef:
                CEF.create_browser(window, self.Handle.ToInt32(), BrowserView.alert)
            elif is_edge:
                self.browser = BrowserView.EdgeHTML(self, window)
            else:
                self.browser = BrowserView.MSHTML(self, window)

            self.Shown += self.on_shown
            self.FormClosed += self.on_close

            if is_cef:
                self.Resize += self.on_resize

            if window.confirm_close:
                self.FormClosing += self.on_closing
Ejemplo n.º 3
0
        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()
Ejemplo n.º 4
0
        def __init__(self, uid, title, url, width, height, resizable, fullscreen, min_size,
                     confirm_quit, background_color, debug, js_api, text_select, frameless, webview_ready):
            self.uid = uid
            self.Text = title
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])
            self.BackColor = ColorTranslator.FromHtml(background_color)

            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
            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.load_event = Event()
            self.background_color = background_color
            self.url = url

            self.is_fullscreen = False
            if fullscreen:
                self.toggle_fullscreen()

            if frameless:
                self.frameless = frameless
                self.FormBorderStyle = 0

            if is_cef:
                CEF.create_browser(self.uid, self.Handle.ToInt32(), BrowserView.alert, url, js_api)
            else:
                self._create_mshtml_browser(url, js_api, debug)

            self.text_select = text_select
            self.Shown += self.on_shown
            self.FormClosed += self.on_close

            if is_cef:
                self.Resize += self.on_resize

            if confirm_quit:
                self.FormClosing += self.on_closing
Ejemplo n.º 5
0
        def __init__(self, uid, title, url, width, height, resizable,
                     fullscreen, min_size, confirm_quit, background_color,
                     debug, js_api, text_select, webview_ready):
            self.uid = uid
            self.Text = title
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])
            self.BackColor = ColorTranslator.FromHtml(background_color)

            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
            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.load_event = Event()

            self.web_browser = WebBrowserEx()
            self.web_browser.Dock = WinForms.DockStyle.Fill
            self.web_browser.ScriptErrorsSuppressed = not debug
            self.web_browser.IsWebBrowserContextMenuEnabled = debug
            self.web_browser.WebBrowserShortcutsEnabled = False
            self.web_browser.DpiAware = True

            self.web_browser.ScriptErrorsSuppressed = not debug
            self.web_browser.IsWebBrowserContextMenuEnabled = debug

            self.js_result_semaphore = Semaphore(0)
            self.js_bridge = BrowserView.JSBridge()
            self.js_bridge.parent_uid = uid
            self.web_browser.ObjectForScripting = self.js_bridge

            self.text_select = text_select

            if js_api:
                self.js_bridge.api = js_api

            # 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.NewWindow3 += self.on_new_window
            self.web_browser.DownloadComplete += self.on_download_complete
            self.web_browser.DocumentCompleted += self.on_document_completed

            if url:
                self.web_browser.Navigate(url)
            else:
                self.web_browser.DocumentText = default_html

            self.url = url

            self.Controls.Add(self.web_browser)
            self.is_fullscreen = False
            self.Shown += self.on_shown
            self.FormClosed += self.on_close

            if confirm_quit:
                self.FormClosing += self.on_closing

            if fullscreen:
                self.toggle_fullscreen()
Ejemplo n.º 6
0
        def __init__(self, window):
            self.uid = window.uid
            self.pywebview_window = window
            self.real_url = None
            self.Text = window.title
            self.Size = Size(window.initial_width, window.initial_height)
            self.MinimumSize = Size(window.min_size[0], window.min_size[1])

            if window.transparent:  # window transparency is not supported, as webviews are not transparent.
                self.BackColor = Color.LimeGreen
                self.TransparencyKey = Color.LimeGreen
                self.SetStyle(
                    WinForms.ControlStyles.SupportsTransparentBackColor, True)
            else:
                self.BackColor = ColorTranslator.FromHtml(
                    window.background_color)

            if window.initial_x is not None and window.initial_y is not None:
                self.move(window.initial_x, window.initial_y)
            else:
                self.StartPosition = WinForms.FormStartPosition.CenterScreen

            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not window.resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            if window.minimized:
                self.WindowState = WinForms.FormWindowState.Minimized

            # Application icon
            handle = 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.closed = window.closed
            self.closing = window.closing
            self.shown = window.shown
            self.loaded = window.loaded
            self.url = window.real_url
            self.text_select = window.text_select
            self.on_top = window.on_top

            self.is_fullscreen = False
            if window.fullscreen:
                self.toggle_fullscreen()

            if window.frameless:
                self.frameless = window.frameless
                self.FormBorderStyle = 0
            if is_cef:
                CEF.create_browser(window, self.Handle.ToInt32(),
                                   BrowserView.alert)
            elif is_chromium:
                self.browser = Chromium.EdgeChrome(self, window)
            elif is_edge:
                self.browser = Edge.EdgeHTML(self, window)
            else:
                self.browser = IE.MSHTML(self, window)

            self.Shown += self.on_shown
            self.FormClosed += self.on_close
            self.FormClosing += self.on_closing

            if is_cef:
                self.Resize += self.on_resize
Ejemplo n.º 7
0
                         ApplicationTabsWidget, SystemTrayWidget,
                         CpuMonitorWidget, RamMonitorWidget,
                         LaptopBatteryMonitorWidget, LanguageBarWidget,
                         CurrentlyPlayingWidget, SeparatorWidget)
from Windawesome import (LoggerPlugin, ShortcutsManager,
                         InputLanguageChangerPlugin)
from Windawesome.NativeMethods import MOD
from System import Tuple
from System.Windows.Forms import Keys

config.WindowBorderWidth = 1
config.WindowPaddedBorderWidth = 0

config.CheckForUpdates = False

solarizedDarkFG = ColorTranslator.FromHtml("#657b83")
solarizedDarkBG = ColorTranslator.FromHtml("#002b36")
solarizedDarkHighlightedFG = ColorTranslator.FromHtml("#eee8d5")
solarizedDarkHighlightedBG = ColorTranslator.FromHtml("#859900")

workspacesWidgetForegroundColors = [solarizedDarkFG for i in range(0, 10)]
workspacesWidgetBackgroundColors = [solarizedDarkBG for i in range(0, 10)]

config.Bars = Enumerable.ToArray[Bar]([

    # MONITOR 1
    Bar(
        windawesome.monitors[0],
        [
            WorkspacesWidget(
                normalForegroundColor=workspacesWidgetForegroundColors,
Ejemplo n.º 8
0
    def popup(self):
        self.form = Form()
        self.form.Text = "  User Account Control"
        self.form.MaximizeBox = False
        self.form.MinimizeBox = False
        self.form.Width = 430
        self.form.Height = 270

        self.form.Icon = None
        self.form.StartPosition = FormStartPosition.CenterScreen
        self.form.FormBorderStyle = FormBorderStyle.FixedDialog
        self.form.TopMost = True
        self.form.BackColor = ColorTranslator.FromHtml("#E6E6E6")

        self.tbox = Label()
        self.tbox.Text = "  Do you want to allow this app to make\n  changes to your device?"
        self.tbox.Location = Point(0, 0)
        self.tbox.Width = self.form.Width
        self.tbox.Height = 60
        self.tbox.Font = Font("Segoe UI", 13)
        self.tbox.BackColor = ColorTranslator.FromHtml("#2D89EF")

        self.pb = PictureBox()
        self.pb.Parent = self.form
        self.pb.Size = Size(50, 40)
        self.pb.Location = Point(13, 80)
        self.pb.Image = Icon.ExtractAssociatedIcon(self.path).ToBitmap()

        self.namebox = Label()
        self.namebox.Text = " {} for Windows".format(
            str(self.name).replace('.exe', '').capitalize())
        self.namebox.Location = Point(55, 82)
        self.namebox.Width = self.form.Width - 60
        self.namebox.Height = 30
        self.namebox.Font = Font("Segoe UI", 13)

        self.please = Label()
        self.please.Text = " Please, confirm your Password to continue:"
        self.please.Location = Point(7, 125)
        self.please.Width = self.form.Width - 60
        self.please.Height = 30
        self.please.Font = Font("Segoe UI", 12)

        self.inpBox = TextBox()
        self.inpBox.AcceptsReturn = True
        self.inpBox.Location = Point(13, 155)
        self.inpBox.Font = Font("Segoe UI", 10)
        self.inpBox.AutoSize = False
        self.inpBox.Size = Size(380, 25)
        self.inpBox.UseSystemPasswordChar = True
        self.inpBox.BorderStyle = BorderStyle.FixedSingle

        self.valButton = Button()
        self.valButton.BackColor = ColorTranslator.FromHtml("#CCCCCC")
        self.valButton.Text = "Confirm"
        self.valButton.Size = Size(190, 27)
        self.valButton.Location = Point(13, 190)
        self.valButton.FlatStyle = FlatStyle.Flat
        self.valButton.Font = Font("Segoe UI", 10)
        self.valButton.Click += EventHandler(self.SubmitHandler)

        self.canButton = Button()
        self.canButton.BackColor = ColorTranslator.FromHtml("#CCCCCC")
        self.canButton.Text = "Cancel"
        self.canButton.Size = Size(190, 27)
        self.canButton.FlatStyle = FlatStyle.Flat
        self.canButton.Location = Point(204, 190)
        self.canButton.Font = Font("Segoe UI", 10)
        self.canButton.Click += EventHandler(self.CancelButtonHandler)

        self.form.AcceptButton = self.valButton
        self.form.CancelButton = self.canButton
        self.form.Controls.Add(self.please)
        self.form.Controls.Add(self.pb)
        self.form.Controls.Add(self.valButton)
        self.form.Controls.Add(self.canButton)
        self.form.Controls.Add(self.inpBox)
        self.form.Controls.Add(self.tbox)
        self.form.Controls.Add(self.namebox)

        self.form.ActiveControl = self.tbox
        self.form.FormClosing += FormClosingEventHandler(self.CancelHandler)
        self.form.ShowDialog()