示例#1
0
 def _build_textual_interface(self):
     self.root = Column(layout_width=self.width,
                        layout_height=self.height,
                        padding=20)
     # Nested Column
     column = Column(parent=self.root, padding=0)
     column.add_spacer(20)
     self.root.add_node(column)
     # Nested Row
     row = Row(parent=self.root, padding=10, align=ALIGN_CENTER)
     row.add_text_content('Test 1')
     row.add_text_content('Test 2')
     row.add_text_content('Test 3')
     row.add_text_content('Test 4')
     self.root.add_node(row)
     # Other text nodes
     self.root.add_text_content('Good Morning, Rahul', text_size=3)
     self.root.add_text_content('Some text')
     self.root.add_text_content('Some more text')
     self.root.add_text_content('Medium Text',
                                text_size=5,
                                align=ALIGN_CENTER)
     self.root.add_text_content('More Medium Text',
                                text_size=5,
                                align=ALIGN_RIGHT)
     self.root.add_text_content('Large Text',
                                text_size=9,
                                align=ALIGN_CENTER)
     self.root.add_text_content('Largest Text',
                                text_size=10,
                                align=ALIGN_CENTER)
示例#2
0
    def build_calendar_ui(self):
        '''
        Builds the actual Calendar UI after making the RESTful request.
        '''
        if not self.device_auth.authorized:
            self._error('Need to authorize first.')

        if not self.calendar:
            self.calendar = Calendar(self.device_auth)

        events = self.calendar.events()
        date_today = DateTime.today()
        sync_at = date_today.formatted()
        sync_at_message = 'Last updated at %s' % (sync_at)
        if len(events) <= 0:
            messages = [sync_at_message]
            self._notify('No events.', messages=messages)
        else:
            root = Column(layout_width=self.width,
                          layout_height=self.height,
                          padding=10)
            header = Row(parent=root, layout_height=40, wrap_content=False)
            f_date_today = date_today.formatted(include_day=True,
                                                include_time=False)
            header.add_text_content('Today - %s' % (f_date_today), text_size=4)
            header.add_image(CALENDAR_40_40, 40, 40, align=ALIGN_RIGHT)
            content_root = Row(parent=root,
                               layout_height=480,
                               wrap_content=False,
                               outline=True)
            content = Column(parent=content_root, wrap_content=False)
            content.add_spacer(10, outline=True)
            content.add_spacer(20)
            for event in events:
                summary = event.summary
                duration_info = None
                if event.start_at:
                    include_day = not event.start_at.is_today()
                    duration_info = 'At %s' % (event.start_at.formatted(
                        include_day=include_day))
                elif event.end_at:
                    duration_info = 'Ends at %s' % (event.end_at.formatted(
                        include_day=True, include_time=False))

                content.add_text_content(summary)
                if duration_info:
                    content.add_text_content(duration_info)
                content.add_spacer(height=15)
            content_root.add_node(content)
            status = Row(parent=root,
                         layout_height=40,
                         wrap_content=False,
                         outline=True)
            status.add_text_content(sync_at_message, align=ALIGN_RIGHT)
            root.add_node(header)
            root.add_node(content_root)
            root.add_node(status)
            self._draw(root)
示例#3
0
 def _build_auth(self):
     self.root = Column(layout_width=self.width,
                        layout_height=self.height,
                        padding=10)
     header = Row(parent=self.root, layout_height=40, wrap_content=False)
     header.add_text_content('Calendar', text_size=4)
     header.add_image(CALENDAR_40_40, 40, 40, align=ALIGN_RIGHT)
     content_root = Row(parent=self.root,
                        layout_height=520,
                        wrap_content=False,
                        outline=True)
     content = Column(parent=content_root, wrap_content=False)
     content.add_spacer(10, outline=True)
     content.add_spacer(self.width // 4)
     content.add_text_content('ABCD-EFGH', text_size=6, align=ALIGN_CENTER)
     content.add_text_content('google.com/auth/code to continue',
                              align=ALIGN_CENTER)
     content_root.add_node(content)
     self.root.add_node(header)
     self.root.add_node(content_root)
示例#4
0
 def _notify(self, title, messages=list()):
     root = Column(layout_width=self.width,
                   layout_height=self.height,
                   padding=10)
     header = Row(parent=root, layout_height=40, wrap_content=False)
     header.add_text_content('Calendar', text_size=4)
     header.add_image(CALENDAR_40_40, 40, 40, align=ALIGN_RIGHT)
     content_root = Row(parent=root,
                        layout_height=520,
                        wrap_content=False,
                        outline=True)
     content = Column(parent=content_root, wrap_content=False)
     content.add_spacer(10, outline=True)
     content.add_spacer(self.width // 4)
     content.add_text_content(title, text_size=6, align=ALIGN_CENTER)
     for message in messages:
         content.add_text_content(message, align=ALIGN_CENTER)
     content_root.add_node(content)
     root.add_node(header)
     root.add_node(content_root)
     self._draw(root)
示例#5
0
 def _build_calendar(self):
     self.root = Column(layout_width=self.width,
                        layout_height=self.height,
                        padding=20)
     header = Row(parent=self.root, layout_height=40, wrap_content=False)
     header.add_text_content('Calendar', text_size=4)
     header.add_image(CALENDAR_40_40, 40, 40, align=ALIGN_RIGHT)
     content_root = Row(parent=self.root,
                        layout_height=440,
                        wrap_content=False,
                        outline=True)
     content = Column(parent=content_root, wrap_content=False)
     content.add_spacer(10, outline=True)
     content_root.add_node(content)
     status = Row(parent=self.root,
                  layout_height=40,
                  wrap_content=False,
                  outline=True)
     status.add_text_content('Last updated at <>', align=ALIGN_RIGHT)
     self.root.add_node(header)
     self.root.add_node(content_root)
     self.root.add_node(status)