示例#1
0
    def action_show_options(self, OptionsDialog):
        # TODO
        """create a customs window dialog with helpful user info including
        SQL Server, Parts database name/location"""

        self.OptionsDialog = OptionsDialog(self.context)
        self.OptionsDialog.exec()

        return None
示例#2
0
文件: DEAPPanel.py 项目: emcnany/deap
    def OnOptions(self, event):
        cl     = self.GetCommandLine()
        dialog = OptionsDialog(self, -1)

        dialog.SetAutoComplete(cl.autoComplete)
        if wx.ID_OK <> dialog.ShowModal():
            dialog.destroy()
            return

        # TBF
        cl.autoComplete = dialog.GetAutoComplete()
        cl.wrap(dialog.GetWordWrap())
示例#3
0
文件: Main.py 项目: babytux/PyCamimg
 def __openOptionsEvent__ (self, b):
     """
     @summary: Open options window.
     @param b: Button that threw event.
     """
     optionsDialog = OptionsDialog(self.__langs__,
                                   self.__currLang__,
                                   callback=self.__applyConfigurationCallback__,
                                   parent=self.__mainWindow__)
     
     __log__.debug("Option dialog created. %s" % optionsDialog)
     optionsDialog.run()
示例#4
0
class MainWindow(QtWidgets.QMainWindow, config_main_window.Ui_MainWindow):
    def __init__(self):
        #   Это здесь нужно для доступа к переменным, методам
        #   и т.д. в файле config_main_window.py
        super().__init__()
        self.initUi()

    def initUi(self):
        self.setupUi(self)  #   Это нужно для инициализации нашего дизайна

        self.actionSettings.triggered.connect(self.open_settings_dialog)
        self.actionEnter_table.triggered.connect(self.open_enterTable_widget)
        self.actionOpen_file.triggered.connect(self.open_loadFile_dialog)

    def open_enterTable_widget(self):
        self.EnterTableWindow = EnterTableWidget(self)
        self.EnterTableWindow.show()

    def open_loadFile_dialog(self):
        self.OpenFileDialog = OpenFileDialog(self)
        self.OpenFileDialog.show()

    def open_settings_dialog(self):
        self.OptionsWindow = OptionsDialog(self)
        self.OptionsWindow.setWindowModality(QtCore.Qt.WindowModal)
        self.OptionsWindow.show()

    def set_size_data_Table_Widget(self, data_arrays):
        rows = max(len(array) for array in data_arrays)
        columns = len(data_arrays)
        self.data_Table_Widget.setRowCount(rows + 10)
        self.data_Table_Widget.setColumnCount(columns + 2)

    def fill_data_Table(self, data_arrays):
        for data_array in data_arrays:
            for number in data_array:
                self.data_Table_Widget.setItem(data_array.index(number),
                                               data_arrays.index(data_array),
                                               QTableWidgetItem(f'{number}'))
示例#5
0
    def OnOptions(self, event):
        cl     = self.GetCommandLine()
        if cl is not None:
            dialog = OptionsDialog(self, -1)

            dialog.SetAutoComplete(cl.autoComplete)
            if wx.ID_OK <> dialog.ShowModal():
                dialog.destroy()
                return

            # TBF
            cl.autoComplete = dialog.GetAutoComplete()
            cl.wrap(dialog.GetWordWrap())
        else:
            wx.MessageBox('No command line options available', 'Options', wx.OK)
    def open_options_dialog(self):
        win = OptionsDialog()
        win.setValues(self.firstSize, self.secondSize, self.thirdSize)

        if win.exec_() == QtWidgets.QDialog.Accepted:
            sizes = win.get_values()
            self.firstSize = sizes[0]
            self.secondSize = sizes[1]
            self.thirdSize = sizes[2]
            self.new_game()
示例#7
0
    def init_sql_master_connection(self):
        """Create a database connection for other apps to use"""

        # Read configuration options for database connection
        if '_DEFAULT_FILE_PATH' not in self.__dict__:
            self.init_application_options()
        options = OptionsDialog(self)._action_read_json_options(self._OPTIONS_FILE_PATH)
        self.sql_server = options['sql_server']
        self.sql_driver = options['sql_driver']
        self.default_jobs_folder = options['default_jobs_folder']

        # Initialize database connection to master database
        try:
            self.SQLBase = SQLBase(self.sql_server, self.sql_driver)
        except Exception as e:
            msg=('There was an error connecting to the specified SQL Server' +
                 ' instance. Please navigate to options and enter a correct' +
                 ' SQL Server hostname.\n' +
                 'SQL Server : {}\n' +
                 'SQL Driver : {}'.format(self.sql_server, self.sql_driver))
            self.action_user_message('Database Connection', msg, detail=str(e))

        return None
