graphviz-code-viewer 0.1.0__tar.gz → 0.1.1__tar.gz
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-0.1.0 → graphviz_code_viewer-0.1.1}/PKG-INFO +1 -1
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/about.py +1 -1
- graphviz_code_viewer-0.1.1/graphviz_code_viewer/modules/configure.py +60 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/program.py +162 -47
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/PKG-INFO +1 -1
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/pyproject.toml +1 -1
- graphviz_code_viewer-0.1.0/graphviz_code_viewer/modules/configure.py +0 -33
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/LICENSE +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/README.md +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/__init__.py +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/desktop.py +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/icons/logo.png +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/modules/__init__.py +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/modules/wabout.py +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/program.old.py +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/SOURCES.txt +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/dependency_links.txt +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/entry_points.txt +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/requires.txt +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/top_level.txt +0 -0
- {graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: graphviz_code_viewer
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Program to edit and view Graphviz code.
|
|
5
5
|
Author-email: Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
|
|
6
6
|
Maintainer-email: Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
|
|
19
|
+
def merge_defaults(config, defaults):
|
|
20
|
+
"""
|
|
21
|
+
Adiciona valores de defaults que não existam em config.
|
|
22
|
+
Funciona recursivamente para dicionários aninhados.
|
|
23
|
+
"""
|
|
24
|
+
for key, value in defaults.items():
|
|
25
|
+
if key not in config:
|
|
26
|
+
config[key] = value
|
|
27
|
+
elif isinstance(value, dict) and isinstance(config[key], dict):
|
|
28
|
+
merge_defaults(config[key], value)
|
|
29
|
+
return config
|
|
30
|
+
|
|
31
|
+
# Lê o JSON no início do programa
|
|
32
|
+
def load_config(config_path, default_content=None):
|
|
33
|
+
"""
|
|
34
|
+
Carrega o JSON de configuração e preenche com valores padrão se necessário.
|
|
35
|
+
"""
|
|
36
|
+
config = {}
|
|
37
|
+
if os.path.exists(config_path):
|
|
38
|
+
with open(config_path, 'r', encoding='utf-8') as f:
|
|
39
|
+
try:
|
|
40
|
+
config = json.load(f)
|
|
41
|
+
except json.JSONDecodeError:
|
|
42
|
+
print("Erro ao ler config, usando defaults")
|
|
43
|
+
config = {}
|
|
44
|
+
|
|
45
|
+
if default_content:
|
|
46
|
+
config = merge_defaults(config, default_content)
|
|
47
|
+
|
|
48
|
+
return config
|
|
49
|
+
|
|
50
|
+
def save_config(path,content):
|
|
51
|
+
"""
|
|
52
|
+
Cria o arquivo JSON no caminho especificado com conteúdo padrão,
|
|
53
|
+
criando diretórios intermediários se necessário.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
# Garante que os diretórios existam
|
|
57
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
58
|
+
with open(path, 'w', encoding='utf-8') as f:
|
|
59
|
+
json.dump(content, f, ensure_ascii=False, indent=4)
|
|
60
|
+
|
|
@@ -5,10 +5,11 @@ import subprocess
|
|
|
5
5
|
import tempfile
|
|
6
6
|
import os
|
|
7
7
|
import signal
|
|
8
|
+
import shutil
|
|
8
9
|
|
|
9
10
|
from PyQt5.QtWidgets import (
|
|
10
11
|
QApplication, QMainWindow, QPlainTextEdit, QLabel, QSplitter, QToolBar,
|
|
11
|
-
QAction, QVBoxLayout, QWidget, QProgressBar, QFileDialog, QScrollArea, QMessageBox, QSizePolicy
|
|
12
|
+
QAction, QVBoxLayout, QWidget, QProgressBar, QFileDialog, QScrollArea, QMessageBox, QSizePolicy, QLineEdit
|
|
12
13
|
)
|
|
13
14
|
from PyQt5.QtGui import QSyntaxHighlighter, QTextCharFormat, QColor, QFont, QPixmap, QIcon, QDesktopServices
|
|
14
15
|
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QUrl
|
|
@@ -16,19 +17,20 @@ from PyQt5.QtCore import Qt, QThread, pyqtSignal, QUrl
|
|
|
16
17
|
from PyQt5.QtSvg import QSvgRenderer
|
|
17
18
|
from PyQt5.QtGui import QPainter
|
|
18
19
|
from PyQt5.QtCore import QSize
|
|
20
|
+
from PyQt5.QtWidgets import QShortcut
|
|
21
|
+
from PyQt5.QtGui import QKeySequence, QTextDocument
|
|
22
|
+
|
|
19
23
|
|
|
20
24
|
import graphviz_code_viewer.about as about
|
|
21
25
|
import graphviz_code_viewer.modules.configure as configure
|
|
22
26
|
from graphviz_code_viewer.desktop import create_desktop_file, create_desktop_directory, create_desktop_menu
|
|
23
27
|
from graphviz_code_viewer.modules.wabout import show_about_window
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
# ------------------------------------------------------------------------------
|
|
26
30
|
# Path to config file
|
|
27
31
|
CONFIG_PATH = os.path.join(os.path.expanduser("~"),".config",about.__package__,"config.json")
|
|
28
32
|
|
|
29
33
|
DEFAULT_CONTENT={ "error_loading_svg": "Error loading SVG file",
|
|
30
|
-
"font_size": 11,
|
|
31
|
-
"font_name": "Courier",
|
|
32
34
|
"window_width": 1200,
|
|
33
35
|
"window_height": 700,
|
|
34
36
|
"action_compile":"Compile",
|
|
@@ -41,8 +43,10 @@ DEFAULT_CONTENT={ "error_loading_svg": "Error loading SVG file",
|
|
|
41
43
|
"action_saveas_tooltip": "Save the DOT file as",
|
|
42
44
|
"action_saveimg":"Save image",
|
|
43
45
|
"action_saveimg_tooltip": "Save the output image",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
+
"action_configure_window": "Conf. window",
|
|
47
|
+
"action_configure_window_tooltip": "Open the configure window Json file",
|
|
48
|
+
"action_configure_editor": "Conf. Editor",
|
|
49
|
+
"action_configure_editor_tooltip": "Open the configure editor Json file",
|
|
46
50
|
"action_about": "About",
|
|
47
51
|
"action_about_tooltip": "About the program",
|
|
48
52
|
"action_coffee": "Coffee",
|
|
@@ -64,12 +68,35 @@ DEFAULT_CONTENT={ "error_loading_svg": "Error loading SVG file",
|
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
configure.verify_default_config(CONFIG_PATH,default_content=DEFAULT_CONTENT)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
CONFIG=configure.load_config(CONFIG_PATH,default_content=DEFAULT_CONTENT)
|
|
72
|
+
|
|
73
|
+
# ------------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
CONFIG_EDITOR_PATH = os.path.join(os.path.expanduser("~"),".config",about.__package__,"config_editor.json")
|
|
76
|
+
|
|
77
|
+
DEFAULT_EDITOR_CONTENT= { "font_size": 11,
|
|
78
|
+
"font_name": "Monospace",
|
|
79
|
+
"save_file": "Ctrl+S",
|
|
80
|
+
"find_text": "Ctrl+F",
|
|
81
|
+
"syntax_rules": {
|
|
82
|
+
"digraph": {"color": "blue", "bold": True},
|
|
83
|
+
"->": {"color": "darkRed", "bold": True},
|
|
84
|
+
"=": {"color": "darkGreen", "bold": True},
|
|
85
|
+
"\"": {"color": "darkMagenta", "bold": True},
|
|
86
|
+
"[": {"color": "black", "bold": True},
|
|
87
|
+
"]": {"color": "black", "bold": True},
|
|
88
|
+
"{": {"color": "darkGreen", "bold": True},
|
|
89
|
+
"}": {"color": "darkGreen", "bold": True},
|
|
90
|
+
";": {"color": "darkGray", "bold": True}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
configure.verify_default_config(CONFIG_EDITOR_PATH,default_content=DEFAULT_EDITOR_CONTENT)
|
|
95
|
+
CONFIG_EDITOR=configure.load_config(CONFIG_EDITOR_PATH,default_content=DEFAULT_EDITOR_CONTENT)
|
|
96
|
+
|
|
97
|
+
# ------------------------------------------------------------------------------
|
|
71
98
|
# Syntax Highlighter
|
|
72
|
-
#
|
|
99
|
+
# ------------------------------------------------------------------------------
|
|
73
100
|
class GraphvizHighlighter(QSyntaxHighlighter):
|
|
74
101
|
def __init__(self, parent, rules_dict):
|
|
75
102
|
super().__init__(parent)
|
|
@@ -89,12 +116,12 @@ class GraphvizHighlighter(QSyntaxHighlighter):
|
|
|
89
116
|
self.setFormat(index, length, fmt)
|
|
90
117
|
index = text.find(keyword, index + length)
|
|
91
118
|
|
|
92
|
-
#
|
|
119
|
+
# ------------------------------------------------------------------------------
|
|
93
120
|
# Worker thread para compilar Graphviz
|
|
94
|
-
#
|
|
121
|
+
# ------------------------------------------------------------------------------
|
|
95
122
|
class CompileThread(QThread):
|
|
96
123
|
progress = pyqtSignal(int)
|
|
97
|
-
finished = pyqtSignal(str)
|
|
124
|
+
finished = pyqtSignal(str, str) # (output_file, error_message)
|
|
98
125
|
|
|
99
126
|
def __init__(self, dot_code, output_file):
|
|
100
127
|
super().__init__()
|
|
@@ -111,24 +138,28 @@ class CompileThread(QThread):
|
|
|
111
138
|
with open(tmp_dot, "w") as f:
|
|
112
139
|
f.write(self.dot_code)
|
|
113
140
|
self.progress.emit(50)
|
|
141
|
+
|
|
114
142
|
try:
|
|
115
|
-
subprocess.run(
|
|
143
|
+
result = subprocess.run(
|
|
116
144
|
["dot", "-Tsvg", tmp_dot, "-o", self.output_file],
|
|
117
|
-
check=True
|
|
145
|
+
check=True,
|
|
146
|
+
capture_output=True,
|
|
147
|
+
text=True
|
|
118
148
|
)
|
|
119
149
|
self.progress.emit(100)
|
|
120
|
-
self.finished.emit(self.output_file)
|
|
121
|
-
except subprocess.CalledProcessError:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
os.
|
|
150
|
+
self.finished.emit(self.output_file, "") # sucesso, sem erro
|
|
151
|
+
except subprocess.CalledProcessError as e:
|
|
152
|
+
error_msg = e.stderr if e.stderr else "Erro desconhecido ao rodar o Graphviz"
|
|
153
|
+
self.finished.emit("", error_msg)
|
|
154
|
+
finally:
|
|
155
|
+
if os.path.exists(tmp_dot):
|
|
156
|
+
os.remove(tmp_dot)
|
|
126
157
|
|
|
127
158
|
|
|
128
|
-
# ---------------------------
|
|
129
|
-
# Widget da imagem com zoom/move
|
|
130
|
-
# ---------------------------
|
|
131
159
|
|
|
160
|
+
# ------------------------------------------------------------------------------
|
|
161
|
+
# Widget da imagem com zoom/move
|
|
162
|
+
# ------------------------------------------------------------------------------
|
|
132
163
|
|
|
133
164
|
class SvgViewer(QScrollArea):
|
|
134
165
|
def __init__(self):
|
|
@@ -195,9 +226,24 @@ class SvgViewer(QScrollArea):
|
|
|
195
226
|
class TextEditor(QPlainTextEdit):
|
|
196
227
|
def __init__(self):
|
|
197
228
|
super().__init__()
|
|
198
|
-
self.setFont(QFont(
|
|
229
|
+
self.setFont(QFont(CONFIG_EDITOR["font_name"], CONFIG_EDITOR["font_size"]))
|
|
199
230
|
self.zoom_factor = 1.0
|
|
200
231
|
|
|
232
|
+
# Não quebrar linhas
|
|
233
|
+
self.setLineWrapMode(QPlainTextEdit.NoWrap)
|
|
234
|
+
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
|
235
|
+
|
|
236
|
+
# Filtro de busca
|
|
237
|
+
self.search_bar = QLineEdit(self)
|
|
238
|
+
self.search_bar.setPlaceholderText("Buscar...")
|
|
239
|
+
self.search_bar.setFixedHeight(24)
|
|
240
|
+
self.search_bar.hide()
|
|
241
|
+
self.search_bar.textChanged.connect(self.highlight_search)
|
|
242
|
+
self.search_bar.installEventFilter(self) # Para capturar Enter/Esc na barra
|
|
243
|
+
|
|
244
|
+
self.search_format = QTextCharFormat()
|
|
245
|
+
self.search_format.setBackground(QColor("yellow"))
|
|
246
|
+
|
|
201
247
|
def wheelEvent(self, event):
|
|
202
248
|
if event.modifiers() & Qt.ControlModifier:
|
|
203
249
|
angle = event.angleDelta().y()
|
|
@@ -209,6 +255,64 @@ class TextEditor(QPlainTextEdit):
|
|
|
209
255
|
else:
|
|
210
256
|
super().wheelEvent(event)
|
|
211
257
|
|
|
258
|
+
def keyPressEvent(self, event):
|
|
259
|
+
# Cria a representação textual do atalho pressionado
|
|
260
|
+
key_seq = QKeySequence(event.modifiers() | event.key()).toString()
|
|
261
|
+
|
|
262
|
+
# Lê o atalho do seu config ou usa literal
|
|
263
|
+
search_shortcut = CONFIG_EDITOR["find_text"]
|
|
264
|
+
|
|
265
|
+
if key_seq == search_shortcut:
|
|
266
|
+
self.toggle_search_bar()
|
|
267
|
+
return
|
|
268
|
+
|
|
269
|
+
super().keyPressEvent(event)
|
|
270
|
+
|
|
271
|
+
def toggle_search_bar(self):
|
|
272
|
+
if self.search_bar.isVisible():
|
|
273
|
+
self.search_bar.hide()
|
|
274
|
+
self.setFocus()
|
|
275
|
+
self.highlight_search("") # remove highlights
|
|
276
|
+
else:
|
|
277
|
+
self.search_bar.show()
|
|
278
|
+
self.search_bar.setFocus()
|
|
279
|
+
|
|
280
|
+
def highlight_search(self, text):
|
|
281
|
+
# Remove highlights anteriores
|
|
282
|
+
cursor = self.textCursor()
|
|
283
|
+
fmt_clear = QTextCharFormat()
|
|
284
|
+
cursor.select(cursor.Document)
|
|
285
|
+
cursor.setCharFormat(fmt_clear)
|
|
286
|
+
cursor.clearSelection()
|
|
287
|
+
|
|
288
|
+
if not text:
|
|
289
|
+
return
|
|
290
|
+
|
|
291
|
+
# Aplicar destaque
|
|
292
|
+
cursor = self.document().find(text, 0, QTextDocument.FindCaseSensitively)
|
|
293
|
+
while not cursor.isNull():
|
|
294
|
+
cursor.mergeCharFormat(self.search_format)
|
|
295
|
+
cursor = self.document().find(text, cursor.position(), QTextDocument.FindCaseSensitively)
|
|
296
|
+
|
|
297
|
+
def eventFilter(self, obj, event):
|
|
298
|
+
if hasattr(self, "search_bar") and obj == self.search_bar:
|
|
299
|
+
if event.type() == event.KeyPress:
|
|
300
|
+
if event.key() == Qt.Key_Escape:
|
|
301
|
+
self.toggle_search_bar()
|
|
302
|
+
return True # consome o evento
|
|
303
|
+
elif event.key() in (Qt.Key_Return, Qt.Key_Enter):
|
|
304
|
+
# Seleciona próxima ocorrência
|
|
305
|
+
text = self.search_bar.text()
|
|
306
|
+
if text:
|
|
307
|
+
cursor = self.textCursor()
|
|
308
|
+
pos = cursor.position()
|
|
309
|
+
next_cursor = self.document().find(text, pos, QTextDocument.FindCaseSensitively)
|
|
310
|
+
if not next_cursor.isNull():
|
|
311
|
+
self.setTextCursor(next_cursor)
|
|
312
|
+
return True
|
|
313
|
+
return super().eventFilter(obj, event)
|
|
314
|
+
|
|
315
|
+
|
|
212
316
|
# ---------------------------
|
|
213
317
|
# Main Window
|
|
214
318
|
# ---------------------------
|
|
@@ -246,18 +350,8 @@ class MainWindow(QMainWindow):
|
|
|
246
350
|
|
|
247
351
|
# Editor e visualizador
|
|
248
352
|
self.editor = TextEditor()
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
"->": {"color": "darkRed", "bold": True},
|
|
252
|
-
"=": {"color": "darkRed", "bold": True},
|
|
253
|
-
"\"": {"color": "darkMagenta", "bold": True},
|
|
254
|
-
"[": {"color": "black", "bold": True},
|
|
255
|
-
"]": {"color": "black", "bold": True},
|
|
256
|
-
"{": {"color": "darkGreen", "bold": True},
|
|
257
|
-
"}": {"color": "darkGreen", "bold": True},
|
|
258
|
-
";": {"color": "darkGray", "bold": True}
|
|
259
|
-
}
|
|
260
|
-
self.highlighter = GraphvizHighlighter(self.editor.document(), syntax_rules)
|
|
353
|
+
|
|
354
|
+
self.highlighter = GraphvizHighlighter(self.editor.document(), CONFIG_EDITOR["syntax_rules"])
|
|
261
355
|
self.viewer = SvgViewer()
|
|
262
356
|
|
|
263
357
|
splitter = QSplitter(Qt.Horizontal)
|
|
@@ -279,6 +373,9 @@ class MainWindow(QMainWindow):
|
|
|
279
373
|
|
|
280
374
|
if os.path.exists(self.input_filepath):
|
|
281
375
|
self.load_dot(filepath=self.input_filepath)
|
|
376
|
+
|
|
377
|
+
save_shortcut = QShortcut(QKeySequence(CONFIG_EDITOR["save_file"]), self)
|
|
378
|
+
save_shortcut.activated.connect(lambda: self.save_dot(from_input=True, exist_ok=True))
|
|
282
379
|
|
|
283
380
|
def func_toolbar(self):
|
|
284
381
|
toolbar = QToolBar()
|
|
@@ -323,9 +420,15 @@ class MainWindow(QMainWindow):
|
|
|
323
420
|
toolbar.addWidget(spacer)
|
|
324
421
|
|
|
325
422
|
#
|
|
326
|
-
self.
|
|
327
|
-
self.
|
|
328
|
-
self.
|
|
423
|
+
self.configure_editor_action = QAction(QIcon.fromTheme("document-properties"), CONFIG["action_configure_editor"], self)
|
|
424
|
+
self.configure_editor_action.setToolTip(CONFIG["action_configure_editor_tooltip"])
|
|
425
|
+
self.configure_editor_action.triggered.connect(self.open_configure_editor)
|
|
426
|
+
toolbar.addAction(self.configure_editor_action)
|
|
427
|
+
|
|
428
|
+
#
|
|
429
|
+
self.configure_action = QAction(QIcon.fromTheme("document-properties"), CONFIG["action_configure_window"], self)
|
|
430
|
+
self.configure_action.setToolTip(CONFIG["action_configure_window_tooltip"])
|
|
431
|
+
self.configure_action.triggered.connect(self.open_configure_window)
|
|
329
432
|
toolbar.addAction(self.configure_action)
|
|
330
433
|
|
|
331
434
|
#
|
|
@@ -344,6 +447,12 @@ class MainWindow(QMainWindow):
|
|
|
344
447
|
QDesktopServices.openUrl(QUrl("https://ko-fi.com/trucomanx"))
|
|
345
448
|
|
|
346
449
|
def open_configure_editor(self):
|
|
450
|
+
if os.name == 'nt': # Windows
|
|
451
|
+
os.startfile(CONFIG_PATH)
|
|
452
|
+
elif os.name == 'posix': # Linux/macOS
|
|
453
|
+
subprocess.run(['xdg-open', CONFIG_EDITOR_PATH])
|
|
454
|
+
|
|
455
|
+
def open_configure_window(self):
|
|
347
456
|
if os.name == 'nt': # Windows
|
|
348
457
|
os.startfile(CONFIG_PATH)
|
|
349
458
|
elif os.name == 'posix': # Linux/macOS
|
|
@@ -392,7 +501,10 @@ class MainWindow(QMainWindow):
|
|
|
392
501
|
pixmap.save(path, "PNG")
|
|
393
502
|
else: # SVG
|
|
394
503
|
# Copia o arquivo temporário para o destino
|
|
395
|
-
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
if not path.lower().endswith(".svg"):
|
|
507
|
+
path = path + ".svg"
|
|
396
508
|
shutil.copyfile(self.temp_svg_path, path)
|
|
397
509
|
|
|
398
510
|
self.status.showMessage(CONFIG["image_save_in"]+" "+path, 5000)
|
|
@@ -452,6 +564,8 @@ class MainWindow(QMainWindow):
|
|
|
452
564
|
self.status.showMessage(CONFIG["saved_file"]+" "+path, 5000)
|
|
453
565
|
except Exception as e:
|
|
454
566
|
QMessageBox.critical(self, CONFIG["erro"], CONFIG["error_saving_file"]+"\n"+ e)
|
|
567
|
+
|
|
568
|
+
self.input_filepath = str(path)
|
|
455
569
|
|
|
456
570
|
def compile_dot(self):
|
|
457
571
|
dot_code = self.editor.toPlainText()
|
|
@@ -462,12 +576,13 @@ class MainWindow(QMainWindow):
|
|
|
462
576
|
self.thread.finished.connect(self.show_image)
|
|
463
577
|
self.thread.start()
|
|
464
578
|
|
|
465
|
-
def show_image(self, path):
|
|
466
|
-
if
|
|
467
|
-
|
|
579
|
+
def show_image(self, path, error_msg):
|
|
580
|
+
if error_msg: # deu erro
|
|
581
|
+
QMessageBox.critical(None, CONFIG["error_compilation"], error_msg)
|
|
468
582
|
else:
|
|
469
|
-
|
|
470
|
-
|
|
583
|
+
if path:
|
|
584
|
+
self.viewer.load_image(path)
|
|
585
|
+
self.progress.setValue(0)
|
|
471
586
|
# ---------------------------
|
|
472
587
|
# Run
|
|
473
588
|
# ---------------------------
|
{graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: graphviz_code_viewer
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Program to edit and view Graphviz code.
|
|
5
5
|
Author-email: Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
|
|
6
6
|
Maintainer-email: Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "graphviz_code_viewer"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.1"
|
|
8
8
|
description = "Program to edit and view Graphviz code."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{name = "Fernando Pujaico Rivera", email = "fernando.pujaico.rivera@gmail.com"}]
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/icons/logo.png
RENAMED
|
File without changes
|
{graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/modules/__init__.py
RENAMED
|
File without changes
|
{graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/modules/wabout.py
RENAMED
|
File without changes
|
{graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer/program.old.py
RENAMED
|
File without changes
|
{graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{graphviz_code_viewer-0.1.0 → graphviz_code_viewer-0.1.1}/graphviz_code_viewer.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|