예제 #1
0
    def build(self):
        # Create a box layout
        boxLayout = BoxLayout()

        # Anchor Layout1
        anchorLayout1 = AnchorLayout(anchor_x='left', anchor_y='bottom')
        button1 = Button(text='Bottom-Left', size_hint=(0.6, 0.3))
        anchorLayout1.add_widget(button1)

        # Anchor Layout2
        anchorLayout2 = AnchorLayout()
        anchorLayout2.anchor_x = 'right'
        anchorLayout2.anchor_y = 'top'

        # Anchor Layout3
        anchorLayout3 = AnchorLayout()
        anchorLayout3.anchor_x = 'left'
        anchorLayout3.anchor_y = 'top'

        # Add the anchor layouts to a box layout
        button2 = Button(text='Top-Right', size_hint=(0.6, 0.3))
        anchorLayout2.add_widget(button2)

        # Add the anchor layouts to a box layout
        button3 = Button(text='Top-Left', size_hint=(0.6, 0.3))
        anchorLayout3.add_widget(button3)

        # Add both the anchor layouts to the box layout
        boxLayout.add_widget(anchorLayout1)
        boxLayout.add_widget(anchorLayout2)
        boxLayout.add_widget(anchorLayout3)

        # Return the boxlayout widget
        return boxLayout
예제 #2
0
    def build(self):
        layout = AnchorLayout(anchor_x='right', anchor_y='center')

        btn1 = Button(text="Button 1")
        btn2 = Button(text="Button 2")
        btn3 = Button(text="Button 3")
        btn4 = Button(text="Button 4")
        btn5 = Button(text="Button 5")

        layout.add_widget(btn1)

        layout.anchor_x = 'center'
        layout.anchor_y = 'center'
        layout.add_widget(btn2)

        layout.anchor_x = 'left'
        layout.anchor_y = 'center'
        layout.add_widget(btn3)

        layout.anchor_x = 'right'
        layout.anchor_y = 'bottom'
        layout.add_widget(btn4)

        layout.anchor_x = 'center'
        layout.anchor_y = 'bottom'
        layout.add_widget(btn5)
        return layout
예제 #3
0
    def setLayout(self):
        self.size = (1500, 1000)

        with self.canvas:
            Color(.532345, 1.0, .742, 1.0)
            Rectangle(size=self.size)

        sound_board_layout = AnchorLayout()
        sound_board_layout.anchor_x = "center"
        sound_board_layout.anchor_y = "top"
        sound_board_layout.size = self.size
        sound_board_layout.pos = self.pos
        sound_board_layout.size_hint = (1.0, 1.0)
        sound_board_layout.spacing = 50

        self.title_layout.orientation = "vertical"
        self.title_layout.size_hint = (1.0, 1.0)
        self.title_layout.spacing = 10

        title_label = Label()
        title_label.text = "Soundboard"
        title_label.color = [.6, .2, 1, .5]
        title_label.font_size = 50
        title_label.font_name = "C:\\Windows\\Fonts\\Arial"
        title_label.size_hint = (1, 1)
        self.title_layout.add_widget(title_label)

        self.set_settings_layout()

        self.set_sounds()

        self.title_layout.add_widget(self.grid_layout)
        sound_board_layout.add_widget(self.title_layout)

        self.add_widget(sound_board_layout)
예제 #4
0
    def build(self):
        # Anchor Layout1
        anchorLayout1 = AnchorLayout(anchor_x='left', anchor_y='bottom')
        button1 = Button(text='test', size_hint=(0.3, 0.3))

        def callback(instance):
            print('The button <%s> is being pressed' % instance.text)
            publish.single("test", hostname="192.168.1.11")

        button1.bind(on_press=callback)
        anchorLayout1.add_widget(button1)

        # Anchor Layout2
        anchorLayout2 = AnchorLayout()
        anchorLayout2.anchor_x = 'right'
        anchorLayout2.anchor_y = 'top'

        # Add the anchor layouts to a box layout
        vid = Video(source="http://192.168.1.11:8081/", play=True)
        anchorLayout2.add_widget(vid)

        # Create a box layout
        boxLayout = BoxLayout()

        # Add both the anchor layouts to the box layout
        boxLayout.add_widget(anchorLayout1)
        boxLayout.add_widget(anchorLayout2)

        # Return the boxlayout widget
        return boxLayout
