|
6 | 6 | from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QRadioButton, QLineEdit, QPushButton, QMessageBox, QGridLayout, QFileDialog, QComboBox, QVBoxLayout |
7 | 7 | from PyQt5.QtGui import QPixmap, QIcon |
8 | 8 | from PyQt5.QtCore import Qt |
9 | | - |
| 9 | +from win32com.client import Dispatch |
| 10 | + |
| 11 | +import winshell |
10 | 12 | import sys |
11 | 13 | import os |
12 | 14 | import math |
13 | 15 | import unicodedata |
14 | 16 | import re |
15 | 17 | import shutil |
16 | 18 | import pandas as pd |
| 19 | + |
| 20 | +############################################################ |
| 21 | +####################### ALERTAS ############################ |
| 22 | +############################################################ |
| 23 | + |
| 24 | +def show_error_message(title, message): |
| 25 | + app = QApplication.processEvents() |
| 26 | + error_box = QMessageBox() |
| 27 | + error_box.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
| 28 | + error_box.setIcon(QMessageBox.Critical) |
| 29 | + error_box.setWindowTitle(title) |
| 30 | + error_box.setText(message) |
| 31 | + error_box.setStandardButtons(QMessageBox.Ok) |
| 32 | + error_box.exec_() |
| 33 | + QApplication.processEvents() |
| 34 | + |
| 35 | +def show_warning_message(title, message): |
| 36 | + app = QApplication.processEvents() |
| 37 | + warning_box = QMessageBox() |
| 38 | + warning_box.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
| 39 | + warning_box.setIcon(QMessageBox.Warning) |
| 40 | + warning_box.setWindowTitle(title) |
| 41 | + warning_box.setText(message) |
| 42 | + warning_box.setStandardButtons(QMessageBox.Ok) |
| 43 | + warning_box.exec_() |
| 44 | + QApplication.processEvents() |
| 45 | + |
| 46 | +def show_information_message(title, message): |
| 47 | + app = QApplication.processEvents() |
| 48 | + information = QMessageBox() |
| 49 | + information.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
| 50 | + information.setIcon(QMessageBox.Information) |
| 51 | + information.setWindowTitle(title) |
| 52 | + information.setText(message) |
| 53 | + information.setStandardButtons(QMessageBox.Ok) |
| 54 | + information.exec_() |
| 55 | + QApplication.processEvents() |
| 56 | + |
| 57 | +def show_information_message_with_link(title, message, link): |
| 58 | + msg_box = QMessageBox() |
| 59 | + msg_box.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
| 60 | + msg_box.setIcon(QMessageBox.Information) |
| 61 | + msg_box.setWindowTitle(title) |
| 62 | + msg_box.setText(message) |
| 63 | + |
| 64 | + # Adiciona um botão com o texto "Copiar link" |
| 65 | + copy_button = msg_box.addButton("Copiar link", QMessageBox.ActionRole) |
| 66 | + copy_button.clicked.connect(lambda: QApplication.clipboard().setText(link)) |
| 67 | + |
| 68 | + msg_box.exec_() |
| 69 | + |
| 70 | +############################################################ |
| 71 | +################## ATALHO DO EXECUTÁVEL ################### |
| 72 | +############################################################ |
| 73 | + |
| 74 | +def create_shortcut(target_path, shortcut_name, start_in): |
| 75 | + desktop = winshell.desktop() |
| 76 | + shortcut_path = os.path.join(desktop, shortcut_name) |
| 77 | + shell = Dispatch('WScript.Shell') |
| 78 | + shortcut = shell.CreateShortCut(shortcut_path) |
| 79 | + shortcut.Targetpath = target_path |
| 80 | + shortcut.WorkingDirectory = start_in # Definir o diretório de trabalho |
| 81 | + shortcut.save() |
| 82 | + |
| 83 | +target_path = os.getcwd() + "../Script Calculadora AWS.exe" |
| 84 | +shortcut_name = "Script Calculadora AWS.lnk" |
| 85 | +shortcut_path = os.path.join(winshell.desktop(), shortcut_name) |
17 | 86 |
|
18 | 87 | ############################################################ |
19 | 88 | ################ INTERFACE DO USUÁRIO ###################### |
@@ -83,6 +152,13 @@ def ajustar_dimensionamento(): |
83 | 152 |
|
84 | 153 | app = QApplication(sys.argv) |
85 | 154 | root = QWidget() |
| 155 | + |
| 156 | +# Verificar se o atalho já existe |
| 157 | +if not os.path.exists(shortcut_path): |
| 158 | + # Se o atalho não existir, criar |
| 159 | + create_shortcut(target_path, shortcut_name, os.getcwd()) |
| 160 | + show_information_message("Aviso", f"Foi criado um atalho na área de trabalho") |
| 161 | + |
86 | 162 | root.setWindowTitle("Script Calculadora AWS") |
87 | 163 | root.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
88 | 164 |
|
@@ -667,56 +743,6 @@ def copiar_dados(origem, destino): |
667 | 743 | show_warning_message("Aviso", f"Informações insuficientes para gerar o Modelo AWS") |
668 | 744 | exit(1) |
669 | 745 |
|
670 | | -############################################################ |
671 | | -####################### ALERTAS ############################ |
672 | | -############################################################ |
673 | | - |
674 | | -def show_error_message(title, message): |
675 | | - app = QApplication.processEvents() |
676 | | - error_box = QMessageBox() |
677 | | - error_box.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
678 | | - error_box.setIcon(QMessageBox.Critical) |
679 | | - error_box.setWindowTitle(title) |
680 | | - error_box.setText(message) |
681 | | - error_box.setStandardButtons(QMessageBox.Ok) |
682 | | - error_box.exec_() |
683 | | - QApplication.processEvents() |
684 | | - |
685 | | -def show_warning_message(title, message): |
686 | | - app = QApplication.processEvents() |
687 | | - warning_box = QMessageBox() |
688 | | - warning_box.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
689 | | - warning_box.setIcon(QMessageBox.Warning) |
690 | | - warning_box.setWindowTitle(title) |
691 | | - warning_box.setText(message) |
692 | | - warning_box.setStandardButtons(QMessageBox.Ok) |
693 | | - warning_box.exec_() |
694 | | - QApplication.processEvents() |
695 | | - |
696 | | -def show_information_message(title, message): |
697 | | - app = QApplication.processEvents() |
698 | | - information = QMessageBox() |
699 | | - information.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
700 | | - information.setIcon(QMessageBox.Information) |
701 | | - information.setWindowTitle(title) |
702 | | - information.setText(message) |
703 | | - information.setStandardButtons(QMessageBox.Ok) |
704 | | - information.exec_() |
705 | | - QApplication.processEvents() |
706 | | - |
707 | | -def show_information_message_with_link(title, message, link): |
708 | | - msg_box = QMessageBox() |
709 | | - msg_box.setWindowIcon(QIcon(os.getcwd() + "/assets/ntt_icone.ico")) |
710 | | - msg_box.setIcon(QMessageBox.Information) |
711 | | - msg_box.setWindowTitle(title) |
712 | | - msg_box.setText(message) |
713 | | - |
714 | | - # Adiciona um botão com o texto "Copiar link" |
715 | | - copy_button = msg_box.addButton("Copiar link", QMessageBox.ActionRole) |
716 | | - copy_button.clicked.connect(lambda: QApplication.clipboard().setText(link)) |
717 | | - |
718 | | - msg_box.exec_() |
719 | | - |
720 | 746 | ############################################################ |
721 | 747 | ######################### EXEC ############################# |
722 | 748 | ############################################################ |
|
0 commit comments