예제 #1
0
파일: app.py 프로젝트: ztangaj/toga
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)
        self.top_label = toga.Label('www is loading |',
                                    style=Pack(flex=1, padding_left=10))
        self.math_button = toga.Button("2 + 2? ", on_press=self.do_math_in_js)
        self.mutate_page_button = toga.Button("mutate page!",
                                              on_press=self.mutate_page)
        self.set_content_button = toga.Button("set content!",
                                              on_press=self.set_content)
        self.set_agent_button = toga.Button("set agent!",
                                            on_press=self.set_agent)
        self.top_box = toga.Box(children=[
            self.math_button,
            self.mutate_page_button,
            self.set_content_button,
            self.set_agent_button,
            self.top_label,
        ],
                                style=Pack(flex=0, direction=ROW))
        self.webview = toga.WebView(url='https://beeware.org/',
                                    on_key_down=self.on_webview_button_press,
                                    on_webview_load=self.on_webview_load,
                                    style=Pack(flex=1))

        box = toga.Box(children=[
            self.top_box,
            self.webview,
        ],
                       style=Pack(flex=1, direction=COLUMN))

        self.main_window.content = box
        self.main_window.show()
예제 #2
0
파일: deck.py 프로젝트: jnothman/podium
 def create(self):
     self.html_view = toga.WebView(style=Pack(
         flex=1,
         width=984 if self.deck.aspect == '16:9' else 738,
         height=576),
                                   on_key_down=self.deck.on_key_press)
     self.content = self.html_view
예제 #3
0
파일: app.py 프로젝트: yuntiaoOS/toga
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)

        self.webview = toga.WebView(style=Pack(flex=1))
        self.url_input = toga.TextInput(initial='https://github.com/',
                                        style=Pack(flex=1))

        box = toga.Box(children=[
            toga.Box(children=[
                self.url_input,
                toga.Button('Go',
                            on_press=self.load_page,
                            style=Pack(width=50, padding_left=5)),
            ],
                     style=Pack(
                         direction=ROW,
                         alignment=CENTER,
                         padding=5,
                     )),
            self.webview,
        ],
                       style=Pack(direction=COLUMN))

        self.main_window.content = box
        self.webview.url = self.url_input.value

        # Show the main window
        self.main_window.show()
예제 #4
0
    def startup(self):
        # We want the web canvas to be 1024x768;
        # 22 pixels is the window header size.
        self.main_window = toga.MainWindow(self.name, size=(1024, 768 + 22))
        self.main_window.app = self

        webview = toga.WebView()

        self.main_window.content = webview

        files = []
        filenames = [
            os.path.join(self.root, 'css', self.path, f)
            for f in os.listdir(os.path.join(self.root, 'css', self.path))
            if f.endswith('.xht') or f.endswith('.htm') or f.endswith('.html')
        ]

        loader = Loader.alloc().init()
        loader.webview = webview
        loader.filenames = iter(filenames)
        loader.path = self.path
        loader.output = self.output

        NSTimer.scheduledTimerWithTimeInterval(0.5,
                                               target=loader,
                                               selector=SEL('run:'),
                                               userInfo=None,
                                               repeats=False)

        # Show the main window
        self.main_window.show()
예제 #5
0
def build(app):
    def on_load(widget):
        print('Finished loading!')
        print(widget.dom)

    def on_key(event, flag):
        print('Key down: ', event, ' Flag: ', flag)

    webview = toga.WebView(on_key_down=on_key,
                           on_webview_load=on_load,
                           style=CSS(flex=1))
    url_input = toga.TextInput(initial='https://github.com/',
                               style=CSS(flex=1, margin=5))

    def load_page(widget):
        print('loading: ', url_input.value)
        webview.url = url_input.value

    def print_dom(widget):
        print(webview.dom)

    box = toga.Box(children=[
        toga.Box(children=[
            url_input,
            toga.Button('Go', on_press=load_page, style=CSS(width=50)),
        ],
                 style=CSS(flex_direction='row', padding_top=25)), webview,
        toga.Box(children=[toga.Button('Print DOM', on_press=print_dom)])
    ],
                   style=CSS(flex_direction='column'))

    webview.url = url_input.value

    # Show the main window
    return box
예제 #6
0
파일: app.py 프로젝트: willingc/hera
    def __init__(self, filename, app):
        super().__init__(filename=filename,
                         document_type='Jupyter Notebook',
                         app=app)

        self.window = toga.Window(title=filename, size=(768, 768))
        self.window.on_close = self.close_window
        self.webview = toga.WebView(style=Pack(flex=1))
        self.window.content = self.webview
예제 #7
0
파일: app.py 프로젝트: gridl/liquid-demo
    def startup(self):
        self.main_window = toga.MainWindow(self.name, size=(800, 1000))
        self.main_window.app = self

        self.webview = toga.WebView()
        self.webview.url = "https://github.com/login"

        self.main_window.content = self.webview
        self.main_window.show()
예제 #8
0
파일: msf.py 프로젝트: pshouse/mischief
 def create(self):
     self.html_view = toga.WebView(
         style=Pack(
             flex=1,
             width=984,
             height=576
         ),
         #on_key_down=self.msf.on_key_press
     )
     self.content = self.html_view
예제 #9
0
파일: app.py 프로젝트: willyhakim/slick
    def startup(self):
        self.main_window = toga.MainWindow(self.name)
        self.main_window.app = self

        self.webview = toga.WebView()

        self.main_window.content = self.webview

        self.webview.user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8"
        self.webview.url = "https://djangoconus2017.slack.com/messages"

        self.main_window.show()
예제 #10
0
    def setUp(self):
        super().setUp()

        self.url = 'https://beeware.org/'

        def callback(widget):
            pass

        self.on_key_down = callback
        self.web_view = toga.WebView(url=self.url,
                                     on_key_down=self.on_key_down,
                                     factory=toga_dummy.factory,
                                     user_agent='DUMMY AGENT')
예제 #11
0
    def setUp(self):
        self.factory = MagicMock()
        self.factory.WebView = MagicMock(return_value=MagicMock(spec=toga_dummy.factory.WebView))

        self.url = 'https://pybee.org/'

        def callback(widget):
            pass

        self.on_key_down = callback
        self.web_view = toga.WebView(url=self.url,
                                     on_key_down=self.on_key_down,
                                     factory=self.factory)
예제 #12
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)

        self.webview = toga.WebView(style=Pack(flex=1))
        self.url_input = toga.TextInput(initial='http://localhost:5001/',
                                        style=Pack(flex=1))

        box = toga.Box(children=[
            self.webview,
        ], style=Pack(direction=COLUMN))

        self.main_window.content = box
        self.webview.url = self.url_input.value

        # Show the main window
        self.main_window.show()
예제 #13
0
    def __init__(
        self,
        title="Alert",
        message="",
        button_labels=("Ok",),
        default="Ok",
        icon=None,
        callback=None,
        details_title="Traceback",
        details="",
        app=None,
    ):

        label = Label(
            details_title,
            style=Pack(
                width=self.CONTENT_WIDTH,
                padding_bottom=10,
                font_size=12,
                font_weight=BOLD,
                background_color=TRANSPARENT,
            ),
        )

        html_view_height = self.WINDOW_MIN_HEIGHT - Dialog.WINDOW_MIN_HEIGHT - 15
        self.web_view = toga.WebView(
            style=Pack(
                width=self.CONTENT_WIDTH, height=html_view_height, padding_bottom=15
            ),
        )
        self.web_view.set_content("", details)
        accessory_view = toga.Box(
            children=[label, self.web_view], style=Pack(direction=COLUMN)
        )

        super().__init__(
            title=title,
            message=message,
            button_labels=button_labels,
            default=default,
            icon=icon,
            callback=callback,
            accessory_view=accessory_view,
            app=app,
        )
예제 #14
0
    def startup(self):
        self.main_window = toga.MainWindow(self.name)

        self.webview = toga.WebView(style=Pack(flex=1))
        self.url_input = toga.TextInput(
            initial='https://github.com/anirudhkannanvp',
            style=Pack(flex=1, padding=5)
        )

        box = toga.Box(
            children=[
                toga.Box(
                    children=[
                        self.url_input,
                        toga.Button('GO', on_press=self.load_page, style=Pack(width=90, padding_right=10)),
                        toga.Button('HOME', on_press=self.load_page1, style=Pack(width=90, padding_right=10)),
                        toga.Button('BACK', on_press=self.load_page2, style=Pack(width=90, padding_right=10)),
                        toga.Button('TWITTER', on_press=self.load_page3, style=Pack(width=90, padding_right=10)),
                        toga.Button('YOUTUBE', on_press=self.load_page4, style=Pack(width=90, padding_right=10)),
                        toga.Button('LINKEDIN', on_press=self.load_page5, style=Pack(width=90, padding_right=10)),
                        toga.Button('HACKERRANK', on_press=self.load_page6, style=Pack(width=90, padding_right=10)),
                        toga.Button('CODECHEF', on_press=self.load_page7, style=Pack(width=90, padding_right=10)),
                        toga.Button('IDEONE', on_press=self.load_page8, style=Pack(width=90, padding_right=10))
                    ],
                    style=Pack(
                        direction=ROW
                    )
                ),
                self.webview,
            ],
            style=Pack(
                direction=COLUMN
            )
        )

        self.main_window.content = box
        t = self.url_input.value
        self.webview.url = str(t)
        prev.append(t)
        global k
        k+=1
        print(prev)

        # Show the main window
        self.main_window.show()