示例#8
0
 def open_settings_dialog(self):
     self.OptionsWindow = OptionsDialog(self)
     self.OptionsWindow.setWindowModality(QtCore.Qt.WindowModal)
     self.OptionsWindow.show()
 def openOptionsDialog(self):
     od = OptionsDialog(self, self.settings)
     od.exec_()
    def doClickEvent(self, index, tag):
        if self.is_loading == True:  # block click event if loading data in process
            return

        if tag.find('check#') != -1:
            print('index: %s label: %s' % (index, tag))
            print(self.check[index].get())
        else:
            if tag is 'Open':
                self.filename = filedialog.askopenfilename(
                    initialdir="/",
                    title=self.openfdialog_filter,
                    filetypes=(("Supported Files (*.py)", "*.py"),
                               ("All Files", "*.*")))
                print(self.filename)
            elif tag.find('Server') != -1:
                s = ServerDialog(self.parent, title=tag)
            elif tag is 'SaveAs':
                self.filename = filedialog.asksaveasfilename(
                    initialdir="/",
                    title=self.savefdialog_filter,
                    filetypes=(("Supported Files (*.py)", "*.py"),
                               ("All Files", "*.*")))
            elif tag is 'Recipients':
                r = RecipientDialog(self.parent, title="Email Addresses ")
            elif tag is 'New':
                c = ConfigCrawlDialog(self.parent, title="New Crawl")
                self.init_settings()
                self.init_workspaces()
            elif tag.find('Preferences') != -1:
                o = OptionsDialog(self.parent, title=tag)
            elif tag.find('About') != -1:
                a = AboutDialog(self.parent, title=tag)
            elif tag.find('Dispatchers') != -1:
                self.settings.SetSettings(
                    'selected_table',
                    'dispatchers')  # set an action button that in dialog
                d = DispatcherDialog(self.parent, title=tag)
            elif tag.find('Companies') != -1:
                self.settings.SetSettings(
                    'selected_table',
                    'companies')  # set an action button that in dialog
                d = DispatcherDialog(self.parent, title=tag)
            elif tag.find('Refresh') != -1:
                self.init_workspaces()
                self.start_dataThread()
            elif tag.find('All') != -1:
                res = messagebox.askquestion(
                    'Load All Crawled Data',
                    'This may take a few time.\nAre you sure you want to load all crawled data from WFM?'
                )
                if res == 'yes':
                    self.set_WFMTable(TABLE_ALLDATA)
                    self.start_dataThread()
            elif tag.find('Status') != -1:
                self.settings.SetSettings(
                    'selected_table',
                    'status')  # set an action button that in dialog
                d = DispatcherDialog(self.parent, title=tag)

            elif tag.find('Exit') != -1:
                self.onExit()
            elif tag.find('StartCrawl') != -1:
                if self.kill_ie.get() == 1:
                    self.process.kill_process('iexplore.exe')

                self.crawlDialog = CrawlerDialog(self.parent)  # init GUI
                #self.crawler = Crawler(self.crawlDialog) #init Controller
                #self.crawler.startCrawler()

            else:
                print('doClickEvent  index: %s label: %s' % (index, tag))