예제 #5
0
    def build(self):
        screen_manager = ScreenManager()
        self.loaded_values = [
            1, 0, 0, 0, 0, 0
        ]  # round num, cp, primary obj, 1st secondary, 2nd secondary, 3rd secondary
        self.update_values()
        self.theme_cls.primary_palette = "Gray"
        self.theme_cls.primary_hue = "800"

        # Game counters screen and backgrgound color

        self.counters = Screen(name="Counters")
        self.change_bg_color()

        screen_manager.add_widget(self.counters)

        # SCROLLVIEW

        self.scroll = ScrollView()
        self.counters.add_widget(self.scroll)

        # MENU
        self.menu_button = MDIconButton(icon='format-color-fill',
                                        on_release=self.menu_open)
        self.menu_button.pos_hint = {'center_x': .9, 'center_y': .1}
        self.menu_button.md_bg_color = (1, 1, 1, 1)
        items = [{
            "text": "Ceramic White"
        }, {
            "text": "Loyal Angels Green"
        }, {
            "text": "Space Doggos Gray"
        }, {
            "text": "Codex Blue"
        }, {
            "text": "Vampire Angels Red"
        }, {
            "text": "Gray Nights"
        }, {
            "text": "Stubborn Fists Yellow"
        }]
        self.menu = MDDropdownMenu(caller=self.menu_button,
                                   items=items,
                                   callback=self.menu_callback,
                                   width_mult=5)
        self.counters.add_widget(self.menu_button)

        # MAIN GRID
        app_grid = GridLayout(cols=1, spacing=100, size_hint_y=None)
        app_grid.padding = [
            Window.width / 40, Window.height / 20, Window.width / 40,
            Window.height / 4
        ]  # [left,top,right,bottom]
        app_grid.bind(minimum_height=app_grid.setter('height'))
        self.scroll.add_widget(app_grid)

        # ROUND COUNTER

        round_parent_grid = MDGridLayout()
        round_parent_grid.cols = 1
        round_parent_grid.rows = 2
        round_parent_grid.adaptive_height = True

        round_label = MDLabel(text='Round number:')
        round_label.halign = 'center'
        round_parent_grid.add_widget(round_label)
        app_grid.add_widget(round_parent_grid)

        grid_round = GridLayout()
        grid_round.cols = 3

        increase_round = MDIconButton(icon="arrow-right-bold",
                                      on_press=self.increase_round)
        self.round_counter = MDLabel(text=str(self.loaded_values[0]))
        self.round_counter.halign = 'center'
        self.round_counter.valign = 'middle'
        decrease_round = MDIconButton(icon="arrow-left-bold",
                                      on_press=self.decrease_round)

        grid_round.add_widget(decrease_round)
        grid_round.add_widget(self.round_counter)
        grid_round.add_widget(increase_round)
        round_parent_grid.add_widget(grid_round)

        # COMMAND POINTS

        cp_parent_grid = MDGridLayout()
        cp_parent_grid.cols = 1
        cp_parent_grid.rows = 2
        cp_parent_grid.adaptive_height = True

        cp_label = MDLabel(text='Command Points Left:')
        cp_label.halign = 'center'
        cp_parent_grid.add_widget(cp_label)
        app_grid.add_widget(cp_parent_grid)

        grid_cp = MDGridLayout()
        grid_cp.cols = 3

        increase_cp = MDIconButton(icon="arrow-right-bold",
                                   on_press=self.increase_cp)
        self.cp_counter = MDLabel(text=str(self.loaded_values[1]))
        self.cp_counter.halign = 'center'
        self.cp_counter.valign = 'middle'
        decrease_cp = MDIconButton(icon="arrow-left-bold",
                                   on_press=self.decrease_cp)

        grid_cp.add_widget(decrease_cp)
        grid_cp.add_widget(self.cp_counter)
        grid_cp.add_widget(increase_cp)
        cp_parent_grid.add_widget(grid_cp)

        # VP PRIMARY

        prim_parent_grid = MDGridLayout()
        prim_parent_grid.cols = 1
        prim_parent_grid.rows = 2
        prim_parent_grid.adaptive_height = True

        prim_label = MDLabel(text='Primary Objective Points:')
        prim_label.halign = 'center'
        prim_parent_grid.add_widget(prim_label)
        app_grid.add_widget(prim_parent_grid)

        grid_prim = MDGridLayout()
        grid_prim.cols = 3

        increase_prim = MDIconButton(icon="arrow-right-bold",
                                     on_press=self.increase_prim)
        self.prim_counter = MDLabel(text=str(self.loaded_values[2]))
        self.prim_counter.halign = 'center'
        self.prim_counter.valign = 'middle'
        decrease_prim = MDIconButton(icon="arrow-left-bold",
                                     on_press=self.decrease_prim)

        grid_prim.add_widget(decrease_prim)
        grid_prim.add_widget(self.prim_counter)
        grid_prim.add_widget(increase_prim)
        prim_parent_grid.add_widget(grid_prim)

        # VP SECONDARY 1

        sec1_parent_grid = MDGridLayout()
        sec1_parent_grid.cols = 1
        sec1_parent_grid.rows = 2
        sec1_parent_grid.adaptive_height = True

        sec1_label = MDTextField()
        sec1_label.hint_text = '1st Secondary Objective Points:'
        sec1_label.multiline = False
        #sec1_label = MDLabel(text='1st Secondary Objective Points:')
        sec1_label.halign = 'center'
        sec1_parent_grid.add_widget(sec1_label)
        app_grid.add_widget(sec1_parent_grid)

        grid_sec1 = MDGridLayout()
        grid_sec1.cols = 3

        increase_sec1 = MDIconButton(icon="arrow-right-bold",
                                     on_press=self.increase_sec1)
        self.sec1_counter = MDLabel(text=str(self.loaded_values[3]))
        self.sec1_counter.halign = 'center'
        self.sec1_counter.valign = 'middle'
        decrease_sec1 = MDIconButton(icon="arrow-left-bold",
                                     on_press=self.decrease_sec1)

        grid_sec1.add_widget(decrease_sec1)
        grid_sec1.add_widget(self.sec1_counter)
        grid_sec1.add_widget(increase_sec1)
        sec1_parent_grid.add_widget(grid_sec1)

        # VP SECONDARY 2

        sec2_parent_grid = MDGridLayout()
        sec2_parent_grid.cols = 1
        sec2_parent_grid.rows = 2
        sec2_parent_grid.adaptive_height = True

        sec2_label = MDTextField()
        sec2_label.hint_text = '2nd Secondary Objective Points:'
        sec2_label.multiline = False
        #sec2_label = MDLabel(text='2nd Secondary Objective Points:')
        sec2_label.halign = 'center'
        sec2_parent_grid.add_widget(sec2_label)
        app_grid.add_widget(sec2_parent_grid)

        grid_sec2 = MDGridLayout()
        grid_sec2.cols = 3

        increase_sec2 = MDIconButton(icon="arrow-right-bold",
                                     on_press=self.increase_sec2)
        self.sec2_counter = MDLabel(text=str(self.loaded_values[4]))
        self.sec2_counter.halign = 'center'
        self.sec2_counter.valign = 'middle'
        decrease_sec2 = MDIconButton(icon="arrow-left-bold",
                                     on_press=self.decrease_sec2)

        grid_sec2.add_widget(decrease_sec2)
        grid_sec2.add_widget(self.sec2_counter)
        grid_sec2.add_widget(increase_sec2)
        sec2_parent_grid.add_widget(grid_sec2)

        # VP SECONDARY 3

        sec3_parent_grid = MDGridLayout()
        sec3_parent_grid.cols = 1
        sec3_parent_grid.rows = 2
        sec3_parent_grid.adaptive_height = True

        sec3_label = MDTextField()
        sec3_label.hint_text = '3rd Secondary Objective Points:'
        sec3_label.multiline = False
        #sec3_label = MDLabel(text='3rd Secondary Objective Points:')
        sec3_label.halign = 'center'
        sec3_parent_grid.add_widget(sec3_label)
        app_grid.add_widget(sec3_parent_grid)

        grid_sec3 = MDGridLayout()
        grid_sec3.cols = 3

        increase_sec3 = MDIconButton(icon="arrow-right-bold",
                                     on_press=self.increase_sec3)
        self.sec3_counter = MDLabel(text=str(self.loaded_values[5]))
        self.sec3_counter.halign = 'center'
        self.sec3_counter.valign = 'middle'
        decrease_sec3 = MDIconButton(icon="arrow-left-bold",
                                     on_press=self.decrease_sec3)

        grid_sec3.add_widget(decrease_sec3)
        grid_sec3.add_widget(self.sec3_counter)
        grid_sec3.add_widget(increase_sec3)
        sec3_parent_grid.add_widget(grid_sec3)

        # Empty grid to create space

        empty_grid = MDGridLayout()
        app_grid.add_widget(empty_grid)

        # Bottom grid for Score and Reset buttons

        bottom_grid = MDGridLayout()
        bottom_grid.cols = 2
        app_grid.add_widget(bottom_grid)

        # SCORE TOAST

        score_button = MDFillRoundFlatIconButton(icon='flag-plus-outline',
                                                 text="Show score",
                                                 on_press=self.sum_up)
        button_anchor = AnchorLayout()
        button_anchor.anchor_y = 'bottom'
        button_anchor.add_widget(score_button)
        bottom_grid.add_widget(button_anchor)

        # RESET

        reset_button = MDFillRoundFlatIconButton(icon='backup-restore',
                                                 text="Reset",
                                                 on_press=self.reset_values)
        reset_button_anchor = AnchorLayout()
        reset_button_anchor.anchor_y = 'bottom'
        reset_button_anchor.add_widget(reset_button)
        bottom_grid.add_widget(reset_button_anchor)

        return screen_manager