1 Star 1 Fork 0

ysun/gqlgen

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.py 2.31 KB
一键复制 编辑 原始数据 按行查看 历史
YuSUN 提交于 2022-07-23 17:54 . feat: full screen for client interactive
"""
A simple example of a few buttons and click handlers.
"""
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.key_binding.bindings.focus import focus_next, focus_previous
from prompt_toolkit.layout import HSplit, Layout, VSplit
from prompt_toolkit.styles import Style
from prompt_toolkit.widgets import Box, Button, Frame, Label, TextArea
# Event handlers for all the buttons.
def button1_clicked():
text_area.text = "Button 1 clicked"
def button2_clicked():
text_area.text = "Button 2 clicked"
def button3_clicked():
text_area.text = "Button 3 clicked"
def exit_clicked():
get_app().exit()
# All the widgets for the UI.
button1 = Button("Button 1", handler=button1_clicked)
button2 = Button("Button 2", handler=button2_clicked)
button3 = Button("Button 3", handler=button3_clicked)
button4 = Button("Exit", handler=exit_clicked)
text_area = TextArea(focusable=True)
# Combine all the widgets in a UI.
# The `Box` object ensures that padding will be inserted around the containing
# widget. It adapts automatically, unless an explicit `padding` amount is given.
root_container = Box(
HSplit(
[
Label(text="Press `Tab` to move the focus."),
VSplit(
[
Box(
body=HSplit([button1, button2, button3, button4], padding=1),
padding=1,
style="class:left-pane",
),
Box(body=Frame(text_area), padding=1, style="class:right-pane"),
]
),
]
),
)
layout = Layout(container=root_container, focused_element=button1)
# Key bindings.
kb = KeyBindings()
kb.add("tab")(focus_next)
kb.add("s-tab")(focus_previous)
# Styling.
style = Style(
[
("left-pane", "bg:#888800 #000000"),
("right-pane", "bg:#00aa00 #000000"),
("button", "#000000"),
("button-arrow", "#000000"),
("button focused", "bg:#ff0000"),
("text-area focused", "bg:#ff0000"),
]
)
# Build a main application object.
application = Application(layout=layout, key_bindings=kb, style=style, full_screen=True)
def main():
application.run()
if __name__ == "__main__":
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/acidrain/gqlgen.git
git@gitee.com:acidrain/gqlgen.git
acidrain
gqlgen
gqlgen
master

搜索帮助