示例#11
0
class MainWindow(QMainWindow, Ui_MainWindow):
    # action_find_job_Signal = pyqtSignal()

    def __init__(self, context):
        super(MainWindow, self).__init__()

        # Set user interface from Designer
        self.setupUi(self)

        # FBS Context manager
        self.context = context

        # This will be the main user interface on startup
        self.MyWindowDialog = MainWindowDialog()
        self.MyWindowDialog.init_signals(self)
        self.setCentralWidget(self.MyWindowDialog)
        self.setWindowIcon(self.context.main_icon)
        self.setWindowTitle('Panel Builder')

        # Connect buttons
        self.init_menu()

        # Initialize database connection
        self.context.init_application_options()
        self.context.init_sql_master_connection()

        return None

    def init_menu(self):
        """Define all signals and slots for this widget, including the menu bar
        """
        # Find_Job QAction
        self.actionFind_Job.setStatusTip('Find SQL Database')
        self.actionFind_Job.triggered\
            .connect(lambda state : self.action_find_job())

        # Options QAction
        self.actionOptions.setStatusTip('Change application settings & Options')
        self.actionOptions.triggered\
            .connect(lambda : self.action_show_options(OptionsDialog))

        # Show Reports QAction
        self.actionOpen_Reports.setStatusTip('Show Reports')
        self.actionOpen_Reports.triggered\
            .connect(lambda state : self.action_show_reports(ReportDialog))

        self.actionBOM.setStatusTip('Show Device Table')
        self.actionBOM.triggered\
            .connect(lambda state : self.action_show_SQL_BOM(DeviceTableDialog))

        # Show update Product DB Dialog
        self.actionUpdate_Product_DB.setStatusTip('Update product DB from EXCEL SOP')
        self.actionUpdate_Product_DB.triggered\
            .connect(lambda state : self.action_show_update_products(ProductUpdateDialog))

        return None


    def closeEvent(self, event):
        msgBox = QMessageBox(QMessageBox.Information,
                             'Exit application',
                             'Do you want to exit?',
                             QMessageBox.Yes | QMessageBox.No)
        msgBox.setWindowIcon(self.context.alarm_icon)
        choice = msgBox.exec()
        if choice == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()
            pass
        return None

    @staticmethod
    def find_mdf(directory):
        """Input a user-defined directory on their file system.  Output a
        full path to a .mdf SQL database file in a sub directory of the user
        specified path.  This function handles (2) cases :
        Look for the .mdf file in the given directory (yield all matching files
        in the given directory matching a pattern *.mdf)
        Look for the .mdf file in the given directory up to 2 sub folders down
        (yield all matching files in the given driectory and its direct child
        directories - do not search recursively)
        Inputs
        directory : (pathlib.Path) Path object
        """
        if isinstance(directory, Path):
            pass
        else:
            # Try to handle strings
            try:
                directory = Path(directory)
            except TypeError:
                msg = ('An incorrect directory argument was passed of ' +
                       'type {} '.format(type(directory)) +
                       'please pass type pathlib.Path')

        # Search the top level directory
        mdf_match_list = list(directory.glob('*.mdf'))
        ldf_match_list = list(directory.glob('*.ldf'))

        if mdf_match_list.__len__() >= 1 and ldf_match_list.__len__() >= 1:
            path_mdf = mdf_match_list[0]
            path_ldf = ldf_match_list[0]
            msg = 'Database found at {}'.format(path_mdf)
            return path_mdf, path_ldf, msg

        # No files are found in root directory
        if mdf_match_list.__len__() < 1:
            # Search child directories
            child_dirs = [x for x in directory.iterdir() if x.is_dir()]

            for child in child_dirs:
                mdf_match_list_sub = list(child.glob('*.mdf'))
                ldf_match_list_sub = list(child.glob('*.ldf'))

                if mdf_match_list_sub.__len__() >= 1 and ldf_match_list_sub.__len__() >= 1:
                    path_mdf = mdf_match_list_sub[0]
                    path_ldf = ldf_match_list_sub[0]
                    msg = 'Database found at {}'.format(path_mdf)
                    return path_mdf, path_ldf, msg

                # No files are found
                else:
                    path_mdf = None
                    path_ldf = None
                    msg = ('No SQL database with a .mdf extension .mdf was found in ' +
                           'the selected directory : {}.'.format(directory) +
                           ' Please select a new directory')


        return path_mdf, path_ldf, msg

    @staticmethod
    def find_j_vars(directory):
        """Input a user-defined directory on their file system.  Output a
        full path to a .mdf SQL database file in a sub directory of the user
        specified path.  This function handles (2) cases :
        Look for the .mdf file in the given directory (yield all matching files
        in the given directory matching a pattern *.mdf)
        Look for the .mdf file in the given directory up to 2 sub folders down
        (yield all matching files in the given driectory and its direct child
        directories - do not search recursively)
        Inputs
        directory : (pathlib.Path) Path object
        """
        if isinstance(directory, Path):
            pass
        else:
            # Try to handle strings
            try:
                directory = Path(directory)
            except TypeError:
                msg = ('An incorrect directory argument was passed of ' +
                       'type {} '.format(type(directory)) +
                       'please pass type pathlib.Path')

        # Search the top level directory
        match_list = list(directory.glob('j_vars.ini'))

        if match_list.__len__() >= 1:
            file_path = match_list[0]
            msg = 'jvars found at {}'.format(file_path)
            return file_path, msg

        # No files are found in root directory
        if match_list.__len__() < 1:
            # Search child directories
            child_dirs = [x for x in directory.iterdir() if x.is_dir()]

            for child in child_dirs:
                match_list_sub = list(child.glob('j_vars.ini'))

                if match_list_sub.__len__() >= 1:
                    file_path = match_list_sub[0]
                    msg = 'j_vars found at {}'.format(file_path)
                    break

                # No files are found
                else:
                    file_path = None
                    msg = ('No j_vars was found in ' +
                           'the selected directory : {}.'.format(directory) +
                           ' Please select a new directory')

        return file_path, msg


    def action_find_job(self):
        """Open QFindDialog to find SQL database file or folder with SQL
        database file"""

        fileDialog = QFileDialog(self)
        fileDialog.setFileMode(QFileDialog.Directory)
        str_directory = QFileDialog.getExistingDirectory(self,
                                                'Select Job Directory',
                                                self.context.default_jobs_folder,
                                                options=QFileDialog.ShowDirsOnly)

        directory = Path(str_directory)

        path_mdf, path_ldf, msg = self.find_mdf(directory)
        j_vars_path, j_vars_msg = self.find_j_vars(directory)

        if path_mdf is None:
            # No database file is found in the selected directory
            msgBox = QMessageBox()
            msgBox.setWindowTitle('Database Search')
            msgBox.setText(msg)
            msgBox.setStandardButtons(QMessageBox.Ok)
            msgBox.setIcon(QMessageBox.Information)
            msgBox.setWindowIcon(self.context.alarm_icon)
            msgBox.exec()
            return None

        elif j_vars_path is None:
            # No job variables found in directory
            msgBox = QMessageBox()
            msgBox.setWindowTitle('Job Variables Search')
            msgBox.setText(j_vars_msg)
            msgBox.setStandardButtons(QMessageBox.Ok)
            msgBox.setIcon(QMessageBox.Information)
            msgBox.setWindowIcon(self.context.alarm_icon)
            msgBox.exec()
            return None

        elif path_ldf is None:
            # No database Log file is found in the selected directory
            msgBox = QMessageBox()
            msgBox.setWindowTitle('Database Search')
            msgBox.setText(msg)
            msgBox.setStandardButtons(QMessageBox.Ok)
            msgBox.setIcon(QMessageBox.Information)
            msgBox.setWindowIcon(self.context.alarm_icon)
            msgBox.exec()
            return None

        else:
            # Database file, Log file, and j_vars file are all found
            msgBox = QMessageBox()
            msgBox.setWindowTitle('Database Search')
            msgBox.setText(msg)
            msgBox.setStandardButtons(QMessageBox.Ok)
            msgBox.setWindowIcon(self.context.alarm_icon)
            msgBox.exec()

        # Change the displayed job file name
        self.context.path_mdf = path_mdf.__str__()
        self.context.path_ldf = path_ldf.__str__()
        self.context.path_j_vars = j_vars_path.__str__()


        self.MyWindowDialog.findChild(QLineEdit, 'JobPathTextEdit')\
            .setText(self.context.path_mdf)

        return None

    def action_show_options(self, OptionsDialog):
        # TODO
        """create a customs window dialog with helpful user info including
        SQL Server, Parts database name/location"""

        self.OptionsDialog = OptionsDialog(self.context)
        self.OptionsDialog.exec()

        return None

    def action_show_reports(self, ReportDialog):
        """Show the report dialog and
        set any data in the class that will be needed for job processing,
        including the selected job path"""

        if 'path_mdf' not in self.context.__dict__:
            self.action_show_select_job_message()

        elif self.context.path_mdf is None:
            self.action_show_select_job_message()

        elif not Path(self.context.path_mdf).is_file():
            self.action_show_select_job_message()

        else:
            try:
                self.ReportDialog = ReportDialog(self.context)
                self.ReportDialog.exec()
            except Exception as e:
                logging.debug(e)
                msg = ('An error occured while opening Reports.' +
                       '\nMake sure \n1. A valid job is selected \n2. A product' +
                       ' database is setup \n3. Your job has systems set up')

                msgBox = QMessageBox()
                msgBox.setWindowIcon(self.context.alarm_icon)
                msgBox.setWindowTitle('Report Error')
                msgBox.setText(msg)
                msgBox.setDetailedText(str(e))
                msgBox.setStandardButtons(QMessageBox.Ok)
                msgBox.setDefaultButton(QMessageBox.Ok)
                choice = msgBox.exec()

        return None

    def action_show_select_job_message(self):

        msg = ('No job has been selected yet. Please select a job' +
                ' using File-> Find Job')
        msgBox = QMessageBox(self)
        msgBox.setWindowIcon(self.context.help_icon)
        msgBox.setWindowTitle('BOM Select')
        msgBox.setText(msg)
        msgBox.setStandardButtons(QMessageBox.Ok)
        msgBox.setDefaultButton(QMessageBox.Ok)
        choice = msgBox.exec()

        return choice

    def action_show_SQL_BOM(self, DeviceTableDialog):

        """Show the Device Table Dialog if the job is already set"""

        if 'path_mdf' not in self.__dict__:
            self.action_show_select_job_message()

        elif self.path_mdf is None:
            self.action_show_select_job_message()

        elif not Path(self.path_mdf).is_file():
            self.action_show_select_job_message()

        else:
            self.DeviceTableDialog = DeviceTableDialog(self.context)
            self.DeviceTableDialog.exec()

        return None

    def action_show_update_products(self, ProductUpdateDialog):
        """Show the dialog to update product database from an SOP Excel file"""
        ProductUpdateDialog = ProductUpdateDialog(self.context)
        ProductUpdateDialog.exec()
        return None

    def action_user_message(self, title, msg, detail=None):
        """Create a simple user message box"""
        msgBox = QMessageBox()
        msgBox.setWindowTitle(title)
        msgBox.setText(msg)
        msgBox.setStandardButtons(QMessageBox.Ok)
        msgBox.setIcon(QMessageBox.Information)
        msgBox.setWindowIcon(self.context.alarm_icon)
        if detail:
            msgBox.setDetailedText(detail)
        msgBox.exec()
        return None
