graphviz-code-viewer 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- graphviz_code_viewer/__init__.py +1 -0
- graphviz_code_viewer/about.py +12 -0
- graphviz_code_viewer/desktop.py +98 -0
- graphviz_code_viewer/icons/logo.png +0 -0
- graphviz_code_viewer/modules/__init__.py +1 -0
- graphviz_code_viewer/modules/configure.py +33 -0
- graphviz_code_viewer/modules/wabout.py +108 -0
- graphviz_code_viewer/program.old.py +12 -0
- graphviz_code_viewer/program.py +519 -0
- graphviz_code_viewer-0.1.0.dist-info/METADATA +59 -0
- graphviz_code_viewer-0.1.0.dist-info/RECORD +15 -0
- graphviz_code_viewer-0.1.0.dist-info/WHEEL +5 -0
- graphviz_code_viewer-0.1.0.dist-info/entry_points.txt +2 -0
- graphviz_code_viewer-0.1.0.dist-info/licenses/LICENSE +674 -0
- graphviz_code_viewer-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# about.py
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
__package__ = "graphviz_code_viewer"
|
|
5
|
+
__program_name__ = "graphviz-code-viewer"
|
|
6
|
+
__author__ = "Fernando Pujaico Rivera"
|
|
7
|
+
__email__ = "fernando.pujaico.rivera@gmail.com"
|
|
8
|
+
__description__ = "Program to edit and view Graphviz code."
|
|
9
|
+
__url_source__ = "https://github.com/trucomanx/GraphvizCodeViewer"
|
|
10
|
+
__url_doc__ = "https://github.com/trucomanx/GraphvizCodeViewer/tree/main/doc"
|
|
11
|
+
__url_funding__ = "https://trucomanx.github.io/en/funding.html"
|
|
12
|
+
__url_bugs__ = "https://github.com/trucomanx/GraphvizCodeViewer/issues"
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import graphviz_code_viewer.about as about
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def update_desktop_database(desktop_path):
|
|
7
|
+
applications_dir = os.path.expanduser(desktop_path)
|
|
8
|
+
try:
|
|
9
|
+
subprocess.run(
|
|
10
|
+
["update-desktop-database", applications_dir],
|
|
11
|
+
check=True
|
|
12
|
+
)
|
|
13
|
+
print("Shortcut database updated successfully.")
|
|
14
|
+
except subprocess.CalledProcessError as e:
|
|
15
|
+
print(f"Error updating the database: {e}")
|
|
16
|
+
except FileNotFoundError:
|
|
17
|
+
print("The command 'update-desktop-database' was not found. Verify that the package 'desktop-file-utils' is installed.")
|
|
18
|
+
|
|
19
|
+
def create_desktop_file(desktop_path, overwrite=False):
|
|
20
|
+
base_dir_path = os.path.dirname(os.path.abspath(__file__))
|
|
21
|
+
icon_path = os.path.join(base_dir_path, 'icons', 'logo.png')
|
|
22
|
+
|
|
23
|
+
script_path = os.path.expanduser(f"~/.local/bin/{about.__program_name__}")
|
|
24
|
+
|
|
25
|
+
desktop_entry = f"""[Desktop Entry]
|
|
26
|
+
Name={about.__program_name__}
|
|
27
|
+
Comment={about.__description__}
|
|
28
|
+
Exec={script_path}
|
|
29
|
+
Terminal=false
|
|
30
|
+
Type=Application
|
|
31
|
+
Icon={icon_path}
|
|
32
|
+
StartupNotify=true
|
|
33
|
+
Categories=Education;ResearchTools;
|
|
34
|
+
Keywords=organizer;python;
|
|
35
|
+
Encoding=UTF-8
|
|
36
|
+
StartupWMClass={about.__package__}
|
|
37
|
+
"""
|
|
38
|
+
path = os.path.expanduser(os.path.join(desktop_path,f"{about.__program_name__}.desktop"))
|
|
39
|
+
|
|
40
|
+
if not os.path.exists(path) or overwrite == True:
|
|
41
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
42
|
+
with open(path, "w") as f:
|
|
43
|
+
f.write(desktop_entry)
|
|
44
|
+
os.chmod(path, 0o755)
|
|
45
|
+
print(f"File {about.__program_name__}.desktop created in {path}.")
|
|
46
|
+
update_desktop_database(desktop_path)
|
|
47
|
+
|
|
48
|
+
def create_desktop_directory( directory_name = "ResearchTools",
|
|
49
|
+
long_name = "Scientific research",
|
|
50
|
+
comment = "Tools for Writing and Research Support",
|
|
51
|
+
icon = "accessories-text-editor",
|
|
52
|
+
overwrite = False):
|
|
53
|
+
|
|
54
|
+
desktop_entry = f"""[Desktop Entry]
|
|
55
|
+
Version=1.0
|
|
56
|
+
Type=Directory
|
|
57
|
+
Name={long_name}
|
|
58
|
+
Comment={comment}
|
|
59
|
+
Icon={icon}
|
|
60
|
+
"""
|
|
61
|
+
path = os.path.expanduser(f"~/.local/share/desktop-directories/{directory_name}.directory")
|
|
62
|
+
|
|
63
|
+
if not os.path.exists(path) or overwrite == True: # Evita sobrescrever
|
|
64
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
65
|
+
with open(path, "w") as f:
|
|
66
|
+
f.write(desktop_entry)
|
|
67
|
+
os.chmod(path, 0o755)
|
|
68
|
+
print(f"File {path} created.")
|
|
69
|
+
|
|
70
|
+
def create_desktop_menu(directory_name = "ResearchTools",
|
|
71
|
+
basename = "research-tools",
|
|
72
|
+
overwrite = False):
|
|
73
|
+
|
|
74
|
+
desktop_entry = f"""<!-- ~/.config/menus/applications-merged/{basename}.menu -->
|
|
75
|
+
<Menu>
|
|
76
|
+
<Name>Applications</Name>
|
|
77
|
+
<Menu>
|
|
78
|
+
<Name>{directory_name}</Name>
|
|
79
|
+
<Directory>{directory_name}.directory</Directory>
|
|
80
|
+
<Include>
|
|
81
|
+
<Category>{directory_name}</Category>
|
|
82
|
+
</Include>
|
|
83
|
+
</Menu>
|
|
84
|
+
</Menu>
|
|
85
|
+
"""
|
|
86
|
+
path = os.path.expanduser(f"~/.config/menus/applications-merged/{basename}.menu")
|
|
87
|
+
|
|
88
|
+
if not os.path.exists(path) or overwrite == True: # Evita sobrescrever
|
|
89
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
90
|
+
with open(path, "w") as f:
|
|
91
|
+
f.write(desktop_entry)
|
|
92
|
+
print(f"File {path} created.")
|
|
93
|
+
|
|
94
|
+
if __name__ == '__main__':
|
|
95
|
+
create_desktop_menu()
|
|
96
|
+
create_desktop_directory()
|
|
97
|
+
create_desktop_file()
|
|
98
|
+
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
def verify_default_config(path,default_content={}):
|
|
5
|
+
"""
|
|
6
|
+
Cria o arquivo JSON no caminho especificado com conteúdo padrão,
|
|
7
|
+
criando diretórios intermediários se necessário.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# Se o arquivo não existir, cria com o conteúdo padrão
|
|
11
|
+
if not os.path.exists(path):
|
|
12
|
+
# Garante que os diretórios existam
|
|
13
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
14
|
+
with open(path, 'w', encoding='utf-8') as f:
|
|
15
|
+
json.dump(default_content, f, ensure_ascii=False, indent=4)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Lê o JSON no início do programa
|
|
19
|
+
def load_config(config_path):
|
|
20
|
+
with open(config_path, 'r', encoding='utf-8') as f:
|
|
21
|
+
return json.load(f)
|
|
22
|
+
|
|
23
|
+
def save_config(path,content):
|
|
24
|
+
"""
|
|
25
|
+
Cria o arquivo JSON no caminho especificado com conteúdo padrão,
|
|
26
|
+
criando diretórios intermediários se necessário.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
# Garante que os diretórios existam
|
|
30
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
31
|
+
with open(path, 'w', encoding='utf-8') as f:
|
|
32
|
+
json.dump(content, f, ensure_ascii=False, indent=4)
|
|
33
|
+
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
from PyQt5.QtWidgets import QDialog, QLabel, QPushButton, QVBoxLayout
|
|
2
|
+
from PyQt5.QtGui import QPixmap
|
|
3
|
+
from PyQt5.QtCore import Qt
|
|
4
|
+
|
|
5
|
+
class AboutWindow(QDialog):
|
|
6
|
+
"""About dialog window"""
|
|
7
|
+
def __init__(self, data, logo_path, parent=None):
|
|
8
|
+
super().__init__(parent)
|
|
9
|
+
self.setWindowTitle("About")
|
|
10
|
+
self.setMinimumSize(500, 300)
|
|
11
|
+
|
|
12
|
+
# Create layout
|
|
13
|
+
layout = QVBoxLayout(self)
|
|
14
|
+
|
|
15
|
+
# Logo
|
|
16
|
+
logo_label = QLabel()
|
|
17
|
+
pixmap = QPixmap(logo_path)
|
|
18
|
+
pixmap = pixmap.scaled(100, 100, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
|
19
|
+
logo_label.setPixmap(pixmap)
|
|
20
|
+
logo_label.setAlignment(Qt.AlignCenter)
|
|
21
|
+
layout.addWidget(logo_label)
|
|
22
|
+
|
|
23
|
+
# Description
|
|
24
|
+
description_label = QLabel(f"<b>{data['description']}</b>")
|
|
25
|
+
description_label.setWordWrap(True)
|
|
26
|
+
description_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
27
|
+
layout.addWidget(description_label)
|
|
28
|
+
|
|
29
|
+
# Add separator
|
|
30
|
+
separator = QLabel()
|
|
31
|
+
separator.setFrameShape(QLabel.HLine)
|
|
32
|
+
separator.setFrameShadow(QLabel.Sunken)
|
|
33
|
+
layout.addWidget(separator)
|
|
34
|
+
|
|
35
|
+
# Package info
|
|
36
|
+
package_label = QLabel(f"Package: {data['package']}")
|
|
37
|
+
package_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
38
|
+
package_label.setAlignment(Qt.AlignLeft)
|
|
39
|
+
layout.addWidget(package_label)
|
|
40
|
+
|
|
41
|
+
# Program info
|
|
42
|
+
program_label = QLabel(f"Program: {data['program_name']}")
|
|
43
|
+
program_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
44
|
+
program_label.setAlignment(Qt.AlignLeft)
|
|
45
|
+
layout.addWidget(program_label)
|
|
46
|
+
|
|
47
|
+
# Version info
|
|
48
|
+
version_label = QLabel(f"Version: {data['version']}")
|
|
49
|
+
version_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
50
|
+
version_label.setAlignment(Qt.AlignLeft)
|
|
51
|
+
layout.addWidget(version_label)
|
|
52
|
+
|
|
53
|
+
# Author info
|
|
54
|
+
author_label = QLabel(f"Author: {data['author']}")
|
|
55
|
+
author_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
56
|
+
author_label.setAlignment(Qt.AlignLeft)
|
|
57
|
+
layout.addWidget(author_label)
|
|
58
|
+
|
|
59
|
+
# Email info
|
|
60
|
+
email_label = QLabel(f"Email: <a href=\"mailto:{data['email']}\">{data['email']}</a>")
|
|
61
|
+
email_label.setTextInteractionFlags(Qt.TextSelectableByMouse| Qt.LinksAccessibleByMouse)
|
|
62
|
+
email_label.setOpenExternalLinks(True)
|
|
63
|
+
email_label.setAlignment(Qt.AlignLeft)
|
|
64
|
+
layout.addWidget(email_label)
|
|
65
|
+
|
|
66
|
+
# Add another separator
|
|
67
|
+
separator2 = QLabel()
|
|
68
|
+
separator2.setFrameShape(QLabel.HLine)
|
|
69
|
+
separator2.setFrameShadow(QLabel.Sunken)
|
|
70
|
+
layout.addWidget(separator2)
|
|
71
|
+
|
|
72
|
+
# Source URL
|
|
73
|
+
source_label = QLabel(f"Source: <a href=\"{data['url_source']}\">{data['url_source']}</a>")
|
|
74
|
+
source_label.setTextInteractionFlags(Qt.TextSelectableByMouse| Qt.LinksAccessibleByMouse)
|
|
75
|
+
source_label.setOpenExternalLinks(True)
|
|
76
|
+
source_label.setAlignment(Qt.AlignLeft)
|
|
77
|
+
layout.addWidget(source_label)
|
|
78
|
+
|
|
79
|
+
# Doc URL
|
|
80
|
+
doc_label = QLabel(f"Documentation: <a href=\"{data['url_doc']}\">{data['url_doc']}</a>")
|
|
81
|
+
doc_label.setTextInteractionFlags(Qt.TextSelectableByMouse| Qt.LinksAccessibleByMouse)
|
|
82
|
+
doc_label.setOpenExternalLinks(True)
|
|
83
|
+
doc_label.setAlignment(Qt.AlignLeft)
|
|
84
|
+
layout.addWidget(doc_label)
|
|
85
|
+
|
|
86
|
+
# Funding URL
|
|
87
|
+
funding_label = QLabel(f"Funding: <a href=\"{data['url_funding']}\">{data['url_funding']}</a>")
|
|
88
|
+
funding_label.setTextInteractionFlags(Qt.TextSelectableByMouse| Qt.LinksAccessibleByMouse)
|
|
89
|
+
funding_label.setOpenExternalLinks(True)
|
|
90
|
+
funding_label.setAlignment(Qt.AlignLeft)
|
|
91
|
+
layout.addWidget(funding_label)
|
|
92
|
+
|
|
93
|
+
# Bugs URL
|
|
94
|
+
bugs_label = QLabel(f"Bugs: <a href=\"{data['url_bugs']}\">{data['url_bugs']}</a>")
|
|
95
|
+
bugs_label.setTextInteractionFlags(Qt.TextSelectableByMouse| Qt.LinksAccessibleByMouse)
|
|
96
|
+
bugs_label.setOpenExternalLinks(True)
|
|
97
|
+
bugs_label.setAlignment(Qt.AlignLeft)
|
|
98
|
+
layout.addWidget(bugs_label)
|
|
99
|
+
|
|
100
|
+
# OK Button
|
|
101
|
+
ok_button = QPushButton("OK")
|
|
102
|
+
ok_button.clicked.connect(self.accept)
|
|
103
|
+
layout.addWidget(ok_button)
|
|
104
|
+
|
|
105
|
+
def show_about_window(data, logo_path):
|
|
106
|
+
dialog = AboutWindow(data, logo_path)
|
|
107
|
+
dialog.exec_()
|
|
108
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import graphviz_code_viewer.about as about
|
|
4
|
+
import graphviz_code_viewer.modules.configure as configure
|
|
5
|
+
|
|
6
|
+
# Caminho para o arquivo de configuração
|
|
7
|
+
CONFIG_PATH = os.path.join(os.path.expanduser("~"),".config",about.__package__,"config.json")
|
|
8
|
+
|
|
9
|
+
configure.verify_default_config(CONFIG_PATH, default_content={"casa":"verde"})
|
|
10
|
+
|
|
11
|
+
CONFIG=configure.load_config(CONFIG_PATH)
|
|
12
|
+
print("Hola!")
|