Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HEV - High Energy Ventilator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
HEV - High Energy Ventilator
Commits
20561d96
Commit
20561d96
authored
May 21, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added LCA for setting the initial language for the UI
parent
e9592490
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
2 deletions
+53
-2
NativeUI.py
NativeUI/NativeUI.py
+53
-2
No files found.
NativeUI/NativeUI.py
View file @
20561d96
...
...
@@ -99,7 +99,14 @@ class NativeUI(HEVClient, QMainWindow):
q_send_personal (Slot) - send personal information to the MCU.
"""
def
__init__
(
self
,
resolution
:
list
,
*
args
,
skip_startup
=
False
,
**
kwargs
):
def
__init__
(
self
,
resolution
:
list
,
*
args
,
skip_startup
:
bool
=
False
,
language
:
str
=
"english"
,
**
kwargs
,
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
# Set the resolution of the display window
...
...
@@ -118,7 +125,15 @@ class NativeUI(HEVClient, QMainWindow):
self
.
colors
=
json
.
load
(
infile
)
for
key
in
self
.
colors
:
self
.
colors
[
key
]
=
QColor
.
fromRgb
(
*
self
.
colors
[
key
])
with
open
(
os
.
path
.
join
(
config_path
,
"text_english.json"
))
as
infile
:
language_config
=
os
.
path
.
join
(
config_path
,
"text_
%
s.json"
%
language
)
if
not
os
.
path
.
isfile
(
language_config
):
logging
.
error
(
"No config file for
%
s language (expected file at
%
s)"
,
(
language
,
language_config
),
)
language_config
=
os
.
path
.
join
(
config_path
,
"text_english.json"
)
with
open
(
language_config
)
as
infile
:
self
.
text
=
json
.
load
(
infile
)
# Set up fonts based on the screen resolution. text_font and value_font are 20
...
...
@@ -664,6 +679,20 @@ def parse_command_line_arguments() -> argparse.Namespace:
default
=
False
,
help
=
"Run the UI without the startup sequence"
,
)
parser
.
add_argument
(
"-l"
,
"--language"
,
action
=
"store"
,
dest
=
"language"
,
default
=
"English"
,
type
=
str
,
help
=
"""
Set the language for the UI from the following list:
\n
Language Recognised Values
\n
English e, E, english, English
\n
Portugues p, P, portugues, Portugues
"""
,
)
return
parser
.
parse_args
()
...
...
@@ -683,6 +712,27 @@ def set_logging_level(debug_level: int) -> int:
return
0
def
interpret_language
(
input_string
:
str
)
->
str
:
"""
Convert the value given for the language CLA to one that NativeUI can interpret.
"""
default_language
=
"English"
if
input_string
is
None
:
return
default_language
keys_english
=
[
"e"
,
"E"
,
"english"
,
"English"
]
keys_portugues
=
[
"p"
,
"P"
,
"portugues"
,
"Portugues"
,
"portuguese"
,
"Portuguese"
]
if
input_string
in
keys_english
:
return
"english"
if
input_string
in
keys_portugues
:
return
"portuguese"
logging
.
error
(
"Unrecognised language value
%
s, defaulting to
%
s"
,
(
input_string
,
default_language
),
)
return
default_language
def
interpret_resolution
(
input_string
:
str
)
->
list
:
"""
Convert a string to a pair of numbers specifying the window size.
...
...
@@ -743,6 +793,7 @@ if __name__ == "__main__":
dep
=
NativeUI
(
interpret_resolution
(
command_line_args
.
resolution
),
skip_startup
=
command_line_args
.
no_startup
,
language
=
interpret_language
(
command_line_args
.
language
),
)
set_window_size
(
dep
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment