Browse Source

maint: remove `output_fixed_height` setting

wangweimin 4 years ago
parent
commit
e3189a0cea

+ 1 - 1
demos/bmi.py

@@ -13,7 +13,7 @@ from pywebio.session import set_env
 
 
 def main():
-    set_env(title="BMI Calculation", output_fixed_height=True)
+    set_env(title="BMI Calculation")
 
     put_markdown("""计算 [`BMI指数`](https://baike.baidu.com/item/%E4%BD%93%E8%B4%A8%E6%8C%87%E6%95%B0/1455733) 的简单应用,源代码[链接](https://github.com/wang0618/PyWebIO/blob/master/demos/bmi.py)""", lstrip=True)
 

+ 1 - 1
demos/chat_room.py

@@ -42,7 +42,7 @@ async def refresh_msg(my_name):
 async def main():
     global chat_msgs
 
-    set_env(title="PyWebIO Chat Room", output_fixed_height=True)
+    set_env(title="PyWebIO Chat Room")
 
     put_markdown("""欢迎来到聊天室,你可以和当前所有在线的人聊天\n
     本应用使用不到80行代码实现,源代码[链接](https://github.com/wang0618/PyWebIO/blob/master/demos/chat_room.py)""", lstrip=True)

+ 0 - 8
demos/set_env_demo.py

@@ -33,7 +33,6 @@ async def main():
         'title': 'PyWebIO set_env() Demo',
         'output_animation': True,
         'auto_scroll_bottom': True,
-        'output_fixed_height': True,
     }
     set_env(**state)
 
@@ -44,13 +43,6 @@ async def main():
             state['title'] = await input('请输入标题', value=state['title'])
             set_env(title=state['title'])
             toast('已将标题设置为%r' % state['title'])
-        elif key == 'output_fixed_height':
-            act = await actions('选择要对output_fixed_height设置项进行的操作', ['设置为False', '自定义高度'])
-            if act == '自定义高度':
-                state['output_fixed_height'] = await input('请输入输出区高度(像素)', type=NUMBER)
-            else:
-                state['output_fixed_height'] = False
-            set_env(output_fixed_height=state['output_fixed_height'])
         elif key in state:
             state[key] = not (state[key])
             set_env(**{key: state[key]})

+ 0 - 5
docs/guide.rst

@@ -493,11 +493,6 @@ PyWebIO使用Scope栈来保存运行时的Scope的嵌套层级。
 页面环境设置
 ^^^^^^^^^^^^^^
 
-**输出区外观**
-
-PyWebIO支持两种外观:可变高度的输出区(默认)和固定高度的输出区。
-可以通过调用 `pywebio.session.set_env(output_fixed_height=True) <pywebio.session.set_env>` 来开启输出区固定高度或直接传入自定义的高度值(比如 `set_env(output_fixed_height=600) <pywebio.session.set_env>` )。
-
 **设置页面标题**
 
 调用 `set_env(title=...) <pywebio.session.set_env>` 可以设置页面标题。

+ 6 - 43
pywebio/html/css/app.css

@@ -7,13 +7,14 @@
     max-width: 880px;
 }
 
-#input-container h5.card-header {
-    padding: .4rem 1.25rem;
+#output-container {
+    -webkit-font-smoothing: antialiased;
+    margin-top: 20px;
+    margin-bottom: 20px;
 }
 
-#input-cards {
-    padding-left: 25px;
-    padding-right: 25px;
+#input-container h5.card-header {
+    padding: .4rem 1.25rem;
 }
 
 #input-container {
@@ -83,44 +84,6 @@
     font-size: 13px
 }
 