示例#12
0
    def __init__(self, iface):
        self.iface = iface

        # Création du dialogue
        dlg = OptionsDialog()

        # Lecture du fichier de config
        config = ConfigParser.RawConfigParser()
        print os.path.abspath(currentPath) + "/Potimart.cfg"
        config.read(os.path.abspath(currentPath) + "/Potimart.cfg")
        print config._sections

        # Mise à jour des champs de la fenêtre d'options
        dlg.ui.hostLineEdit.setText(config.get("postgres", "host"))
        dlg.ui.portLineEdit.setText(config.get("postgres", "port"))
        dlg.ui.dbnameLineEdit.setText(config.get("postgres", "dbname"))
        dlg.ui.usernameLineEdit.setText(config.get("postgres", "username"))
        dlg.ui.passwordLineEdit.setText(config.get("postgres", "password"))
        dlg.ui.railsLineEdit.setText(config.get("rails", "server"))

        # Affichage du dialogue
        dlg.show()

        # See if OK was pressed
        result = dlg.exec_()
        if result == 1:
            # Test de connexion à la base PostgreSQL
            uri = QgsDataSourceURI()
            # set host name, port, database name, username and password
            uri.setConnection(  str(dlg.ui.hostLineEdit.text()),\
                                str(dlg.ui.portLineEdit.text()),\
                                str(dlg.ui.dbnameLineEdit.text()),\
                                str(dlg.ui.usernameLineEdit.text()),\
                                str(dlg.ui.passwordLineEdit.text())     )
            uri.setDataSource("potimart", "service_links", "the_geom", "")
            layer = QgsVectorLayer(uri.uri(), "Test", "postgres")

            if layer.isValid():
                QMessageBox.information(
                    self.iface.mainWindow(),
                    QString.fromUtf8("Test de connexion à la base PostgreSQL"),
                    QString.fromUtf8("Connexion à la base PostgreSQL réussi."),
                    "Ok")
                # Mise à jour des infos de connexions
                config.set("postgres", "host", str(dlg.ui.hostLineEdit.text()))
                config.set("postgres", "port", str(dlg.ui.portLineEdit.text()))
                config.set("postgres", "dbname",
                           str(dlg.ui.dbnameLineEdit.text()))
                config.set("postgres", "username",
                           str(dlg.ui.usernameLineEdit.text()))
                config.set("postgres", "password",
                           str(dlg.ui.passwordLineEdit.text()))
                config.set("rails", "server", str(dlg.ui.railsLineEdit.text()))

                # MAJ du fichier de config
                configFile = open(
                    os.path.abspath(currentPath) + "/Potimart.cfg", 'w')
                config.write(configFile)
                configFile.close()
            else:
                QMessageBox.critical(self.iface.mainWindow(), QString.fromUtf8("Test de connexion à la base PostgreSQL"),\
                    QString.fromUtf8("Echec de la connexion, vérifier les paramètres entrés."), "Ok")

            # Test de connexion au serveur Rails (localhost:3000 par exemple)
            srv_rails = config.get("rails", "server")
            try:
                url_rails = urllib.urlopen('http://' + srv_rails +
                                           '/lines.xml')
                QMessageBox.information(self.iface.mainWindow(), QString.fromUtf8("Test de connexion au serveur RAILS"), \
                    QString.fromUtf8("Connexion au serveur RAILS réussi."), "Ok")
            except IOError:
                QMessageBox.critical(self.iface.mainWindow(), "Test de connexion au serveur RAILS",\
                  QString.fromUtf8("Echec de la connexion, vérifier les paramètres entrés."), "Ok")
