○ 新たなHTMLファイルの作成(雛形の作成)【Python】
copy
copied!
make_html.py
展開
折り畳む
#! /usr/local/bin/env python3
#! encode : -*- utf-8 -*-
#% 新たなhtmlページの生成
import os
import pprint
import time
MASTER_PATH = '/Users/osadamasashi/Desktop/ossa2019.stars.ne.jp'
PROFILE_PATH = 'programs/html_profile.txt'
os.chdir(MASTER_PATH)
#### 愉快な関数たち
dir_path = lambda x : '' if x == '' else '../'*dir_count(x)
dir_count = lambda x : 0 if x == '' else len(x.split('/'))
slash = lambda x : '' if x == '' else '/'
def tab_where(x:str = '3') -> str:
x = '3' if x == '' else x
re = ['' for i in range(4)]
re[int(x)] = ' id="now"'
return re
def tab_where_path(x:str, d_path:str) -> list:
x = '3' if x == '' else x
dir_depth = dir_count(d_path)
re = ['../'*dir_depth for i in range(4)]
re[int(x)] = '../'*(dir_depth-1)
result = [re, re[int(x)], int(x)]
return result
with open(PROFILE_PATH, 'r') as f: profile_input = f.read().split('\n')
profile_arrange = []
for p in range(len(profile_input)):
if(len(profile_input[p]) == 0):
profile_arrange.append('')
elif not(profile_input[p][0] == '#'):
profile_arrange.append(profile_input[p])
#### 付加する変数たち
KEY_LIST = ['directory', 'file_name', 'title', 'tab_now', 'og:title', 'og:description', 'og:site_name', 'og:type', 'page title', 'caption', 'insert preset', 'reset']
PROFILE = dict(zip(KEY_LIST, profile_arrange))
pprint.pprint(PROFILE)
SRC_PATH = dir_path(PROFILE['directory'])
FILE_NAME = 'NoneName_'+str(time.time()) if PROFILE['file_name'] == '' else PROFILE['file_name']
FILE_PATH = PROFILE['directory']+slash(PROFILE['directory'])+FILE_NAME+'.html'
OG_SITE_NAME = PROFILE['og:title'] if PROFILE['og:site_name'] == '' else PROFILE['og:site_name']
OG_TYPE = 'blog' if PROFILE['og:type'] == '' else PROFILE['og:type']
TAB_NOW = tab_where(PROFILE['tab_now'])
TAB_NOW_ = tab_where_path(PROFILE['tab_now'], PROFILE['directory'])
TAB_NOW_PATH = TAB_NOW_[0]
TAB_LIST = ['index', 'apps', 'Remember/Remember', 'blog']
TAB_NOW_CHAR = TAB_NOW_[1]+TAB_LIST[TAB_NOW_[2]]
TAB_LIST_JUMP = ['トップ', 'アプリ', '備忘録', 'にっき']
TAB_NOW_CHAR_JUMP = TAB_LIST_JUMP[TAB_NOW_[2]]
#### htmlソース
head = """\
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="%spic/o.ico">
<link rel="shortcut icon" href="%spic/o.ico">
<link rel="apple-touch-icon-precomposed" href="%spic/o.png">
<!-- pc版css -->
<link rel="stylesheet" href="%scss/mainContent.css" media="screen and (min-width:600px)">
<link rel="stylesheet" href="%scss/sidebar.css" media="screen and (min-width:600px)">
<link rel="stylesheet" href="%scss/pointerEffect.css" media="screen and (min-width:600px)">
<!-- モバイル版css -->
<link rel="stylesheet" href="%scss/sidebar_mobile.css" media="screen and (max-width:599px)">
<link rel="stylesheet" href="%scss/mainContent_mobile.css" media="screen and (max-width:599px)">
<link rel="stylesheet" href="%scss/pointerEffect_mobile.css" media="screen and (max-width:599px)">
<link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'>
<meta property="og:title" content="%s">
<meta property="og:description" content="%s">
<meta property="og:site_name" content="%s">
<meta property="og:type" content="%s">
<meta property="og:url" content="https://ossa2019.stars.ne.jp/%s">
<title>%s</title>
</head>
<body>
<div class="sidebar">
<div class="logo_content">
<div class="logo">
<!-- <i class='bx bxl-python'></i> -->
<img src="%spic/o_alpha.PNG">
<div class="name" id="jp_font">
おさだのホームページ
</div>
</div>
<i class='bx bx-menu' id="open_btn"></i>
<i class='bx bx-x' id="close_btn"></i>
</div>
<ul class="page_list">
<!-- search -->
<li>
<i class='bx bx-search'></i>
<input type="text" placeholder="サイト内検索..." id="search-key">
<i class='bx bx-right-arrow-circle' id="search_btn" onclick="jump()"></i>
</li>
<!-- home -->
<li%s>
<a href="%sindex.html">
<i class='bx bx-home'></i>
<span class="link_name">home</span>
</a>
<span class="popup_text">home</span>
</li>
<!-- note -->
<li%s>
<a href="%sblog.html">
<i class='bx bx-book'></i>
<span class="link_name">note</span>
</a>
<span class="popup_text">note</span>
</li>
<!-- programs -->
<li%s>
<a href="%sapps.html">
<i class='bx bx-code-alt'></i>
<span class="link_name">programs</span>
</a>
<span class="popup_text">programs</span>
</li>
<!-- remember -->
<li%s>
<a href="%sRemember/Remember.html">
<i class='bx bx-paperclip'></i>
<span class="link_name">remember</span>
</a>
<span class="popup_text">remember</span>
</li>
<li>
<!-- space -->
</li>
<!-- 基本情報技術者試験 -->
<li>
<a href="%sjouhou.html" target="_blank" rel="noopener noreferrer">
<i class='bx bx-radio-circle'></i>
<span class="link_name" id="jp_font">基本情報技術者試験の解答</span>
</a>
<span class="popup_text" id="jp_font">基本情報技術者試験の解答</span>
</li>
<!-- 文字数カウンター -->
<li>
<a href="%stext.html" target="_blank" rel="noopener noreferrer">
<i class='bx bx-radio-circle'></i>
<span class="link_name" id="jp_font">文字数カウンター</span>
</a>
<span class="popup_text" id="jp_font">文字数カウンター</span>
</li>
<li></li>
<!-- secret page -->
<li id="secret">
<a href="%smyPage/home.html" target="_blank" rel="noopener noreferrer" id="secret_page">
<i class='bx bx-key'></i>
<span class="link_name">test page</span>
</a>
<span class="popup_text_secret">test page</span>
</li>
</ul>
<div class="profile_content">
<div class="profile">
<div class="profile_details">
<div class="subscript">Writer</div>
<div class="name">
Osada Masashi
<br>
<a href="https://x.com/Masashi_Osada" target="_blank" rel="noopener noreferrer">
> twitter
</a>
</div>
</div>
</div>
</div>
</div>
<div class="main_content">
<div class="tmTopBtn" id="topScroll" onclick="tmTopScroll()">
<i class='bx bx-upvote'></i>
<br>
<span class="topScroll_ception">
top
</span>
</div>
<div class="text_content">
<div class="top_title_text" id="jp_font">おさだのホームページ</div>
<br>
<div class="page_title" id="fade_0">
<div class="title_text">
%s
</div>
<div class="caption_text" id="jp_font">
%s
</div>
</div>
"""%(SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH,
PROFILE['og:title'],
PROFILE['og:description'],
OG_SITE_NAME,
OG_TYPE,
FILE_PATH,
PROFILE['title'],
SRC_PATH,
TAB_NOW[0],
TAB_NOW_PATH[0],
TAB_NOW[1],
TAB_NOW_PATH[1],
TAB_NOW[2],
TAB_NOW_PATH[2],
TAB_NOW[3],
TAB_NOW_PATH[3],
SRC_PATH,
SRC_PATH,
SRC_PATH,
PROFILE['page title'],
PROFILE['caption'])
foot = """\
</div>
</div>
<script src="%sjs/copy.js"></script>
<script src="%sjs/scroll.js"></script>
<script src="%sjs/sidebar.js"></script>
<script src="%sjs/details.js"></script>
<script src="%sjs/i_btn.js"></script>
<script src="%sjs/pointerEffect.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="%sjs/fade.js"></script>
<script src="%sjs/counter.js"></script>
<script>
let topBtn = document.querySelector(".tmTopBtn");
$(window).on('load scroll', function(){
if ($(window).scrollTop() > 200) {
topBtn.classList.add("active");
} else {
topBtn.classList.remove("active");
}
});
</script>
<script src="%scount/count.php"></script>
</body>
</html>
"""%(SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH)
middle = """\
<div class="article">
<br>
<div class="title" id="fade_1">text</div>
<div class="text" id="fade_2">
<span id="jp_font">
text
</span>
</div>
</div>
"""
#### html書き込み
with open(MASTER_PATH+'/'+FILE_PATH, 'w') as f:
f.write(head+middle+foot if PROFILE['insert preset'] == 't' else head+foot)
#### html_profile.txtをリセットする関数
def reset():
with open('programs/html_profile.txt', 'w') as f:
f.write("""\
## directory ( /Users/osadamasashi/Desktop/ossa2019.stars.ne.jp/ ˜˜ )
## file name ( ˜˜ .html )
## title
## tab_now ( 0:index, 1:note, 2:programs, 3:remember )
1
## og:title ( shortcut name )
## og:description ( site's introduction )
## og:site_name ( 2nd shortcut name )
## og:type
blog
## page title
## caption
## insert preset ( 't' or 'f' )
t
## reset ( 't' or 'f' )
t
#% end""")
#### 最後の出力
none_value = ''
for k in PROFILE.keys():
if(PROFILE[k] == ''):
none_value += f'{k}, '
if not(len(none_value) == 0):
none_value = '\n空白の要素 : '+none_value[:len(none_value)-3]
print(none_value)
else:
print('\n空白の要素なし')
print(f'\n{FILE_PATH} を作成しました!\n')
#### html_profile.txtのリセット
if(__name__ == '__main__') and (PROFILE['reset'] == 't'):
reset()
#! encode : -*- utf-8 -*-
#% 新たなhtmlページの生成
import os
import pprint
import time
MASTER_PATH = '/Users/osadamasashi/Desktop/ossa2019.stars.ne.jp'
PROFILE_PATH = 'programs/html_profile.txt'
os.chdir(MASTER_PATH)
#### 愉快な関数たち
dir_path = lambda x : '' if x == '' else '../'*dir_count(x)
dir_count = lambda x : 0 if x == '' else len(x.split('/'))
slash = lambda x : '' if x == '' else '/'
def tab_where(x:str = '3') -> str:
x = '3' if x == '' else x
re = ['' for i in range(4)]
re[int(x)] = ' id="now"'
return re
def tab_where_path(x:str, d_path:str) -> list:
x = '3' if x == '' else x
dir_depth = dir_count(d_path)
re = ['../'*dir_depth for i in range(4)]
re[int(x)] = '../'*(dir_depth-1)
result = [re, re[int(x)], int(x)]
return result
with open(PROFILE_PATH, 'r') as f: profile_input = f.read().split('\n')
profile_arrange = []
for p in range(len(profile_input)):
if(len(profile_input[p]) == 0):
profile_arrange.append('')
elif not(profile_input[p][0] == '#'):
profile_arrange.append(profile_input[p])
#### 付加する変数たち
KEY_LIST = ['directory', 'file_name', 'title', 'tab_now', 'og:title', 'og:description', 'og:site_name', 'og:type', 'page title', 'caption', 'insert preset', 'reset']
PROFILE = dict(zip(KEY_LIST, profile_arrange))
pprint.pprint(PROFILE)
SRC_PATH = dir_path(PROFILE['directory'])
FILE_NAME = 'NoneName_'+str(time.time()) if PROFILE['file_name'] == '' else PROFILE['file_name']
FILE_PATH = PROFILE['directory']+slash(PROFILE['directory'])+FILE_NAME+'.html'
OG_SITE_NAME = PROFILE['og:title'] if PROFILE['og:site_name'] == '' else PROFILE['og:site_name']
OG_TYPE = 'blog' if PROFILE['og:type'] == '' else PROFILE['og:type']
TAB_NOW = tab_where(PROFILE['tab_now'])
TAB_NOW_ = tab_where_path(PROFILE['tab_now'], PROFILE['directory'])
TAB_NOW_PATH = TAB_NOW_[0]
TAB_LIST = ['index', 'apps', 'Remember/Remember', 'blog']
TAB_NOW_CHAR = TAB_NOW_[1]+TAB_LIST[TAB_NOW_[2]]
TAB_LIST_JUMP = ['トップ', 'アプリ', '備忘録', 'にっき']
TAB_NOW_CHAR_JUMP = TAB_LIST_JUMP[TAB_NOW_[2]]
#### htmlソース
head = """\
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="%spic/o.ico">
<link rel="shortcut icon" href="%spic/o.ico">
<link rel="apple-touch-icon-precomposed" href="%spic/o.png">
<!-- pc版css -->
<link rel="stylesheet" href="%scss/mainContent.css" media="screen and (min-width:600px)">
<link rel="stylesheet" href="%scss/sidebar.css" media="screen and (min-width:600px)">
<link rel="stylesheet" href="%scss/pointerEffect.css" media="screen and (min-width:600px)">
<!-- モバイル版css -->
<link rel="stylesheet" href="%scss/sidebar_mobile.css" media="screen and (max-width:599px)">
<link rel="stylesheet" href="%scss/mainContent_mobile.css" media="screen and (max-width:599px)">
<link rel="stylesheet" href="%scss/pointerEffect_mobile.css" media="screen and (max-width:599px)">
<link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'>
<meta property="og:title" content="%s">
<meta property="og:description" content="%s">
<meta property="og:site_name" content="%s">
<meta property="og:type" content="%s">
<meta property="og:url" content="https://ossa2019.stars.ne.jp/%s">
<title>%s</title>
</head>
<body>
<div class="sidebar">
<div class="logo_content">
<div class="logo">
<!-- <i class='bx bxl-python'></i> -->
<img src="%spic/o_alpha.PNG">
<div class="name" id="jp_font">
おさだのホームページ
</div>
</div>
<i class='bx bx-menu' id="open_btn"></i>
<i class='bx bx-x' id="close_btn"></i>
</div>
<ul class="page_list">
<!-- search -->
<li>
<i class='bx bx-search'></i>
<input type="text" placeholder="サイト内検索..." id="search-key">
<i class='bx bx-right-arrow-circle' id="search_btn" onclick="jump()"></i>
</li>
<!-- home -->
<li%s>
<a href="%sindex.html">
<i class='bx bx-home'></i>
<span class="link_name">home</span>
</a>
<span class="popup_text">home</span>
</li>
<!-- note -->
<li%s>
<a href="%sblog.html">
<i class='bx bx-book'></i>
<span class="link_name">note</span>
</a>
<span class="popup_text">note</span>
</li>
<!-- programs -->
<li%s>
<a href="%sapps.html">
<i class='bx bx-code-alt'></i>
<span class="link_name">programs</span>
</a>
<span class="popup_text">programs</span>
</li>
<!-- remember -->
<li%s>
<a href="%sRemember/Remember.html">
<i class='bx bx-paperclip'></i>
<span class="link_name">remember</span>
</a>
<span class="popup_text">remember</span>
</li>
<li>
<!-- space -->
</li>
<!-- 基本情報技術者試験 -->
<li>
<a href="%sjouhou.html" target="_blank" rel="noopener noreferrer">
<i class='bx bx-radio-circle'></i>
<span class="link_name" id="jp_font">基本情報技術者試験の解答</span>
</a>
<span class="popup_text" id="jp_font">基本情報技術者試験の解答</span>
</li>
<!-- 文字数カウンター -->
<li>
<a href="%stext.html" target="_blank" rel="noopener noreferrer">
<i class='bx bx-radio-circle'></i>
<span class="link_name" id="jp_font">文字数カウンター</span>
</a>
<span class="popup_text" id="jp_font">文字数カウンター</span>
</li>
<li></li>
<!-- secret page -->
<li id="secret">
<a href="%smyPage/home.html" target="_blank" rel="noopener noreferrer" id="secret_page">
<i class='bx bx-key'></i>
<span class="link_name">test page</span>
</a>
<span class="popup_text_secret">test page</span>
</li>
</ul>
<div class="profile_content">
<div class="profile">
<div class="profile_details">
<div class="subscript">Writer</div>
<div class="name">
Osada Masashi
<br>
<a href="https://x.com/Masashi_Osada" target="_blank" rel="noopener noreferrer">
</a>
</div>
</div>
</div>
</div>
</div>
<div class="main_content">
<div class="tmTopBtn" id="topScroll" onclick="tmTopScroll()">
<i class='bx bx-upvote'></i>
<br>
<span class="topScroll_ception">
top
</span>
</div>
<div class="text_content">
<div class="top_title_text" id="jp_font">おさだのホームページ</div>
<br>
<div class="page_title" id="fade_0">
<div class="title_text">
%s
</div>
<div class="caption_text" id="jp_font">
%s
</div>
</div>
"""%(SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH,
PROFILE['og:title'],
PROFILE['og:description'],
OG_SITE_NAME,
OG_TYPE,
FILE_PATH,
PROFILE['title'],
SRC_PATH,
TAB_NOW[0],
TAB_NOW_PATH[0],
TAB_NOW[1],
TAB_NOW_PATH[1],
TAB_NOW[2],
TAB_NOW_PATH[2],
TAB_NOW[3],
TAB_NOW_PATH[3],
SRC_PATH,
SRC_PATH,
SRC_PATH,
PROFILE['page title'],
PROFILE['caption'])
foot = """\
</div>
</div>
<script src="%sjs/copy.js"></script>
<script src="%sjs/scroll.js"></script>
<script src="%sjs/sidebar.js"></script>
<script src="%sjs/details.js"></script>
<script src="%sjs/i_btn.js"></script>
<script src="%sjs/pointerEffect.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="%sjs/fade.js"></script>
<script src="%sjs/counter.js"></script>
<script>
let topBtn = document.querySelector(".tmTopBtn");
$(window).on('load scroll', function(){
if ($(window).scrollTop() > 200) {
topBtn.classList.add("active");
} else {
topBtn.classList.remove("active");
}
});
</script>
<script src="%scount/count.php"></script>
</body>
</html>
"""%(SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH,
SRC_PATH, SRC_PATH, SRC_PATH)
middle = """\
<div class="article">
<br>
<div class="title" id="fade_1">text</div>
<div class="text" id="fade_2">
<span id="jp_font">
text
</span>
</div>
</div>
"""
#### html書き込み
with open(MASTER_PATH+'/'+FILE_PATH, 'w') as f:
f.write(head+middle+foot if PROFILE['insert preset'] == 't' else head+foot)
#### html_profile.txtをリセットする関数
def reset():
with open('programs/html_profile.txt', 'w') as f:
f.write("""\
## directory ( /Users/osadamasashi/Desktop/ossa2019.stars.ne.jp/ ˜˜ )
## file name ( ˜˜ .html )
## title
## tab_now ( 0:index, 1:note, 2:programs, 3:remember )
1
## og:title ( shortcut name )
## og:description ( site's introduction )
## og:site_name ( 2nd shortcut name )
## og:type
blog
## page title
## caption
## insert preset ( 't' or 'f' )
t
## reset ( 't' or 'f' )
t
#% end""")
#### 最後の出力
none_value = ''
for k in PROFILE.keys():
if(PROFILE[k] == ''):
none_value += f'{k}, '
if not(len(none_value) == 0):
none_value = '\n空白の要素 : '+none_value[:len(none_value)-3]
print(none_value)
else:
print('\n空白の要素なし')
print(f'\n{FILE_PATH} を作成しました!\n')
#### html_profile.txtのリセット
if(__name__ == '__main__') and (PROFILE['reset'] == 't'):
reset()
○ 作成するHTMLの設定情報【テキスト】
copy
copied!
html_profile.txt
展開
折り畳む
## directory ( /Users/osadamasashi/Desktop/ossa2019.stars.ne.jp/ ˜˜ )
## file name ( ˜˜ .html )
## title
## tab_now ( 0:index, 1:note, 2:programs, 3:remember )
1
## og:title ( shortcut name )
## og:description ( site's introduction )
## og:site_name ( 2nd shortcut name )
## og:type
blog
## page title
## caption
## insert preset ( 't' or 'f' )
t
## reset ( 't' or 'f' )
t
#% end
## file name ( ˜˜ .html )
## title
## tab_now ( 0:index, 1:note, 2:programs, 3:remember )
1
## og:title ( shortcut name )
## og:description ( site's introduction )
## og:site_name ( 2nd shortcut name )
## og:type
blog
## page title
## caption
## insert preset ( 't' or 'f' )
t
## reset ( 't' or 'f' )
t
#% end
○ サイトマップの生成【Python】
copy
copied!
make_sitemap.py
展開
折り畳む
#! /usr/local/bin/env python3
#! encode : -*- utf-8 -*-
#% sitemapの生成(URL, priority, lastmod)
import os
import pathlib
import datetime
import pprint
os.chdir("/Users/osadamasashi/Desktop/ossa2019.stars.ne.jp")
SITE_NAME = "https://ossa2019.stars.ne.jp/"
PROFILE_PATH = "programs/sitemap_profile.txt"
OUTPUT_PATH = "sitemap.xml"
top_data = ["", ""]
#### sitemap_profileの読み込み
with open(PROFILE_PATH, "r", encoding="utf8") as f:
input_txt = f.read().split("\n")[1:]
profile = dict()
for i in input_txt:
if(len(i) != 0) and (i[0] != "#") and (i[0] != ":"):
bf = i.split(":")
bf[0] = bf[0].replace(" ", "")
bf[1] = bf[1].replace(" ", "")
profile[bf[0]] = bf[1]
elif(i[0] == ":"):
top_data[0] = i[1:]
#### sitemapの生成
result = """\
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- created with Python program (made by osada https://ossa2019.stars.ne.jp) -->"""
for p in profile.keys():
result += f"\n<url>\n <loc>{SITE_NAME}{p}.html</loc>\n <priority>{profile[p]}</priority>\n <lastmod>"
file = pathlib.Path(p+".html")
dt = datetime.datetime.fromtimestamp(file.stat().st_mtime)
dt_str = dt.strftime("%Y-%m-%dT%H:%M:%S+09:00")
if(p == "index"):
top_data[1] = dt_str
result += dt_str + "</lastmod>\n </url>"
result += """
<url>
<loc>https://ossa2019.stars.ne.jp/</loc>
<priority>%s</priority>
<lastmod>%s</lastmod>
</url>
</urlset>
"""%(top_data[0], top_data[1])
#### 書き込み
with open(OUTPUT_PATH, "w", encoding="utf8") as f:
f.write(result)
#### 最後の出力
pprint.pprint(profile)
print(f"\n{OUTPUT_PATH}に書き込みました。\n")
#! encode : -*- utf-8 -*-
#% sitemapの生成(URL, priority, lastmod)
import os
import pathlib
import datetime
import pprint
os.chdir("/Users/osadamasashi/Desktop/ossa2019.stars.ne.jp")
SITE_NAME = "https://ossa2019.stars.ne.jp/"
PROFILE_PATH = "programs/sitemap_profile.txt"
OUTPUT_PATH = "sitemap.xml"
top_data = ["", ""]
#### sitemap_profileの読み込み
with open(PROFILE_PATH, "r", encoding="utf8") as f:
input_txt = f.read().split("\n")[1:]
profile = dict()
for i in input_txt:
if(len(i) != 0) and (i[0] != "#") and (i[0] != ":"):
bf = i.split(":")
bf[0] = bf[0].replace(" ", "")
bf[1] = bf[1].replace(" ", "")
profile[bf[0]] = bf[1]
elif(i[0] == ":"):
top_data[0] = i[1:]
#### sitemapの生成
result = """\
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- created with Python program (made by osada https://ossa2019.stars.ne.jp) -->"""
for p in profile.keys():
result += f"\n<url>\n <loc>{SITE_NAME}{p}.html</loc>\n <priority>{profile[p]}</priority>\n <lastmod>"
file = pathlib.Path(p+".html")
dt = datetime.datetime.fromtimestamp(file.stat().st_mtime)
dt_str = dt.strftime("%Y-%m-%dT%H:%M:%S+09:00")
if(p == "index"):
top_data[1] = dt_str
result += dt_str + "</lastmod>\n </url>"
result += """
<url>
<loc>https://ossa2019.stars.ne.jp/</loc>
<priority>%s</priority>
<lastmod>%s</lastmod>
</url>
</urlset>
"""%(top_data[0], top_data[1])
#### 書き込み
with open(OUTPUT_PATH, "w", encoding="utf8") as f:
f.write(result)
#### 最後の出力
pprint.pprint(profile)
print(f"\n{OUTPUT_PATH}に書き込みました。\n")
○ サイトマップに含めるページと優先度の設定【テキスト】
copy
copied!
sitemap_profile.txt
展開
折り畳む
#% file pass (https://ossa2019.stars.ne.jp/ ˜˜ .html) : priority
: 1.0
### independent pages
index : 1.0
apps : 1.0
## other site pages
jouhou : 1.0
text : 1.0
### blog pages
blog/blog : 0.5
## chromeEx
blog/chromeEx/chromeEx1 : 0.8
## other
blog/other/plot_anime : 0.8
blog/other/python3_10 : 0.8
blog/other/python_benri : 0.8
blog/other/linear_separation : 0.8
blog/other/rsa : 0.8
blog/other/font_class : 0.8
## number
blog/number/mandelblot : 0.8
blog/number/long_division : 0.8
blog/number/comp_binomial : 0.8
blog/number/complex : 0.8
blog/number/diff : 0.8
blog/number/isprime : 0.8
## meiro
blog/meiro/meiro1 : 0.5
blog/meiro/meiro2 : 0.5
blog/meiro/meiro3 : 0.5
### Remember pages
Remember/Remember : 0.5
## html
Remember/html/target : 1.0
## tkinter
Remember/tkinter/tkinter : 1.0
Remember/tkinter/tk1 : 1.0
Remember/tkinter/tk2 : 1.0
Remember/tkinter/tk3 : 1.0
Remember/tkinter/tk4 : 1.0
Remember/tkinter/tk5 : 1.0
Remember/tkinter/tk6 : 1.0
Remember/tkinter/tk7 : 1.0
Remember/tkinter/tk8 : 1.0
Remember/tkinter/tk9 : 1.0
Remember/tkinter/tk10 : 1.0
Remember/tkinter/tk11 : 1.0
#% end
: 1.0
### independent pages
index : 1.0
apps : 1.0
## other site pages
jouhou : 1.0
text : 1.0
### blog pages
blog/blog : 0.5
## chromeEx
blog/chromeEx/chromeEx1 : 0.8
## other
blog/other/plot_anime : 0.8
blog/other/python3_10 : 0.8
blog/other/python_benri : 0.8
blog/other/linear_separation : 0.8
blog/other/rsa : 0.8
blog/other/font_class : 0.8
## number
blog/number/mandelblot : 0.8
blog/number/long_division : 0.8
blog/number/comp_binomial : 0.8
blog/number/complex : 0.8
blog/number/diff : 0.8
blog/number/isprime : 0.8
## meiro
blog/meiro/meiro1 : 0.5
blog/meiro/meiro2 : 0.5
blog/meiro/meiro3 : 0.5
### Remember pages
Remember/Remember : 0.5
## html
Remember/html/target : 1.0
## tkinter
Remember/tkinter/tkinter : 1.0
Remember/tkinter/tk1 : 1.0
Remember/tkinter/tk2 : 1.0
Remember/tkinter/tk3 : 1.0
Remember/tkinter/tk4 : 1.0
Remember/tkinter/tk5 : 1.0
Remember/tkinter/tk6 : 1.0
Remember/tkinter/tk7 : 1.0
Remember/tkinter/tk8 : 1.0
Remember/tkinter/tk9 : 1.0
Remember/tkinter/tk10 : 1.0
Remember/tkinter/tk11 : 1.0
#% end
○ PythonやJavaScriptのテキストを装飾付きのHTML形式に変換【Python】
copy
copied!
toHtml.py
展開
折り畳む
#! /usr/local/bin/env python3
#! encode : -*- utf-8 -*-
import tkinter as t
def func(code:str=None):
# 通常変換
def rep(xs):
xs = xs.replace('&', '&')
#xs = xs.replace('\t', '	')
xs = xs.replace('\t', ' ')
#xs = xs.replace('\t', '  ')
xs = xs.replace(' ', ' ')
xs = xs.replace('<', '<')
xs = xs.replace('>', '>')
xs = xs.replace('¥', '¥')
xs = xs.replace('←', '←')
xs = xs.replace('↑', '↑')
xs = xs.replace('→', '→')
xs = xs.replace('↓', '↓')
xs = xs.replace('ˆ', 'ˆ')
xs = xs.replace('˜', '˜')
xs = xs.replace('—', '—')
xs = xs.replace('"', '"')
xs = xs.replace('\n', '<br>\n')
return xs
frm = inp.get(0., t.END)
boo = [ True, True ]
new = ''
for i in frm:
boo[1] = True
if(boo[0]):
if(i == ' '):
new += ' '
boo[1] = False
else:
boo[0] = False
if(i == '\n'):
boo[0] = True
if(boo[1]):
new += rep(i)
if(code=='py'):
new = rep_py(new)
elif(code=='html'):
new = rep_html(new)
new = rep_html_1(new)
elif(code=='js'):
new = rep_js(new)
elif(code=='sp'):
new = rep_sp(new)
if(new[ len(new)-5: ] == '<br>\n'):
new = new[ :len(new)-5 ]
out.delete(0., t.END)
out.insert(0., new)
if(len(new) == 0):
first()
def func_py(event):
func('py')
def func_html(event):
func('html')
def func_js(event):
func('js')
def func_sp(event):
func('sp')
# Python
def rep_py(xs):
# ValueError
xs = xs.replace('ValueError', '<span class="dec4">ValueError</span>')
# dec0
lis0 = ['def', 'return', 'import', 'pass', 'yield', 'lambda', 'raise', 'break', 'continue', 'with', 'while', 'from', 'match', 'case']
for l in lis0:
xs = xs.replace(l, '<span class="dec0">'+l+'</span>')
xs = xs.replace('class ', '<span class="dec0">class</span> ')
# dec1
xs = xs.replace('elif', '<span class="dec1">el</span>if')
xs = xs.replace('if(', '<span class="dec1">if</span>(')
lis1 = ['else', 'try', 'except']
lis1_space = ['if', 'for', 'in', 'is', 'as']
for l in lis1:
xs = xs.replace(l, '<span class="dec1">'+l+'</span>')
for l in lis1_space:
xs = xs.replace(l+' ', '<span class="dec1">'+l+'</span> ')
# dec2
xs = xs.replace('kwargs', '<span class="dec2">kw</span>args')
lis2 = ['self', '@', 'event', 'args']
for l in lis2:
xs = xs.replace(l, '<span class="dec2">'+l+'</span>')
# dec3
lis3 = ['True', 'False', 'None']
lis3_space = ['not', 'and', 'or']
lis3_kakko = ['not', 'and', 'or']
for l in lis3:
xs = xs.replace(l, '<span class="dec3">'+l+'</span>')
for l in lis3_space:
xs = xs.replace(l+' ', '<span class="dec3">'+l+'</span> ')
for l in lis3_kakko:
xs = xs.replace(l+'(', '<span class="dec3">'+l+'</span>(')
# dec4
lis4_underScore = ['init', 'name', 'main', 'del', 'new']
lis4_kakko = ['print', 'range', 'type', 'super', 'replace', 'open', 'close', 'read', 'write', 'isinstance', 'len', 'chr', 'ord', 'append', 'pop', 'get',
'int', 'float', 'str', 'byte', 'list', 'dict', 'set', 'taple', 'max', 'min', 'sum', 'abs', 'translate', 'maketrans']
for l in lis4_underScore:
xs = xs.replace('__'+l+'__', '<span class="dec4">__'+l+'__</span>')
for l in lis4_kakko:
xs = xs.replace(l+'(', '<span class="dec4">'+l+'</span>(')
# dec5
# なし
xs = xs.replace('auth<span class="dec3">or</span>', 'author')
return xs
# HTMl
def rep_html(xs):
# space
xs = xs.replace('    ', '  ')
# class, span
xs = xs.replace(' class', ' <span class="dec1">class</span>')
xs = xs.replace('</span', '</<span class="dec0">span</span>')
xs = xs.replace('<span', '<<span class="dec0">span</span>')
# dec0
lis0 = ['html', 'body', 'head', 'meta', '!DOCTYPE html', 'link', 'title', 'div', 'p1', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p', 'p0', 'a', 'section', 'br', 'hr', 'script',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9', 'h10', 'details', 'summary', 'form', 'table', 'tr', 'td', 'input', 'textarea', 'img', 'select', 'label', 'area', 'button', 'frameset', 'main']
for l in lis0:
xs = xs.replace('<'+l, '<<span class="dec0">'+l+'</span>')
xs = xs.replace('</'+l, '</<span class="dec0">'+l+'</span>')
# dec1
lis1 = ['lang', 'charset', 'name', 'content', 'rel', 'href', 'media', 'property', 'id', 'style', 'src', 'action', 'type', 'value', 'size', 'checked', 'target', 'width', 'height',
'onclick', 'ondbclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmouseout', 'onkeypress', 'onkeyup', 'onkeydown', 'onload', 'onunload', 'onfocus', 'onblur', 'onsubmit', 'onreset', 'onselect', 'onchange', 'align', 'border']
for l in lis1:
xs = xs.replace(' '+l, ' <span class="dec1">'+l+'</span>')
# dec2
# なし
# dec3
# rep_html_1()
# dec4
# なし
# dec5
lis5 = ['altername', 'canonial', 'author', 'bookmark', 'icon', 'shortcut icon', 'stylesheet', 'og:title', 'og:description', 'og:site_name', 'og:type', 'og:url', 'apple-touch-icon-precomposed', 'UTF-8', 'SHIFT-JIS', 'viewport', 'ja', 'en']
for l in lis5:
xs = xs.replace('\''+l+'\'', '\'<span class="dec5">'+l+'</span>\'')
xs = xs.replace('"'+l+'"', '"<span class="dec5">'+l+'</span>"')
return xs
# HTML 特殊文字
def rep_html_1(xs):
# dec3
lis3 = ['ensp', 'lt', 'gt', 'emsp', 'amp', '#9', 'yen', 'larr', 'uarr', 'rarr', 'darr', 'circ', 'tilde', 'mdash', 'quot']
for l in lis3:
xs = xs.replace('&'+l+';', '<span class="dec3">&'+l+';</span>')
return xs
# JavaScript
def rep_js(xs):
# dec0
lis0 = ['function', 'let', 'const', 'var']
for l in lis0:
xs = xs.replace(l, '<span class="dec0">'+l+'</span>')
# dec1
lis1 = ['for', 'else', 'try', 'catch', 'return', 'break', 'continue']
for l in lis1:
xs = xs.replace(l, '<span class="dec1">'+l+'</span>')
xs = xs.replace('elif', '<span class="dec1">el</span>if')
xs = xs.replace('if(', '<span class="dec1">if</span>(')
xs = xs.replace('if (', '<span class="dec1">if</span> (')
# dec2
xs = xs.replace('\'use strict\';', '<span class="dec2">\'use strict\';</span>')
xs = xs.replace('"use strict";', '<span class="dec2">"use strict";</span>')
# dec3
lis3 = ['true', 'false', 'none', 'String', 'Boolean', 'int', 'float', 'any', 'Number']
for l in lis3:
xs = xs.replace(l, '<span class="dec3">'+l+'</span>')
# dec4
lis4 = ['window', 'console', 'log', 'confirm', 'alert', 'document', 'body', 'documentElement', 'scrollLeft', 'scrollRight', 'scrollTop', 'scrollBottom', 'location', 'href', 'Math', 'round'
,'getElementById', 'getElementsByName', 'getElementsByClassName', 'event', 'innerHTML', 'value', 'onsubmit', 'onclick', 'onkeyup', 'onkeydown', 'replace', 'length', 'textContent', 'checked',
'fromCharCode', 'charCodeAt', 'keyup', 'click', 'submit', 'keydown', 'execCommand', 'addEventListener', 'select', 'innerText']
for l in lis4:
xs = xs.replace(l, '<span class="dec4">'+l+'</span>')
xs = xs.replace('pr<span class="dec4">event</span>Default', '<span class="dec4">preventDefault</span>')
# dec5
return xs
#特殊変換
def rep_sp(xs):
#dec2
lis2 = ['*']
for l in lis2:
xs = xs.replace(l, '<span class="dec2">'+l+'</span>')
#dec6
lis6 = ['>>', '$', '%']
for l in lis6:
xs = xs.replace(l, '<span class="dec6">'+l+'</span>')
return xs
def first():
out.insert(0., '←左画面にHtmlに変換したい文章を入力')
def main():
global app, inp, out
app = t.Tk()
app.geometry('1300x625')
app.title('Text to Html 変換アプリ')
app.resizable(width=False, height=False)
inp = t.Text(app, background='#f0f0e0', font=('Arial',12))
inp.place(x=0, y=0, width=500, height=600)
out = t.Text(app, background='#d0d0f8', font=('Arial',12))
out.place(x=500, y=0, width=800, height=600)
but = t.Button(text=u'通常変換', background='#ffaaaa')
but.place(x=5, y=600, width=70, height=20)
but.bind('<Button-1>', func)
but_py = t.Button(text=u'Python', background='#ffffff')
but_py.place(x=75, y=600, width=70, height=20)
but_py.bind('<Button-1>', func_py)
but_html = t.Button(text=u'HTML', background='#ffffff')
but_html.place(x=145, y=600, width=70, height=20)
but_html.bind('<Button-1>', func_html)
but_js = t.Button(text=u'JavaScript', background='#ffffff')
but_js.place(x=215, y=600, width=70, height=20)
but_js.bind('<Button-1>', func_js)
but_sp = t.Button(text=u'特殊変換', background='#ffffff')
but_sp.place(x=285, y=600, width=70, height=20)
but_sp.bind('<Button-1>', func_sp)
but['background'] = '#ffffff'
but_py['background'] = '#ffffff'
but_html['background'] = '#ffffff'
but_js['background'] = '#ffffff'
but_sp['background'] = '#ffffff'
app.bind('<Key-v>', func)
first()
app.mainloop()
if(__name__ == '__main__'):
main()
#! encode : -*- utf-8 -*-
import tkinter as t
def func(code:str=None):
# 通常変換
def rep(xs):
xs = xs.replace('&', '&')
#xs = xs.replace('\t', '	')
xs = xs.replace('\t', ' ')
#xs = xs.replace('\t', '  ')
xs = xs.replace(' ', ' ')
xs = xs.replace('<', '<')
xs = xs.replace('>', '>')
xs = xs.replace('¥', '¥')
xs = xs.replace('←', '←')
xs = xs.replace('↑', '↑')
xs = xs.replace('→', '→')
xs = xs.replace('↓', '↓')
xs = xs.replace('ˆ', 'ˆ')
xs = xs.replace('˜', '˜')
xs = xs.replace('—', '—')
xs = xs.replace('"', '"')
xs = xs.replace('\n', '<br>\n')
return xs
frm = inp.get(0., t.END)
boo = [ True, True ]
new = ''
for i in frm:
boo[1] = True
if(boo[0]):
if(i == ' '):
new += ' '
boo[1] = False
else:
boo[0] = False
if(i == '\n'):
boo[0] = True
if(boo[1]):
new += rep(i)
if(code=='py'):
new = rep_py(new)
elif(code=='html'):
new = rep_html(new)
new = rep_html_1(new)
elif(code=='js'):
new = rep_js(new)
elif(code=='sp'):
new = rep_sp(new)
if(new[ len(new)-5: ] == '<br>\n'):
new = new[ :len(new)-5 ]
out.delete(0., t.END)
out.insert(0., new)
if(len(new) == 0):
first()
def func_py(event):
func('py')
def func_html(event):
func('html')
def func_js(event):
func('js')
def func_sp(event):
func('sp')
# Python
def rep_py(xs):
# ValueError
xs = xs.replace('ValueError', '<span class="dec4">ValueError</span>')
# dec0
lis0 = ['def', 'return', 'import', 'pass', 'yield', 'lambda', 'raise', 'break', 'continue', 'with', 'while', 'from', 'match', 'case']
for l in lis0:
xs = xs.replace(l, '<span class="dec0">'+l+'</span>')
xs = xs.replace('class ', '<span class="dec0">class</span> ')
# dec1
xs = xs.replace('elif', '<span class="dec1">el</span>if')
xs = xs.replace('if(', '<span class="dec1">if</span>(')
lis1 = ['else', 'try', 'except']
lis1_space = ['if', 'for', 'in', 'is', 'as']
for l in lis1:
xs = xs.replace(l, '<span class="dec1">'+l+'</span>')
for l in lis1_space:
xs = xs.replace(l+' ', '<span class="dec1">'+l+'</span> ')
# dec2
xs = xs.replace('kwargs', '<span class="dec2">kw</span>args')
lis2 = ['self', '@', 'event', 'args']
for l in lis2:
xs = xs.replace(l, '<span class="dec2">'+l+'</span>')
# dec3
lis3 = ['True', 'False', 'None']
lis3_space = ['not', 'and', 'or']
lis3_kakko = ['not', 'and', 'or']
for l in lis3:
xs = xs.replace(l, '<span class="dec3">'+l+'</span>')
for l in lis3_space:
xs = xs.replace(l+' ', '<span class="dec3">'+l+'</span> ')
for l in lis3_kakko:
xs = xs.replace(l+'(', '<span class="dec3">'+l+'</span>(')
# dec4
lis4_underScore = ['init', 'name', 'main', 'del', 'new']
lis4_kakko = ['print', 'range', 'type', 'super', 'replace', 'open', 'close', 'read', 'write', 'isinstance', 'len', 'chr', 'ord', 'append', 'pop', 'get',
'int', 'float', 'str', 'byte', 'list', 'dict', 'set', 'taple', 'max', 'min', 'sum', 'abs', 'translate', 'maketrans']
for l in lis4_underScore:
xs = xs.replace('__'+l+'__', '<span class="dec4">__'+l+'__</span>')
for l in lis4_kakko:
xs = xs.replace(l+'(', '<span class="dec4">'+l+'</span>(')
# dec5
# なし
xs = xs.replace('auth<span class="dec3">or</span>', 'author')
return xs
# HTMl
def rep_html(xs):
# space
xs = xs.replace('    ', '  ')
# class, span
xs = xs.replace(' class', ' <span class="dec1">class</span>')
xs = xs.replace('</span', '</<span class="dec0">span</span>')
xs = xs.replace('<span', '<<span class="dec0">span</span>')
# dec0
lis0 = ['html', 'body', 'head', 'meta', '!DOCTYPE html', 'link', 'title', 'div', 'p1', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p', 'p0', 'a', 'section', 'br', 'hr', 'script',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9', 'h10', 'details', 'summary', 'form', 'table', 'tr', 'td', 'input', 'textarea', 'img', 'select', 'label', 'area', 'button', 'frameset', 'main']
for l in lis0:
xs = xs.replace('<'+l, '<<span class="dec0">'+l+'</span>')
xs = xs.replace('</'+l, '</<span class="dec0">'+l+'</span>')
# dec1
lis1 = ['lang', 'charset', 'name', 'content', 'rel', 'href', 'media', 'property', 'id', 'style', 'src', 'action', 'type', 'value', 'size', 'checked', 'target', 'width', 'height',
'onclick', 'ondbclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmouseout', 'onkeypress', 'onkeyup', 'onkeydown', 'onload', 'onunload', 'onfocus', 'onblur', 'onsubmit', 'onreset', 'onselect', 'onchange', 'align', 'border']
for l in lis1:
xs = xs.replace(' '+l, ' <span class="dec1">'+l+'</span>')
# dec2
# なし
# dec3
# rep_html_1()
# dec4
# なし
# dec5
lis5 = ['altername', 'canonial', 'author', 'bookmark', 'icon', 'shortcut icon', 'stylesheet', 'og:title', 'og:description', 'og:site_name', 'og:type', 'og:url', 'apple-touch-icon-precomposed', 'UTF-8', 'SHIFT-JIS', 'viewport', 'ja', 'en']
for l in lis5:
xs = xs.replace('\''+l+'\'', '\'<span class="dec5">'+l+'</span>\'')
xs = xs.replace('"'+l+'"', '"<span class="dec5">'+l+'</span>"')
return xs
# HTML 特殊文字
def rep_html_1(xs):
# dec3
lis3 = ['ensp', 'lt', 'gt', 'emsp', 'amp', '#9', 'yen', 'larr', 'uarr', 'rarr', 'darr', 'circ', 'tilde', 'mdash', 'quot']
for l in lis3:
xs = xs.replace('&'+l+';', '<span class="dec3">&'+l+';</span>')
return xs
# JavaScript
def rep_js(xs):
# dec0
lis0 = ['function', 'let', 'const', 'var']
for l in lis0:
xs = xs.replace(l, '<span class="dec0">'+l+'</span>')
# dec1
lis1 = ['for', 'else', 'try', 'catch', 'return', 'break', 'continue']
for l in lis1:
xs = xs.replace(l, '<span class="dec1">'+l+'</span>')
xs = xs.replace('elif', '<span class="dec1">el</span>if')
xs = xs.replace('if(', '<span class="dec1">if</span>(')
xs = xs.replace('if (', '<span class="dec1">if</span> (')
# dec2
xs = xs.replace('\'use strict\';', '<span class="dec2">\'use strict\';</span>')
xs = xs.replace('"use strict";', '<span class="dec2">"use strict";</span>')
# dec3
lis3 = ['true', 'false', 'none', 'String', 'Boolean', 'int', 'float', 'any', 'Number']
for l in lis3:
xs = xs.replace(l, '<span class="dec3">'+l+'</span>')
# dec4
lis4 = ['window', 'console', 'log', 'confirm', 'alert', 'document', 'body', 'documentElement', 'scrollLeft', 'scrollRight', 'scrollTop', 'scrollBottom', 'location', 'href', 'Math', 'round'
,'getElementById', 'getElementsByName', 'getElementsByClassName', 'event', 'innerHTML', 'value', 'onsubmit', 'onclick', 'onkeyup', 'onkeydown', 'replace', 'length', 'textContent', 'checked',
'fromCharCode', 'charCodeAt', 'keyup', 'click', 'submit', 'keydown', 'execCommand', 'addEventListener', 'select', 'innerText']
for l in lis4:
xs = xs.replace(l, '<span class="dec4">'+l+'</span>')
xs = xs.replace('pr<span class="dec4">event</span>Default', '<span class="dec4">preventDefault</span>')
# dec5
return xs
#特殊変換
def rep_sp(xs):
#dec2
lis2 = ['*']
for l in lis2:
xs = xs.replace(l, '<span class="dec2">'+l+'</span>')
#dec6
lis6 = ['>>', '$', '%']
for l in lis6:
xs = xs.replace(l, '<span class="dec6">'+l+'</span>')
return xs
def first():
out.insert(0., '←左画面にHtmlに変換したい文章を入力')
def main():
global app, inp, out
app = t.Tk()
app.geometry('1300x625')
app.title('Text to Html 変換アプリ')
app.resizable(width=False, height=False)
inp = t.Text(app, background='#f0f0e0', font=('Arial',12))
inp.place(x=0, y=0, width=500, height=600)
out = t.Text(app, background='#d0d0f8', font=('Arial',12))
out.place(x=500, y=0, width=800, height=600)
but = t.Button(text=u'通常変換', background='#ffaaaa')
but.place(x=5, y=600, width=70, height=20)
but.bind('<Button-1>', func)
but_py = t.Button(text=u'Python', background='#ffffff')
but_py.place(x=75, y=600, width=70, height=20)
but_py.bind('<Button-1>', func_py)
but_html = t.Button(text=u'HTML', background='#ffffff')
but_html.place(x=145, y=600, width=70, height=20)
but_html.bind('<Button-1>', func_html)
but_js = t.Button(text=u'JavaScript', background='#ffffff')
but_js.place(x=215, y=600, width=70, height=20)
but_js.bind('<Button-1>', func_js)
but_sp = t.Button(text=u'特殊変換', background='#ffffff')
but_sp.place(x=285, y=600, width=70, height=20)
but_sp.bind('<Button-1>', func_sp)
but['background'] = '#ffffff'
but_py['background'] = '#ffffff'
but_html['background'] = '#ffffff'
but_js['background'] = '#ffffff'
but_sp['background'] = '#ffffff'
app.bind('<Key-v>', func)
first()
app.mainloop()
if(__name__ == '__main__'):
main()