예제 #15
0
    def startup(self):
        self.main_window = toga.MainWindow(self.name)
        self.main_window.app = self

        self.webview = toga.WebView(style=CSS(flex=1))
        self.url_input = toga.TextInput(initial='https://github.com/',
                                        style=CSS(flex=1, margin=5))

        container = toga.Container(children=[
            toga.Container(children=[
                self.url_input,
                toga.Button('Go', on_press=self.load_page, style=CSS(width=50))
            ],
                           style=CSS(flex_direction='row')), self.webview
        ],
                                   style=CSS(flex_direction='column'))

        self.main_window.content = container
        self.webview.url = self.url_input.value

        # Show the main window
        self.main_window.show()
예제 #16
0
import toga

content = toga.WebView()
content.url = 'http://www.google.com'
container = toga.ScrollContainer(content=content, horizontal=False)
container.vertical = False


def build(app):
    return container


toga.App('First App', 'org.pybee.helloworld', startup=build).main_loop()
예제 #17
0
    def __init__(
        self,
        version: str = "",
        release_notes: str = "",
        icon: toga.Icon | None = None,
        app: toga.App | None = None,
    ) -> None:

        link_button = FollowLinkButton(
            label="GitHub Releases",
            url=f"{__url__}/download",
            style=Pack(padding_bottom=10),
        )

        label = Label(
            "Release Notes",
            style=Pack(
                width=self.CONTENT_WIDTH,
                padding_bottom=10,
                font_size=12,
                font_weight=BOLD,
                background_color=TRANSPARENT,
            ),
        )

        html_notes = markdown2.markdown(release_notes)

        with open(RELEASE_NOTES_CSS_PATH) as f:
            release_notes_css = f.read()

        html_notes = f"""
        <html>
        <head>
        <style>{release_notes_css}</style>
        </head>
        <body>{html_notes}</body>
        </html>
        """

        html_view_height = self.WINDOW_MIN_HEIGHT - Dialog.WINDOW_MIN_HEIGHT - 15
        self.web_view = toga.WebView(
            style=Pack(
                width=self.CONTENT_WIDTH,
                height=html_view_height,
                padding_bottom=15,
                font_family="Helvetica Neue",
            ),
        )
        self.web_view.set_content("", html_notes)
        accessory_view = toga.Box(
            children=[link_button, label, self.web_view], style=Pack(direction=COLUMN)
        )

        message = (
            f"Maestral v{version} is available, you have v{__version__}. Please use "
            f"your package manager to update or download the latest binary from GitHub."
        )

        super().__init__(
            title="Update available",
            message=message,
            button_labels=("Ok",),
            icon=icon,
            accessory_view=accessory_view,
            app=app,
        )
        self.msg_content.style.padding_bottom = 0
        self.msg_content.style.font_size = 12
        self.msg_content.style.height = 40
