예제 #1
0
    def doStopSubProcess(self, strObjName):
        print('Button {} clicked'.format(strObjName))
        args0 = strObjName.split('_')
        iIndex = int(args0[1])
        strAddress = self.lstTextEditAddress[iIndex].text()
        strPort = self.lstTextEditPort[iIndex].text()

        #todo fix here
        if strAddress != "" and strAddress != 'localhost':
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Information)
            msg.setText("远程程服务进程!😹  ")
            msg.setInformativeText("不是本地localhost本地进程😹 ")
            msg.setWindowTitle("操作提示:")
            msg.setDetailedText("请在远程机器上关闭服务进程")
            retval = msg.exec()
            return

        if strAddress == "":
            strAddress = 'localhost'
        if strPort == "":
            strPort = portNumberStart + iIndex

        mediator = self.getMediator()

        mediator.shutdownEastMoneyZjlxProcess(self, iIndex, strAddress,
                                              strPort)

        # self.lstBntStartSubProcessSocketServer[iIndex].setEnabled(True)
        # self.lstBntStopSubProcessSocketServer[iIndex].setEnabled(False)
        #
        # self.lstTextEditPort[iIndex].setEnabled(True)
        # self.lstTextEditAddress[iIndex].setEnabled(True)
        pass
예제 #2
0
    def doStartSubProcess(self, strObjName):
        print('Button {} clicked'.format(strObjName))

        args0 = strObjName.split('_')
        iIndex = int(args0[1])

        strAddress = self.lstTextEditAddress[iIndex].text()
        strPort = self.lstTextEditPort[iIndex].text()

        #todo fix here
        if strAddress != "" and strAddress != 'localhost':
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Information)
            msg.setText("尝试启动远程服务进程!😹  ")
            msg.setInformativeText("不是本地localhost本地进程😹 ")
            msg.setWindowTitle("操作提示:")
            msg.setDetailedText("请在远程机器上启动本程序启动服务进程")
            retval = msg.exec()
            return

        if strAddress == "":
            strAddress = 'localhost'
        if strPort == "":
            strPort = str(portNumberStart + iIndex)

        mediator = self.getMediator()
        bRetOk = mediator.startUpEastMoneyZjlxProcess(self, iIndex, strAddress,
                                                      strPort)
예제 #3
0
def copy_selection(p_selection,p_with_connections=True):
    """Copy p_selection into a new collection and adds this to
        the selection of """
    global_properties = GlobalProperties.get_instance()
    new_selection = deepcopy(p_selection)
    copy_selection_name = new_selection.name
    copy_selection_name = copy_selection_name + " ( copy )"
    if global_properties.mpdj_data.selection_with_name_exists(copy_selection_name):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText("Unable to create selection_copy, name exists.")
        msg.setInformativeText(
            "{} can't be created, a selection with this name exists.".format(copy_selection_name))
        msg.setWindowTitle("MessageBox ")
        msg.setDetailedText("The details are as follows:")
    new_selection.set_name(copy_selection_name)
    global_properties.mpdj_data.add_song_selection(new_selection)
    if p_with_connections:
        neighbours = global_properties.mpdj_data.get_neighbours_for_node_name(
            p_selection.get_name())
        for neighbour in neighbours:
            global_properties.mpdj_data.set_connected(copy_selection_name,neighbour,1,False)
        all_selections = global_properties.mpdj_data.get_song_selection_names()
        for selection in all_selections:
            if global_properties.mpdj_data.is_connected(selection,
                                                        p_selection.get_name()):
                global_properties.mpdj_data.set_connected(selection,copy_selection_name,1,False)
    global_properties.inform_update_listener()
예제 #4
0
    def startAllThread(self):

        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText("😯还未实现,请一个个点击 按钮启动进程!😹  ")
        msg.setInformativeText("🤐一次启动,电脑会变得很慢,后期实现😹 ")
        msg.setWindowTitle("😬操作提示:")
        msg.setDetailedText("🤔笔记本电脑严重发烫")
        retval = msg.exec()
        pass
