Skip to content

Commit

Permalink
Fixed a bug related to set language after installing, and made some i…
Browse files Browse the repository at this point in the history
…mprovements.
  • Loading branch information
MahmoudAtef999 committed Apr 21, 2023
1 parent b4ef073 commit 70c0a77
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
21 changes: 13 additions & 8 deletions WikiSearch.iss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define MyAppName "WikiSearch"
#define MyAppVersion "1.3.0"
#define MyAppVersion "1.4.0"
#define MyAppPublisher "Tecwindow"
#define MyAppURL "https://t.me/tecwindow"
#define MyAppURL "https://tecwindow.net/"
#define MyAppExeName "WikiSearch.exe"

[Setup]
Expand Down Expand Up @@ -30,7 +30,7 @@ CloseApplications=force
restartApplications=yes
SolidCompression=yes
WizardStyle=modern

DisableWelcomePage=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "arabic"; MessagesFile: "compiler:Languages\Arabic.isl"
Expand All @@ -47,16 +47,21 @@ Source: "WikiSearch\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs cr
[CustomMessages]
arabic.AppLNGfile = Arabic
english.AppLNGfile = English
french.AppLNGfile = Français
spanish.AppLNGfile = Español
french.AppLNGfile = French
spanish.AppLNGfile = Spanish

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall

[INI]
Filename: "{userappdata}\WikiSearch\Settingss.ini"; Section: "default"; Key: "language"; String: "{cm:AppLNGfile}"
Filename: "{app}\User Data\Settingss.ini"; Section: "default"; Key: "language"; String: "{cm:AppLNGfile}"
Filename: "{app}\User Data\Settingss.ini"; Section: "default"; Key: "language"; String: "{cm:AppLNGfile}"

[InstallDelete]
Type: filesandordirs; Name: "{app}"

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall

11 changes: 7 additions & 4 deletions WikiSearch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#-*- coding: utf-8 -*-
# import project libraries.
from custome_errors import *
sys.excepthook = my_excepthook
import wx
import json
import nlpia2_wikipedia as wikipedia
Expand All @@ -9,7 +11,7 @@
import os
import sys
#change working dir to main exe dir
os.chdir(os.path.dirname(sys.argv[0]))
#os.chdir(os.path.dirname(sys.argv[0]))
import globals as g
from view_search_dialog import ViewSearch
from update_dialog import UpdateDialog
Expand All @@ -19,11 +21,12 @@
from packaging import version
from view_search_dialog import *


#Set language for main window
_ = SetLanguage(Settings().ReadSettings())

# information of program
CurrntVersion = "1.3.0"
CurrntVersion = "1.4.0"
ProgramName = "WikiSearch"
ProgramDescription = _("With this program, you can search or browse any Wikipedia article. site: https://github.com/tecwindow/WikiSearch")
CurrentSettings = Settings().ReadSettings()
Expand Down Expand Up @@ -331,8 +334,8 @@ def OnHelp(self, event):
language = {
"English": "en",
"Arabic": "ar",
"Español": "es",
"Français": "fr"
"Spanish": "es",
"French": "fr"
}

CurrentLanguage = language[CurrentSettings["language"]]
Expand Down
18 changes: 18 additions & 0 deletions custome_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import traceback
import os
import ctypes
import sys
def my_excepthook(exctype, value, tb):
tb_list = traceback.extract_tb(tb)
error_message = ""

for tb in tb_list:
file_name = os.path.basename(tb.filename)
line_number = tb.lineno
code = tb.line

error_message += f"\nFile: {file_name}\nLine: {line_number}\nCode: {code}\n"

error_message += f"\n{exctype.__name__}: {value}"

ctypes.windll.user32.MessageBoxW(None, error_message, "Error", 0x10)
4 changes: 2 additions & 2 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def SetLanguage(CurrentSettings):
language = {
"English": "en",
"Arabic": "ar",
"Español": "es",
"Français": "fr"
"Spanish": "es",
"French": "fr"
}

try:
Expand Down
9 changes: 8 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,15 @@ def __init__(self, parent):
#Save Settings function
def OnSaveSettings(self, event):

languages = {
"Arabic": "Arabic",
"English": "English",
"Español": "Spanish",
"Français": "French"
}

NewSettings = {
"language": self.ProgramLanguage.Value,
"language": languages[self.ProgramLanguage.Value],
"results number": str(self.NumberResults.Value),
"random articles number": str(self.random_articles_number.Value),
"close message": str(self.VerificationMsg.Value),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"packages": ["web_viewer", "view_search_dialog", "view_article_window", "update_dialog", "settings", "my_classes", "functions", "dialogs"],
"includes": ["wx", "nlpia2_wikipedia", "pyperclip", "accessible_output2", "mouse", "bs4", "requests", ],
"zip_include_packages": ["wx"],
"excludes": ["tkinter", "test", "setuptools", "PyInstaller", "pip"],
"excludes": ["tkinter", "test", "setuptools", "PyInstaller", "pip", "numpy"],
"include_msvcr": False
}

Expand Down
3 changes: 1 addition & 2 deletions web_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, parent, GetValues, handle):

#creating web viewer
self.ArticleTitle = wx.StaticText(Panel, -1, "please wait:")
self.ViewArticle = wx.html2.WebView.New(Panel, -1)
self.ViewArticle = wx.html2.WebView.New(Panel, -1, name="")
self.ViewArticle.SetPage(self.html, "")
self.ViewArticle.EnableContextMenu(False)
#loading article
Expand Down Expand Up @@ -420,7 +420,6 @@ def MakeAccessible(self):
position = self.ViewArticle.GetPosition()
position = self.ViewArticle.ClientToScreen(position)
robot.MouseMove(position)
robot.MouseClick(True)
mouse.move(100, 100, absolute=False, duration=0.5)
mouse.click('left')

Expand Down

0 comments on commit 70c0a77

Please sign in to comment.