コード例 #1
0
def on_touch_moodle_login(x, y):
    global state, moodle_username, moodle_password, login_error, entries
    if username_button_rect.collidepoint(x, y):
        keyboard = VirtualKeyboard(screen)
        userinput = keyboard.run(
            text=moodle_username if moodle_username != None else "")
        moodle_username = userinput
    elif password_button_rect.collidepoint(x, y):
        keyboard = VirtualKeyboard(screen)
        moodle_password = keyboard.run(password=True)
    elif login_button_rect.collidepoint(x, y):
        if moodle_username == None or moodle_password == None:
            login_error = True
            return
        try:
            moodle.connect(moodle_username, moodle_password)
        except Exception as exc:
            if len(exc.args) == 1 and exc.args[0] == "invalidlogin":
                login_error = True
            else:
                raise
        else:
            change_state("moodle")
    elif home_button_rect.collidepoint(x, y):
        change_state("welcome")
コード例 #2
0
ファイル: main.py プロジェクト: jmm526/Cactus-Pet
def game_intro(game_state):

    # Load initial game_intro screen
    intro_screen = pygame.image.load('Sprites/Intro_Screen.png')
    game_state.displaySurf.blit(intro_screen, (0, 0))

    # Introduction dialogue
    TextDisplayFN(
        game_state,
        [['Hello, and welcome to your', 'own personal cactus simulator'],
         ['I will be your host, ', 'Master Programmer Jake.'],
         ['Together we will explore', 'the wonderful world of Cacti!'],
         ['Please take a moment and', 'enter your name:']])

    # Input Name
    vkeybd = VirtualKeyboard(game_state.displaySurf)
    game_state.init_player(vkeybd.run(defPlayerName))

    game_state.displaySurf.blit(intro_screen, (0, 0))  # Put screen back on

    # Post Name Dialogue
    TextDisplayFN(game_state,
                  [['Thanks ' + game_state.myPlayer.name + '!', ''],
                   ['Now then, I think', 'something\'s missing'],
                   ['...', '...'], ['Ahh yes of course, ', 'the cactus!'],
                   ['Lucky for you I just', 'returned from the desert'],
                   ['and have the perfect', 'buddy for you!']])

    # Load Cactus + Animation
    introScreenCactus = pygame.image.load('Sprites/Intro_Screen_Cactus.png')
    game_state.displaySurf.blit(introScreenCactus, (0, 0))

    game_state = gold_burst(game_state, 112, 149, True)

    # Dialogue
    TextDisplayFN(game_state,
                  [['Meet your new friend!', ''],
                   ['This particular specimen', 'looks like a female.'],
                   ['What would you like', 'to name her?']])

    # Input Name
    vkeybd = VirtualKeyboard(game_state.displaySurf)
    game_state.myPlayer.init_cactus(vkeybd.run('Cactuar'))

    # Dialogue
    TextDisplayFN(game_state,
                  [['Splendid!', ''],
                   [
                       'You and ' + game_state.myPlayer.myCactus.name,
                       'will make a great team.'
                   ], ['Now that we\'re settled,', 'I\'ll give you a quick'],
                   ['tour of your home.', '']])

    # game_state.myPlayer.newGame = False
    game_state.save_game()

    return game_state
コード例 #3
0
def pageDateTime():
    global page
    print 'DateTime'
    while page == pageDateTime:
        #    if checkEvent(): return
        vkey = VirtualKeyboard(screen)  # create a virtual keyboard
        if gps_on and gps.statusOK:
            tn = gps.datetime + timedelta(seconds=5)  # set ahead a bit
        else:
            tn = datetime.now() + timedelta(seconds=5)  # set ahead a bit
        txt = vkey.run(tn.strftime('%Y-%m-%d %H:%M:%S'))
        print 'datetime: {}'.format(txt)
        if len(txt) > 0:
            try:
                dt = datetime.strptime(txt,
                                       '%Y-%m-%d %H:%M:%S')  # check format
                print 'dt: {}'.format(dt)
                os.system('sudo date -s "{}"'.format(dt))
            except:
                pass
        else:
            Exit()

#    page = pageMenu
        return
