Esempio n. 1
0
    def display(self):
        displist = []
        # auton switch
        autonButton = halfButton("Auton")
        autonButton.bind(on_release=lambda x: self.switcher.switch("auton"))
        displist.append(autonButton)
        # teleop switch
        teleopButton = halfButton("Teleop")
        teleopButton.bind(on_release=lambda x: self.switcher.switch("teleop"))
        displist.append(teleopButton)

        # login switch
        teamButton = halfButton("Change team (data will be lost if not saved)")
        teamButton.bind(on_release=lambda x: self.switcher.switch("login"))
        displist.append(teamButton)
        # layout for save and export buttons
        databaseLayout = StackLayout(size_hint=(.5, .5))
        displist.append(databaseLayout)
        # save button
        saveButton = fullButton("Save")
        saveButton.bind(on_release=self.switcher.robot.localSave)
        databaseLayout.add_widget(saveButton)
        # export button
        exportButton = fullButton("Export")
        databaseLayout.add_widget(exportButton)

        # actually displaying everything
        self.clear_widgets()
        for widg in displist:
            self.add_widget(widg)
Esempio n. 2
0
class Container(FloatLayout):
    def __init__(self, **kwargs):
        super(Container, self).__init__(**kwargs)
        self.players_dick = {}
        self.layout = StackLayout()
        anchor = AnchorLayout()
        self.new_player_btn = Button(text="Add New Players", size=(100, 100), size_hint=(None, None))
        anchor.add_widget(self.new_player_btn)
        self.new_player_btn.bind(on_press=self.new_players)
        self.add_widget(anchor)
        self.names_input(2)

    def names_input(self,num):

        for i in range(int(num)):
            txt_input1 = TextInput(text='Name', size=(100, 100), size_hint=(None, None))
            self.layout.add_widget(txt_input1)
            txt_input2 = TextInput(text='#', size=(100, 100), size_hint=(None, None))
            self.layout.add_widget(txt_input2)
            label_1 = Label(text='', size=(100, 100), size_hint=(None, None))
            self.layout.add_widget(label_1)
            txt_input3 = TextInput(text='name', size=(100, 100), size_hint=(None, None))
            self.layout.add_widget(txt_input3)
            txt_input4 = TextInput(text='#', size=(100, 100), size_hint=(None, None))
            self.layout.add_widget(txt_input4)
            self.players_dick.update({txt_input1:txt_input2})
            self.players_dick.update({txt_input3:txt_input4})
        self.add_widget(self.layout)

    def new_players(self,btn):
        return True
Esempio n. 3
0
class SelectPad(Popup):
    '''a popup that is called by NumberSelect.  creates a number pad of number
    choices.'''
    def __init__(self, parent_btn, **kwargs):
        '''parent_btn is the NumberSelect associated with this select pad'''
        super(SelectPad, self).__init__(**kwargs)
        self.parent_btn = parent_btn

        self.content = StackLayout(orientation='lr-tb', size_hint=(1, 1))
        rows, remainder = divmod(len(self.parent_btn.the_range), 3)
        rows += bool(remainder)
        y_hint_ = 0.01 * (100 // rows)
        # y_hint_ = 0.01* int(100 /(1 + len(self.parent_btn.the_range)//3))
        for number in self.parent_btn.the_range:
            self.content.add_widget(
                Button(text=str(number),
                       size_hint=(0.33, y_hint_),
                       on_press=self.record_number))
        self.title = self.parent_btn.ids['title'].text
        self.title_align = 'center'

    def record_number(self, btn):
        '''assigns button's number to parent'''
        self.parent_btn.ids['number'].text = btn.text
        self.dismiss()
Esempio n. 4
0
    class SinnerApp(DefaultApp):
        def build(self):
            super().build()

            self.root = StackLayout()

            self.root.spacing = 10
            self.root.padding = 10, 10, 10, 10
            Builder.load_file('attributes.kv')
            Builder.load_file('person.kv')
            Builder.load_file('skills.kv') 
            Builder.load_file('calculations.kv')

            attrs_layout = PersonLayout()
            attrs_layout.size_hint = 0.1, 0.1
            self.root.add_widget(attrs_layout)

            attrs_layout = AttributesLayout()
            attrs_layout.size_hint = 0.1, 0.1
            self.root.add_widget(attrs_layout)

            attrs_layout = SkillsWidget()
            attrs_layout.size_hint = 0.1, 0.1
            self.root.add_widget(attrs_layout)

            attrs_layout = CalculationWidget()
            attrs_layout.size_hint = 0.1, 0.1
            self.root.add_widget(attrs_layout)

            for i in range(100):
                self.char.mutation.gear.append(Gear(self.char, gears.gear[i], 5))

            attrs_layout = GearWidget()
            attrs_layout.size_hint = 0.1, 0.1
            self.root.add_widget(attrs_layout)
Esempio n. 5
0
 def __init__(self, **kwargs):
     super(NumberInput, self).__init__(**kwargs)
     pad = StackLayout(orientation='lr-tb')
     texts = itertools_cycle(['+', '-', '='])
     for digit in range(1, 10):
         pad.add_widget(
             Button(text=str(digit),
                    size_hint=(0.29, 0.25),
                    on_press=self.add_digit))
         if digit % 3 == 0:
             pad.add_widget(
                 Button(text=next(texts),
                        size_hint=(0.1, 0.25),
                        on_press=self.plus_minus))
     pad.add_widget(
         Button(text='<-BS-',
                size_hint=(0.29, 0.25),
                on_press=self.back_space))
     pad.add_widget(
         Button(text='0', size_hint=(0.29, 0.25), on_press=self.add_digit))
     pad.add_widget(
         Button(text='ENT', size_hint=(0.39, 0.25),
                on_press=self.enter_val))
     self.num_pad = Popup(title='',
                          content=pad,
                          size_hint=(0.8, 0.5),
                          pos_hint={
                              'x': 0.1,
                              'y': 0
                          })
     self.text = ''
     self.background_color = (0.4, 0.2, 1.0, 0.8)
     self.bind(on_release=self.open_pad)
     self.to_add = 0
     self.sign = 1
Esempio n. 6
0
    def buildCategory(self, category):
        container = StackLayout()

        for device in category.devices:
            state = 'down' if device.is_on else 'normal'
            GPIO.output(device.pin, device.is_on)

            def callback(widget):
                device = widget.device
                is_on = not device.is_on
                Device.objects(id=widget.device.id).update(is_on=is_on)
                device.is_on = is_on
                Logger.info("Application: Seting pin %d to %s" %
                            (device.pin, is_on))
                GPIO.output(device.pin, is_on)

            button = ToggleButton(text=device.label,
                                  width=80,
                                  size_hint=(None, 0.15),
                                  state=state,
                                  on_press=callback)

            button.device = device
            container.add_widget(button)
            Logger.info("Application: Adding device %s on" % device.label)

            #container.add_widget( LightWidget())

        return container
Esempio n. 7
0
    def draw_buses(self):
        """Adds the buses to the main screen."""
        # Clear the screen of any buses.
        self.ids.bx_buses.clear_widgets()

        # Get a list of just those buses who are included in the filter.
        buses = [b for b in self.buses if b["route"] in self.filters]

        # Work out the height needed to display all the buses
        # (we need this for the StackLayout)
        h = (len(buses) * 30)

        # Create a StackLayout and ScrollView
        sl = StackLayout(orientation="tb-lr", height=h, size_hint=(1, None))
        sv = ScrollView(size_hint=(1, 1))
        sv.add_widget(sl)
        self.ids.bx_buses.add_widget(sv)

        # Loop over the buses, create a FinlandArrivals object and add it to the
        # StackLayout
        for bus in buses:
            bs = FinlandArrivals(bus=bus)
            if "alert" in(bus):
                self.alert = bus["alert"]
            sl.add_widget(bs)
Esempio n. 8
0
 def build(self):
     s = StackLayout()
     p = MyFilechooser(title = 'test')
     b = Button(size_hint = (1,0.2))
     b.bind(on_press = p.open)
     s.add_widget(b)
     return s
Esempio n. 9
0
class CreateNew(Screen):
    def __init__(self, **kwargs):
        super(CreateNew, self).__init__(**kwargs)
        self.name = 'createnew'
        self.key = 0
        self.stack = StackLayout(cols = 1,
                                 spacing=0,)

        #ActionBar
        self.actionbar = ActionBar(pos_hint={'top':1},
                                   background_color = (0.50,0.50,0.50,1),
                                   height = Window.height*.06,
                                   width = Window.width)
        self.actionview = ActionView()
        self.actionbar.add_widget(self.actionview)
        self.actionprevious = ActionPrevious(with_previous=True,
                                        app_icon = 'mylogo.png',
                                        previous_image = 'arrow.png',
                                        title = '')
        self.actionview.add_widget(self.actionprevious)

        self._savebutton = SaveButton()
        self.savebutton = self._savebutton.button
        self.actionview.add_widget(self._savebutton)
        self.stack.add_widget(self.actionbar)
        self.scroll = Text()
        self.txt = self.scroll.children[0]
        # self.txt = TextInput(size_hint=(1, .92),
        #                  pos_hint={'center_x': .5,'center_y': .46},
        #                      font_size = '35sp')
        self.stack.add_widget(self.scroll)

        self.dropdown = drop()
        self.actionview.add_widget(self.dropdown._main, -1)
        self.add_widget(self.stack)
Esempio n. 10
0
        def __init__(self, **kwargs):
                super(MenuWidget, self).__init__(**kwargs)

                default_choice = "demo_tiles"
                self.choices = {
                        "demo_text": "Text drawing",
                        "demo_bounce": "Basic physics simulation",
                        "demo_starship": "'Endless' scrolling background and animation",
                        "demo_tiles": "Tile map scrolling",
                        "demo_pong": "Simple Pong game",
                        "demo_breakout": "Breakout implemented with physical mover",
                        "demo_collision": "Optimized collision checking demo/test",
                        "demo_collision_1": "Simple collision test case",
                        "demo_control_1": "Demonstrates a more complex control scheme",
                        }

                layout = StackLayout(orientation="tb-lr", padding=[10, 20, 10, 20])

                layout.add_widget(Image(source="assets/img/ui/logo.png", size_hint=(1, 0.4)))

                layout.add_widget(Label(text="Choose demo:", size_hint=(1, 0.1)))

                self.spinner = Spinner(text=default_choice, values=[x for x in self.choices.iterkeys()], size_hint=(1, 0.1))
                layout.add_widget(self.spinner)
                self.spinner.bind(text=self.show_selected_value)

                self.description_label = Label(text=self.choices[default_choice], valign="middle", halign="center", size_hint=(1, 0.3))
                self.description_label.bind(size=self.description_label.setter("text_size"))
                layout.add_widget(self.description_label)

                run_button = Button(text="Run", size_hint=(1, 0.1))
                run_button.bind(state=self.on_run)
                layout.add_widget(run_button)

                self.add_widget(layout)
Esempio n. 11
0
    def draw_buses(self):
        """Adds the buses to the main screen."""
        # Clear the screen of any buses.
        self.ids.bx_buses.clear_widgets()

        # Get a list of just those buses who are included in the filter.
        buses = [b for b in self.buses if b["route"] in self.filters]

        # Work out the height needed to display all the buses
        # (we need this for the StackLayout)
        h = (len(buses) * 30)

        # Create a StackLayout and ScrollView
        sl = StackLayout(orientation="tb-lr", height=h, size_hint=(1, None))
        sv = ScrollView(size_hint=(1, 1))
        sv.add_widget(sl)
        self.ids.bx_buses.add_widget(sv)

        # Loop over the buses, create a FinlandArrivals object and add it to the
        # StackLayout
        for bus in buses:
            bs = FinlandArrivals(bus=bus)
            if "alert" in (bus):
                self.alert = bus["alert"]
            sl.add_widget(bs)
Esempio n. 12
0
class LodScreen(Screen):
    def set(self):
        self.name = "LodgingScreen"
        self.T = Title()
        self.T.set()
        self.add_widget(self.T, index = 0)
        self.L = LodBg()
        self.L.set()
        self.add_widget(self.L,index = 1)
        self.bl = StackLayout(orientation = 'rl-tb',size_hint = (1,None),height = 30)
        self.bl.add_widget(Button(text = 'Back',size_hint= (.1,1),on_press = self.back))
        self.add_widget(self.bl)
        self.bk = False

    def update(self,a):
        for i in range(10):
            if self.L.rooms[i].rcin == True and self.L.rooms[i].cin == True:
                self.d = '{}/{}/{}'.format(now.day, now.month, now.year)
                self.t = '{}:{}:{}'.format(now.hour, now.minute, now.second)
                self.queryin = 'insert into lodgedetails values ("{}","{}","{}","{}","in")'.format(self.d, self.t,random.randint(10,10000),self.L.rooms[i].room)
                cursor.execute(self.queryin)
                self.L.rooms[i].cin = False
                hmdb.commit()
            elif self.L.rooms[i].rcout == True and self.L.rooms[i].cout == True:
                self.d = '{}/{}/{}'.format(now.day, now.month, now.year)
                self.t = '{}:{}:{}'.format(now.hour, now.minute, now.second)
                self.queryout = 'insert into lodgedetails values ("{}","{}","{}","{}","out")'.format(self.d, self.t,random.randint(10,10000),self.L.rooms[i].room)
                self.L.rooms[i].cout = False
                cursor.execute(self.queryout)
                hmdb.commit()


    def back(self,a):
        self.bk = True
    def build(self):
        # screen manager steup
        sm = ScreenManager()

        # main menu setup
        main_menu = 

        # define Spell screen
        spell_layout = BoxLayout()
        # add big_layout to ScreenManger
        sm.add_widget(spell_layout)
        left_box = BoxLayout(orientation='vertical', spacing=10, size_hint=(.3, 1))
        right_box = StackLayout(size_hint=(.7, 1))
        left_top_box = ListView(size_hint=(1, .8))
        left_bottom_box = BoxLayout(size_hint=(1, .2))

        rb = Label(text='right box')
        ltb = Label(text='left top box')
        btn_rest = Button(text='Rest')
        btn_main = Button(text='Main Menu')
        btn_quit = Button(text='Quit')

        spell_layout.add_widget(left_box)
        spell_layout.add_widget(right_box)

        left_box.add_widget(left_top_box)
        left_box.add_widget(left_bottom_box)

        right_box.add_widget(rb)
        left_top_box.add_widget(ltb)
        left_bottom_box.add_widget(btn_rest)
        left_bottom_box.add_widget(btn_main)
        left_bottom_box.add_widget(btn_quit)

        return sm
Esempio n. 14
0
    def _create_popup(self, instance):

        content = GridLayout(cols=1, spacing='10dp')
        scrollview = ScrollView(do_scroll_x=False, size_hint=(1, 0.85))
        scrollcontent = StackLayout(size_hint=(1, None), spacing='5dp')
        scrollcontent.bind(minimum_height=scrollcontent.setter('height'))
        self.popup = popup = Popup(content=content,
                                   title=self.title,
                                   size_hint=(0.5, 0.9),
                                   auto_dismiss=False)
        popup.open()

        content.add_widget(Widget(size_hint_y=None, height=dp(2)))
        uid = str(self.uid)
        for option in self.options:
            state = 'down' if option == self.value else 'normal'
            btn = ToggleButton(text=option,
                               state=state,
                               group=uid,
                               height=dp(50),
                               size_hint=(1, None))
            btn.bind(on_release=self._set_option)
            scrollcontent.add_widget(btn)

        scrollview.add_widget(scrollcontent)
        content.add_widget(scrollview)
        btn = Button(text='Cancel', height=dp(50), size_hint=(1, None))
        btn.bind(on_release=popup.dismiss)
        content.add_widget(btn)
Esempio n. 15
0
 def test(value):
     content = StackLayout()
     for k in self.configurable_properties.keys():
         content.add_widget(self.configurable_properties[k].
                            getConfigurationSubpanel())
     popup = Popup(title='Configure', content=content)
     popup.open()
class FileBrowser(BoxLayout):
    def __init__(self, name):
        super().__init__()
        self.orientation = "vertical"
        self.size_hint = (1, 1)

        self.scroll_body = ScrollView()
        self.add_widget(self.scroll_body)

        self.body = StackLayout(orientation="lr-tb", size_hint_y=None)
        self.scroll_body.add_widget(self.body)
        ##Settings##
        self.body.bind(minimum_height=self.body.setter('height'))

        self.draw()
        self.bind(pos=self.update_rectangles, size=self.update_rectangles)

        self.populate("placeholderforsource")

    def draw(self):
        self.canvas.before.clear()
        with self.canvas.before:
            Color(0.8, 1, 1, 1)
            self.rectangle = Rectangle(pos=self.pos, size=self.size)

    def update_rectangles(self, *args):
        self.rectangle.pos = self.pos
        self.rectangle.size = self.size

    def populate(self, source):  # a means of setting source
        for i in range(0, 10):
            self.body.add_widget(SpecialImage("placeholderfordirentry"))
Esempio n. 17
0
    def popup_names(self, button):
        popup_layout = StackLayout(orientation='tb-lr',
                                   spacing=[20, 20],
                                   padding=[20, 20])

        self.popup = Popup(title='EDIT NAMES',
                           content=popup_layout,
                           size_hint=(0.8, None),
                           height=300)
        self.popup.open()

        for num in range(1, 5):
            label_text = 'PLAYER ' + str(num)
            label = Label(text=label_text,
                          font_size=self.popup.font_size,
                          size_hint=(0.5, None),
                          height=30)
            popup_layout.add_widget(label)

        self.name_inputs = []
        for name in self.manager.all_names:
            name_input = TextInput(text=name,
                                   multiline=False,
                                   size_hint=(0.5, None),
                                   height=30)
            name_input.bind(on_text_validate=self.change_names)
            self.name_inputs.append(name_input)
            popup_layout.add_widget(name_input)
Esempio n. 18
0
    def __init__(self, **kwargs):
        super(MenuWidget, self).__init__(**kwargs)

        self.choices = {
            "demo_bounce": "Basic physics simulation",
            "demo_breakout": "Breakout demo",
            "demo_gauntlet": "Top down tile map game",
            "demo_starship": "'Endless' scrolling background and animation",
            "demo_text": "Text drawing",
            "demo_tiles": "Tile map scrolling",
            "demo_pinball": "Simple pinball demo",
            "demo_squares": "Random set of falling physical objects",
            "demo_car": "Top down car driving game",
            "demo_sprites": "Draw a large amount of sprites",
        }

        layout = StackLayout(orientation="tb-lr", padding=[10, 20, 10, 20])

        layout.add_widget(
            Image(
                source="assets/img/ui/logo.png",
                size_hint=(1, 0.4),
                allow_stretch=True,
            ))

        layout.add_widget(Label(text="Choose demo:", size_hint=(1, 0.1)))

        self.spinner = Spinner(text=DEFAULT_START_CHOICE,
                               values=[x for x in self.choices.iterkeys()],
                               size_hint=(1, 0.1))
        layout.add_widget(self.spinner)
        self.spinner.bind(text=self.show_selected_value)

        self.description_label = Label(text=self.choices[DEFAULT_START_CHOICE],
                                       valign="middle",
                                       halign="center",
                                       size_hint=(1, 0.2))
        self.description_label.bind(
            size=self.description_label.setter("text_size"))
        layout.add_widget(self.description_label)

        run_button = Button(text="Run", size_hint=(1, 0.1))
        run_button.bind(state=self.on_run)
        layout.add_widget(run_button)

        debug_layout = BoxLayout(orientation='horizontal', size_hint=(1, 0.1))
        debug_layout.add_widget(Label(text=" "))
        self.debug_checkbox = CheckBox()
        self.debug_checkbox.active = False
        debug_layout.add_widget(self.debug_checkbox)
        debug_layout.add_widget(
            Label(text="Show debug info", valign="middle", halign="center"))
        debug_layout.add_widget(Label(text=" "))
        debug_layout.add_widget(Label(text=" "))
        self.add_widget(debug_layout)

        self.add_widget(layout)

        if platform == 'win' or platform == 'linux' or platform == 'macosx':
            Window.bind(on_key_up=self._on_keyboard_up)
Esempio n. 19
0
class Container(FloatLayout):
    def __init__(self, **kwargs):
        super(Container, self).__init__(**kwargs)
        self.players_dick = {}
        anchor = AnchorLayout()
        self.new_player_btn = Button(text="New players", size=(100, 100), size_hint=(None, None))
        anchor.add_widget(self.restart)
        #self.new_player_btn.bind(on_press=self.new_players)
        self.add_widget(anchor)
        self.stack1 = StackLayout()
        self.names_input(2)

    def names_input(self,num):

        for i in range(int(num)):
            txt_lbl1 = Label(text='Name', size=(100, 100), size_hint=(None, None))
            self.stack1.add_widget(txt_lbl1)
            txt_lbl2 = Label(text='#', size=(100, 100), size_hint=(None, None))
            self.stack1.add_widget(txt_lbl2)
            label_1 = Label(text='', size=(100, 100), size_hint=(None, None))
            self.stack1.add_widget(label_1)
            txt_lbl3 = Label(text='name', size=(100, 100), size_hint=(None, None))
            self.stack1.add_widget(txt_lbl3)
            txt_lbl4 = Label(text='#', size=(100, 100), size_hint=(None, None))
            self.stack1.add_widget(txt_lbl4)
        self.add_widget(self.stack1)

    def restart(self,btn):
        open('main.py')
Esempio n. 20
0
    def __init__(self, config, **kwargs):
        self.config = config
        super(SettingsScreen, self).__init__(**kwargs)

        # Creates the main layout
        setting_layout = StackLayout()

        # Adds the high level widgets
        self.navBar = NavigationBar()
        slide = Slider(min=-100, max=100, value=25)
        returnBtn = NavigationButton(name="Return", text="Return to Home")
        returnBtn.bind(on_press=self.returnHome)

        # Creates the language dropdown menu and associated buttons
        self.languages = self.buildDropdown(possible_lang)

        self.mainbutton = Button(text=self.config["DISPLAY"]["language"],
                                 size_hint=(0.1, 1))
        self.mainbutton.bind(on_release=self.languages.open)
        self.languages.bind(
            on_select=lambda instance, x: setattr(self.mainbutton, 'text', x))

        # Adds all widgets to layout
        self.navBar.add_widget(returnBtn)
        self.navBar.add_widget(self.mainbutton)

        setting_layout.add_widget(slide)
        setting_layout.add_widget(self.navBar)
        self.add_widget(setting_layout)
Esempio n. 21
0
        def build(self):
                govde = StackLayout(orientation = "lr-tb")

                for i in range(1,11):
                        govde.add_widget(Button(text = "{}".format(i),size_hint = (None,None),size = (100,50)))

                return govde
Esempio n. 22
0
	def build(self):
		lay = StackLayout()
		btn = Button(text="hello", width=40, height=40)
		btn2 = Button(text="sup", width=40, height=40)
		lay.add_widget(btn)
		lay.add_widget(btn2)
		return lay
    def display(self):
        scrolllist = []
        displist = []

        searchBar = TextInput(size_hint=(.75, .1), multiline=False)
        searchBar.bind(
            on_text_validate=lambda x: self.processQuery(searchBar.text))
        displist.append(searchBar)

        back = ColorButton("Go", (.125, .1), darkblue)
        back.bind(on_release=lambda x: self.processQuery(searchBar.text))
        displist.append(back)

        back = ColorButton("Back", (.125, .1), darkblue)
        back.bind(on_release=lambda x: self.switcher.switch("login"))
        displist.append(back)

        teamList = ScrollView(size_hint=(1, None),
                              size=(Window.width,
                                    Window.height - searchBar.height))
        displist.append(teamList)
        teamListLayout = StackLayout(size_hint_y=None)
        teamListLayout.bind(minimum_height=teamListLayout.setter('height'))
        teamList.add_widget(teamListLayout)

        database = sqlite3.connect("scoutingdatabase.db")
        cursor = database.cursor()
        cursor.execute("SELECT * FROM pitscoutingdata " + self.query)
        for teamData in cursor.fetchall():
            teamNumber = teamData[0]
            button = ColorButton(str(teamNumber), (.875, None),
                                 fairBlue,
                                 height=40)
            button.bind(on_release=self.pitScouterMainSwitch)
            scrolllist.append(button)
            hasBeenScouted = "scouted" if teamData[1] else "NOT SCOUTED"
            labelBackground = green if teamData[1] else red
            label = ColorLabel(hasBeenScouted, (.125, None),
                               labelBackground,
                               height=40)
            scrolllist.append(label)
        database.close()

        addTeam = ColorButton("add team", (.5, None), darkblue, height=40)
        addTeam.bind(on_release=lambda x: self.addPitRobot(addText.text))
        scrolllist.append(addTeam)
        addText = TextInput(text=str(""),
                            multiline=False,
                            size_hint=(.5, None),
                            height=40)
        addText.bind(on_validate_text=lambda x: self.addPitRobot(addText.text))
        scrolllist.append(addText)

        for widget in scrolllist:
            teamListLayout.add_widget(widget)

        self.clear_widgets()
        for widget in displist:
            self.add_widget(widget)
Esempio n. 24
0
    def build(self):
        self.needConfirm = True
        self.client = Client()
        layout = BoxLayout(orientation='horizontal')
        layoutRight = BoxLayout(orientation='vertical')

        self.l_log = ScrollableLabel()
        # scollView = ScrollView(size_hint=(1, None), size=(Window.width, Window.height))
        layout.add_widget(self.l_log)
        layout.add_widget(layoutRight)
        # self.l_log.text_size = scollView.width,None

        left_window_up = StackLayout()
        left_window_down = GridLayout(cols=2)

        layoutRight.add_widget(left_window_up)
        layoutRight.add_widget(left_window_down)

        # dropdown_hao = DropDown()
        # self.dd_hao = genDropDownButton(2,["dahao","xiaohao"],dropdown_hao)
        # dropdown_start = DropDown()
        # self.dd_start = genDropDownButton(2,["0","1"],dropdown_start)
        # dropdown_chapter = DropDown()
        # self.dd_chapter = genDropDownButton(2,["11","5"],dropdown_chapter)
        # dropdown_aimEnergy = DropDown()
        # self.dd_aimEnergy = genDropDownButton(2,["20","30"],dropdown_aimEnergy)
        # dropdown_rush = DropDown()
        # self.dd_rush = genDropDownButton(2,["True","False"],dropdown_rush)

        self.dd_hao = genSpinner(['dahao', 'xiaohao'])
        self.dd_start = genSpinner(['0', '1'])
        self.dd_chapter = genSpinner(['11', '5'])
        self.dd_aimEnergy = genSpinner(['20', '30', '99'])
        self.dd_rush = genSpinner(['True', 'False'])

        left_window_up.add_widget(self.dd_hao)
        left_window_up.add_widget(self.dd_start)
        left_window_up.add_widget(self.dd_chapter)
        left_window_up.add_widget(self.dd_aimEnergy)
        left_window_up.add_widget(self.dd_rush)

        # b_readLog = Button(text = 'readLog',size_hint=(None, None),width = 60*times)
        # b_exe = Button(text = 'execute',size_hint=(None, None),width = 60*times)
        b_readLog = Button(text='readLog')
        b_readLog.bind(on_press=self.sendLog)
        b_exe = Button(text='execute')
        b_exe.bind(on_press=self.sendCmd)

        left_window_down.add_widget(b_exe)
        left_window_down.add_widget(b_readLog)

        # layout.add_widget(dd_start)
        # left_window.add_widget(dd_hao)
        # left_window.add_widget(dd_start)
        # left_window.add_widget(dd_chapter)
        # left_window.add_widget(dd_aimEnergy)

        # layout.add_widget(l_log)
        return layout
Esempio n. 25
0
 def test_stacklayout_nospace(self):
     # happens when padding is too big
     sl = StackLayout()
     wgts = [Widget(size_hint=(1., .25)) for i in range(1, 4)]
     for wgt in wgts:
         sl.add_widget(wgt)
     sl.padding = 10
     sl.do_layout()
Esempio n. 26
0
 def dict_to_label_list(self):
     list_widget = StackLayout()
     for i in self.characters_dict_list:
         list_widget.add_widget(
             Label(text=i['name'], size_hint=[1.0, 0.1, 10]))
         list_widget.add_widget(
             Image(source=i[img], size_hint=[1.0, 0.1, 10]))
     return list_widget
Esempio n. 27
0
 def test_stacklayout_nospace(self):
     # happens when padding is too big
     sl = StackLayout()
     wgts = [Widget(size_hint=(1., .25)) for i in range(1, 4)]
     for wgt in wgts:
         sl.add_widget(wgt)
     sl.padding = 10
     sl.do_layout()
Esempio n. 28
0
class DragTab(BoxLayout):
	def __init__(self,**kwargs):
		super(DragTab,self).__init__(**kwargs)
		#Base Layer is a BoxLayout
		#right-hand column is StackLayout, lefthand is a vertical box layout
		self.Scrollhome=StackLayout(orientation='tb-rl', size_hint=(.3,1))
		#self.Scrollhome.add_widget(Button(text='hi'))
		self.lefthand=BoxLayout(orientation='vertical', size_hint=(.7,1))
		#within lefthand, stats and a series of semesters
		self.Planner=GridLayout(size_hint=(1,.9),rows=2, cols=4, spacing=5)

		self.slot1=Semester(text=str(semesters[0]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot1)
		self.slot2=Semester(text=str(semesters[2]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot2)
		self.slot3=Semester(text=str(semesters[4]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot3)
		self.slot4=Semester(text=str(semesters[6]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot4)
		self.slot5=Semester(text=str(semesters[1]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot5)
		self.slot6=Semester(text=str(semesters[3]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot6)
		self.slot7=Semester(text=str(semesters[5]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot7)
		self.slot8=Semester(text=str(semesters[7]), color=(0, 0, 1., .2))
		self.Planner.add_widget(self.slot8)

		self.lefthand.add_widget(self.Planner)
		self.lefthand.add_widget(Label(size_hint=(1,.1),text= 'We can display statistics here', color=(1,1,1,.3)))		

		self.add_widget(self.lefthand)
		self.add_widget(self.Scrollhome)

		for course in catalog:
			self.add_Icon(course)
		

	def add_Icon(self, display):
		Icon=DragableButton(text=display,size=(100,100),
                              droppable_zone_objects=[],
                              bound_zone_objects=[],
                              drag_opacity=.5,
                              remove_on_drag=True)
		Icon.bound_zone_objects.append(self.Planner)
		Icon.bound_zone_objects.append(self.Scrollhome)
		
		Icon.droppable_zone_objects.append(self.slot1.coursehouse)
		Icon.droppable_zone_objects.append(self.slot2.coursehouse)
		Icon.droppable_zone_objects.append(self.slot3.coursehouse)
		Icon.droppable_zone_objects.append(self.slot4.coursehouse)
		Icon.droppable_zone_objects.append(self.slot5.coursehouse)
		Icon.droppable_zone_objects.append(self.slot6.coursehouse)
		Icon.droppable_zone_objects.append(self.slot7.coursehouse)
		Icon.droppable_zone_objects.append(self.slot8.coursehouse)
		
		Icon.droppable_zone_objects.append(self.Scrollhome)
		self.Scrollhome.add_widget(Icon)
Esempio n. 29
0
    def display(self):
        displist = []

        def appendLabel(text, sizeHint, color, widget=None, **kwargs):
            label = ColorLabel(text, sizeHint, color, **kwargs)
            if not widget: displist.append(label)
            else: widget.add_widget(label)

        def appendButton(text, sizeHint, color, bind, widget=None, **kwargs):
            button = ColorButton(text, sizeHint, color, **kwargs)
            button.bind(on_release=bind)
            if not widget: displist.append(button)
            else: widget.add_widget(button)

        # auton switch
        appendButton("Auton", halfHalf, fairBlue,
                     lambda x: self.switcher.switch("auton"))
        # teleop switch
        appendButton("Teleop", halfHalf, fairBlue,
                     lambda x: self.switcher.switch("teleop"))

        # change team button
        appendButton("Change team (data will be lost if not saved)", (.5, .5),
                     fairBlue, lambda x: self.switcher.switch("login"))

        # layout for save and export buttons
        databaseLayout = StackLayout(size_hint=(.5, .5))
        displist.append(databaseLayout)
        # save button
        appendButton("Save", (1, .5), fairBlue, self.switcher.robot.localSave,
                     databaseLayout)
        # ip input text
        if self.ipInputTextHint:
            text = ""
        else:
            text = getIp()
        ipInput = TextInput(text=text,
                            size_hint=(.25, .5),
                            multiline=False,
                            hint_text=self.ipInputTextHint)

        def exportBind(_):
            ipInput.hint_text = export(ipInput.text)
            ipInput.text = ""

        ipInput.bind(on_text_validate=exportBind)
        # export button
        appendButton("Export all", (.5, .5), fairBlue, exportBind,
                     databaseLayout)
        # mysql ip label
        appendLabel("mysql IP", (.25, .5), fairBlue, databaseLayout)
        databaseLayout.add_widget(ipInput)

        # actually displaying everything
        self.clear_widgets()
        for widg in displist:
            self.add_widget(widg)
Esempio n. 30
0
class QueueContainer(ScrollView):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.inner_queue = StackLayout(padding="10px", spacing="10px")
        self.add_widget(self.inner_queue)

        add_table_btn = Button(text='Queue Customers', size_hint_y=.1)
        add_table_btn.bind(on_press=lambda e: ClockInPopup().open())
        self.inner_queue.add_widget(add_table_btn)
Esempio n. 31
0
	def __infoshow(self, msgtitle, msg):
		sl = StackLayout(size=(550, 550), orientation='bt-rl')
		butt = Button(text='Back', size_hint=(.20,.10))
		sl.add_widget(butt)
		lb = Label(text=msg, text_size=(300,400))
		sl.add_widget(lb)
		popup = Popup(title=msgtitle, content=sl, size_hint=(None, None), size=(600, 600))
		butt.on_release = popup.dismiss
		popup.open()
Esempio n. 32
0
 def build(self):
     root = StackLayout()
     custom_widget1 = MyCustomWidget(id='my_custom_widget')
     custom_widget1.status = 'ok'
     custom_widget2 = MyCustomWidget(id='my_custom_widget')
     custom_widget2.status = 'nope'
     root.add_widget(custom_widget1)
     root.add_widget(custom_widget2)
     return root
Esempio n. 33
0
    def build(self):
        oscAPI.init()
        main_layout = StackLayout()
        for i in range(4):
            xy_pad = XyPad(size_hint=(0.5, 0.5))
            xy_pad.x_msg = '/fxparam/{0}/value'.format(i*2 + 1)
            xy_pad.y_msg = '/fxparam/{0}/value'.format(i*2 + 2)
            main_layout.add_widget(xy_pad)

        return main_layout
    def test_tb_lr_stacklayout(self):
        stacklayout = StackLayout(orientation='tb-lr',
                                  size=(200, 200),
                                  padding=20,
                                  spacing=10)

        widget = Widget(width=100, size_hint=(0.2, 0.4))
        stacklayout.add_widget(widget)
        stacklayout.do_layout()

        self.assertEqual(stacklayout.top - widget.top, 20)
Esempio n. 35
0
class GameScreen(Screen):
    def __init__(self, players, name="Game"):
        Screen.__init__(self, name=name)
        _layout = BoxLayout(orientation='vertical')
        self._question = Label(text='question', markup=True, font_size=36)
        _layout.add_widget(self._question)
        self._answer = Label(text='', font_size=42)
        _layout.add_widget(self._answer)
        self._vote_buttons = StackLayout(orientation='tb-lr', spacing=10)
        for player_id, player_name in players:
            btn = Button(text=f"{player_id}:{player_name}",
                         size_hint=(0.3, 0.2),
                         disabled=True)
            btn.bind(on_release=partial(self.on_vote, player_id=player_id))
            self._vote_buttons.add_widget(btn)
        _layout.add_widget(self._vote_buttons)
        self.add_widget(_layout)

    def on_pre_enter(self, *args):
        client.add_listener(self.new_turn_handler)
        client.add_listener(self.game_over_handler)

    def on_pre_leave(self, *args):
        client.remove_listener(self.new_turn_handler)
        client.remove_listener(self.game_over_handler)

    def on_leave(self, *args):
        self.manager.remove_widget(self)

    def on_vote(self, instance: Button, *, player_id):
        for button in self._vote_buttons.children:
            button.disabled = True
        client.send({'op': 'Vote', 'winner': player_id})

    def new_turn_handler(self, msg):
        if msg.get('op') == 'NewTurn':
            if msg['your-turn']:
                self._question.color = (1, 1, 1)
                for button in self._vote_buttons.children:
                    button.disabled = False
            else:
                self._question.color = (0.5, 0.5, 0.5)
            self._question.text = msg['question']
            self._answer.text = msg['answer'] or ''
            return True

    def game_over_handler(self, msg):
        if msg.get('op') == 'GameOver':
            ladderboard = msg['scores']
            next_screen = SummaryScreen(ladderboard)
            self.manager.add_widget(next_screen)
            self.manager.current = next_screen.name
            return True
Esempio n. 36
0
    def test_stacklayout_fixed_size(self):
        sl = StackLayout()
        wgts = [Widget(size=(50, 50), size_hint=(None, None))
                for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, 0])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
Esempio n. 37
0
    def test_stacklayout_padding(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.padding = 5.
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [5., sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [5., 5.])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 5.])
Esempio n. 38
0
    def test_stacklayout_spacing(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.spacing = 10
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2. + 5, sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, -10])
        self.assertEqual(wgts[3].pos, [sl.width / 2. + 5, -10])
Esempio n. 39
0
    def test_stacklayout_default(self):
        # Default orientation is lr-tb.
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, 0])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
Esempio n. 40
0
    def test_tb_lr_stacklayout(self):
        stacklayout = StackLayout(
            orientation='tb-lr',
            size=(200, 200),
            padding=20,
            spacing=10)

        widget = Widget(width=100, size_hint=(0.2, 0.4))
        stacklayout.add_widget(widget)
        stacklayout.do_layout()

        self.assertEqual(stacklayout.top - widget.top, 20)
Esempio n. 41
0
    def test_stacklayout_spacing(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.spacing = 10
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2. + 5, sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, -10])
        self.assertEqual(wgts[3].pos, [sl.width / 2. + 5, -10])
Esempio n. 42
0
    def test_stacklayout_default(self):
        # Default orientation is lr-tb.
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, 0])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
Esempio n. 43
0
class LogBox(ScrollView):
    _current_selection = 0


    def __init__(self, root):
        super(LogBox, self).__init__()
        self.root = root
        self.size_hint = (1, None)
        self.height = 150

        self.stack = StackLayout()
        self.stack.orientation = 'lr-tb'
        self.stack.size_hint = (1, None)
        self.stack.bind(minimum_height=self.stack.setter('height'))

        self.add_widget(self.stack)



    def add(self, note):
        self.stack.add_widget(LogEntry(note))

    def get_entry(self, at):
        if at == 0:
            return None
        if at > len(self.stack.children):
            return None
        return self.stack.children[len(self.stack.children)-at]
    def get_current_entry(self):
        return self.get_entry(self.current_selection)

    @property
    def current_selection(self):
        return self._current_selection
    @current_selection.setter
    def current_selection(self, value):
        for child in self.stack.children:
            child.color = [1,1,1,1]

        if value > len(self.stack.children):
            self._current_selection = 0
            return

        self._current_selection = value
        self.stack.children[len(self.stack.children)-value].color = [1,0,0,1]

        # We send a KEY ON signal for each note
        # only if we are on play mode.
        # Reset done status for each note.
        if self.root.app.playing:
            for note in self.get_current_entry().notes:
                note['done'] = False
                arduino.send(str.format("+{0}", note['note']))
Esempio n. 44
0
    def test_stacklayout_padding(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.padding = 5.
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [5., sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [5., 5.])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 5.])
Esempio n. 45
0
    def askInfo(self,requiredInfo):
        #the button size is wrong on my laptop but right on the tablet so
        close=Button(text='Add')
        cancel=Button(text='Cancel')

        buttonGrid=GridLayout(cols=2,size_hint_y=.5)
        buttonGrid.add_widget(close)
        buttonGrid.add_widget(cancel)
        content=StackLayout(spacing=5)
        valueList=[]#empty list that gets filled with the inputs' getValue functions
        for x,y in requiredInfo:
            content.add_widget(Label(text=x,size_hint=(None,None),size=(50,32)))

            if y.split()[0]=='text':    #v if it's length 1, then it isn't a list
                tmpWidget=_RetrievableText(len(y.split())-1,multiline=False,size_hint=(None,None),
                        write_tab=False,size=(100,32))
                #^ height 32 bc font size defaults to 10 and y padding defaults to 12
                valueList.append(tmpWidget.getValue)
                content.add_widget(tmpWidget)

            elif y.split()[0]=='int':
                tmpWidget=_RetrievableText(len(y.split())-1,multiline=False,input_type='number',
                        write_tab=False,size_hint=(None,None),size=(100,32))
                #^ height 32 bc font size defaults to 10 and y padding defaults to 12
                valueList.append(tmpWidget.getValue)
                content.add_widget(tmpWidget)
        #buttonGrid.height=.5*content.height #size_hint_y=.5 should do this but i guess not
        content.add_widget(buttonGrid)
        self.askPane=Popup(title='Get Info',content=content,size_hint=(.5,None),
            height=1.5*content.height,
                auto_dismiss=False,)#on_dismiss=lambda x: self._setInfo(valueList))
        close.bind(on_release=lambda x: self._setInfo(valueList,False))#askPane.dismiss)
        cancel.bind(on_release=lambda x: self._setInfo(valueList,True))
        self.askPane.open()
Esempio n. 46
0
 def __init__(self, **kwargs):
     super(MagicTab, self).__init__(**kwargs)
     self.text = 'Magic'
     tab_magic_ui = StackLayout(orientation='tb-lr',
                                minimum_width=3100,
                                padding=(5, 5, 0, 0),
                                spacing=1)
     spells = ["Fireball", "Healing Rain", "Taunt", "Holy Light", "Steady Shot",
               "Might", "Strike", "Dance"]
     for i in range(0, len(spells)):
         spell_string = spells[i]
         tab_magic_ui.add_widget(Button(text=spell_string,
                                        size_hint=(.2, .1)))  # Width of the buttons
     self.add_widget(tab_magic_ui)
Esempio n. 47
0
    def test_stacklayout_overflow(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.2 * i, .2 * i)) for i in range(1, 4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.padding = 5
        sl.spacing = 5
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [5, 77])
        self.assertEqual(wgts[1].pos, [27, 59])
        # floating point error, requires almost equal
        self.assertAlmostEqual(wgts[2].pos[0], 5)
        self.assertAlmostEqual(wgts[2].pos[1], 0)
Esempio n. 48
0
def winPopup(winCondition):
	
	winLayout = StackLayout()
	
	winLabel = Label(text = winCondition, size_hint = (1.0,0.8))
	menuBtn = Button(text = 'Main Menu', size_hint = (0.5,0.2))
	menuBtn.bind(on_release = mainMenu)
	quitBtn = Button(text = 'Quit to Desktop', size_hint = (0.5,0.2))
	quitBtn.bind(on_release = ExitFunc)
	
	winLayout.add_widget(winLabel)
	winLayout.add_widget(menuBtn)
	winLayout.add_widget(quitBtn)
	
	win_popup.content = winLayout
