Skip to content

Commit 2935f80

Browse files
committed
mac
1 parent 4fe6b8f commit 2935f80

File tree

6 files changed

+76
-35
lines changed

6 files changed

+76
-35
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
__pycache__
22
dist/
33
build/
4-
.vscode
4+
.vscode
5+
.*

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[[source]]
2-
url = "http://mirrors.aliyun.com/pypi/simple/"
2+
url = "https://mirrors.aliyun.com/pypi/simple/"
33
verify_ssl = true
44
name = "pypi"
55

Pipfile.lock

Lines changed: 50 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353

5454

5555
## 运行
56+
### Windows
5657
下载zip包,执行双击 typewords.exe
5758

5859
运行后,可点击左上角图标,在下拉菜单中选“属性”,设置字体Font,方便孩子看得更清楚。
60+
### Mac
61+
下载zip包,命令行或双击执行 typewords
62+

typewords.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,31 @@
22
import random
33
import excel
44
import time
5-
from colorama import init, Fore#, Style # Back
6-
5+
import sys
6+
import os
7+
from colorama import init, Fore, Back#, Style # Back
8+
from os import path
9+
debug = False
10+
#data = path.abspath(path.join(path.dirname(__file__), 'words.xlsx'))
11+
data = path.abspath(path.join(path.dirname(sys.argv[0])))+'/words.xlsx'
712
class TypeWords:
813
help_cmds={"/help":"相关命令帮助", "/exit":"退出","/choose":"选类别,[99]为全部","/next":"下一个类别"}
914
params = {"exit":False, "type":99}
1015
sheetnames={}
1116

1217
def __init__(self):
13-
18+
if debug:
19+
print( 'sys.argv[0] is', sys.argv[0] )
20+
print( 'sys.executable is', sys.executable )
21+
print( 'os.getcwd is', os.getcwd() )
22+
bundle_dir = path.abspath(path.dirname(__file__))
23+
print( 'bundle_dir is', bundle_dir)
24+
print( '__file__ path is ',path.dirname(__file__))
25+
print( 'data is',data)
1426
self.points = 0
1527
self.dicts={}
1628
# get words
17-
self.words = excel.ReadExcel('words.xlsx')
29+
self.words = excel.ReadExcel(data)
1830
self.cmds={"/help":self.help_print, "/choose":self.choose_types,"/exit":self.exit,
1931
"/next":self.next_type}
2032

@@ -71,7 +83,7 @@ def practise(self):
7183
leng = len(word)
7284
print()
7385
print(Fore.CYAN+"---points: %d---" % (self.points, ))
74-
print(Fore.WHITE+self.dicts[word])
86+
print(Fore.RESET+self.dicts[word])
7587
print(Fore.GREEN)
7688
print(word)
7789
print(Fore.YELLOW, end="")
@@ -98,4 +110,4 @@ def practise(self):
98110
if __name__ == '__main__':
99111
init()
100112
t = TypeWords()
101-
t.practise()
113+
t.practise()

typewords.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ block_cipher = None
77
a = Analysis(['typewords.py'],
88
pathex=[],
99
binaries=[],
10-
datas=[],
10+
datas=[('words.xlsx', '.'), ('Readme.md', '.')],
1111
hiddenimports=[],
1212
hookspath=[],
1313
hooksconfig={},

0 commit comments

Comments
 (0)