示例#13
0
    def __init__(self, iface):
        self.iface = iface

        # Création du dialogue
        dlg = OptionsDialog()

        # Lecture du fichier de config
        config = ConfigParser.RawConfigParser()
        print os.path.abspath(currentPath) + "/Potimart.cfg"
        config.read(os.path.abspath(currentPath) + "/Potimart.cfg")
        print config._sections

        # Mise à jour des champs de la fenêtre d'options
        dlg.ui.hostLineEdit.setText(config.get("postgres", "host"))
        dlg.ui.portLineEdit.setText(config.get("postgres", "port"))
        dlg.ui.dbnameLineEdit.setText(config.get("postgres", "dbname"))
        dlg.ui.usernameLineEdit.setText(config.get("postgres", "username"))
        dlg.ui.passwordLineEdit.setText(config.get("postgres", "password"))
        dlg.ui.railsLineEdit.setText(config.get("rails", "server"))

        # Affichage du dialogue
        dlg.show()

        # See if OK was pressed
        result = dlg.exec_()
        if result == 1:
            # Test de connexion à la base PostgreSQL
            uri = QgsDataSourceURI()
            # set host name, port, database name, username and password
            uri.setConnection(  str(dlg.ui.hostLineEdit.text()),\
                                str(dlg.ui.portLineEdit.text()),\
                                str(dlg.ui.dbnameLineEdit.text()),\
                                str(dlg.ui.usernameLineEdit.text()),\
                                str(dlg.ui.passwordLineEdit.text())     )
            uri.setDataSource("potimart", "service_links", "the_geom", "")
            layer = QgsVectorLayer(uri.uri(), "Test", "postgres")

            if layer.isValid():
                QMessageBox.information(self.iface.mainWindow(), QString.fromUtf8("Test de connexion à la base PostgreSQL"), QString.fromUtf8("Connexion à la base PostgreSQL réussi."), "Ok")
                # Mise à jour des infos de connexions
                config.set("postgres", "host", str(dlg.ui.hostLineEdit.text()))
                config.set("postgres", "port", str(dlg.ui.portLineEdit.text()))
                config.set("postgres", "dbname", str(dlg.ui.dbnameLineEdit.text()))
                config.set("postgres", "username", str(dlg.ui.usernameLineEdit.text()))
                config.set("postgres", "password", str(dlg.ui.passwordLineEdit.text()))
                config.set("rails", "server", str(dlg.ui.railsLineEdit.text()))

                # MAJ du fichier de config
                configFile = open(os.path.abspath(currentPath) + "/Potimart.cfg", 'w')
                config.write(configFile)
                configFile.close()
            else:
                QMessageBox.critical(self.iface.mainWindow(), QString.fromUtf8("Test de connexion à la base PostgreSQL"),\
                    QString.fromUtf8("Echec de la connexion, vérifier les paramètres entrés."), "Ok")

            # Test de connexion au serveur Rails (localhost:3000 par exemple)
            srv_rails = config.get("rails", "server")
            try:
                url_rails = urllib.urlopen('http://' + srv_rails + '/lines.xml')
                QMessageBox.information(self.iface.mainWindow(), QString.fromUtf8("Test de connexion au serveur RAILS"), \
                    QString.fromUtf8("Connexion au serveur RAILS réussi."), "Ok")
            except IOError:
                QMessageBox.critical(self.iface.mainWindow(), "Test de connexion au serveur RAILS",\
                  QString.fromUtf8("Echec de la connexion, vérifier les paramètres entrés."), "Ok")
