云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > PythonWindowsTutorial

PythonWindowsTutorial

  • 62 次阅读
  • 3 次下载
  • 2025/6/24 9:24:02

Using Python To Harness Windows

5.3 A Minimal COM Server

# SimpleCOMServer.py - almost as small as they come! class PythonUtilities: _public_methods_ = [ 'SplitString' ] _reg_progid_ = \ # NEVER copy the following ID # Use \ _reg_clsid_ = \ def SplitString(self, val, item=None): import string if item != None: item = str(item) return string.split(str(val), item) # Add code so that when this script is run by Python.exe, it self-registers. if __name__=='__main__': print \ import win32com.server.register win32com.server.register.UseCommandLine(PythonUtilities)

5.4 Using the minimal server from VB or VBA

Page 17 of 71

6795.doc

Using Python To Harness Windows

5.5 Why write Python COM Servers?

? ?

Easiest way to expose Python functionality to your own or other applications Python is best at the business logic, other tools are best at other things (e.g. VB GUIs)

5.6 Doubletalk – Sample Application

Python Financial Modelling Toolkit. Models “Sets of Books” and “Transactions”

Good candidate for this architecture because ? ?

Very wide general applicability – from local data input app to back-office server

Every company needs to customize it a little!

How could we sell it? ? ? ? ? ? ? ? ? ?

100% Native Windows GUI

Distributed, Dynamic Multi-tier Network Architecture

Embedded Scripting Language – lets you customize the way it works! Extensible Plug-In Architecture Command Prompt for Power Users Integration with Word and Excel Open Database Connectivity

Option to run critical tasks on Unix servers without changing a line of code! Totally Buzzword Compliant!

Page 18 of 71

6795.doc

Using Python To Harness Windows

Now to discuss what the app is about:

5.7 Transactions

Crudely, a movement of money.

All accounts must sum to zero!

Simple two-line (“Double-Entry”) Date: 01/01/1998 Comment: Start the company Cash +10 000 Share Capital -10 000

Multi-line Date: 10/03/1999 Comment: Sell Widgets Cash +117.50 Sales Category 1 -50.00 Sales Category 2 -30.00 Sales Category 3 -20.00 Sales tax on all three (owed to Customs & Excise) -17.50

Functionality: ? Store ? Edit ? Add ? Validate

? effectOn(self, account) ? Extra keys/values

? add, multiply – an algebra for financial transactions!

Page 19 of 71

6795.doc

Using Python To Harness Windows

5.8 Accounts

Accounts form a tree – this is the “Balance Sheet”…

? ?

Represent tree as dotted string notation: “MyCo.Assets.Cash.PiggyBank” Assets, Cash and Expenditure are positive; Liabilities, Income and Profit are negative.

5.9 BookSets

A wrapper around a list of transactions. ? ?

Fundamental change operations ? ?

Querying ? ? ? ?

get history of an account get the ?tree of accounts?

get all balances on date -> Balance Sheet report

get all changes between two dates -> Profit & Loss reports Add/Edit/Delete transactions Rename Account

Load/Save with cPickle (one of Python?s killer features!) Import/Export ASCII text, list/dictionary/tuple structures etc.

Page 20 of 71

6795.doc

搜索更多关于: PythonWindowsTutorial 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

Using Python To Harness Windows 5.3 A Minimal COM Server # SimpleCOMServer.py - almost as small as they come! class PythonUtilities: _public_methods_ = [ 'SplitString' ] _reg_progid_ = \ # NEVER copy the following ID # Use \ _reg_clsid_ = \ def SplitString(self, val, item=None): import string if item != None: item = str(item)

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com