Esempio n. 49
0
        def __init__(self, **kwargs):
                super(MenuWidget, self).__init__(**kwargs)

                self.choices = {
                        "demo_bounce": "Basic physics simulation",
                        "demo_breakout": "Breakout demo",
                        "demo_gauntlet": "Top down tile map game",
                        "demo_starship": "'Endless' scrolling background and animation",
                        "demo_text": "Text drawing",
                        "demo_tiles": "Tile map scrolling",
                        "demo_pinball": "Simple pinball demo",
                        "demo_squares": "Random set of falling physical objects",
                        "demo_car": "Top down car driving game",
                        "demo_sprites": "Draw a large amount of sprites",
                        }

                layout = StackLayout(orientation="tb-lr", padding=[10, 20, 10, 20])

                layout.add_widget(Image(source="assets/img/ui/logo.png", size_hint=(1, 0.4), allow_stretch = True,))

                layout.add_widget(Label(text="Choose demo:", size_hint=(1, 0.1)))

                self.spinner = Spinner(text=DEFAULT_START_CHOICE, values=[x for x in self.choices.iterkeys()], size_hint=(1, 0.1))
                layout.add_widget(self.spinner)
                self.spinner.bind(text=self.show_selected_value)

                self.description_label = Label(text=self.choices[DEFAULT_START_CHOICE], valign="middle", halign="center", size_hint=(1, 0.2))
                self.description_label.bind(size=self.description_label.setter("text_size"))
                layout.add_widget(self.description_label)

                run_button = Button(text="Run", size_hint=(1, 0.1))
                run_button.bind(state=self.on_run)
                layout.add_widget(run_button)

                debug_layout = BoxLayout(orientation='horizontal', size_hint=(1, 0.1))
                debug_layout.add_widget(Label(text=" "))
                self.debug_checkbox = CheckBox()
                self.debug_checkbox.active = False
                debug_layout.add_widget(self.debug_checkbox)
                debug_layout.add_widget(Label(text="Show debug info", valign="middle", halign="center"))
                debug_layout.add_widget(Label(text=" "))
                debug_layout.add_widget(Label(text=" "))
                self.add_widget(debug_layout)

                self.add_widget(layout)

                if platform == 'win' or platform == 'linux' or platform == 'macosx':
                        Window.bind(on_key_up=self._on_keyboard_up)
