Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CFA Analysis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JOSSOUD Olivier
CFA Analysis
Commits
b8b970d0
Commit
b8b970d0
authored
3 years ago
by
JOSSOUD Olivier
Browse files
Options
Downloads
Patches
Plain Diff
ui2py.py. Use space instead of tab to indent auto-generated code.
parent
957a6aaa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/ui2py.py
+14
-12
14 additions, 12 deletions
scripts/ui2py.py
with
14 additions
and
12 deletions
scripts/ui2py.py
+
14
−
12
View file @
b8b970d0
...
...
@@ -8,21 +8,22 @@ import os
def
create_window_file
(
base_name
:
str
,
dest_dir
:
str
):
camel_basename
=
base_name
.
replace
(
"
_
"
,
"
"
).
title
().
replace
(
"
"
,
""
)
content
=
"
from PyQt5.QtWidgets import QDialog
\n
"
content
+=
"
from
"
+
"
gui.ui_
"
+
base_name
.
lower
()
+
"
import Ui_
"
+
camel_basename
+
"
\n
"
content
+=
(
"
from
"
+
"
gui.ui_
"
+
base_name
.
lower
()
+
"
import Ui_
"
+
camel_basename
+
"
\n
"
)
content
+=
"
\n
"
content
+=
"
\n
"
content
+=
"
class
"
+
camel_basename
+
"
(QDialog):
\n
"
content
+=
"
\t
def __init__(self, parent_window):
\n
"
content
+=
"
\t\t
super(
"
+
camel_basename
+
"
, self).__init__(parent_window)
\n
"
content
+=
"
\t\t
self.ui = Ui_
"
+
camel_basename
+
"
()
\n
"
content
+=
"
\t\t
self.ui.setupUi(self)
\n
"
content
+=
"
def __init__(self, parent_window):
\n
"
content
+=
"
super(
"
+
camel_basename
+
"
, self).__init__(parent_window)
\n
"
content
+=
"
self.ui = Ui_
"
+
camel_basename
+
"
()
\n
"
content
+=
"
self.ui.setupUi(self)
\n
"
dest_filename
=
os
.
path
.
join
(
dest_dir
,
base_name
+
"
.py
"
)
with
open
(
dest_filename
,
'
w
'
)
as
out_file
:
with
open
(
dest_filename
,
"
w
"
)
as
out_file
:
out_file
.
write
(
content
)
# Determine the projects base path and the directory containing the .ui files.
possible_base_paths
=
[
"
../
"
,
"
../../
"
]
pyqt_dir
=
None
...
...
@@ -46,7 +47,9 @@ else:
# Build the path to the `pyuic` executable
pyuic_exec_path
=
os
.
path
.
join
(
base_path
,
"
venv/bin
"
,
pyuic_exec_file
)
if
not
os
.
path
.
exists
(
pyuic_exec_path
):
raise
FileNotFoundError
(
"
[
"
+
pyuic_exec_path
+
"
] not found. Please install PyQt5.
"
)
raise
FileNotFoundError
(
"
[
"
+
pyuic_exec_path
+
"
] not found. Please install PyQt5.
"
)
# Find destination folder for .py output files
possible_pkg_names
=
[
os
.
path
.
basename
(
os
.
path
.
abspath
(
os
.
path
.
pardir
)),
"
src
"
]
...
...
@@ -65,9 +68,8 @@ for ui_file in os.listdir(pyqt_dir):
if
ui_file
.
endswith
(
"
.ui
"
):
ui_file_basename
=
os
.
path
.
splitext
(
ui_file
)[
0
]
py_file
=
os
.
path
.
join
(
dest_dir
,
"
ui_
"
+
ui_file_basename
+
"
.py
"
)
os
.
system
(
pyuic_exec_path
+
"
"
+
os
.
path
.
join
(
pyqt_dir
,
ui_file
)
+
"
-o
"
+
py_file
)
os
.
system
(
pyuic_exec_path
+
"
"
+
os
.
path
.
join
(
pyqt_dir
,
ui_file
)
+
"
-o
"
+
py_file
)
if
ui_file
.
endswith
(
"
_dialog.ui
"
):
create_window_file
(
ui_file_basename
,
dest_dir
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment