Exemple #1
0
    def __init__(self, parent_window, course_data, on_close):
        # Create window
        super().__init__(parent_window, on_close, caption='Confirm courses')

        # Window background
        gl.glClearColor(43 / 255, 65 / 255, 98 / 255, 1)
        waves = Sprite(image('front-waves.png'), x=0, y=0, batch=self.batch)
        waves.opacity = 160

        # The courses entered so far will be stored in self.course_data.
        # This is a dict, where each key is the course section
        # and the value is a tuple of the format (<title>, <venue>, <instructor>).
        self.course_data = course_data

        # UI text
        self.x_coords = [80, 250, 370,
                         480]  # section, title, venue, instructor
        self.heading_y = self.height - 90
        self.labels = [
            Text('Confirm your',
                 x=self.margin,
                 y=self.height - self.margin - 12,
                 size=20,
                 batch=self.batch),
            Text('courses',
                 x=self.margin + 170,
                 y=self.height - self.margin - 12,
                 size=20,
                 bold=True,
                 batch=self.batch),
            Text('Section',
                 x=self.x_coords[0],
                 y=self.heading_y,
                 size=12,
                 bold=True,
                 batch=self.batch),
            Text('Title',
                 x=self.x_coords[1],
                 y=self.heading_y,
                 size=12,
                 bold=True,
                 batch=self.batch),
            Text('Venue',
                 x=self.x_coords[2],
                 y=self.heading_y,
                 size=12,
                 bold=True,
                 batch=self.batch),
            Text('Instructor',
                 x=self.x_coords[3],
                 y=self.heading_y,
                 size=12,
                 bold=True,
                 batch=self.batch),
            Text('Page 1 of 1',
                 x=self.margin * 4,
                 y=self.margin + 8,
                 size=10,
                 batch=self.batch)
        ]

        # Next button
        next_button = Button('next', self, self.batch, y=self.margin)
        next_button.x = self.width - next_button.image.width - 24
        next_button.scale = 0.8
        self.ui_buttons = [next_button]

        # Table pagination
        self.page = 0
        self.pages = []
        self.paginate()
        self.ui_buttons.extend([
            Button('left', self, self.batch, x=self.margin, y=self.margin),
            Button('right', self, self.batch, x=self.margin * 2,
                   y=self.margin),
        ])

        # Rows
        self.delete_buttons = []
        self.course_rows = []
        self.generate_rows()
Exemple #2
0
    def __init__(self, window, bus, manager):
        super().__init__(window,
                         bus,
                         draw_waves=True,
                         title='tabulr | Input subjects')
        self.title = Text('Input a',
                          batch=self.batch,
                          size=22,
                          x=self.margin,
                          y=self.window.height - self.margin - 22)
        self.title_bold = Text('course',
                               bold=True,
                               batch=self.batch,
                               size=22,
                               x=self.margin + self.title.content_width + 8,
                               y=self.window.height - self.margin - 22)

        # Next button
        next_button = Button('next', self.window, self.batch, y=self.margin)
        next_button.x = self.window.width - self.margin - next_button.image.width
        self.init_sprite('next_button', next_button)

        # Add button
        add_button = Button('add-course',
                            self.window,
                            self.batch,
                            x=self.margin,
                            y=self.margin)
        self.init_sprite('add_button', add_button)

        # Text inputs
        self.inputs = [
            # Course Title
            TextInput('', self.margin, 310, 280, self.batch),
            # Section
            TextInput('', self.margin + 330, 310, 100, self.batch),
            # Venue
            TextInput('', self.margin, 240, self.window.width - 210,
                      self.batch),
            # Instructor (Optional)
            TextInput('', self.margin, 170, self.window.width - 210,
                      self.batch)
        ]
        self.window.focus = None
        self.set_focus(self.inputs[0])

        # Text input labels and status messages
        self.labels = [
            Text('Course title',
                 size=14,
                 x=self.margin,
                 y=350,
                 batch=self.batch),
            Text('Section',
                 size=14,
                 x=self.margin + 330,
                 y=350,
                 batch=self.batch),
            Text('Venue', size=14, x=self.margin, y=280, batch=self.batch),
            Text('Instructor (optional)',
                 size=14,
                 x=self.margin,
                 y=210,
                 batch=self.batch),
            Text('',
                 size=12,
                 x=add_button.x + add_button.width + self.margin,
                 y=self.margin + add_button.height // 2 - 4,
                 batch=self.batch),
        ]

        # Error message
        self.error_msg.y = self.margin * 2 + add_button.height

        # Course manager instance
        self.manager = manager
        self.manager.set_close_handler(self.on_viewer_closed)