本文整理汇总了Python中webview.create_window函数的典型用法代码示例。如果您正苦于以下问题:Python create_window函数的具体用法?Python create_window怎么用?Python create_window使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_window函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: serve_forever
def serve_forever(self):
try:
import webview
Server.start(self)
webview.create_window(self.title, self.address, **self._application_conf)
Server.stop(self)
except ImportError:
raise ImportError('PyWebView is missing. Please install it by:\n '
'pip install pywebview\n '
'more info at https://github.com/r0x0r/pywebview')
示例2: invalid_bg_color
def invalid_bg_color():
with pytest.raises(ValueError):
webview.create_window('Background color test', 'https://www.example.org', background_color='#dsg0000FF')
with pytest.raises(ValueError):
webview.create_window('Background color test', 'https://www.example.org', background_color='FF00FF')
with pytest.raises(ValueError):
webview.create_window('Background color test', 'https://www.example.org', background_color='#ac')
with pytest.raises(ValueError):
webview.create_window('Background color test', 'https://www.example.org', background_color='#EFEFEH')
with pytest.raises(ValueError):
webview.create_window('Background color test', 'https://www.example.org', background_color='#0000000')
示例3: create_new_window
def create_new_window():
# Create new window and store its uid
child_window = webview.create_window('Window #2', width=800, height=400)
# Load content into both windows
webview.load_html('<h1>Master Window</h1>')
webview.load_html('<h1>Child Window</h1>', uid=child_window)
示例4: localization
def localization():
strings = {
"cocoa.menu.about": u"О программе",
"cocoa.menu.services": u"Cлужбы",
"cocoa.menu.view": u"Вид",
"cocoa.menu.hide": u"Скрыть",
"cocoa.menu.hideOthers": u"Скрыть остальные",
"cocoa.menu.showAll": u"Показать все",
"cocoa.menu.quit": u"Завершить",
"cocoa.menu.fullscreen": u"Перейти ",
"windows.fileFilter.allFiles": u"Все файлы",
"windows.fileFilter.otherFiles": u"Остальлные файльы",
"linux.openFile": u"Открыть файл",
"linux.openFiles": u"Открыть файлы",
"linux.openFolder": u"Открыть папку",
"linux.saveFile": u"Сохранить файл",
}
webview.create_window('Localization test', 'https://www.example.org', strings=strings)
示例5: js_bridge
def js_bridge():
class Api2:
def test2(self, params):
return 2
webview.load_html('<html><body><h1>Master window</h1></body></html>')
api2 = Api2()
child_window = webview.create_window('Window #2', js_api=api2)
assert child_window != 'MainWindow'
webview.load_html('<html><body><h1>Secondary window</h1></body></html>', uid=child_window)
assert_js(webview, 'test1', 1)
assert_js(webview, 'test2', 2, uid=child_window)
webview.destroy_window(child_window)
示例6: evaluate_js
def evaluate_js():
child_window = webview.create_window('Window #2', 'https://google.com')
assert child_window != 'MainWindow'
result1 = webview.evaluate_js("""
document.body.style.backgroundColor = '#212121';
// comment
function test() {
return 2 + 5;
}
test();
""")
assert result1 == 7
result2 = webview.evaluate_js("""
document.body.style.backgroundColor = '#212121';
// comment
function test() {
return 2 + 2;
}
test();
""", uid=child_window)
assert result2 == 4
webview.destroy_window(child_window)
示例7:
import webview
"""
This example demonstrates how to enable debugging of webview content. To open
up debugging console, right click on an element and select Inspect.
"""
if __name__ == '__main__':
webview.create_window('Debug window', 'https://pywebview.flowrl.com/hello', debug=True)
示例8: serve_forever
def serve_forever(self):
import webview
Server.start(self)
webview.create_window(self._application_name, self.address, **self._application_conf)
Server.stop(self)
示例9: get_current_url
import webview
import threading
"""
This example demonstrates how to get the current url loaded in the webview.
"""
def get_current_url():
print(webview.get_current_url())
if __name__ == '__main__':
t = threading.Thread(target=get_current_url)
t.start()
webview.create_window("Get current URL", "https://pywebview.flowrl.com/hello")
示例10: load_html
import webview
import threading
"""
This example demonstrates how to load HTML in a web view window
"""
def load_html():
webview.load_html("<h1>This is dynamically loaded HTML</h1>")
if __name__ == '__main__':
t = threading.Thread(target=load_html)
t.start()
# Create a non-resizable webview window with 800x600 dimensions
webview.create_window("Simple browser", width=800, height=600, resizable=True)
示例11: start
def start(self):
thread.start_new_thread(self.counter, (2, "https://calendar.google.com?mode=day", 0))
webview.create_window("wall program", "html/start.html", fullscreen=True)
示例12:
import webview
"""
This example demonstrates how to create a CEF window. Available only on Windows.
"""
if __name__ == '__main__':
# Create a CEF window
webview.config.gui = 'cef'
webview.create_window('CEF browser', 'https://pywebview.flowrl.com/hello')
示例13:
import webview
"""
This example demonstrates a webview window with a quit confirmation dialog
"""
if __name__ == '__main__':
# Create a standard webview window
webview.create_window("Simple browser", "http://www.flowrl.com", confirm_quit=True)
示例14:
import webview
"""
This example demonstrates how to create a webview window.
"""
if __name__ == '__main__':
# Create a non-resizable webview window with 800x600 dimensions
webview.create_window("Simple browser", "http://www.flowrl.com", width=800, height=600, resizable=False)
示例15: handle_event
if evt.type in [X.KeyPress, X.KeyRelease]: #ignore X.MappingNotify(=34)
handle_event(evt)
#else handle_event_pinyin(evt)
data=''
try:
data, address=sock.recvfrom(4096)
if data!='':
print 'receive udp:',data
#{"detail":"j", "state":0, "type":2}
#{"detail":"j", "state":0, "type":3}
evt_key=json.loads(data);
if is_on:
if evt_key['detail']=='f':
evt_key['detail']='s'
elif evt_key['detail']=='s':
evt_key['detail']='f'
evt_key={'detail':string_to_keycode(evt_key['detail']), 'state':evt_key['state'], 'type':evt_key['type']}
if evt_key['type']==5:
fake_input(disp, 2, evt_key['detail'])
fake_input(disp, 3, evt_key['detail'])
else:
fake_input(disp, evt_key['type'], evt_key['detail'])
#handle_event(namedtuple('Struct', evt_key.keys())(*evt_key.values()))
except socket.error:
continue
if __name__ == '__main__':
thread.start_new_thread(main, ())
webview.create_window('myboard_jack', 'https://www.google.com', None, screen.width_in_pixels-200, 0, False, False)