Beispiel #1
0
    def build(self):
        self.icon = ICON
        Window.minimum_width, Window.minimum_height = Window.size
        root = FloatLayout()
        navdrawer = NavigationDrawer()
        navdrawer.toggle_state()
        navdrawer.anim_type = "slide_above_anim"

        self.chisel = chisel = Chisel()
        self.chisel_on_touch_down = chisel.on_touch_down
        self.chisel_on_touch_move = chisel.on_touch_move

        options_panel = OptionsPanel(chisel)
        navdrawer.add_widget(options_panel)

        burger = BurgerButton()
        burger.bind(on_release=navdrawer.toggle_state)

        rel_layout = RelativeLayout()
        rel_layout.add_widget(chisel)  # To push it when side panel is opened.
        navdrawer.add_widget(rel_layout)
        options_panel.build()
        options_panel.bind_to_burger(burger)
        navdrawer.bind(_anim_progress=self._set_side_panel_opacity)
        navdrawer.bind(_anim_progress=self.disable_chisel)

        root.add_widget(navdrawer)
        root.add_widget(burger)
        Window.add_widget(CURSOR, canvas="after")
        return root
Beispiel #2
0
    def build(self):
        self.icon = ICON
        cursor = Cursor()
        Window.minimum_width, Window.minimum_height = Window.size
        root = FloatLayout()
        navdrawer = NavigationDrawer()
        navdrawer.toggle_state()
        navdrawer.anim_type = "slide_above_anim"

        chisel = Chisel()

        options_panel = OptionsPanel(chisel)
        navdrawer.add_widget(options_panel)

        burger = BurgerButton()
        burger.bind(on_release=navdrawer.toggle_state)

        rel_layout = RelativeLayout(
        )  # This layout allows navdrawer to push contained widgets.
        rel_layout.add_widget(chisel)

        tools = (ToolButton(*args, chisel, cursor)
                 for args in zip(range(3), TOOLS_NORMAL, TOOLS_SELECTED))

        for tool in tools:
            tool.pos_hint = {"x": tool._id * .1 + .35, "y": .01}
            if tool._id == 0:  # First tool button is selected.
                tool.state = "down"
            rel_layout.add_widget(tool)

        navdrawer.add_widget(rel_layout)
        options_panel.build()
        options_panel.bind_to_burger(burger)

        def on_anim(instance, value):
            instance.side_panel.opacity = chisel.disabled = 1 if instance._anim_progress else 0

        navdrawer.bind(_anim_progress=on_anim)

        root.add_widget(navdrawer)
        root.add_widget(burger)

        Window.add_widget(cursor, canvas="after")
        return root
Beispiel #3
0
class Mafia(App):
    phase = 'day' #'day' or 'night'
    dayCount = 1
    nightCount = 1
    aliveList = []
    deadList = []
    setup = StringProperty()
    #setup = 'Vengeful'
    playerNumber = NumericProperty()
    #playerNumber = 5
    winningTeam = ''

    def reset(self, instance):
        Mafia.phase = 'day'
        Mafia.dayCount = 1
        Mafia.nightCount = 1
        Mafia.aliveList[:] = []
        Mafia.deadList[:] = []
        Mafia.setup = StringProperty()
        Mafia.playerNumber = NumericProperty(1)
        winningTeam = ''
        sm.current = 'titleScreen'

    def build(self):
        self.root = NavigationDrawer()
        self.root.side_panel_opacity = 0
        self.root.separator_image_width = sp(0)
        menu = BoxLayout(orientation='vertical')

        resetButton = Factory.GreenButton(text='New Game')
        settingsButton = Factory.OrangeButton(text='Settings')
        helpButton = Factory.PurpleButton(text='Help')
        menu.add_widget(resetButton)
        menu.add_widget(settingsButton)
        menu.add_widget(helpButton)
        resetButton.bind(on_press=self.reset)

        self.root.add_widget(menu)

        content = AnchorLayout(anchor_x='right', anchor_y='bottom', paddind=sp(5))



        toggleButton = IconButton (icon="atlas://img/icon/iconatlas/icon-menu", size_hint=(.15, .1),
            background_normal='atlas://img/button/buttonatlas/red',
            background_down='atlas://img/button/buttonatlas/orange')
        toggleButton.bind(on_press=lambda j: self.root.toggle_state())

        content.add_widget(sm)
        content.add_widget(toggleButton)
        self.root.add_widget(content)
        sm.current = 'titleScreen'
        return self.root
