Skip to content

Commit 296bf1e

Browse files
committed
初始化
1 parent 2813ce5 commit 296bf1e

File tree

11 files changed

+154
-3
lines changed

11 files changed

+154
-3
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ MANIFEST
3131
# Usually these files are written by a python script from a template
3232
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3333
*.manifest
34-
*.spec
3534

3635
# Installer logs
3736
pip-log.txt
@@ -127,3 +126,6 @@ dmypy.json
127126

128127
# Pyre type checker
129128
.pyre/
129+
130+
# IDE
131+
.vscode

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2020, PytHub Project
3+
Copyright (c) 2020, Pythub Project
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# pythub
1+
# Pythub

src/aa.py

Whitespace-only changes.

src/bb.py

Whitespace-only changes.

src/build.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# _*_ coding:utf-8 _*_
2+
3+
pyinstaller\
4+
--onedir\
5+
--clean\
6+
--noconfirm\
7+
-w\
8+
build.spec

src/build.spec

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- mode: python -*-
2+
3+
BLOCK_CIPHER = None
4+
APP_NAME = 'Pythub'
5+
APP_APP = 'Pythub.app'
6+
APP_VERSION = '0.0.1'
7+
SCRIPTS = ['pythub.py']
8+
BINARIES = []
9+
DATAS = []
10+
HIDDEN_IMPORTS = [] # 源文件的依赖模块
11+
HOOKSPATH = []
12+
EXCLUDES = [] # 不需要打包的模块
13+
RUNTIME_HOOKS = []
14+
BUNDLE_IDENTIFIER = 'com.crogram.pythub' # 一般情况下Bundle ID的格式为:com.公司名称.项目名称
15+
UPX = True # 如果有UPX安装(执行Configure.py时检测),会压缩执行文件(Windows系统中的DLL也会)
16+
PATHEX = ['aa.py', 'bb.py', 'cc.py', '/Users/douzhenjiang/Projects/pythub/src']
17+
18+
a = Analysis(
19+
SCRIPTS,
20+
pathex = PATHEX,
21+
binaries=BINARIES,
22+
datas=DATAS,
23+
hiddenimports=HIDDEN_IMPORTS,
24+
hookspath=HOOKSPATH,
25+
runtime_hooks=RUNTIME_HOOKS,
26+
excludes=EXCLUDES,
27+
win_no_prefer_redirects=False,
28+
win_private_assemblies=False,
29+
cipher=BLOCK_CIPHER,
30+
noarchive=False
31+
)
32+
pyz = PYZ(
33+
a.pure,
34+
a.zipped_data,
35+
cipher=BLOCK_CIPHER
36+
)
37+
exe = EXE(
38+
pyz,
39+
a.scripts,
40+
[],
41+
exclude_binaries=True,
42+
name=APP_NAME,
43+
debug=False,
44+
bootloader_ignore_signals=False,
45+
strip=False,
46+
upx=UPX,
47+
console=False
48+
)
49+
coll = COLLECT(
50+
exe,
51+
a.binaries,
52+
a.zipfiles,
53+
a.datas,
54+
strip=False,
55+
upx=UPX,
56+
name=APP_NAME
57+
)
58+
app = BUNDLE(
59+
coll,
60+
name=APP_APP,
61+
icon=None,
62+
bundle_identifier=BUNDLE_IDENTIFIER,
63+
info_plist={
64+
'CFBundleName': APP_NAME,
65+
'CFBundleDisplayName': APP_NAME,
66+
'CFBundleExecutable': APP_NAME,
67+
'CFBundlePackageType': 'APPL',
68+
'CFBundleSupportedPlatforms': 'MacOSX',
69+
'CFBundleGetInfoString': "Dou Zhenjiang",
70+
'CFBundleIdentifier': BUNDLE_IDENTIFIER,
71+
'CFBundleVersion': APP_VERSION,
72+
'CFBundleInfoDictionaryVersion': APP_VERSION,
73+
'CFBundleShortVersionString': APP_VERSION,
74+
'NSHighResolutionCapable': True,
75+
'NSHumanReadableCopyright': 'Copyright © 2020, ' + APP_NAME + ', All Rights Reserved'
76+
}
77+
)

src/cc.py

Whitespace-only changes.

src/dev.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# _*_ coding:utf-8 _*_
2+
3+
pyinstaller\
4+
--onedir\
5+
--clean\
6+
--noconfirm\
7+
-p aa.py\
8+
-p bb.py\
9+
-p cc.py\
10+
-w\
11+
--osx-bundle-identifier com.pythub.app\
12+
--osx-name Pythub\
13+
pythub.py

src/pythub.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# _*_ coding:utf-8 _*_
2+
import tkinter
3+
4+
import aa
5+
import bb
6+
import cc
7+
import utils
8+
9+
window = tkinter.Tk()
10+
window.title('Pythub')
11+
window.resizable(width=False, height=False)
12+
utils.set_window_center(window, 800, 600)
13+
14+
window.mainloop() # 将窗口显示出来

src/utils.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# _*_ coding:utf-8 _*_
2+
# utils functions
3+
4+
5+
def set_window_center(window, width, height):
6+
"""设置窗口宽高及居中"""
7+
# 获取屏幕 宽、高
8+
w_s = window.winfo_screenwidth()
9+
h_s = window.winfo_screenheight()
10+
# 计算 x, y 位置
11+
x_co = (w_s - width) / 2
12+
y_co = (h_s - height) / 2 - 50
13+
window.geometry("%dx%d+%d+%d" % (width, height, x_co, y_co))
14+
window.minsize(width, height)
15+
16+
17+
def get_screen_size(window):
18+
"""获取屏幕 宽、高"""
19+
return window.winfo_screenwidth(), window.winfo_screenheight()
20+
21+
22+
def get_window_size(window):
23+
"""获取窗口 宽、高"""
24+
return window.winfo_reqwidth(), window.winfo_reqheight()
25+
26+
27+
def treeview_sort_column(tv, col, reverse):
28+
"""Treeview、列名、排列方式"""
29+
l = [(tv.set(k, col), k) for k in tv.get_children('')]
30+
# print(tv.get_children(''))
31+
l.sort(reverse=reverse) # 排序方式
32+
# rearrange items in sorted positions
33+
for index, (val, k) in enumerate(l): # 根据排序后索引移动
34+
tv.move(k, '', index)
35+
# print(k)
36+
tv.heading(col, command=lambda: treeview_sort_column(
37+
tv, col, not reverse)) # 重写标题,使之成为再点倒序的标题

0 commit comments

Comments
 (0)