diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..c18b767 --- /dev/null +++ b/config.ini @@ -0,0 +1,7 @@ +[otwórz terminal] +type = command_line +command = gnome-terminal + +[zakończ] +type = python +command = window.close() diff --git a/main_ui.py b/main_ui.py index f1b0332..4bd1246 100644 --- a/main_ui.py +++ b/main_ui.py @@ -26,6 +26,7 @@ def setupUi(self, MainWindow): self.stateLabel = QtWidgets.QLabel(self.centralwidget) self.stateLabel.setLayoutDirection(QtCore.Qt.LeftToRight) self.stateLabel.setAutoFillBackground(False) + self.stateLabel.setText("") self.stateLabel.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop) self.stateLabel.setObjectName("stateLabel") self.verticalLayout.addWidget(self.stateLabel) @@ -54,7 +55,6 @@ def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "Mex Assistant")) self.speakButton.setText(_translate("MainWindow", "Mów")) - self.stateLabel.setText(_translate("MainWindow", "Ładowanie...")) self.menu_Plik.setTitle(_translate("MainWindow", "&Plik")) self.action_Ustawienia.setText(_translate("MainWindow", "&Ustawienia")) self.action_Zakoncz.setText(_translate("MainWindow", "&Zakończ")) diff --git a/process_command.py b/process_command.py index 1332917..c78156f 100644 --- a/process_command.py +++ b/process_command.py @@ -1,9 +1,28 @@ +import configparser +import re +import subprocess + from voice_operations import * class CommandProcessing(): def __init__(self): pass + def loadConfig(self): + config = configparser.ConfigParser() + config.read("config.ini") + self.config = config + def processCommand(self, window): command = takeVoice(3, window) window.stateLabel.setText(command) + command = command.lower() + self.loadConfig() + for i in self.config: + if re.search(i, command): + if self.config[i]["type"] == "command_line": + subprocess.Popen(self.config[i]["command"]) + if self.config[i]["type"] == "python": + exec(self.config[i]["command"]) + + diff --git a/test.py b/test.py new file mode 100644 index 0000000..7547255 --- /dev/null +++ b/test.py @@ -0,0 +1,6 @@ +import configparser +#Read config.ini file +config_obj = configparser.ConfigParser() +config_obj.read("config.ini") +for i in config_obj: + print(i) \ No newline at end of file diff --git a/ui/Main.ui b/ui/Main.ui index 40a2a9c..9af7322 100644 --- a/ui/Main.ui +++ b/ui/Main.ui @@ -34,7 +34,7 @@ false - Ładowanie... + Qt::AlignHCenter|Qt::AlignTop