-.mditor {
-    height: 400px;
-    width: auto;
-}
-
-/*非固定行高模式*/
-.no-fix-height {
-    margin-top: 20px;
-}
-
-.no-fix-height .mditor {
-    height: initial;
-    padding-top: 0;
-    border: 0;
-}
-
-.no-fix-height .mditor .body {
-    height: initial;
-    box-shadow: unset;
-}
-
-.no-fix-height .mditor .viewer {
-    height: initial;
-    padding-bottom: 20px;
-}
-
-.no-fix-height .mditor .head {
-    display: none;
-}
-
-.no-fix-height #input-container {
-    margin: 0 10px;
-}
-
-.no-fix-height #input-container h5.card-header {
-    padding: .4rem 1.25rem;
-}
-
 h5.card-header:empty {
     padding: 0 !important;
     border-bottom: 0 !important;

+ 3 - 15
pywebio/html/index.html

@@ -16,27 +16,15 @@
 <body>
 <div class="pywebio">
     <div class="container no-fix-height" id="output-container">
-        <div tabindex="1" class="mditor preview">
-            <div class="head">
-                <ul class="toolbar">
-                    <span id="title">PyWebIO</span>
-                </ul>
-            </div>
-            <div class="body">
-                <div class="viewer">
-                    <div class="markdown-body" id="markdown-body">
-                        <div id="pywebio-scope-ROOT"></div>
-                    </div>
-                </div>
-            </div>
+        <div class="markdown-body" id="markdown-body">
+            <div id="pywebio-scope-ROOT"></div>
         </div>
         <div id="end-space"></div>
 
     </div>
 
     <div id="input-container">
-        <div id="input-cards" class="container">
-        </div>
+        <div id="input-cards" class="container"></div>
     </div>
 </div>
 

+ 1 - 2
pywebio/session/__init__.py

@@ -288,14 +288,13 @@ def set_env(**env_info):
     * ``output_animation`` (bool): 是否启用输出动画(在输出内容时,使用过渡动画),默认启用
     * ``auto_scroll_bottom`` (bool): 是否在内容输出时将页面自动滚动到底部,默认启用
     * ``http_pull_interval`` (int): HTTP轮训后端消息的周期(单位为毫秒,默认1000ms),仅在使用HTTP的连接中可用
-    * ``output_fixed_height`` (int/bool): 输出区高度(单位为css像素值),0或False表示不固定高度。默认不固定高度
 
     调用示例::
 
         set_env(title='Awesome PyWebIO!!', output_animation=False)
     """
     from ..io_ctrl import send_msg
-    assert all(k in ('title', 'output_animation', 'auto_scroll_bottom', 'http_pull_interval', 'output_fixed_height')
+    assert all(k in ('title', 'output_animation', 'auto_scroll_bottom', 'http_pull_interval')
                for k in env_info.keys())
     send_msg('set_env', spec=env_info)
 

+ 0 - 12
webiojs/src/handlers/env.ts

@@ -11,21 +11,9 @@ export class EnvSettingHandler implements CommandHandler {
     handle_message(msg: Command) {
         let spec = msg.spec;
         if (spec.title !== undefined) {
-            $('#title').text(spec.title);  // 直接使用#title不规范 todo
             document.title = spec.title;
         }
 
-        if (spec.output_fixed_height !== undefined) {
-            state.OutputFixedHeight = !!(spec.output_fixed_height);
-            if (spec.output_fixed_height) {
-                $('.container').removeClass('no-fix-height');  // todo 不规范
-                if (typeof spec.output_fixed_height == 'number')
-                    $('.mditor')[0].style.height = spec.output_fixed_height + 'px';
-            } else {
-                $('.container').addClass('no-fix-height');  // todo 不规范
-            }
-        }
-
         if (spec.auto_scroll_bottom !== undefined)
             state.AutoScrollBottom = spec.auto_scroll_bottom;
 

+ 1 - 6
webiojs/src/handlers/output.ts

@@ -22,10 +22,7 @@ export class OutputHandler implements CommandHandler {
     }
 
     scroll_bottom() {
-        if (state.OutputFixedHeight) // 固定高度窗口滚动
-            box_scroll_to(this.container_elem, this.container_parent, 'bottom', undefined, 30);
-        else  // 整个页面自动滚动
-            body_scroll_to($('.container'), 'bottom');
+        body_scroll_to($('.pywebio'), 'bottom', null,15);
     };
 
     handle_message(msg: Command) {
@@ -118,8 +115,6 @@ export class OutputHandler implements CommandHandler {
             let target = $(`${msg.spec.scroll_to}`);
             if (!target.length) {
                 console.error(`Scope ${msg.spec.scroll_to} not found`);
-            } else if (state.OutputFixedHeight) {
-                box_scroll_to(target, this.container_parent, msg.spec.position);
             } else {
                 body_scroll_to(target, msg.spec.position);
             }

+ 0 - 1
webiojs/src/state.ts

@@ -3,7 +3,6 @@ import {Session} from "./session";
 // 运行时状态
 export let state = {
     AutoScrollBottom: true,  // 是否有新内容时自动滚动到底部
-    OutputFixedHeight: false,  // 是否固定输出区域宽度
     CurrentSession: null as Session,  // 当前正在活跃的会话
     ShowDuration: 200,  // ms, 显示表单的过渡动画时长
 };