zoukankan      html  css  js  c++  java
  • python的sciter库Pysciter安装教程(win32 + win64)

    Pysciter是一个结合HTMLPython编写桌面软件个三方库

    注:无论是32位还是64位电脑,建议安装32位的sciter,这样写出来的软件可以在win32和win64电脑上都可以运行(前提python安装了32位的),下面介绍32位sciter安装方法(32位电脑和64位电脑安装方式有所区别,会分别说明)。

    一:sciter-sdk相关配置:

    1.下载 sciter-sdk中32位的 sciter.dll 文件

    https://github.com/c-smile/sciter-sdk/blob/master/bin/32/sciter.dll

    2. 注册sciter.dll

    32位系统电脑:把sciter.dll复制到C:WindowsSystem32目录,打开DOS窗口输入命令(管理员身份运行)

    regsvr32 /s sciter.dll

    64位系统电脑:把sciter.dll复制到C:WindowsSysWOW64目录,然后在C:WindowsSysWOW64目录中找到cmd.exe以管理员身份运行,然后输入命令:

    regsvr32 /s sciter.dll

    如:

    3. 下载 pysciter 并解压到D盘

    https://codeload.github.com/sciter-sdk/pysciter/zip/master

    4. 在pysciter-master目录中打开命令行,输入命令

    python setup.py install

    此时就会将pysciter安装到python第三方安装包的目录下,我的是 D:PythonPython36Libsite-packagesPySciter-0.4.25-py3.6.egg

    5. 修改pysciter源码

     用编辑器打开 D:PythonPython36Libsite-packagesPySciter-0.4.25-py3.6.eggscitercapisctypes.py

    第101行把SCITER_DLL_NAME = "sciter" 修改为 注册sciter.dll所在位置(去掉后缀):

    32位:SCITER_DLL_NAME = "C:WindowsSystem32sciter"

    64位:SCITER_DLL_NAME = "C:WindowsSysWOW64sciter"

    6. 运行实例查看效果

    python pysciter.py

    出现上图表示安装正常

    7. python的idea中使用sciter,包括python中和html交互,示例如下:

    import sciter
    import time
    import threading
    
    def run(self):
        while 1:
            time.sleep(2)
            # 调用html中方法
            self.eval_script('hello("42");')
    
    class Frame(sciter.Window):
        def __init__(self):
            super().__init__(ismain=True, uni_theme=True)
            pass
    
        @sciter.script
        def PythonCall(self, arg):
            print("参数:", str(arg))
            return "通信成功了,返回值:" + str(arg) + ' -_-'
    
        @sciter.script
        def inti(self):
            # 启动独立的线程
            t = threading.Thread(target=run, args=(self,))
            t.start()
    
    if __name__ == '__main__':
        import os
        htm = os.path.join(os.path.dirname(__file__), 'Gui/pysciter.html')   #pysciter.html文件编码格式必须 Unix(LF) UTF-8-BOM 以防止中文乱码
        frame = Frame()
        frame.load_file(htm)
        frame.run_app()

    Gui/pysciter.html(pysciter.html文件编码格式必须 Unix(LF) UTF-8-BOM 以防止中文乱码):

    <html window-icon="icon.png">
      <head>
        <title>PySciter示例</title>
        <style>
          html {
            background: radial-gradient(75% 75%, circle farthest-side, white, orange, rgb(0,0,204));
            color:#fff;
          }
          html:rtl {
            mapping: left-to-right(background);
          }
        </style>
        <script type="text/tiscript">
          //ti调用py方法
          view.cc = "haha哈";
          $(button#ti2py).on("click", function() {
            var answer = view.PythonCall(view.cc);
            $(body).$append(<h1#test>{answer}</h1>);
          })
    
          //py调用ti方法
          function hello(who) {
              $(body).$append(<h1#test>{who}</h1>);
          }
          view.inti()
    
          //输出语句
          //stdout.println("2 + 3 = ");
        </script>
      </head>
    <body>
      <h1>Pythonic Sciter Application</h1>
      <button #ti2py>ti调用py方法</button>
    </body>
    </html>
  • 相关阅读:
    正则表达式中匹配中文
    计算机中的颜色——颜色概述
    人物系列Claude Shannon
    reading listfrom other blog
    how to write Makefile
    《麻省理工大学开放课程:线性代数》[中英双语字幕]视频下载
    正则表达式30分钟入门教程
    usage of fscanf and other read functions in C/C++
    《麻省理工大学开放课程:线性代数》学习
    Open review of papers
  • 原文地址:https://www.cnblogs.com/007sx/p/9439179.html
Copyright © 2011-2022 走看看