예제 #18
0
    def openMainWindow(self, widget):
        # self.view_box = toga.Box(style=Pack(direction=COLUMN))

        # contenedor primario para carga de url
        self.first_box = toga.Box(style=Pack(direction=ROW))
        self.second_box = toga.Box(style=Pack(direction=ROW))

        # Input text de la url del servicio
        self.url_input = toga.TextInput(placeholder=_TX_URL_PLACEHOLDER,
                                        style=Pack(flex=3))
        if self.url_added:
            self.url_input.value = self.url_added

        # Boton que permite cargar la url
        self.url_load = toga.Button(_TX_LOADURL_BUTTON,
                                    on_press=self.load_metadata,
                                    style=Pack(width=100,
                                               height=36,
                                               background_color='#fbceb5'))

        # Se agregan los elementos al contenedor primario
        self.first_box.add(self.url_input)
        self.first_box.add(self.url_load)

        # Contenedor de metadata
        # self.metadata = toga.MultilineTextInput(id=_ID_MULTILINETEXTINPUT_METADATA)
        # self.metadata.readonly = True

        self.web = toga.WebView(style=Pack(flex=1))

        # Contenedor para seleccionar el folder
        # self.window = toga.Window()

        # Input text que almacenara el folder donde se almacenara el resultado
        self.output_folder = toga.TextInput(style=Pack(flex=1))
        self.output_folder.readonly = True
        self.output_folder.value = self.outputFolder

        # Abre ventana para seleccionar un folder de almacenamiento
        self.savefolder = toga.Button(_TC_OUTPUT_BUTTON,
                                      on_press=self.saveAs,
                                      style=Pack(background_color='#52de97',
                                                 width=100,
                                                 height=36))
        self.config = toga.Button(_TC_CONFIG_BUTTON,
                                  on_press=self.openConfigWindow,
                                  style=Pack(background_color='#52de97',
                                             width=100,
                                             height=36))

        self.second_box.add(self.output_folder)
        self.second_box.add(self.savefolder)
        self.second_box.add(self.config)

        # self.updateurl = toga.Button(_TC_UPDATEURL_BUTTON, on_press=self.updateUrl)

        # Boton de decarga
        self.downloadBtn = toga.Button(_TC_DOWNLOAD_BUTTON,
                                       on_press=self.download,
                                       style=Pack(background_color='#52de97',
                                                  height=36))

        # Boton para abril la descarga
        self.openfolder = toga.Button(_TC_OPENFOLDER_BUTTON,
                                      on_press=self.openSaveAs,
                                      style=Pack(background_color='#52de97',
                                                 height=36))
        # self.openfolder.enabled = False

        self.donate = toga.Button(_TC_DONATE_BUTTON,
                                  on_press=self.load_yape_html_widget,
                                  style=Pack(background_color='#FF6363',
                                             height=36))

        self.main_box.remove(self.config_box)

        self.main_box.add(self.first_box)
        self.main_box.add(self.web)
        self.main_box.add(self.second_box)
        self.main_box.add(self.downloadBtn)
        self.main_box.add(self.openfolder)
        self.main_box.add(self.donate)

        if self.url_added:
            self.web.url = self.url_added
            self.web.refresh()
        else:
            self.load_yape_html()
        self.main_window.content = self.main_box
        self.main_window.show()
예제 #19
0
    def startup(self):

        location.location_use()

        self.outputFolder = packages.get_config_param_value(5)[0][0]
        if not self.outputFolder or self.outputFolder == '%temp%':
            self.outputFolder = tempfile.gettempdir()
            packages.set_config_param(5, self.outputFolder, iscommit=True)

        self.pid = None
        # contenedor principal de la aplicacion
        self.main_box = toga.Box(style=Pack(direction=COLUMN, padding=10))

        # contenedor primario para carga de url
        self.first_box = toga.Box(style=Pack(direction=ROW))
        self.second_box = toga.Box(style=Pack(direction=ROW))

        # Input text de la url del servicio
        self.url_input = toga.TextInput(placeholder=_TX_URL_PLACEHOLDER,
                                        style=Pack(flex=3))
        self.url_added = None

        # Boton que permite cargar la url
        self.url_load = toga.Button(_TX_LOADURL_BUTTON,
                                    on_press=self.load_metadata,
                                    style=Pack(width=100,
                                               height=36,
                                               background_color='#fbceb5'))

        # Se agregan los elementos al contenedor primario
        self.first_box.add(self.url_input)
        self.first_box.add(self.url_load)

        # Contenedor de metadata
        # self.metadata = toga.MultilineTextInput(id=_ID_MULTILINETEXTINPUT_METADATA)
        # self.metadata.readonly = True

        self.web = toga.WebView(style=Pack(flex=1))

        # Contenedor para seleccionar el folder
        self.window = toga.Window()

        # Input text que almacenara el folder donde se almacenara el resultado
        self.output_folder = toga.TextInput(style=Pack(flex=1))
        self.output_folder.readonly = True
        self.output_folder.value = self.outputFolder

        # Abre ventana para seleccionar un folder de almacenamiento
        self.savefolder = toga.Button(_TC_OUTPUT_BUTTON,
                                      on_press=self.saveAs,
                                      style=Pack(background_color='#52de97',
                                                 width=100,
                                                 height=36))
        self.config = toga.Button(_TC_CONFIG_BUTTON,
                                  on_press=self.openConfigWindow,
                                  style=Pack(background_color='#52de97',
                                             width=100,
                                             height=36))

        self.second_box.add(self.output_folder)
        self.second_box.add(self.savefolder)
        self.second_box.add(self.config)

        # self.updateurl = toga.Button(_TC_UPDATEURL_BUTTON, on_press=self.updateUrl)

        # Boton de decarga
        self.downloadBtn = toga.Button(_TC_DOWNLOAD_BUTTON,
                                       on_press=self.download,
                                       style=Pack(background_color='#52de97',
                                                  height=36))

        # Boton para abril la descarga
        self.openfolder = toga.Button(_TC_OPENFOLDER_BUTTON,
                                      on_press=self.openSaveAs,
                                      style=Pack(background_color='#52de97',
                                                 height=36))
        # self.openfolder.enabled = False

        self.donate = toga.Button(_TC_DONATE_BUTTON,
                                  on_press=self.load_yape_html_widget,
                                  style=Pack(background_color='#FF6363',
                                             height=36))

        self.main_box.add(self.first_box)
        # self.main_box.add(self.metadata)
        self.main_box.add(self.web)
        self.main_box.add(self.second_box)
        # self.main_box.add(self.savefolder)
        # self.main_box.add(self.output_folder)
        # self.main_box.add(self.updateurl)
        self.main_box.add(self.downloadBtn)
        self.main_box.add(self.openfolder)
        self.main_box.add(self.donate)

        self.main_window = toga.MainWindow(title=self.formal_name +
                                           ' by DanielGIS',
                                           size=(600, 700))
        self.main_window.content = self.main_box
        self.main_window.show()

        self.response_pool = list()
        self.inputsConfig = dict()

        self.load_yape_html()

        # Ventana de configuracion
        self.config_window = toga.Window(title='Config parameters',
                                         size=(900, 500))