Beispiel #4
0
class TabDrawer(BoxLayout, Sender):
    current_tab = ObjectProperty(None)
    current_text = StringProperty('BalanceBot')
    main_panel = ObjectProperty(None)
    orientation = 'vertical'

    Data = (('Stability', (
        ('Vertical', (0, -5, 5, 0.1)),
        ('kPs', (5, 0, 100, 0.1)),
        ('kIs', (5, 0, 100, 0.1)),
        ('kDs', (5, 0, 100, 0.1)),
    ), (
        ('Angle', (1, 0, 0)),
        ('PID_stab', (0, 1, 0)),
        ('P_stab', (0.5, 0.5, 0)),
        ('I_stab', (0, 0.5, 0.5)),
        ('D_stab', (0, 0, 1)),
    )), ('Deplacement', (
        ('Origine', (0, -100, 100, 1)),
        ('kPd', (5, 0, 10, 0.1)),
        ('kId', (5, 0, 10, 0.1)),
        ('kDd', (5, 0, 10, 0.1)),
    ), (
        ('Encoder', (1, 0, 0)),
        ('PID_dep', (0, 1, 0)),
        ('P_dep', (0.5, 0.5, 0)),
        ('I_dep', (0, 0.5, 0.5)),
        ('D_dep', (0, 0, 1)),
    )), ('Rotation', (
        ('Direction', (0, -100, 100, 1)),
        ('kPr', (5, 0, 10, 0.1)),
        ('kIr', (5, 0, 10, 0.1)),
        ('kDr', (5, 0, 10, 0.1)),
    ), (
        ('Dif_Enc', (1, 0, 0)),
        ('PID_rot', (0, 1, 0)),
        ('P_rot', (0.5, 0.5, 0)),
        ('I_rot', (0, 0.5, 0.5)),
        ('D_rot', (0, 0, 1)),
    )))

    def __init__(self, **kwargs):

        super(TabDrawer, self).__init__(**kwargs)

        self.navdraw = NavigationDrawer()
        self.side_panel = BoxLayout(orientation='vertical')
        self.side_panel.tabbed_panel = self
        self.navdraw.add_widget(self.side_panel)
        self.add_widget(self.navdraw)

        self.add_widget(ConnectionLayout())

        pad_Layout = TabDrawerItem(text='control')
        pad_Layout.add_widget(Pad())
        self.add_widget(pad_Layout)

        for item in self.Data:
            self.add_widget(PidLayout(item))

        self.add_widget(LogLayout())

    def add_widget(self, widget, index=0):
        if issubclass(widget.__class__, TabDrawerItem):
            #if len( self.children ) > 2 :
            self.side_panel.add_widget(widget)
            if len(self.side_panel.children) == 1:
                self.switch_to(widget)
        else:
            super(TabDrawer, self).add_widget(widget)
            #print widget, len(self.children), len(self.children) > 2

    def switch_to(self, header):
        if self.navdraw.state == 'open':
            self.navdraw.toggle_state()

        if self.current_tab:
            self.current_tab.state = 'normal'
        header.state = 'down'
        self.current_tab = header
        self.current_text = header.text
        if self.main_panel:
            self.navdraw.remove_widget(self.main_panel)
        self.navdraw.add_widget(header.content)
        self.main_panel = header.content

    def toggle_state(self):
        self.navdraw.toggle_state()

    def on_current_text(self, *args):
        self.send("get", self.current_text)

    def toggle_menu(self):
        self.current_tab.menu = not self.current_tab.menu
Beispiel #5
0
    def build(self):
        navigationdrawer = NavigationDrawer()

        side_panel = BoxLayout(orientation='vertical')
        side_panel.add_widget(Label(text='Panel label'))
        side_panel.add_widget(Button(text='A button'))
        side_panel.add_widget(Button(text='Another button'))
        navigationdrawer.add_widget(side_panel)

        label_head = (
            '[b]Example label filling main panel[/b]\n\n[color=ff0000](p'
            'ull from left to right!)[/color]\n\nIn this example, the le'
            'ft panel is a simple boxlayout menu, and this main panel is'
            ' a BoxLayout with a label and example image.\n\nSeveral pre'
            'set layouts are available (see buttons below), but users ma'
            'y edit every parameter for much more customisation.')
        main_panel = BoxLayout(orientation='vertical')
        label_bl = BoxLayout(orientation='horizontal')
        label = Label(text=label_head,
                      font_size='15sp',
                      markup=True,
                      valign='top')
        label_bl.add_widget(Widget(size_hint_x=None, width=dp(10)))
        label_bl.add_widget(label)
        label_bl.add_widget(Widget(size_hint_x=None, width=dp(10)))
        main_panel.add_widget(Widget(size_hint_y=None, height=dp(10)))
        main_panel.add_widget(label_bl)
        main_panel.add_widget(Widget(size_hint_y=None, height=dp(10)))
        main_panel.add_widget(
            Image(source='red_pixel.png',
                  allow_stretch=True,
                  keep_ratio=False,
                  size_hint_y=0.2))
        navigationdrawer.add_widget(main_panel)
        label.bind(size=label.setter('text_size'))

        def set_anim_type(name):
            navigationdrawer.anim_type = name

        modes_layout = BoxLayout(orientation='horizontal')
        modes_layout.add_widget(Label(text='preset\nanims:'))
        slide_an = Button(text='slide_\nabove_\nanim')
        slide_an.bind(on_press=lambda j: set_anim_type('slide_above_anim'))
        slide_sim = Button(text='slide_\nabove_\nsimple')
        slide_sim.bind(on_press=lambda j: set_anim_type('slide_above_simple'))
        fade_in_button = Button(text='fade_in')
        fade_in_button.bind(on_press=lambda j: set_anim_type('fade_in'))
        reveal_button = Button(text='reveal_\nbelow_\nanim')
        reveal_button.bind(
            on_press=lambda j: set_anim_type('reveal_below_anim'))
        slide_button = Button(text='reveal_\nbelow_\nsimple')
        slide_button.bind(
            on_press=lambda j: set_anim_type('reveal_below_simple'))
        modes_layout.add_widget(slide_an)
        modes_layout.add_widget(slide_sim)
        modes_layout.add_widget(fade_in_button)
        modes_layout.add_widget(reveal_button)
        modes_layout.add_widget(slide_button)
        main_panel.add_widget(modes_layout)

        button = Button(text='toggle NavigationDrawer state (animate)',
                        size_hint_y=0.2)
        button.bind(on_press=lambda j: navigationdrawer.toggle_state())
        button2 = Button(text='toggle NavigationDrawer state (jump)',
                         size_hint_y=0.2)
        button2.bind(on_press=lambda j: navigationdrawer.toggle_state(False))
        button3 = Button(text='toggle _main_above', size_hint_y=0.2)
        button3.bind(on_press=navigationdrawer.toggle_main_above)
        main_panel.add_widget(button)
        main_panel.add_widget(button2)
        main_panel.add_widget(button3)

        return navigationdrawer
