Пример #1
0
class WebBrowserSample(Form):
    """WebBrowser control class"""
    def __init__(self):
        """WebBrowserSample class init function."""

        # setup title
        self.Text = "WebBrowser control"
        self.Width = 800
        self.Height = 600
        url = 'http://mono-project.com/Accessibility'

        # setup webbrowser
        self.webbrowser = WebBrowser()
        self.webbrowser.Navigate(url)
        self.webbrowser.Dock = DockStyle.Fill
        self.webbrowser.Navigated += self.navigated

        # setup Location bar
        self.location = TextBox()
        self.location.Text = url
        self.location.Dock = DockStyle.Top
        self.location.KeyPress += self.key_press

        # add controls
        self.Controls.Add(self.webbrowser)
        self.Controls.Add(self.location)

    def key_press(self, sender, event):
        if event.KeyChar == u'\r':
            self.webbrowser.Navigate(self.location.Text.strip())

    def navigated(self, sender, event):
        self.location.Text = event.Url.ToString()
def LocateYTID():
    """Function to find YouTube Channel ID!"""
    f = Form()
    f.Text = "YouTube Advanced Account Settings"
    f.Width = 630
    f.Height = 630
    wb = WebBrowser()
    wb.ScriptErrorsSuppressed = True
    wb.Navigate("https://www.youtube.com/account_advanced")
    wb.Dock = DockStyle.Fill
    f.Controls.Add(wb)
    f.ShowDialog()