Skip to content

Instantly share code, notes, and snippets.

@trsqxyz
Last active December 22, 2015 08:59
Show Gist options
  • Save trsqxyz/6449226 to your computer and use it in GitHub Desktop.
Save trsqxyz/6449226 to your computer and use it in GitHub Desktop.
Delphi のカラムエディタ用に FieldName と Title.Caption を書き出す。 field.txt に FieldName 、title.txt に Title.Caption を一行づつ書く。 DBGrid をエディタ表示にして item.txt を貼り付ける。
# -*- coding: utf-8 -*-
"""
For Delphi7 column editor set FieldName and Title.Caption.
Write FieldName to field.txt, Title.Caption to title.txt.
Result in item.txt
"""
with open('item.txt', 'w') as item:
with open('field.txt') as field, open('title.txt') as title:
expanded = '\t\titem\n\t\tExpanded = False\n'
fields = ['\t\tFieldName = \'' + f.strip() + '\'\n' for f in field]
titles = ['\t\tTitle.Caption = \'' + t.strip() + '\'\n' for t in title]
visible = '\t\tVisible = True\n\t\tend\n'
items = [expanded + f + t + visible for (f, t) in zip(fields, titles)]
for i in items: item.write(i)
item.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment