示例#1
0
文件: new_grid.py 项目: giserh/mca
    def computeNewGrid(self):
        # get form values
        self.projectName = self.sizerHProject.getValue()
        self.authorName = self.sizerHAuthor.getValue()
        self.polygon = self.sizerHPolygon.getValue()
        self.obstacle = self.sizerHObstacles.getValue()
        self.srsObstacle = self.sizerHObstacles.getSRSValue()
        self.res = self.sizerHResolution.getValue()
        self.srsPolygon = self.sizerHPolygon.getSRSValue()
        self.srsPolygon = re.search(r'\[(\d*)\].*', self.srsPolygon).group(1)

        Publisher().subscribe(self.catchError,
                              'catchError')  # create a pubsub receiver
        self.tmpP = None  # path to temporary polygon files created during populate
        self.tmpO = None  # path to temporary obstacles files created during populate
        self.gridCreated = False

        self.Hide()
        self.load = Loading(self, "Loading")
        self.start = time.time()

        callback = 'populatePolygonEnd'
        Publisher().subscribe(self.populatePolygonEnd,
                              callback)  # create a pubsub receiver
        Populate(self.polygon, self.srsPolygon, self.srsProject, 'polygon',
                 callback)
示例#2
0
    def __init__(self):
        super(Preview, self).__init__()
        layout = QGridLayout(self)
        layout.setAlignment(Qt.AlignCenter)

        self.loading = Loading(200)
        self.loading.hide()
        layout.addWidget(self.loading, 0, 0)

        self.image = None
示例#3
0
def callRestAsync(parent,  apiName,  args,  callBack):
    load = Loading(parent)
    if myGlobal.serverType == 'web':
        targetFunc = callRestWithCallBack
    else:
        targetFunc = callCustomRestWithCallBack
    thread = threading.Thread(target = targetFunc,  args=(apiName,  args,  callBack,  load))
    thread.setDaemon(True)
    thread.start()
    load.exec_()
示例#4
0
def callRestAsync(parent, apiName, args, callBack):
    load = Loading(parent)
    if myGlobal.serverType == 'web':
        targetFunc = callRestWithCallBack
    else:
        targetFunc = callCustomRestWithCallBack
    thread = threading.Thread(target=targetFunc,
                              args=(apiName, args, callBack, load))
    thread.setDaemon(True)
    thread.start()
    load.exec_()
示例#5
0
    def __init__(self, stdscr):
        self.__stdscr = stdscr
        loading = Loading(stdscr)
        loading.start()

        try:
            cred = Credentials()
            flag, email, password = cred.get_credentials()
            if not flag:
                raise Exception("Invalid credentials")
            imap = IMAP(email, password)
            folders = imap.get_mailboxes()
            options = []
            for item in folders:
                options.append({
                    'title': item.replace('"', ''),
                    'Function': EMAIL_LIST,
                    'args': (item, imap)
                })
            options.append({'title': "Back", 'Function': None, 'args': None})
            loading.stop()
            Menu(self.__stdscr, options, "Folders")

        except:
            loading.stop()
            utils.show_message(self.__stdscr,
                               "Something went wrong! Press 'q' to go back")
示例#6
0
    def __fetch_body(self, index):
        '''To fetch body of emails using imap object'''

        try:
            # start loading
            loading = Loading(self.__stdscr)
            loading.start()
            response = self.__imap.fetch_text_body(self.__index)
            self.__body = response['body']
            self.__is_attachment_present = response['is_attachment']
            self.__attachment_filenames = response['filename']

            # If attachment is_present add it in options array
            if response['is_attachment']:
                self.options.insert(0, {
                    'key': 'D',
                    'msg': 'Download Attachment'
                })
            loading.stop()
        except Exception as e:
            # To show the error message
            loading.stop()
            self.__is_error = True
            msg = "Something went wrong! Press 'q' to go back"
            self.__show_message(msg)
示例#7
0
    def __init__(self, parent):
        super(IntroFrame, self).__init__(parent)
        layout = QVBoxLayout(self)
        layout.setContentsMargins(20, 15, 20, 20)

        self.title = Title('', 23)
        titleLayout = QHBoxLayout()
        titleLayout.setAlignment(Qt.AlignTop)
        titleLayout.addWidget(QLabel(' ' * 5))
        titleLayout.addWidget(self.title, 1)
        layout.addLayout(titleLayout, 0)

        self.loading = Loading(200)
        self.loading.hide()
        layout.addWidget(self.loading, 1, Qt.AlignCenter)
示例#8
0
文件: compute_sc.py 项目: giserh/mca
    def action(self, event):
        fnBase = getFileNameBase(get_param_selectedProjectName(),
                                 self.sizerHNetNod.isNetwork(),
                                 fn_straightness)
        fileNames = getGeneratedFiles(fnBase)

        errorMsg = self.sizerHSave.check(fileNames)
        if errorMsg == '':
            if self.sizerHSave.isOverwritten():
                path = self.sizerHSave.getValue()
                Publisher().subscribe(self.catchError, 'catchError')
                normalized = self.sizerHNorm.isNormalized()

                self.Hide()
                self.load = Loading(self, "Computation")

                self.start = time.time()
                callback = "actionEnd"
                Publisher().subscribe(self.actionEnd,
                                      callback)  # create a pubsub receiver

                # launch computation
                if self.sizerHNetNod.isNetwork():
                    EdgeStraightness(path, fnBase, callback, normalized)
                else:
                    NodeStraightness(path, fnBase, callback, normalized)
        else:
            dlg = wx.MessageDialog(self, errorMsg, 'Errors',
                                   wx.CANCEL | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
示例#9
0
    def __init__(self, screen):
        Mode.__init__(self, screen)
        #create a loading screen
        Loading(screen)
        self.loading = True

        #border color
        self.surface.fill((0, 0, 0))

        screen.blit(self.surface, (0, 0))
        #create border at top and bottom
        self.game_dimension = (screen.get_size()[0],
                               screen.get_size()[1] * 0.75)
        self.game_surface = pygame.Surface(self.game_dimension)

        #MUST BE FIXED
        self.stage = Stage(self.game_dimension)
        self.stage.load_stage('Intro')
        self.map = self.stage.rooms[0]

        #133442__klankbeeld__horror-ambience-11.wav
        pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)

        self.fade = Fade(screen, 'in', 3)
        #add player
        self.player = Player(self.map.spawn_x, self.map.spawn_y,
                             self.map.entity)

        self.map.entity.append(self.player)
        self.shade = Shade(self.player, 0, self.fade.surface)
        #test
        self.loading = False
        self.next_before = True
示例#10
0
    def action(self, event):
        error = self.sizerHSave.check(self.fileNames)
        if error == '':
            if self.sizerHSave.isOverwritten():
                self.path = self.sizerHSave.getValue()
                self.path_2_network = os.path.join(self.path,
                                                   self.proj + fn_edges)
                self.path_2_nodes = os.path.join(self.path,
                                                 self.proj + fn_nodes)

                Publisher().subscribe(self.catchError,
                                      'catchError')  # create a pubsub receiver

                self.Hide()
                self.load = Loading(self, "Loading")

                self.start = time.time()
                self.callback = "postgresql_2_shpEnd"
                Publisher().subscribe(
                    self.postgresql_2_shpEnd,
                    self.callback)  # create a pubsub receiver
                Postgresql_2_shp(self.path_2_network, self.proj, 'edge_data',
                                 self.callback)
        else:
            dlg = wx.MessageDialog(self, error, 'Errors',
                                   wx.CANCEL | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
示例#11
0
文件: Main.py 项目: Joby890/LSV2
 def loadScripts(self, dir):
     import sys
     sys.path.insert(0, "./scripts")
     from Script import Script
     s = Script(self, "test")
     from loading import Loading
     l = Loading(self.segments[0])
     self.scripts.append(l)
     from TheaterChase import TheaterChase
     t = TheaterChase(self.segments[0])
     self.scripts.append(t)
     from rainbow import Rainbow
     r = Rainbow(self.segments[0])
     self.scripts.append(r)
     from LeftToRightRandom import LeftToRightRandom
     lr = LeftToRightRandom(self.segments[0])
     self.scripts.append(lr)
     from RandomLed import RandomLed
     r = RandomLed(self.segments[0])
     self.scripts.append(r)
     from Light import Light
     self.scripts.append(Light(self.segments[0]))
     from Test import Test
     self.scripts.append(Test(self.segments[0]))
     from Cycle import Cycle
     self.scripts.append(Cycle(self.segments[0]))
     from SingleColor import SingleColor
     self.scripts.append(SingleColor(self.segments[0]))
示例#12
0
class Info(QWidget):
        def __init__(self):
                super(Info, self).__init__()
                layout = QGridLayout(self)
                layout.setAlignment(Qt.AlignCenter)

                self.loading = Loading(70)
                self.loading.hide()
                layout.addWidget(self.loading, 0, 0, 1, -1, Qt.AlignCenter)

                self.info = []
                font = QFont()
                font.setStyleStrategy(QFont.PreferAntialias)
                font.setPixelSize(15)
                font.setFamily('monospace')
                self.valueLabelFont = font
                font = QFont(font)
                font.setBold(True)
                self.nameLabelFont = font

                self.textTemplate = '<font color="white">%s</font>'

        @Slot(list)
        def updateInfo(self, info):
                for nameLabel, valueLabel in self.info:
                        nameLabel.deleteLater()
                        valueLabel.deleteLater()
                self.info = []
                index = 0
                for name, value in info:
                        if all([c == ' ' for c in name]):
                                sep = ' '
                        else:
                                sep = ':'
                        if value is not None:
                                nameLabel = QLabel(self.textTemplate % (name + sep))
                                valueLabel = QLabel(self.textTemplate % (value))
                        else:
                                nameLabel = QLabel(self.textTemplate % (name))
                                valueLabel = QLabel()
                        nameLabel.setFont(self.nameLabelFont)
                        valueLabel.setFont(self.valueLabelFont)
                        self.info.append((nameLabel, valueLabel))
                        self.layout().addWidget(nameLabel, index, 0, Qt.AlignRight)
                        self.layout().addWidget(valueLabel, index, 1, Qt.AlignLeft)
                        index = index + 1
示例#13
0
class IntroFrame(QWidget):
        def __init__(self, parent):
                super(IntroFrame, self).__init__(parent)
                layout = QVBoxLayout(self)
                layout.setContentsMargins(20, 15, 20, 20)
                
                self.title = Title('', 23)
                titleLayout = QHBoxLayout()
                titleLayout.setAlignment(Qt.AlignTop)
                titleLayout.addWidget(QLabel(' ' * 5))
                titleLayout.addWidget(self.title, 1)
                layout.addLayout(titleLayout, 0)

                self.loading = Loading(200)
                self.loading.hide()
                layout.addWidget(self.loading, 1, Qt.AlignCenter)

        def setTitle(self, title):
                self.title.setText(title)
示例#14
0
        def __init__(self):
                super(Preview, self).__init__()
                layout = QGridLayout(self)
                layout.setAlignment(Qt.AlignCenter)

                self.loading = Loading(200)
                self.loading.hide()
                layout.addWidget(self.loading, 0, 0)

                self.image = None
示例#15
0
        def __init__(self):
                super(Info, self).__init__()
                layout = QGridLayout(self)
                layout.setAlignment(Qt.AlignCenter)

                self.loading = Loading(70)
                self.loading.hide()
                layout.addWidget(self.loading, 0, 0, 1, -1, Qt.AlignCenter)

                self.info = []
                font = QFont()
                font.setStyleStrategy(QFont.PreferAntialias)
                font.setPixelSize(15)
                font.setFamily('monospace')
                self.valueLabelFont = font
                font = QFont(font)
                font.setBold(True)
                self.nameLabelFont = font

                self.textTemplate = '<font color="white">%s</font>'
示例#16
0
    def __fetch_emails(self):
        '''To fetch emails from imap server using IMAP class'''

        try:
            # Start loading until mails are fetched
            loading = Loading(self.__stdscr)
            loading.start()
            # Select particular mailbox
            num = self.__imap.select_mailbox(self.__directory_name)

            if num == 0:
                loading.stop()
                self.__is_error = True
                msg = "Nothing in " + \
                    self.__directory_name.replace(
                        '"', '') + "!! Press 'q' to go back"
                utils.show_message(self.__stdscr, msg)
                return
            self.__num = num

            # Fetch atleast 30 mails if total mails are less than that then fetch total number of mails
            count = min(self.__num - 1, 30)
            if (self.__num - self.__fetched_emails) > 0:
                emails = self.__imap.fetch_email_headers(
                    self.__num - self.__fetched_emails, count)
                self.__fetched_emails += count + 1
                self.__main_list.extend(emails)
                self.emails = emails
            else:
                self.__is_end = True

            loading.stop()
        except Exception as e:
            # To show the error message
            loading.stop()
            self.__is_error = True
            msg = "Something went wrong! Press 'q' to go back"
            utils.show_message(self.__stdscr, msg)
示例#17
0
文件: compute_cc.py 项目: giserh/mca
    def action(self, event):
        wantLocal = self.sizerHRadius.isChecked()
        fnBase = getFileNameBase(get_param_selectedProjectName(),
                                 self.sizerHNetNod.isNetwork(),
                                 fn_closeness,
                                 local=wantLocal)
        fileNames = getGeneratedFiles(fnBase)

        errorMsg = ''  # reset error messages
        errorMsg += self.sizerHSave.check(fileNames)
        if wantLocal: errorMsg += self.sizerHRadius.check()
        if errorMsg == '':
            if self.sizerHSave.isOverwritten():
                path = self.sizerHSave.getValue()
                if self.sizerHRadius.isChecked():
                    radius = self.sizerHRadius.getValue()
                Publisher().subscribe(self.catchError, 'catchError')
                normalized = self.sizerHNorm.isNormalized()
                if self.isNetworkProject:
                    weighted = self.sizerHWeighted.isWeighted()
                else:
                    weighted = True if wantLocal else False
                self.Hide()
                self.load = Loading(self, "Computation")

                self.start = time.time()
                callback = "actionEnd"
                Publisher().subscribe(self.actionEnd,
                                      callback)  # create a pubsub receiver
                #launch computation
                if self.sizerHNetNod.isNetwork():
                    if wantLocal:
                        EdgeLocalCloseness(path, radius, fnBase, callback,
                                           weighted, normalized)
                    else:
                        EdgeCloseness(path, fnBase, callback, weighted,
                                      normalized)
                else:
                    if wantLocal:
                        NodeLocalCloseness(path, radius, fnBase, callback,
                                           weighted, normalized)
                    else:
                        NodeCloseness(path, fnBase, callback, weighted,
                                      normalized)

        else:
            dlg = wx.MessageDialog(self, errorMsg, 'Errors',
                                   wx.CANCEL | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
示例#18
0
    def __init__(self):
        super(ItemList, self).__init__()
        layout = QVBoxLayout(self)
        layout.setAlignment(Qt.AlignTop)

        self.loading = Loading(128)
        self.loading.hide()
        layout.insertWidget(0, self.loading, 10, Qt.AlignCenter)

        self.currentPage = 0
        self.prevPage = Button('###UP###', False, True, False)
        self.nextPage = Button('###DOWN###', False, True, False)
        self.prevPage.setEnabled(False)
        self.nextPage.setEnabled(False)
        self.prevPage.clicked.connect(self.showPrevPage)
        self.nextPage.clicked.connect(self.showNextPage)
        pageLayout = QHBoxLayout()
        pageLayout.setAlignment(Qt.AlignBottom)
        pageLayout.addWidget(self.prevPage)
        pageLayout.addWidget(self.nextPage)
        layout.insertLayout(ItemList.ITEM_PER_PAGE + 1, pageLayout, 1)

        self.items = {}
示例#19
0
class Preview(QWidget):
    OFFSET_X = 0
    OFFSET_Y = 10
    WIDTH = 211
    HEIGHT = 477

    def __init__(self):
        super(Preview, self).__init__()
        layout = QGridLayout(self)
        layout.setAlignment(Qt.AlignCenter)

        self.loading = Loading(200)
        self.loading.hide()
        layout.addWidget(self.loading, 0, 0)

        self.image = None

    def setImage(self, image):
        if image is None:
            self.loading.show()
            self.image = None
        else:
            self.loading.hide()
            self.image = image.toImage()
        self.update()

    def paintEvent(self, event):
        if self.image is not None:
            painter = QPainter()
            painter.begin(self)

            image = self.image.scaledToWidth(self.width(),
                                             Qt.SmoothTransformation)

            frame = QImage(QDir.currentPath() + '/gui/images/background.png')
            frame = frame.copy(Preview.OFFSET_X, Preview.OFFSET_Y,
                               Preview.WIDTH, Preview.HEIGHT)
            frame = frame.scaled(image.width(), image.height(),
                                 Qt.IgnoreAspectRatio, Qt.SmoothTransformation)

            x1, y1 = 0, (self.height() - image.height()) / 2
            x2, y2 = x1 + self.width() - 1, y1 + image.height() - 1
            w, h, delta = image.width(), image.height(), 5

            painter.drawImage(x1, y1, frame)
            painter.setPen(QColor(QColor(255, 255, 255, 200)))
            painter.drawLine(x1, y1, x1, y2)
            painter.drawLine(x1, y1, x2, y1)
            painter.setPen(QColor(QColor(0, 0, 0, 200)))
            painter.drawLine(x2, y1, x2, y2)
            painter.drawLine(x1, y2, x2, y2)
            painter.drawImage(x1 + delta, y1 + delta,
                              image.scaled(w - delta * 2, h - delta * 2))

            painter.end()
示例#20
0
    def computeBC(self):
        self.Hide()
        self.load = Loading(self, "Computation")

        Publisher().subscribe(self.catchError, 'catchError')

        self.start = time.time()
        callback = "actionEnd"
        Publisher().subscribe(self.actionEnd, callback) # create a pubsub receiver

        # launch computation
        if self.sizerHNetNod.isNetwork():
            if self.sizerHImplementation.isNormal():
                EdgeBetweenness(self.path, self.fnBase, callback, self.k, self.weighted, self.normalized)
            else:
                EdgeMeanBetweenness(self.path, self.fnBase, callback, self.k, self.weighted, self.normalized)
        else:
            NodeBetweenness(self.path, self.fnBase, callback, self.k, self.weighted, self.normalized)
示例#21
0
class Preview(QWidget):
        OFFSET_X = 0
        OFFSET_Y = 10
        WIDTH = 211
        HEIGHT = 477

        def __init__(self):
                super(Preview, self).__init__()
                layout = QGridLayout(self)
                layout.setAlignment(Qt.AlignCenter)

                self.loading = Loading(200)
                self.loading.hide()
                layout.addWidget(self.loading, 0, 0)

                self.image = None

        def setImage(self, image):
                if image is None:
                        self.loading.show()
                        self.image = None
                else:
                        self.loading.hide()
                        self.image = image.toImage()
                self.update()

        def paintEvent(self, event):
                if self.image is not None:
                        painter = QPainter()
                        painter.begin(self)

                        image = self.image.scaledToWidth(self.width(), Qt.SmoothTransformation)

                        frame = QImage(QDir.currentPath() + '/gui/images/background.png')
                        frame = frame.copy(Preview.OFFSET_X, Preview.OFFSET_Y, Preview.WIDTH, Preview.HEIGHT)
                        frame = frame.scaled(image.width(), image.height(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation)

                        x1, y1 = 0, (self.height() - image.height()) / 2
                        x2, y2 = x1 + self.width() - 1, y1 + image.height() - 1
                        w, h, delta = image.width(), image.height(), 5

                        painter.drawImage(x1, y1, frame)
                        painter.setPen(QColor(QColor(255, 255, 255, 200)))
                        painter.drawLine(x1, y1, x1, y2)
                        painter.drawLine(x1, y1, x2, y1)
                        painter.setPen(QColor(QColor(0, 0, 0, 200)))
                        painter.drawLine(x2, y1, x2, y2)
                        painter.drawLine(x1, y2, x2, y2)
                        painter.drawImage(x1 + delta, y1 + delta, image.scaled(w - delta * 2, h - delta * 2))

                        painter.end()
示例#22
0
        def __init__(self, parent):
                super(GameViewFrame, self).__init__(parent)
                layout = QVBoxLayout(self)
                layout.setContentsMargins(20, 15, 20, 20)
                
                self.title = Title('', 23)
                titleLayout = QHBoxLayout()
                titleLayout.setAlignment(Qt.AlignTop)
                titleLayout.addWidget(QLabel(' ' * 5))
                titleLayout.addWidget(self.title, 1)
                layout.addLayout(titleLayout, 0)

                self.loading = Loading(200)
                self.loading.hide()
                layout.addWidget(self.loading, 1, Qt.AlignCenter)

                self.countDown = CountDown(200, self)
                self.countDown.hide()

                self.gameView = None
示例#23
0
文件: game.py 项目: woo00154/Parkour
    def __init__(self, screen):
        Mode.__init__(self, screen)
        #create a loading screen
        Loading(screen)
        #now do all the intial stuff
        self.surface.fill((0, 0, 0))
        screen.blit(self.surface, (0, 0))
        #create border at top and bottom
        game_dimension = (screen.get_size()[0], screen.get_size()[1] * 0.75)
        self.game_surface = pygame.Surface(game_dimension)

        self.stage = Stage(game_dimension)
        self.stage.load_stage('round_1')
        self.map = self.stage.rooms[0]
        self.fade = Fade(screen, 'in', 3)
        #add player
        self.player = Player(self.map.spawn_x, self.map.spawn_y,
                             self.map.entity)

        self.map.entity.append(self.player)
示例#24
0
文件: new_project.py 项目: giserh/mca
    def createNewProject(self):
        # get form values
        self.projectName = self.sizerHProject.getValue()
        self.authorName = self.sizerHAuthor.getValue()
        self.shape = self.sizerHNetwork.getValue()
        self.tol = self.sizerHTolerance.getValue()
        self.srsI = self.sizerHNetwork.getSRSValue()
        self.srsI = re.search(r'\[(\d*)\].*', self.srsI).group(1)

        Publisher().subscribe(self.catchError,
                              'catchError')  # create a pubsub receiver
        self.tmp = None
        self.topoCreated = False

        self.Hide()
        self.load = Loading(self, "Loading")

        self.start = time.time()

        cbPopEnd = "populateEnd"
        Publisher().subscribe(self.populateEnd,
                              cbPopEnd)  # create a pubsub receiver
        Populate(self.shape, self.srsI, self.srsO, self.projectName, cbPopEnd)
示例#25
0
文件: app.py 项目: pashutk/pisdup
    def run(self):
        self.init()

        sm = SceneManager()

        sm.register_scene(DevicesWaiting(self.display, self.ee))

        # sm.go(SceneId.DEVICES_WAITING)
        sm.register_scene(Dummy(self.display))
        # sm.go(SceneId.DUMMY)

        sm.register_scene(Loading(self.display))
        sm.go(SceneId.LOADING)

        while (True):
            if Config.ENABLE_CLI:
                input_str = self.cli.read()
                if input_str == 'exit':
                    sm.destroy()
                    break
                self.handle_cli_command(input_str)

            time.sleep(0.01)
示例#26
0
文件: new_grid.py 项目: jcaillet/mca
    def computeNewGrid(self):
        # get form values
        self.projectName = self.sizerHProject.getValue()
        self.authorName = self.sizerHAuthor.getValue()
        self.polygon = self.sizerHPolygon.getValue()
        self.obstacle = self.sizerHObstacles.getValue()
        self.srsObstacle = self.sizerHObstacles.getSRSValue()
        self.res = self.sizerHResolution.getValue()
        self.srsPolygon = self.sizerHPolygon.getSRSValue()
        self.srsPolygon = re.search(r'\[(\d*)\].*', self.srsPolygon).group(1)

        Publisher().subscribe(self.catchError, 'catchError') # create a pubsub receiver
        self.tmpP = None # path to temporary polygon files created during populate
        self.tmpO = None # path to temporary obstacles files created during populate
        self.gridCreated = False

        self.Hide()
        self.load = Loading(self, "Loading")
        self.start = time.time()

        callback = 'populatePolygonEnd'
        Publisher().subscribe(self.populatePolygonEnd, callback) # create a pubsub receiver
        Populate(self.polygon, self.srsPolygon, self.srsProject, 'polygon', callback)
示例#27
0
        def __init__(self):
                super(ItemList, self).__init__()
                layout = QVBoxLayout(self)
                layout.setAlignment(Qt.AlignTop)

                self.loading = Loading(128)
                self.loading.hide()
                layout.insertWidget(0, self.loading, 10, Qt.AlignCenter)

                self.currentPage = 0
                self.prevPage = Button('###UP###', False, True, False)
                self.nextPage = Button('###DOWN###', False, True, False)
                self.prevPage.setEnabled(False)
                self.nextPage.setEnabled(False)
                self.prevPage.clicked.connect(self.showPrevPage)
                self.nextPage.clicked.connect(self.showNextPage)
                pageLayout = QHBoxLayout()
                pageLayout.setAlignment(Qt.AlignBottom)
                pageLayout.addWidget(self.prevPage)
                pageLayout.addWidget(self.nextPage)
                layout.insertLayout(ItemList.ITEM_PER_PAGE + 1, pageLayout, 1)

                self.items = {}
示例#28
0
class GameViewFrame(QWidget):
    def __init__(self, parent):
        super(GameViewFrame, self).__init__(parent)
        layout = QVBoxLayout(self)
        layout.setContentsMargins(20, 15, 20, 20)

        self.title = Title('', 23)
        titleLayout = QHBoxLayout()
        titleLayout.setAlignment(Qt.AlignTop)
        titleLayout.addWidget(QLabel(' ' * 5))
        titleLayout.addWidget(self.title, 1)
        layout.addLayout(titleLayout, 0)

        self.loading = Loading(200)
        self.loading.hide()
        layout.addWidget(self.loading, 1, Qt.AlignCenter)

        self.countDown = CountDown(200, self)
        self.countDown.hide()

        self.gameView = None

    def setTitle(self, title):
        self.title.setText(title)

    def showLoading(self):
        if self.gameView is not None:
            self.gameView.hide()
        self.loading.show()

    def showCountDown(self, quick=False):
        center = self.gameView.pos() + QPoint(self.gameView.width() / 2,
                                              self.gameView.height() / 2)
        self.countDown.move(center - QPoint(self.countDown.width() / 2,
                                            self.countDown.height() / 2))
        self.countDown.show()
        self.countDown.raise_()
        self.countDown.start(5 if not quick else 0)

    def showGameView(self, gameMap):
        self.loading.hide()
        self.gameView = GameView(gameMap)
        self.layout().addWidget(self.gameView, 1, Qt.AlignCenter)
示例#29
0
class GameViewFrame(QWidget):
        def __init__(self, parent):
                super(GameViewFrame, self).__init__(parent)
                layout = QVBoxLayout(self)
                layout.setContentsMargins(20, 15, 20, 20)
                
                self.title = Title('', 23)
                titleLayout = QHBoxLayout()
                titleLayout.setAlignment(Qt.AlignTop)
                titleLayout.addWidget(QLabel(' ' * 5))
                titleLayout.addWidget(self.title, 1)
                layout.addLayout(titleLayout, 0)

                self.loading = Loading(200)
                self.loading.hide()
                layout.addWidget(self.loading, 1, Qt.AlignCenter)

                self.countDown = CountDown(200, self)
                self.countDown.hide()

                self.gameView = None

        def setTitle(self, title):
                self.title.setText(title)


        def showLoading(self):
                if self.gameView is not None:
                        self.gameView.hide()
                self.loading.show()

        def showCountDown(self, quick = False):
                center = self.gameView.pos() + QPoint(self.gameView.width() / 2, self.gameView.height() / 2)
                self.countDown.move(center - QPoint(self.countDown.width() / 2, self.countDown.height() / 2))
                self.countDown.show()
                self.countDown.raise_()
                self.countDown.start(5 if not quick else 0)

        def showGameView(self, gameMap):
                self.loading.hide()
                self.gameView = GameView(gameMap)
                self.layout().addWidget(self.gameView, 1, Qt.AlignCenter)
示例#30
0
    if platform.system() == 'Windows':
        conf.read(path, encoding="utf-8-sig")
    else:
        conf.read(path)
    # 数据库实例
    stone = stoneobject()
    # 初始化 定时器
    task = Task("08:00", logger)
    times = conf.get(section="time", option="now")
    if task.times != datetime.time(int(times.split(':')[0]), int(times.split(':')[1])):
        task.times = input("请输入开始时间,例如08:00")
    # task.times = "19:45"
    logger.debug("主程序开始运行")
    # 初始化 邮件发送、短信发送
    send_mail = EmailSend(smtp_server=conf.get(section='email', option='smtp_server'),
                          smtp_port=conf.get(section='email', option='smtp_port'),
                          from_addr=conf.get(section='email', option='from_addr'),
                          from_addr_str=conf.get(section='email', option='from_addr_str'),
                          password=conf.get(section='email', option='password'),
                          error_address=conf.get(section='email', option='error_email'), logger=logger, stone=stone,
                          special=conf.items(section='关注'))
    loading = Loading(stone=stone, logger=logger, conf=conf, )
    to_address_dict = to_send_email(file_name='主管及以上名单.xlsx')
    while True:
        # 到达预定时间后,执行 BlessingPlay.play
        #  收件人需要获取
        # 使用 to_address_dict 传递 收件人字典
        task.run(WarningPlay.play, to_address=to_address_dict, logger=logger, send_mail=send_mail, loading=loading,
                 date=datetime.date.today() + datetime.timedelta(days=0))
        logger.debug("当次执行完毕")
示例#31
0
文件: new_grid.py 项目: giserh/mca
class NewGrid(newUI):

    # Create a new _init_ within the SuperClass MainFrame
    def __init__(self, parent, title):
        # --- variables ---
        self.ActionName = 'Create new grid project'
        self.helperFile = 'new_grid.pdf'

        newUI.__init__(self, parent, title)

        # --- polygon ---
        self.sizerHPolygon = uploadFileSizer(self.panel, 'Polygon', self.fit)
        self.sizerV.Add(self.sizerHPolygon,
                        flag=wx.ALIGN_LEFT | wx.ALL,
                        border=margin)

        # --- separator ---
        self.separator = wx.StaticLine(self.panel,
                                       style=wx.LI_HORIZONTAL,
                                       size=separatorSize)
        self.sizerV.Add(self.separator, flag=wx.ALIGN_CENTER)

        # --- obstacles ---
        self.sizerHObstacles = uploadFileSizer(self.panel, 'Obstacles',
                                               self.fit, True)
        self.sizerV.Add(self.sizerHObstacles,
                        flag=wx.ALIGN_LEFT | wx.ALL,
                        border=margin)

        # --- separator ---
        self.separator = wx.StaticLine(self.panel,
                                       style=wx.LI_HORIZONTAL,
                                       size=separatorSize)
        self.sizerV.Add(self.separator, flag=wx.ALIGN_CENTER)

        # --- resolution ---
        self.sizerHResolution = resolutionSizer(self.panel)
        self.sizerV.Add(self.sizerHResolution,
                        flag=wx.ALIGN_LEFT | wx.ALL,
                        border=margin)

        # --- rendering ---
        self.render()

    def action(self, event):
        self.wantObstacles = self.sizerHObstacles.isChecked()
        # check all inputs data and notify errors
        errorMsg = ''  # reset error messages
        errorMsg += self.sizerHProject.check()
        errorMsg += self.sizerHAuthor.check()
        errorMsg += self.sizerHPolygon.check()
        errorMsg += self.sizerHResolution.check()
        errorMsg += self.sizerHProjectSrs.check()
        if self.wantObstacles:
            errorMsg += self.sizerHObstacles.check()

        if errorMsg == '':
            self.srsProject = self.sizerHProjectSrs.getValue()
            self.srsProject = re.search(r'\[(\d*)\].*',
                                        self.srsProject).group(1)
            unit = getUnit(int(self.srsProject))
            if unit == degreeUnit:
                warningMsg = 'You have chosen a projection with unit in degrees.\n'
                warningMsg += 'Would you like to contiue?'
                dlgWarning = wx.MessageDialog(
                    self, warningMsg, 'Warning lon/lat projection system',
                    wx.YES_NO | wx.ICON_EXCLAMATION)
                if dlgWarning.ShowModal() == wx.ID_YES:
                    self.computeNewGrid()
                dlgWarning.Destroy()
            else:
                self.computeNewGrid()
        else:
            dlg = wx.MessageDialog(self, errorMsg, 'Errors',
                                   wx.CANCEL | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()

    def computeNewGrid(self):
        # get form values
        self.projectName = self.sizerHProject.getValue()
        self.authorName = self.sizerHAuthor.getValue()
        self.polygon = self.sizerHPolygon.getValue()
        self.obstacle = self.sizerHObstacles.getValue()
        self.srsObstacle = self.sizerHObstacles.getSRSValue()
        self.res = self.sizerHResolution.getValue()
        self.srsPolygon = self.sizerHPolygon.getSRSValue()
        self.srsPolygon = re.search(r'\[(\d*)\].*', self.srsPolygon).group(1)

        Publisher().subscribe(self.catchError,
                              'catchError')  # create a pubsub receiver
        self.tmpP = None  # path to temporary polygon files created during populate
        self.tmpO = None  # path to temporary obstacles files created during populate
        self.gridCreated = False

        self.Hide()
        self.load = Loading(self, "Loading")
        self.start = time.time()

        callback = 'populatePolygonEnd'
        Publisher().subscribe(self.populatePolygonEnd,
                              callback)  # create a pubsub receiver
        Populate(self.polygon, self.srsPolygon, self.srsProject, 'polygon',
                 callback)

    def cleanData(self):
        if self.gridCreated:
            cleanPublicSchema(self.projectName)
        if self.tmpP is not None:
            cleanPublicSchema('polygon')
            cleanTemporaryFiles(self.tmpP)
        if self.tmpO is not None:
            cleanPublicSchema('obstacles')
            cleanTemporaryFiles(self.tmpO)

    def populatePolygonEnd(self, msg):
        consoleAppend(' > Populate polygon in %s' %
                      GetTextTime(time.time() - self.start))
        self.tmpP = msg.data

        self.ts = time.time()
        if self.wantObstacles:
            self.srsObstacle = re.search(r'\[(\d*)\].*',
                                         self.srsObstacle).group(1)

            callback = 'populateObstaclesEnd'
            Publisher().subscribe(self.populateObstaclesEnd,
                                  callback)  # create a pubsub receiver
            Populate(self.obstacle, self.srsObstacle, self.srsProject,
                     'obstacles', callback)
        else:
            self.populateObstaclesEnd(None)

    def populateObstaclesEnd(self, msg):
        if self.wantObstacles:
            consoleAppend(' > Populate obstacles in %s' %
                          GetTextTime(time.time() - self.ts))
            self.tmpO = msg.data

        self.ts = time.time()
        callback = "gridNetworkEnd"
        Publisher().subscribe(self.gridNetworkEnd, callback)
        pubDial = "publishDialog"
        Publisher().subscribe(self.publishDialog, pubDial)
        # the srs of the grid network is always the srs out of the polygon
        GridNetwork(callback, pubDial, self.res, self.srsProject,
                    self.projectName, self.wantObstacles)

    def publishDialog(self, msg):
        txt = msg.data
        dlg = wx.MessageDialog(self, txt, 'Warning projection match',
                               wx.OK | wx.ICON_EXCLAMATION)
        dlg.ShowModal()
        dlg.Destroy()
        # clean data
        self.cleanData()
        # enable main frame
        self.load.hide()
        self.parent.Enable()
        self.Destroy()

    def gridNetworkEnd(self, msg):
        consoleAppend(' > The grid network has been created in %s' %
                      GetTextTime(time.time() - self.ts))
        self.gridCreated = True

        self.ts = time.time()
        callback = "topologyEnd"
        Publisher().subscribe(self.topologyEnd,
                              callback)  # create a pubsub receiver
        consoleAppend(
            'Start creating the topology... This can take a while, please be patient...'
        )
        Topology(self.projectName, self.srsProject, self.authorName, 0, 'grid',
                 self.res, callback)

    def gridShpNetworkEnd(self, msg):
        # callback of GridNetwork.creatShp
        consoleAppend("New shapefile has been created in %s" %
                      GetTextTime(time.time() - self.start))

        self.cleanData()
        self.parent.repaintTable()
        self.actionEnd(None)

    def topologyEnd(self, msg):
        consoleAppend('The topology has been created in %s...' %
                      GetTextTime(time.time() - self.ts))

        self.cleanData()
        self.parent.repaintTable()
        self.actionEnd(None)
示例#32
0
 def loading(self):
     self.colorWipe()
     Loading(self.stick).start()
示例#33
0
def main():

    loader = Loading(100, 'installing all the things.', '+')
    for count in range(1, 99):
        loader.complete(count)
        sleep(0.2)


    loader = Loading(100)
    loader.complete(10)
    sleep(1)
    loader.complete(20)
    sleep(1)
    loader.complete(30)
    sleep(1)
    loader.complete(40)
    sleep(1)
    loader.complete(50)
    sleep(1)
    loader.complete(60)
    sleep(1)
    loader.complete(70)
    sleep(1)
    loader.complete(80)
    sleep(1)
    loader.complete(90)
    sleep(1)
示例#34
0
class ItemList(QWidget):

    ANIMATION_LIST_DURATION = 700
    ANIMATION_FLIP_DURATION_PHASE_ONE = 300
    ANIMATION_FLIP_DURATION_PHASE_TWO = 500

    ITEM_PER_PAGE = 12

    def __init__(self):
        super(ItemList, self).__init__()
        layout = QVBoxLayout(self)
        layout.setAlignment(Qt.AlignTop)

        self.loading = Loading(128)
        self.loading.hide()
        layout.insertWidget(0, self.loading, 10, Qt.AlignCenter)

        self.currentPage = 0
        self.prevPage = Button('###UP###', False, True, False)
        self.nextPage = Button('###DOWN###', False, True, False)
        self.prevPage.setEnabled(False)
        self.nextPage.setEnabled(False)
        self.prevPage.clicked.connect(self.showPrevPage)
        self.nextPage.clicked.connect(self.showNextPage)
        pageLayout = QHBoxLayout()
        pageLayout.setAlignment(Qt.AlignBottom)
        pageLayout.addWidget(self.prevPage)
        pageLayout.addWidget(self.nextPage)
        layout.insertLayout(ItemList.ITEM_PER_PAGE + 1, pageLayout, 1)

        self.items = {}

    def addItem(self, id, name, clickable=True):
        if clickable:
            button = Button(name, True, False, False, self)
        else:
            button = Button(name, False, True, True, self)
        button.id = id
        self.items[id] = button
        return button

    def _removeItem(self, id):
        self.items[id].deleteLater()
        del self.items[id]

    def clearItems(self):
        for id in dict(self.items).iterkeys():
            self._removeItem(id)
        self.prevPage.setEnabled(False)
        self.nextPage.setEnabled(False)

    def _pageItems(self, page):
        ids = sorted(
            self.items.iterkeys())[ItemList.ITEM_PER_PAGE *
                                   page:ItemList.ITEM_PER_PAGE * (page + 1)]
        items = []
        for id in ids:
            items.append(self.items[id])
        return items

    def showPage(self, page, flip=False):
        minPage, maxPage = 0, max(
            0, (len(self.items) + ItemList.ITEM_PER_PAGE - 1) /
            ItemList.ITEM_PER_PAGE - 1)
        assert page >= minPage and page <= maxPage
        for item in self.items.itervalues():
            item.hide()
            self.layout().removeWidget(item)
        index = 1
        for item in self._pageItems(page):
            item.show()
            self.layout().insertWidget(index, item)
            index = index + 1
        self.currentPage = page
        self.prevPage.setEnabled(page > minPage)
        self.nextPage.setEnabled(page < maxPage)
        if flip:
            QMetaObject.invokeMethod(self, '_flipAnimation',
                                     Qt.QueuedConnection)
        else:
            QMetaObject.invokeMethod(self, '_listAnimation',
                                     Qt.QueuedConnection)

    def showPrevPage(self):
        self.lastPage = self.currentPage
        self.showPage(self.currentPage - 1, True)

    def showNextPage(self):
        self.lastPage = self.currentPage
        self.showPage(self.currentPage + 1, True)

    def _listItemAnimation(self, item, duration):
        itemAnimation = QPropertyAnimation(item, 'pos')
        itemAnimation.setDuration(duration + item.pos().y() * 2)
        endPos = item.pos()
        startPos = QPoint(endPos.x(), -item.height())
        itemAnimation.setStartValue(startPos)
        itemAnimation.setEndValue(endPos)
        itemAnimation.setEasingCurve(QEasingCurve.OutElastic)
        return itemAnimation

    @Slot()
    def _listAnimation(self):
        self.listAnimationGroup = QParallelAnimationGroup()
        for item in self.items.itervalues():
            self.listAnimationGroup.addAnimation(
                self._listItemAnimation(item,
                                        ItemList.ANIMATION_LIST_DURATION))
        self.listAnimationGroup.start(QAbstractAnimation.DeleteWhenStopped)

    def _flipItemAnimation(self, item, startPos, endPos, invert,
                           durationPhaseOne, durationPhaseTwo):
        midPos = QPoint(endPos.x(), startPos.y())

        itemAnimationPhaseOne = QPropertyAnimation(item, 'pos')
        itemAnimationPhaseOne.setDuration(durationPhaseOne -
                                          abs(endPos.y() - startPos.y()) / 2)
        if not invert:
            itemAnimationPhaseOne.setStartValue(startPos -
                                                QPoint(endPos.y(), 0))
            itemAnimationPhaseOne.setEndValue(midPos)
        else:
            itemAnimationPhaseOne.setEndValue(startPos - QPoint(endPos.y(), 0))
            itemAnimationPhaseOne.setStartValue(midPos)
        itemAnimationPhaseOne.setEasingCurve(QEasingCurve.Linear)

        itemAnimationPhaseTwo = QPropertyAnimation(item, 'pos')
        itemAnimationPhaseTwo.setDuration(durationPhaseTwo -
                                          abs(endPos.y() - startPos.y()))
        if not invert:
            itemAnimationPhaseTwo.setStartValue(midPos)
            itemAnimationPhaseTwo.setEndValue(endPos)
        else:
            itemAnimationPhaseTwo.setEndValue(midPos)
            itemAnimationPhaseTwo.setStartValue(endPos)
        itemAnimationPhaseTwo.setEasingCurve(QEasingCurve.Linear)

        itemAnimationGroup = QSequentialAnimationGroup()
        if not invert:
            itemAnimationGroup.addAnimation(itemAnimationPhaseOne)
            itemAnimationGroup.addAnimation(itemAnimationPhaseTwo)
        else:
            itemAnimationGroup.addAnimation(itemAnimationPhaseTwo)
            itemAnimationGroup.addAnimation(itemAnimationPhaseOne)

        return itemAnimationGroup

    def _calcMinY(self, items):
        minY = sys.maxint
        for item in items:
            if item.pos().y() < minY:
                minY = item.pos().y()
        return minY

    @Slot()
    def _flipAnimation(self):
        self.flipAnimationGroup = QParallelAnimationGroup()

        lastItems = self._pageItems(self.lastPage)
        if self.currentPage < self.lastPage:
            minY = self._calcMinY(lastItems)
            startPos = QPoint(-lastItems[0].width(), minY)
        else:
            startPos = QPoint(
                -lastItems[0].width(),
                self.prevPage.pos().y() - lastItems[0].height() - 5)
        for item in lastItems:
            item.show()
            self.flipAnimationGroup.addAnimation(
                self._flipItemAnimation(
                    item, startPos, item.pos(), True,
                    ItemList.ANIMATION_FLIP_DURATION_PHASE_ONE,
                    ItemList.ANIMATION_FLIP_DURATION_PHASE_TWO))

        currentItems = self._pageItems(self.currentPage)
        if self.currentPage > self.lastPage:
            minY = self._calcMinY(currentItems)
            startPos = QPoint(-currentItems[0].width(), minY)
        else:
            startPos = QPoint(
                -currentItems[0].width(),
                self.prevPage.pos().y() - currentItems[0].height() - 5)
        for item in currentItems:
            self.flipAnimationGroup.addAnimation(
                self._flipItemAnimation(
                    item, startPos, item.pos(), False,
                    ItemList.ANIMATION_FLIP_DURATION_PHASE_ONE,
                    ItemList.ANIMATION_FLIP_DURATION_PHASE_TWO))

        self.flipAnimationGroup.start(QAbstractAnimation.DeleteWhenStopped)
示例#35
0
class ItemList(QWidget):

        ANIMATION_LIST_DURATION = 700
        ANIMATION_FLIP_DURATION_PHASE_ONE = 300
        ANIMATION_FLIP_DURATION_PHASE_TWO = 500

        ITEM_PER_PAGE = 12

        def __init__(self):
                super(ItemList, self).__init__()
                layout = QVBoxLayout(self)
                layout.setAlignment(Qt.AlignTop)

                self.loading = Loading(128)
                self.loading.hide()
                layout.insertWidget(0, self.loading, 10, Qt.AlignCenter)

                self.currentPage = 0
                self.prevPage = Button('###UP###', False, True, False)
                self.nextPage = Button('###DOWN###', False, True, False)
                self.prevPage.setEnabled(False)
                self.nextPage.setEnabled(False)
                self.prevPage.clicked.connect(self.showPrevPage)
                self.nextPage.clicked.connect(self.showNextPage)
                pageLayout = QHBoxLayout()
                pageLayout.setAlignment(Qt.AlignBottom)
                pageLayout.addWidget(self.prevPage)
                pageLayout.addWidget(self.nextPage)
                layout.insertLayout(ItemList.ITEM_PER_PAGE + 1, pageLayout, 1)

                self.items = {}
                
        def addItem(self, id, name, clickable = True):
                if clickable:
                        button = Button(name, True, False, False, self)
                else:
                        button = Button(name, False, True, True, self)
                button.id = id
                self.items[id] = button
                return button

        def _removeItem(self, id):
                self.items[id].deleteLater()
                del self.items[id]

        def clearItems(self):
                for id in dict(self.items).iterkeys():
                        self._removeItem(id)
                self.prevPage.setEnabled(False)
                self.nextPage.setEnabled(False)

        def _pageItems(self, page):
                ids = sorted(self.items.iterkeys())[ItemList.ITEM_PER_PAGE * page:ItemList.ITEM_PER_PAGE * (page + 1)]
                items = []
                for id in ids:
                        items.append(self.items[id])
                return items

        def showPage(self, page, flip = False):
                minPage, maxPage = 0, max(0, (len(self.items) + ItemList.ITEM_PER_PAGE - 1) / ItemList.ITEM_PER_PAGE - 1)
                assert page >= minPage and page <= maxPage
                for item in self.items.itervalues():
                        item.hide()
                        self.layout().removeWidget(item)
                index = 1
                for item in self._pageItems(page):
                        item.show()
                        self.layout().insertWidget(index, item)
                        index = index + 1
                self.currentPage = page
                self.prevPage.setEnabled(page > minPage)
                self.nextPage.setEnabled(page < maxPage)
                if flip:
                        QMetaObject.invokeMethod(self, '_flipAnimation', Qt.QueuedConnection)
                else:
                        QMetaObject.invokeMethod(self, '_listAnimation', Qt.QueuedConnection)

        def showPrevPage(self):
                self.lastPage = self.currentPage
                self.showPage(self.currentPage - 1, True)

        def showNextPage(self):
                self.lastPage = self.currentPage
                self.showPage(self.currentPage + 1, True)

        def _listItemAnimation(self, item, duration):
                itemAnimation = QPropertyAnimation(item, 'pos')
                itemAnimation.setDuration(duration + item.pos().y() * 2)
                endPos = item.pos()
                startPos = QPoint(endPos.x(), -item.height())
                itemAnimation.setStartValue(startPos)
                itemAnimation.setEndValue(endPos)
                itemAnimation.setEasingCurve(QEasingCurve.OutElastic)
                return itemAnimation

        @Slot()
        def _listAnimation(self):
                self.listAnimationGroup = QParallelAnimationGroup()
                for item in self.items.itervalues():
                        self.listAnimationGroup.addAnimation(self._listItemAnimation(item, ItemList.ANIMATION_LIST_DURATION))
                self.listAnimationGroup.start(QAbstractAnimation.DeleteWhenStopped)

        def _flipItemAnimation(self, item, startPos, endPos, invert, durationPhaseOne, durationPhaseTwo):
                midPos = QPoint(endPos.x(), startPos.y())

                itemAnimationPhaseOne = QPropertyAnimation(item, 'pos')
                itemAnimationPhaseOne.setDuration(durationPhaseOne - abs(endPos.y() - startPos.y())/ 2)
                if not invert:
                        itemAnimationPhaseOne.setStartValue(startPos - QPoint(endPos.y(), 0))
                        itemAnimationPhaseOne.setEndValue(midPos)
                else:
                        itemAnimationPhaseOne.setEndValue(startPos - QPoint(endPos.y(), 0))
                        itemAnimationPhaseOne.setStartValue(midPos)
                itemAnimationPhaseOne.setEasingCurve(QEasingCurve.Linear)

                itemAnimationPhaseTwo = QPropertyAnimation(item, 'pos')
                itemAnimationPhaseTwo.setDuration(durationPhaseTwo - abs(endPos.y() - startPos.y()))
                if not invert:
                        itemAnimationPhaseTwo.setStartValue(midPos)
                        itemAnimationPhaseTwo.setEndValue(endPos)
                else:
                        itemAnimationPhaseTwo.setEndValue(midPos)
                        itemAnimationPhaseTwo.setStartValue(endPos)
                itemAnimationPhaseTwo.setEasingCurve(QEasingCurve.Linear)

                itemAnimationGroup = QSequentialAnimationGroup()
                if not invert:
                        itemAnimationGroup.addAnimation(itemAnimationPhaseOne)
                        itemAnimationGroup.addAnimation(itemAnimationPhaseTwo)
                else:
                        itemAnimationGroup.addAnimation(itemAnimationPhaseTwo)
                        itemAnimationGroup.addAnimation(itemAnimationPhaseOne)

                return itemAnimationGroup

        def _calcMinY(self, items):
                minY = sys.maxint
                for item in items:
                        if item.pos().y() < minY:
                                minY = item.pos().y()
                return minY

        @Slot()
        def _flipAnimation(self):
                self.flipAnimationGroup = QParallelAnimationGroup()

                lastItems = self._pageItems(self.lastPage)
                if self.currentPage < self.lastPage:
                        minY = self._calcMinY(lastItems)
                        startPos = QPoint(-lastItems[0].width(), minY)
                else:
                        startPos = QPoint(-lastItems[0].width(), self.prevPage.pos().y() - lastItems[0].height() - 5)
                for item in lastItems:
                        item.show()
                        self.flipAnimationGroup.addAnimation(self._flipItemAnimation(item, startPos, item.pos(), True,
                                                                                     ItemList.ANIMATION_FLIP_DURATION_PHASE_ONE,
                                                                                     ItemList.ANIMATION_FLIP_DURATION_PHASE_TWO))

                currentItems = self._pageItems(self.currentPage)
                if self.currentPage > self.lastPage:
                        minY = self._calcMinY(currentItems)
                        startPos = QPoint(-currentItems[0].width(), minY)
                else:
                        startPos = QPoint(-currentItems[0].width(), self.prevPage.pos().y() - currentItems[0].height() - 5)
                for item in currentItems:
                        self.flipAnimationGroup.addAnimation(self._flipItemAnimation(item, startPos, item.pos(), False,
                                                                                     ItemList.ANIMATION_FLIP_DURATION_PHASE_ONE,
                                                                                     ItemList.ANIMATION_FLIP_DURATION_PHASE_TWO))

                self.flipAnimationGroup.start(QAbstractAnimation.DeleteWhenStopped)
示例#36
0
class Main(QMainWindow):
    def __init__(self, parent=None):
        super(Main, self).__init__(parent)
        self.initUI()
        self.setMenu()

    def initUI(self):
        '''
        初始化UI
        :return:
        '''
        self.resize(1000, 600)
        self.setWindowTitle("海上数据挖掘可视化分析系统")
        self.setWindowIcon(QIcon(".\\res\\boat.ico"))  # 设置窗体图标
        self.center()  # 屏幕居中显示

    def setMenu(self):
        """
        设置菜单栏
        :return:
        """
        menubar = self.menuBar()
        importMenu = menubar.addMenu(u"导入数据")
        remoteAct = QAction("遥感数据", self)
        AisAct = QAction("AIS数据", self)
        ReplayAct = QAction("数据回放", self)
        importMenu.addAction(remoteAct)
        importMenu.addAction(AisAct)
        importMenu.addAction(ReplayAct)
        # remoteAct.triggered.connect()
        # AisAct.triggered.connect()
        # ReplayAct.triggered.connect()

        preMenu = menubar.addMenu(u"预处理")
        defogAct = QAction("视觉去雾", self)
        enhanceAct = QAction("低照度增强", self)
        filterAct = QAction("AIS数据筛选", self)
        preMenu.addAction(defogAct)
        preMenu.addAction(enhanceAct)
        preMenu.addAction(filterAct)
        # defogAct.triggered.connect()
        # enhanceAct.triggered.connect()
        # filterAct.triggered.connect()

        visualMenu = menubar.addMenu(u"源数据可视化")
        trackAct = QAction("船舶轨迹可视化", self)
        densityAct = QAction("船舶密度可视化", self)
        heatAct = QAction("热力图", self)
        trafficFlowAct = QAction("船舶交通流可视化", self)
        visualMenu.addAction(trackAct)
        visualMenu.addAction(densityAct)
        visualMenu.addAction(heatAct)
        visualMenu.addAction(trafficFlowAct)
        # trackAct.triggered.connect()
        # densityAct.triggered.connect()
        # heatAct.triggered.connect()
        # trafficFlowAct.triggered.connect()

        processMenu = menubar.addMenu(u"过程可视化")
        dbscanAct = QAction("航道驱动聚类", self)
        abnAct = QAction("异常模式", self)
        freAct = QAction("频繁模式", self)
        togAct = QAction("共现模式", self)
        cycAct = QAction("周期模式", self)
        processMenu.addAction(dbscanAct)
        processMenu.addAction(abnAct)
        processMenu.addAction(freAct)
        processMenu.addAction(togAct)
        processMenu.addAction(cycAct)
        # dbscanAct.triggered.connect()
        # abnAct.triggered.connect()
        # freAct.triggered.connect()
        # togAct.triggered.connect()
        # cycAct.triggered.connect()

        resultMenu = menubar.addMenu(u"结果可视化")
        randForestAct = QAction("随机森林算法", self)
        resultMenu.addAction(randForestAct)
        # randForestAct.triggered.connect()

        aboutMenu = menubar.addMenu(u"关于")
        aboutAct = QAction("关于", self)
        aboutMenu.addAction(aboutAct)
        aboutAct.triggered.connect(self.showAbout)

    def process(self):
        self.window = Loading()
        self.window.show()

    def center(self):
        '''
        窗口在屏幕居中显示
        :return:
        '''
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)

    def showAbout(self):
        """
        显示关于
        :return:
        """
        QMessageBox.about(self, "关于", "海上数据挖掘可视化分析系统")
示例#37
0
 def process(self):
     self.window = Loading()
     self.window.show()
示例#38
0
os.environ["SDL_FBDEV"] = "/dev/fb1"

MODE = 'activator'
if len(sys.argv) > 1:
    argument = sys.argv[1]
    if argument == 'activator' or argument == 'master' or argument == 'slave' or argument == 'test' or argument == 'tables':
        MODE = argument
    else:
        raise Exception("Unknown argument to the program")
    if argument == 'slave':
        if len(sys.argv) < 2:
            raise Exception("Slave requires master IP")
        masterip = sys.argv[2]

print "Starting in mode: " + MODE
load_window = Loading("Loading, Please wait!")
connect_window = Loading("Connecting, Please wait!")
wait_window = Waiting()  # if MODE == 'slave' else Waiting(10)


def print_tag_callback(tag):
    print "Tag: %s" % tag


#
def activate_tag_callback(tag):
    if display_manager.active_window() != prompt:
        return
    print "Activating tag: %s" % tag
    display_manager.launch(load_window)
    res = urllib2.urlopen("http://192.168.1.10:8000/api/activate?tag=%s" %
示例#39
0
文件: new_grid.py 项目: jcaillet/mca
class NewGrid(newUI):

    # Create a new _init_ within the SuperClass MainFrame
    def __init__(self, parent, title):
        # --- variables ---
        self.ActionName = 'Create new grid project'
        self.helperFile = 'new_grid.pdf'

        newUI.__init__(self, parent, title)

        # --- polygon ---
        self.sizerHPolygon = uploadFileSizer(self.panel, 'Polygon', self.fit)
        self.sizerV.Add(self.sizerHPolygon, flag=wx.ALIGN_LEFT|wx.ALL, border=margin)

        # --- separator ---
        self.separator = wx.StaticLine(self.panel, style=wx.LI_HORIZONTAL, size=separatorSize)
        self.sizerV.Add(self.separator, flag=wx.ALIGN_CENTER)

        # --- obstacles ---
        self.sizerHObstacles = uploadFileSizer(self.panel, 'Obstacles', self.fit, True)
        self.sizerV.Add(self.sizerHObstacles, flag=wx.ALIGN_LEFT|wx.ALL, border=margin)

        # --- separator ---
        self.separator = wx.StaticLine(self.panel, style=wx.LI_HORIZONTAL, size=separatorSize)
        self.sizerV.Add(self.separator, flag=wx.ALIGN_CENTER)

        # --- resolution ---
        self.sizerHResolution = resolutionSizer(self.panel)
        self.sizerV.Add(self.sizerHResolution, flag=wx.ALIGN_LEFT|wx.ALL, border=margin)

        # --- rendering ---
        self.render()


    def action(self, event):
        self.wantObstacles = self.sizerHObstacles.isChecked()
        # check all inputs data and notify errors
        errorMsg = '' # reset error messages
        errorMsg += self.sizerHProject.check()
        errorMsg += self.sizerHAuthor.check()
        errorMsg += self.sizerHPolygon.check()
        errorMsg += self.sizerHResolution.check()
        errorMsg += self.sizerHProjectSrs.check()
        if self.wantObstacles:
            errorMsg += self.sizerHObstacles.check()

        if errorMsg == '':
            self.srsProject = self.sizerHProjectSrs.getValue()
            self.srsProject = re.search(r'\[(\d*)\].*', self.srsProject).group(1)
            unit = getUnit(int(self.srsProject))
            if unit == degreeUnit:
                warningMsg = 'You have chosen a projection with unit in degrees.\n'
                warningMsg += 'Would you like to contiue?'
                dlgWarning = wx.MessageDialog(self, warningMsg, 'Warning lon/lat projection system', wx.YES_NO|wx.ICON_EXCLAMATION)
                if dlgWarning.ShowModal() == wx.ID_YES:
                    self.computeNewGrid()
            	dlgWarning.Destroy()
            else:
                self.computeNewGrid()
        else:
            dlg = wx.MessageDialog(self, errorMsg, 'Errors', wx.CANCEL|wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()

    def computeNewGrid(self):
        # get form values
        self.projectName = self.sizerHProject.getValue()
        self.authorName = self.sizerHAuthor.getValue()
        self.polygon = self.sizerHPolygon.getValue()
        self.obstacle = self.sizerHObstacles.getValue()
        self.srsObstacle = self.sizerHObstacles.getSRSValue()
        self.res = self.sizerHResolution.getValue()
        self.srsPolygon = self.sizerHPolygon.getSRSValue()
        self.srsPolygon = re.search(r'\[(\d*)\].*', self.srsPolygon).group(1)

        Publisher().subscribe(self.catchError, 'catchError') # create a pubsub receiver
        self.tmpP = None # path to temporary polygon files created during populate
        self.tmpO = None # path to temporary obstacles files created during populate
        self.gridCreated = False

        self.Hide()
        self.load = Loading(self, "Loading")
        self.start = time.time()

        callback = 'populatePolygonEnd'
        Publisher().subscribe(self.populatePolygonEnd, callback) # create a pubsub receiver
        Populate(self.polygon, self.srsPolygon, self.srsProject, 'polygon', callback)

    def cleanData(self):
        if self.gridCreated:
            cleanPublicSchema(self.projectName)
        if self.tmpP is not None:
            cleanPublicSchema('polygon')
            cleanTemporaryFiles(self.tmpP)
        if self.tmpO is not None:
            cleanPublicSchema('obstacles')
            cleanTemporaryFiles(self.tmpO)

    def populatePolygonEnd(self, msg):
        consoleAppend(' > Populate polygon in %s' % GetTextTime(time.time() - self.start))
        self.tmpP = msg.data

        self.ts = time.time()
        if self.wantObstacles:
            self.srsObstacle = re.search(r'\[(\d*)\].*', self.srsObstacle).group(1)

            callback = 'populateObstaclesEnd'
            Publisher().subscribe(self.populateObstaclesEnd, callback) # create a pubsub receiver
            Populate(self.obstacle, self.srsObstacle, self.srsProject, 'obstacles', callback)
        else:
            self.populateObstaclesEnd(None)

    def populateObstaclesEnd(self, msg):
        if self.wantObstacles:
            consoleAppend(' > Populate obstacles in %s' % GetTextTime(time.time() - self.ts))
            self.tmpO = msg.data

        self.ts = time.time()
        callback = "gridNetworkEnd"
        Publisher().subscribe(self.gridNetworkEnd, callback)
        pubDial = "publishDialog"
        Publisher().subscribe(self.publishDialog, pubDial)
        # the srs of the grid network is always the srs out of the polygon
        GridNetwork(callback, pubDial, self.res, self.srsProject, self.projectName, self.wantObstacles)

    def publishDialog(self, msg):
        txt = msg.data
        dlg = wx.MessageDialog(self, txt, 'Warning projection match', wx.OK|wx.ICON_EXCLAMATION)
        dlg.ShowModal()
        dlg.Destroy()
        # clean data
        self.cleanData()
        # enable main frame
        self.load.hide()
        self.parent.Enable()
        self.Destroy()

    def gridNetworkEnd(self, msg):
        consoleAppend(' > The grid network has been created in %s' % GetTextTime(time.time() - self.ts))
        self.gridCreated = True

        self.ts = time.time()
        callback = "topologyEnd"
        Publisher().subscribe(self.topologyEnd, callback) # create a pubsub receiver
        consoleAppend('Start creating the topology... This can take a while, please be patient...')
        Topology(self.projectName, self.srsProject, self.authorName, 0, 'grid', self.res, callback)

    def gridShpNetworkEnd(self, msg):
        # callback of GridNetwork.creatShp
        consoleAppend("New shapefile has been created in %s" % GetTextTime(time.time() - self.start))

        self.cleanData()
        self.parent.repaintTable()
        self.actionEnd(None)

    def topologyEnd(self, msg):
        consoleAppend('The topology has been created in %s...' % GetTextTime(time.time() - self.ts))

        self.cleanData()
        self.parent.repaintTable()
        self.actionEnd(None)