Beispiel #6
0
    def build(self):
        navigationdrawer = NavigationDrawer()

        side_panel = BoxLayout(orientation='vertical')
        side_panel.add_widget(Label(text='Panel label'))
        side_panel.add_widget(Button(text='A button'))
        side_panel.add_widget(Button(text='Another button'))
        navigationdrawer.add_widget(side_panel)

        label_head = (
            '[b]Example label filling main panel[/b]\n\n[color=ff0000](p'
            'ull from left to right!)[/color]\n\nIn this example, the le'
            'ft panel is a simple boxlayout menu, and this main panel is'
            ' a BoxLayout with a label and example image.\n\nSeveral pre'
            'set layouts are available (see buttons below), but users ma'
            'y edit every parameter for much more customisation.')
        main_panel = BoxLayout(orientation='vertical')
        label_bl = BoxLayout(orientation='horizontal')
        label = Label(text=label_head, font_size='15sp',
                      markup=True, valign='top')
        label_bl.add_widget(Widget(size_hint_x=None, width=dp(10)))
        label_bl.add_widget(label)
        label_bl.add_widget(Widget(size_hint_x=None, width=dp(10)))
        main_panel.add_widget(Widget(size_hint_y=None, height=dp(10)))
        main_panel.add_widget(label_bl)
        main_panel.add_widget(Widget(size_hint_y=None, height=dp(10)))
        main_panel.add_widget(Image(source='red_pixel.png', allow_stretch=True,
                                    keep_ratio=False, size_hint_y=0.2))
        navigationdrawer.add_widget(main_panel)
        label.bind(size=label.setter('text_size'))

        def set_anim_type(name):
            navigationdrawer.anim_type = name
        modes_layout = BoxLayout(orientation='horizontal')
        modes_layout.add_widget(Label(text='preset\nanims:'))
        slide_an = Button(text='slide_\nabove_\nanim')
        slide_an.bind(on_press=lambda j: set_anim_type('slide_above_anim'))
        slide_sim = Button(text='slide_\nabove_\nsimple')
        slide_sim.bind(on_press=lambda j: set_anim_type('slide_above_simple'))
        fade_in_button = Button(text='fade_in')
        fade_in_button.bind(on_press=lambda j: set_anim_type('fade_in'))
        reveal_button = Button(text='reveal_\nbelow_\nanim')
        reveal_button.bind(on_press=
                           lambda j: set_anim_type('reveal_below_anim'))
        slide_button = Button(text='reveal_\nbelow_\nsimple')
        slide_button.bind(on_press=
                          lambda j: set_anim_type('reveal_below_simple'))
        modes_layout.add_widget(slide_an)
        modes_layout.add_widget(slide_sim)
        modes_layout.add_widget(fade_in_button)
        modes_layout.add_widget(reveal_button)
        modes_layout.add_widget(slide_button)
        main_panel.add_widget(modes_layout)

        button = Button(text='toggle NavigationDrawer state (animate)',
                        size_hint_y=0.2)
        button.bind(on_press=lambda j: navigationdrawer.toggle_state())
        button2 = Button(text='toggle NavigationDrawer state (jump)',
                         size_hint_y=0.2)
        button2.bind(on_press=lambda j: navigationdrawer.toggle_state(False))
        button3 = Button(text='toggle _main_above', size_hint_y=0.2)
        button3.bind(on_press=navigationdrawer.toggle_main_above)
        main_panel.add_widget(button)
        main_panel.add_widget(button2)
        main_panel.add_widget(button3)

        return navigationdrawer