예제 #5
0
    def stopAllThread(self):

        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText("🤑还未实现,请一个个点击 按钮关闭进程!😹  ")
        msg.setInformativeText("🙄一次关闭,电脑会变得很慢,后期实现😹 ")
        msg.setWindowTitle("操作提示:")
        msg.setDetailedText("🤮笔记本电脑严重发烫")
        retval = msg.exec()
        pass
예제 #6
0
 def report_error(self, msg=None):
     if not msg:
         etype, value, tb = exc_info()
         trace = ''.join(format_exception(etype, value, tb))
         delim_len = 40
         msg = ("*" * delim_len + "\n%s\n" + "*" * delim_len) % trace
         error(msg)
     mb = QMessageBox(QMessageBox.Critical, tr('Ошибка'),
                      str(exc_info()[1]))
     mb.setDetailedText(msg)
     mb.exec()
예제 #7
0
def error(txt=None, verbTxt=None):
    msg = QMessageBox()
    msg.setText("              Error                ")
    if txt is None and verbTxt is None:
        msg.setInformativeText("Erro Algo aconteceu tente De novo.")
    elif txt is not None and verbTxt is None:
        msg.setInformativeText(txt)
    else:
        msg.setInformativeText(txt)
        msg.setDetailedText(verbTxt)
    msg.setIcon(QMessageBox.Warning)
    msg.setStandardButtons(QMessageBox.Ok)
    msg.exec()
    def on_about_update(self, text):
        self.add_log("Пришло обновление '{}'".format(text))

        mb = QMessageBox()
        mb.setWindowTitle("Доступно обновление")
        mb.setText("Сейчас доступно обновление")
        mb.setDetailedText(text)
        button_ok = mb.addButton("Обновить", QMessageBox.AcceptRole)
        button_cancel = mb.addButton("Отклонить", QMessageBox.RejectRole)

        mb.exec()

        if mb.clickedButton() == button_cancel:
            self.add_log('Пользователь отказался от обновления...')
            return

        self.add_log('Выполняю обновление...')

        # ...
        # Обновляемся
        # ...

        self.add_log('Обновление поставлено успешно...')
예제 #9
0
class MessageWindow:
    def __init__(self, title, text, type="ok", default=None, customButtons =None, customIcon=None, run=True, destroyAfterRun=True, detailed=False, longText=""):
        self.rc = None
        self.dialog = None
        self.msgBox = QMessageBox()
        self.doCustom = False
        self.customButtons = customButtons

        icon  = None
        buttons = None

        if type == 'ok':
            buttons = QMessageBox.Ok
            icon = "question"
        elif type == 'error':
            icon = "error"
            buttons =  QMessageBox.Ok
        elif type == 'warning':
            icon = "warning"
            buttons =  QMessageBox.Ok
        elif type == 'okcancel':
            icon = "question"
            buttons = QMessageBox.Ok | QMessageBox.Cancel
        elif type == 'question':
            icon = "question"
            buttons = QMessageBox.Ok | QMessageBox.Cancel
        elif type == 'yesno':
            icon = "question"
            buttons = QMessageBox.Yes | QMessageBox.No
        elif type == 'custom':
            self.doCustom = True
            if customIcon:
                icon = customIcon
            else:
                icon = "question"

        text = "<qt>%s</qt>" % text.replace("\n", " ")
        self.msgBox.setText(text)
        if detailed:
            self.msgBox.setDetailedText(unicode(longText))

        if self.doCustom:
            button = None
            for index, text in enumerate(self.customButtons):
                button = self.msgBox.addButton(text, QMessageBox.ActionRole)
                if default is not None and default == index:
                    self.msgBox.setDefaultButton(button)
        else:
            self.msgBox.setStandardButtons(buttons)

            if default == "no":
                default = QMessageBox.No
            elif default == "yes":
                default = QMessageBox.Yes
            elif default == "ok":
                default = QMessageBox.Ok
            else:
                default = None

        self.msgBox.setDefaultButton(default)

        self.dialog = Dialog(_(title), self.msgBox, closeButton=False, isDialog=True, icon=icon)
        self.dialog.resize(QSize(0,0))
        if run:
            self.run(destroyAfterRun)

    def run(self, destroyAfterRun=True):
        self.rc = self.dialog.exec_()
        if self.msgBox.clickedButton():
            if not self.doCustom:
                if self.msgBox.clickedButton().text() in [_("Ok"), _("Yes")]:
                    self.rc = 1
                elif self.msgBox.clickedButton().text() in [_("Cancel"), _("No")]:
                    self.rc = 0
            else:
                if self.msgBox.clickedButton().text() in self.customButtons:
                    self.rc = self.customButtons.index(self.msgBox.clickedButton().text())

        if destroyAfterRun:
            self.dialog = None

        return self.rc