Esempio n. 50
0
 def __init__(self, **kwargs):
     ModalView.__init__(self, size_hint=(.15, 1), pos_hint={'right': 1},
                        **kwargs)
     app = App.get_running_app()
     scroller = ScrollView(do_scroll_x=False)
     layout = StackLayout(padding=[dp(10)], size_hint_y=None)
     layout.height = layout.width * len(app.powerups.purchased)
     for powerup in app.powerups.purchased:
         if not isinstance(powerup, Powerup):
             continue
         if powerup.type == PowerupType.PLAY_CARD:
             if not app.loaded_deck.get_cards(app.powerups.cards()):
                 continue
         layout.add_widget(UsablePowerupIcon(powerup=powerup,
                                             size_hint=(1, None)))
     scroller.add_widget(layout)
     self.add_widget(scroller)
Esempio n. 51
0
    def createStack(self):
        """Works out how to display the league matches.

        Layout depends on the number of matches found.
        """
        matches = self.leagueobject.LeagueMatches
        x = len(matches)

        # Single column, no scrolling
        if x <= 10:
            self.spacer = True
            w = 1
            scroll = False
            self.h = 42 * x

        # Dual columns, no scrolling
        elif x <= 20:
            self.spacer = False
            w = 0.5
            scroll = False
            self.h = round(x/2.0) * 42

        # Dual columns, scrolling
        else:
            self.spacer = False
            w = 0.5
            scroll = True
            self.h = round(x/2.0) * 42

        # Create a stack layout
        stack = StackLayout(orientation="tb-lr",
                            size_hint_y=None,
                            height=self.h)

        stack.bind(minimum_height=stack.setter('height'))

        # Add the league matches to it.
        for l in matches:
            lg = LeagueGame(match=l, size_hint=(w, None))
            stack.add_widget(lg)

        # Create a scroll view
        scroll = ScrollView(size_hint=(1, 1))
        scroll.add_widget(stack)

        return scroll
