Skip to content

Commit

Permalink
fix bugs when build2exe
Browse files Browse the repository at this point in the history
  • Loading branch information
Raibows committed Jul 26, 2020
1 parent 116ab90 commit 894fbd5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
.idea/
.vscode/
venv/
dist/
build/
7 changes: 3 additions & 4 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from word import WordBase

class MainPanel():
def __init__(self):
def __init__(self, database_path=None):
self.root = tk.Tk()
self.root.title("GitHub Raibows©")
self.root.geometry("500x380+550+300")
Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self):
bg='white', text='重新开始', command=self.restart_event)
self.restart.grid(row=0, column=2)

self.backend = WordBase()
self.backend = WordBase(path=database_path)
self.score_int = 0
self.now_word = None
self.tip_num = 3
Expand Down Expand Up @@ -90,5 +90,4 @@ def run(self):


if __name__ == '__main__':
gui = MainPanel()
gui.run()
pass
12 changes: 11 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
from gui import MainPanel
import sys
from os import path


if getattr(sys, 'frozen', False):
bundle_dir = getattr(sys, '_MEIPASS', path.abspath(path.dirname(__file__)))
path_to_dat = path.abspath(path.join(bundle_dir, 'database.cwp'))
else:
path_to_dat = 'database.cwp'

if __name__ == '__main__':
pass
gui = MainPanel(database_path=path_to_dat)
gui.run()
4 changes: 2 additions & 2 deletions word.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def __repr__(self):
return self.word

class WordBase():
def __init__(self):
self.path = r"database.cwp"
def __init__(self, path=None):
self.path = r"database.cwp" if not path else path
self.check_Chinese_regex = r"([\u4e00-\u9fa5]){4}"
self.words = read_database(self.path)
self.build_next_candidates()
Expand Down

0 comments on commit 894fbd5

Please sign in to comment.