コード例 #4
0
ファイル: main.py プロジェクト: jmm526/Cactus-Pet
    def main_menu(self):

        while True:
            mouseClicked = False

            self.displaySurf.blit(self.BGPng, (0, 0))
            self.displaySurf.blit(self.backIcon, self.backIcon_loc)
            self.draw_main_menu()

            for event in pygame.event.get():
                if event.type == QUIT:
                    self.quit_game()
                elif event.type == MOUSEMOTION:
                    self.mouseX, self.mouseY = event.pos
                elif event.type == MOUSEBUTTONUP:
                    self.mouseX, self.mouseY = event.pos
                    mouseClicked = True

            # What does mouse click
            if mouseClicked == True:
                if self.backIcon_rect.collidepoint(self.mouseX, self.mouseY):
                    self.set_state('Main_Screen')
                    break
                elif self.textRectTextBox1.collidepoint(
                        self.mouseX, self.mouseY):
                    self.about_menu()
                elif self.textRectTextBox2.collidepoint(
                        self.mouseX, self.mouseY):
                    vkeybd = VirtualKeyboard(self.displaySurf)
                    self.myPlayer.name = vkeybd.run(self.myPlayer.name)
                elif self.textRectTextBox3.collidepoint(
                        self.mouseX, self.mouseY):
                    self.quit_game()

            # Update Display
            pygame.display.update()
            self.fpsClock.tick(FPS)
            self.frameCounter += 1
            self.frameCounter = self.frameCounter % 2592000
コード例 #5
0
ファイル: main.py プロジェクト: jmm526/Cactus-Pet
    def shop_menu(self):

        while True:
            mouseClicked = False

            self.displaySurf.blit(self.BGPng, (0, 0))
            self.displaySurf.blit(self.backIcon, self.backIcon_loc)
            self.draw_shop_menu()

            for event in pygame.event.get():
                if event.type == QUIT:
                    self.quit_game()
                elif event.type == MOUSEMOTION:
                    self.mouseX, self.mouseY = event.pos
                elif event.type == MOUSEBUTTONUP:
                    self.mouseX, self.mouseY = event.pos
                    mouseClicked = True

            # What does mouse click
            if mouseClicked == True:
                if self.outerBoxWater_R.collidepoint(self.mouseX, self.mouseY):
                    self.myPlayer.buy_water()
                elif self.outerBoxFert_R.collidepoint(self.mouseX,
                                                      self.mouseY):
                    self.myPlayer.buy_fert()
                elif self.outerBoxCN_R.collidepoint(self.mouseX, self.mouseY):
                    vkeybd = VirtualKeyboard(self.displaySurf)
                    self.myPlayermyCactus.name = vkeybd.run(
                        self.myPlayer.myCactus.name)
                elif self.backIcon_rect.collidepoint(self.mouseX, self.mouseY):
                    self.set_state('Main_Screen')
                    break

            # Update Display
            pygame.display.update()
            self.fpsClock.tick(FPS)
            self.frameCounter += 1
            self.frameCounter = self.frameCounter % 2592000
コード例 #6
0
def main():
    """Shows basic usage of the Gmail API.

    Creates a Gmail API service object and outputs a list of label names
    of the user's Gmail account.
    """
    credentials = get_credentials()
    http = credentials.authorize(httplib2.Http())
    service = discovery.build('gmail', 'v1', http=http)

    results = service.users().labels().list(userId='me').execute()
    labels = results.get('labels', [])

    FPS = 30
    WINDOWWIDTH = 480
    WINDOWHEIGHT = 320

    WHITE = (255, 255, 255)
    RED = (255, 0, 0)
    BLUE = (0, 0, 255)
    GREEN = (0, 255, 0)
    BLACK = (0, 0, 0)
    LIGHTGREEN = (53, 230, 97)
    LIGHTBLUE = (53, 156, 230)
    LIGHTORANGE = (242, 109, 19)

    windowBgColor = WHITE

    pygame.init()
    FPSCLOCK = pygame.time.Clock()
    DISPLAYSURFACE = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
    pygame.display.set_caption('PLUTO')

    myfont = pygame.font.Font(None, 30)
    label = myfont.render("<-- Enter address", 1, BLACK)

    buttonEnterEmail  = pygbutton.PygButton((10, 10, 100, 80), 'Enter Email', bgcolor=LIGHTORANGE)
    buttonScan = pygbutton.PygButton((10, 100, 225, 210), 'Scan and Send', bgcolor=LIGHTGREEN, font=myfont)
    buttonReceive = pygbutton.PygButton((245, 100, 225, 210), 'Receive and Print', bgcolor=LIGHTBLUE, font=myfont)
    buttonPrintICR = pygbutton.PygButton((370, 10, 100, 80), 'Letterhead', bgcolor=RED)
    winBgButtons = (buttonEnterEmail, buttonScan, buttonReceive, buttonPrintICR)

    allButtons = winBgButtons

    userinput = ""

    while True:
        for event in pygame.event.get(): # event handling loop
            
            if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
                pygame.quit()
                sys.exit()

            if 'click' in buttonReceive.handleEvent(event): #User called for printing of file
                
                idenListCurr = ListMessagesMatchingQuery(service, 'me', 'in:inbox')
                idenListLast = None
        
                #if idenListLast != idenListCurr: #to be used in future with inbox functionality

                    #msgList = [] #should be a way to do this where only add the new messages
                    
                    #for each in idenListCurr:
                        #iden = each[u'id']
                        #mimeMsg = GetMimeMessage(service, 'me', iden)
                        
                        #msgList.append(mimeMsg)

                    #idenListLast = idenListCurr
                

                #displayInterface(msgList)
                htmlMsg = GetRawMessageHtml(service, 'me', idenListCurr[0][u'id'])
                writeFile(htmlMsg, "temp", "html")
                    
                try:
                    pdfkit.from_file("/home/pi/git/PlutoTest/temp.html", "temp.pdf") #change to your directory
                except IOError:
                    pass
            
                popup = Popup(DISPLAYSURFACE)
                tempInput = popup.run("Your message will print")
                printCups.executePrint("/home/pi/git/PlutoTest/temp.pdf") #change to your directory
                os.remove("/home/pi/git/PlutoTest/temp.pdf") #change to your directory
                os.remove("/home/pi/git/PlutoTest/temp.html") #change to your directory
                time.sleep(5)
                        
            if 'click' in buttonScan.handleEvent(event):#user called for scanning and sending of file
                scan.executeScan("temp")
                
                message = CreateMessageWithAttachment("*****@*****.**", userinput, "Hello from Pluto!", "Enjoy!",
                                                      "/home/pi/git/PlutoTest/", "temp.png") #change to your email, directory
                SendMessage(service, 'me', message)
                
                
                os.remove("/home/pi/git/PlutoTest/temp.png") #change to your directory
                popup = Popup(DISPLAYSURFACE)
                tempInput = popup.run("Your message has been sent")
                print("sent")
                time.sleep(5)
                
            if 'click' in buttonEnterEmail.handleEvent(event): #user called to enter e-mail address
                vkeybd = VirtualKeyboard(DISPLAYSURFACE)
                tempInput = vkeybd.run("...")
                if tempInput != "...":
                    userinput = tempInput
                label = myfont.render("To: " + userinput, 1, BLACK)
                
            if 'click' in buttonPrintICR.handleEvent(event): #user called to print letterhead
                popup = Popup(DISPLAYSURFACE)
                tempInput = popup.run("The letterhead will print")
                printCups.executePrint("/home/pi/git/PlutoTest/DemoPaper.png") #change to your directory
                time.sleep(5)


        DISPLAYSURFACE.fill(windowBgColor)

        for b in allButtons:
            b.draw(DISPLAYSURFACE)

        # draw the text onto the surface
        DISPLAYSURFACE.blit(label, (120, 35, 350, 80))

        pygame.display.update()
        FPSCLOCK.tick(FPS)
コード例 #7
0
 def show_virtual_keyboard(self, text=''):
     vk = VirtualKeyboard(self.window_surface)
     return vk.run(text)
コード例 #8
0
 def gpi_button_click(self, btn, mbtn):
     #         self.vkeyboard=vkeyboard.show_vkeyboard(self.input_vkeyboard, "hoge")
     vkey = VirtualKeyboard(ui.window_surface)
     input_key = vkey.run("")
     print input_key
コード例 #9
0
 def item_selected(self, list_view, item, index):
     print str(index)
     #         vkeyboard.show_vkeyboard(self.input_promptpassword)
     vkey = VirtualKeyboard(ui.window_surface)
     input_key = vkey.run("")
     print input_key