Esempio n. 52
0
    def side_buttons(self):
        rooty = main.Root()

        def open_press(instance):
            rooty.set_sender("arena")
            rooty.show_load()

        # Layout to stack buttons
        side_btn_layout = StackLayout(size_hint_x=None, width=50)

        # Button to open map file
        btn_open = Button(text='Open', size_hint=(1, .1))
        btn_open.bind(on_press=open_press)

        side_btn_layout.add_widget(btn_open)

        return side_btn_layout
Esempio n. 53
0
def popUP():
	popLayout = StackLayout()
	
	popup.content = popLayout
		
	popText = Label(text='What type of game would you like to play?', size_hint=(1.0,0.9))
	
	popBtn1 = Button(text='Single Player [i]COMING SOON[/i]', group='choice', size_hint=( 0.5, 0.1 ), markup = True)
	popBtn1.bind(on_press=clickSoundPlay)
	popBtn1.bind(on_release = singlePlayer)
	popBtn1.disabled = True
	popBtn2 = Button(text='Two Player', group='choice', size_hint=( 0.5, 0.1 ))
	popBtn2.bind(on_press=clickSoundPlay)
	popBtn2.bind(on_release = twoPlayer)
	
	popLayout.add_widget( popText )
	popLayout.add_widget( popBtn1 )
	popLayout.add_widget( popBtn2 )