示例#14
0
class MainWindow(QtWidgets.QMainWindow, config_main_window.Ui_MainWindow):
    def __init__(self):
        #   Это здесь нужно для доступа к переменным, методам
        #   и т.д. в файле config_main_window.py
        super().__init__()
        self.setupUi(self)  #   Это нужно для инициализации нашего дизайна
        self.initActions()

    def initActions(self):
        self.actionSettings.triggered.connect(self.open_settings_dialog)
        self.actionEnter_table.triggered.connect(self.open_enterTable_widget)
        self.actionOpen_file.triggered.connect(self.open_loadFile_dialog)
        self.graphSettings_Button.clicked.connect(
            self.open_graphSettings_dialog)
        self.graphSettings_Button.clicked.connect(self.create_main_data_arrays)
        self.add_Rows_Columns_Button.clicked.connect(self.add_rows_columns)
        self.delete_Rows_Columns_Button.clicked.connect(
            self.delete_rows_columns)

    def create_main_data_arrays(self):
        self.main_data_arrays = []
        for column in range(self.data_Table_Widget.columnCount()):
            self.main_data_arrays.append([])
            for row in range(self.data_Table_Widget.rowCount()):
                element = self.data_Table_Widget.item(row, column)
                if element != None:
                    self.main_data_arrays[column].append(float(element.text()))
                else:
                    self.main_data_arrays[column].append(element)

        print(self.main_data_arrays)

    def open_graphSettings_dialog(self):
        self.GraphSettingsDialog = GraphSettingsDialog(self)
        self.GraphSettingsDialog.show()

    def add_rows_columns(self):
        self.data_Table_Widget.setRowCount(
            self.data_Table_Widget.rowCount() +
            self.additional_Rows_SpinBox.value())
        self.data_Table_Widget.setColumnCount(
            self.data_Table_Widget.columnCount() +
            self.additional_Columns_SpinBox.value())

    def delete_rows_columns(self):
        table_rows = self.data_Table_Widget.rowCount()
        table_columns = self.data_Table_Widget.columnCount()
        rows_SpinBox_Value = self.additional_Rows_SpinBox.value()
        columns_SpinBox_Value = self.additional_Columns_SpinBox.value()

        if table_rows > rows_SpinBox_Value:
            self.data_Table_Widget.setRowCount(table_rows - rows_SpinBox_Value)

        else:
            self.data_Table_Widget.setRowCount(0)

        if table_columns > columns_SpinBox_Value:
            self.data_Table_Widget.setColumnCount(table_columns -
                                                  columns_SpinBox_Value)

        else:
            self.data_Table_Widget.setColumnCount(0)

    def open_enterTable_widget(self):
        self.EnterTableWindow = EnterTableWidget(self)
        self.EnterTableWindow.show()

    def open_loadFile_dialog(self):
        self.OpenFileDialog = OpenFileDialog(self)
        self.OpenFileDialog.show()

    def open_settings_dialog(self):
        self.OptionsWindow = OptionsDialog(self)
        self.OptionsWindow.setWindowModality(QtCore.Qt.WindowModal)
        self.OptionsWindow.show()

    def set_size_data_Table_Widget(self, rows, columns):
        self.data_Table_Widget.setRowCount(
            rows + self.additional_Rows_SpinBox.value())
        self.data_Table_Widget.setColumnCount(
            columns + self.additional_Columns_SpinBox.value())

    def change_size_data_Table_Widget(self, data_arrays):
        rows = max(len(array) for array in data_arrays)
        columns = len(data_arrays)
        self.set_size_data_Table_Widget(rows, columns)

    def fill_data_Table(self, data_arrays):
        for data_array in data_arrays:
            for number in data_array:
                self.data_Table_Widget.setItem(data_array.index(number),
                                               data_arrays.index(data_array),
                                               QTableWidgetItem(f'{number}'))
示例#15
0
 def optionsDialog(self):
     dialog = OptionsDialog()
     dialog.exec_()