예제 #10
0
class MessageWindow:
    def __init__(self,
                 title,
                 text,
                 type="ok",
                 default=None,
                 customButtons=None,
                 customIcon=None,
                 run=True,
                 destroyAfterRun=True,
                 detailed=False,
                 longText=""):
        self.rc = None
        self.dialog = None
        self.msgBox = QMessageBox()
        self.doCustom = False
        self.customButtons = customButtons

        icon = None
        buttons = None

        if type == 'ok':
            buttons = QMessageBox.Ok
            icon = "question"
        elif type == 'error':
            icon = "error"
            buttons = QMessageBox.Ok
        elif type == 'warning':
            icon = "warning"
            buttons = QMessageBox.Ok
        elif type == 'okcancel':
            icon = "question"
            buttons = QMessageBox.Ok | QMessageBox.Cancel
        elif type == 'question':
            icon = "question"
            buttons = QMessageBox.Ok | QMessageBox.Cancel
        elif type == 'yesno':
            icon = "question"
            buttons = QMessageBox.Yes | QMessageBox.No
        elif type == 'custom':
            self.doCustom = True
            if customIcon:
                icon = customIcon
            else:
                icon = "question"

        text = "<qt>%s</qt>" % text.replace("\n", " ")
        self.msgBox.setText(text)
        if detailed:
            self.msgBox.setDetailedText(unicode(longText))

        if self.doCustom:
            button = None
            for index, text in enumerate(self.customButtons):
                button = self.msgBox.addButton(text, QMessageBox.ActionRole)
                if default is not None and default == index:
                    self.msgBox.setDefaultButton(button)
        else:
            self.msgBox.setStandardButtons(buttons)

            if default == "no":
                default = QMessageBox.No
            elif default == "yes":
                default = QMessageBox.Yes
            elif default == "ok":
                default = QMessageBox.Ok
            else:
                default = None

        self.msgBox.setDefaultButton(default)

        self.dialog = Dialog(_(title),
                             self.msgBox,
                             closeButton=False,
                             isDialog=True,
                             icon=icon)
        self.dialog.resize(QSize(0, 0))
        if run:
            self.run(destroyAfterRun)

    def run(self, destroyAfterRun=True):
        self.rc = self.dialog.exec_()
        if self.msgBox.clickedButton():
            if not self.doCustom:
                if self.msgBox.clickedButton().text() in [_("Ok"), _("Yes")]:
                    self.rc = 1
                elif self.msgBox.clickedButton().text() in [
                        _("Cancel"), _("No")
                ]:
                    self.rc = 0
            else:
                if self.msgBox.clickedButton().text() in self.customButtons:
                    self.rc = self.customButtons.index(
                        self.msgBox.clickedButton().text())

        if destroyAfterRun:
            self.dialog = None

        return self.rc