Esempio n. 54
0
    def __init__(self, app):
        """Constructor"""
        # Call the base.
        super(HomePage, self).__init__(app)

        # Load the backend
        self.backend = SpecialBackend(FlatfileBackend())

        # Create a body manually, overriding the default.
        self.body = AnchorLayout(anchor_x='center', anchor_y='center')
        stack_layout = StackLayout(size_hint=(0.95, 0.6))
        self.body.add_widget(stack_layout)

        text_layout =  BoxLayout(anchor_x='left', anchor_y='center', size_hint=(0.8, None))
        text_layout.height = '35px'
        stack_layout.add_widget(text_layout)

        def on_enter(sender):
            self._on_search(sender, self.query.text)
        self.query = TextInput(text='', multiline=False, hint_text='Type here...')
        self.query.bind(on_text_validate=on_enter)
        text_layout.add_widget(self.query)


        button_layout =  BoxLayout(anchor_x='right', anchor_y='center', size_hint=(0.2, None))
        button_layout.height = '35px'
        stack_layout.add_widget(button_layout)

        def on_search_press(sender):
            self._on_search(self.query, self.query.text)
        search = Button(text='Search!')
        search.width = '50px'
        search.bind(on_press=on_search_press)
        button_layout.add_widget(search)

        self.search_results = RichPage.get_page(app, [self], self.backend, 'search')

        def on_category_press(sender):
            RichPage.get_page(app, [self], self.backend, 'categories').show(self)
            self.hide()
        category = Button(text='Categories', size_hint=(None, None), height='35px')
        category.width = '100px'
        category.bind(on_press=on_category_press)        
        self.body.add_widget(category)
Esempio n. 55
0
 def add_results_screen(self):
     game_results = []
     for game_board_screen in self.finished_screens:
         game_result = GameResult(
                 game_board_screen,
                 orientation='horizontal',
                 size_hint=(1, None),
                 height=50
         )
         game_results.append(game_result)
     content = StackLayout(orientation='lr-tb', size_hint=(1, 1))
     label = Label(text='RESULTS', size_hint=(1, None), height=100)
     content.add_widget(label)
     for game_result in game_results:
         content.add_widget(game_result)
     scroller = ScrollView(size_hint=(1, 1))
     scroller.add_widget(content)
     results_screen = ResultsScreen(scroller, name='Results')
     self.screens.add_widget(results_screen)
class SelectPad(Popup):
    '''a popup that is called by NumberSelect.  creates a number pad of number
    choices.'''
    def __init__(self, parent_btn, **kwargs):
        super(SelectPad, self).__init__(**kwargs)
        self.parent_btn = parent_btn

        self.content = StackLayout(orientation='lr-tb', size_hint=(1, 1))
        y_hint_ = 0.01* int(100 /(1 + len(self.parent_btn.the_range)//3))
        for number in self.parent_btn.the_range:
            self.content.add_widget(Button(text=str(number),
                                           size_hint=(0.33, y_hint_),
                                           on_press=self.record_number))
        self.title = self.parent_btn.title
        self.title_align = 'center'
    def record_number(self, btn):
        '''assigns button's number to parent'''
        self.parent_btn.number_value = int(btn.text)
        self.dismiss()
Esempio n. 57
0
class ChessGrid(FloatLayout):

  def __init__(self, **kwargs):
    super(ChessGrid, self).__init__(**kwargs)
    self.boardview = BoardView(size_hint=[.9,.9], pos_hint={'x':.1, 'y':.1})
    self.add_widget(self.boardview)
    self.lay_files = BoxLayout(pos_hint={'x':.1, 'y':0}, size_hint=[.9,.1], orientation='horizontal')
    for i in range(8):
      self.lay_files.add_widget(Label(text=chr(i+97), size_hint=[1./8, 1]))
    self.add_widget(self.lay_files)
    self.lay_ranks = StackLayout(pos_hint={'x':0, 'y':.1}, size_hint=[.1,.9], orientation='tb-lr')
    for i in range(8):
      self.lay_ranks.add_widget(Label(text=str(8-i), size_hint=[1, 1./8]))
    self.add_widget(self.lay_ranks)
    self.flip_button = Button(size_hint=[.1,.1], pos_hint={'x':0, 'y':0})
    self.flip_button.bind(on_press=self.boardview.flip)
    self.add_widget(self.flip_button)
    
    
Esempio n. 58
0
    def build(self):

        main_layout = BoxLayout(orientation='vertical', padding=20)  # create a main layout object called "main_layout"
        header_layout = StackLayout()  # create a StackLayout called header_layout

        # add a size_hint attribute to the header_layout, this will tell the parent layout which
        # proportions it should use when sizing the header_layout with respect to it's neighbors
        header_layout.size_hint = (1, .2)

        title = Label(text='KIVY MPC')   # create a Label called title with the text "KIVY MPC"
        header_layout.add_widget(title)  # add title to header_layout
        main_layout.add_widget(header_layout)  # add the header_layout to the main_layout

        grid_layout = GridLayout(cols=4)  # create a grid layout to contain the drum pads

        generate_buttons(grid_layout)  # pass the grid_layout to the generate_buttons function in order to create the 16 buttons

        main_layout.add_widget(grid_layout)  # add the grid layout

        return main_layout  # return the main_layout to the kivy environment
Esempio n. 59
0
  def resize_carousel(self, size):
    """The monitor screen is broken up into smaller screens that are loaded
       individually; when the screen is resized, they update the number on
       each screen.

       Args:
         size: [width, height] of the Carousel widget
    """
    width = size[0]
    height = size[1]
    channels_per_page = int(width / _CELL_WIDTH) * int(height / _CELL_HEIGHT)
    pages = [self.channels[x:x+channels_per_page] for x in 
             xrange(0, len(self.channels), channels_per_page)]
    for slide in self.ids.monitor_car.slides:
      slide.clear_widgets()
    self.ids.monitor_car.clear_widgets()
    for page in pages:
      slide = StackLayout(size_hint_x=1, size_hint_y=1)
      for cell in page:
        slide.add_widget(cell)
      self.ids.monitor_car.add_widget(slide)
Esempio n. 60
0
class DragTab(BoxLayout):
	def __init__(self,**kwargs):
		super(DragTab,self).__init__(**kwargs)
		#Base Layer
		self.base=BoxLayout()
		#right-hand column is X, lefthand is a vertical box layout
		self.Scrollhome=StackLayout(orientation='tb-lr', size_hint=(.3,1))
		self.Scrollhome.add_widget(Button(text='hi'))
		self.lefthand=BoxLayout(orientation='vertical', size_hint=(.7,1))
		#within lefthand, stats and a series of semesters
		self.Planner=GridLayout(size_hint=(1,.9),rows=2, cols=4)

		self.Planner.add_widget(Semester(size_hint=(1,1)))

		self.Planner.add_widget(Button(text='A Semester'))
		self.Planner.add_widget(Button(text='A Semester'))
		self.Planner.add_widget(Button(text='A Semester'))
		self.Planner.add_widget(Button(text='A Semester'))

		self.lefthand.add_widget(self.Planner)
		self.lefthand.add_widget(Button(size_hint=(1,.1),text= 'We can display statistics here'))
		

		self.base.add_widget(self.lefthand)
		self.base.add_widget(self.Scrollhome)
		


		self.add_widget(self.base)

	def add_Icon(self, display):
		Icon=DragableButton(text=display,size=(100,100),
                              droppable_zone_objects=[],
                              bound_zone_objects=[],
                              drag_opacity=.5,
                              remove_on_drag=True)
		Icon.droppable_zone_objects.append(self.lefthand)
		Icon.bound_zone_objects.append(self.lefthand)
		Icon.bound_zone_objects.append(self.Scrollhome)
		self.Scrollhome.add_widget(Icon)