예제 #20
0
 def get_dativetop_gui(self):
     dativetop_gui = toga.WebView(style=Pack(flex=1))
     dativetop_gui.url = '{}/index.html'.format(self.services.dtgui.url)
     return dativetop_gui
예제 #21
0
 def get_dative_gui(self):
     dative_gui = toga.WebView(style=Pack(flex=1))
     dative_gui.url = self.services.dative_app.url
     return dative_gui
예제 #22
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(1280, 800))

        container = toga.OptionContainer(on_select=self.change_option,
                                         style=Pack(flex=1))

        copy_url = toga.Command(self.setClipboardData,
                                label="Copy URL",
                                tooltip='Copy the current URL')

        self.commands.add(copy_url)
        self.view = None

        if self.summoners['option'] == 'pregame':
            for func in [
                    processor_ProfessorGG, processor_OPGG,
                    processor_LeagueFriend
            ]:
                url, script, site = func(self.summoners['data'],
                                         self.summoners['region'])
                webview = BrowserWebview(style=Pack(flex=1))
                webview.setData(url, script)
                container.add(site,
                              toga.Box(children=[webview], style=Pack(flex=1)))
                if not self.view:
                    self.view = webview
                if func == processor_LeagueFriend:
                    self.webview_runes = webview

        if self.summoners['option'] == 'postgame':
            for func in [processor_BlitzPostGame]:
                url, script, site = func(self.summoners['data'],
                                         self.summoners['region'])
                webview = BrowserWebview(style=Pack(flex=1))
                webview.setData(url, script)
                #webview.url = url
                container.add(
                    site, toga.Box(children=[webview],
                                   style=Pack(padding="5")))
                if not self.view:
                    self.view = webview

        global __DEBUG__
        if __DEBUG__:
            self.debug_webview = toga.WebView(style=Pack(flex=1))
            container.add(
                "DEBUG",
                toga.Box(children=[self.debug_webview], style=Pack(flex=1)))
            self.log("Started. 1")
            self.log("Started. 2")

        box = toga.Box(children=[container],
                       style=Pack(direction=COLUMN, padding="10", flex=1))

        self.main_window.content = box

        # start rpc
        if self.summoners['option'] == 'pregame':
            rpc_thread = threading.Thread(target=self.rpc_server)
            rpc_thread.start()

        # Show the main window
        self.main_window.show()
예제 #23
0
파일: deck.py 프로젝트: cczona/podium
 def startup(self):
     super().startup()
     self.content = toga.Container()
     self.html_view = toga.WebView(style=CSS(flex=1),
                                   on_key_down=self.deck.on_key_press)
     self.content.add(self.html_view)