Esempio n. 1
0
 def build_main_page(self):
     bx = BoxLayout(orientation='vertical', padding=(20, 40), spacing=10)
     bx_switch_screens = BoxLayout(orientation='horizontal',
                                   size_hint=(1, 0.075),
                                   spacing=10)
     bx_main = BoxLayout(orientation='vertical',
                         padding=(0, 0, 0, 0),
                         spacing=30)
     bt_home = Button(text='Home', font_size=self._fs)
     bt_home.bind(on_release=self.go_to_home_page)
     bt_settings = Button(text='Back to settings', font_size=self._fs)
     bt_settings.bind(on_release=self.go_to_settings_page)
     self.label_counter = Label(font_size=self._fs // 2,
                                halign="center",
                                size_hint=(1, 0.1),
                                markup=True)
     self.label_main = Label(font_size=self._fs,
                             halign="center",
                             size_hint=(1, 0.8))
     self.sl_answer = StackLayout(spacing=10)
     self.sl_build = StackLayout(spacing=10)
     self.bt_check = Button(text='Check', font_size=self._fs)
     self.bt_check.bind(on_release=self.next_command)
     return bx, zip(
         (bx_switch_screens, bx_main, bx),
         ((bt_home, bt_settings),
          (self.label_counter, self.label_main, self.sl_answer,
           self.sl_build, self.bt_check), (bx_switch_screens, bx_main)))
Esempio n. 2
0
 def __init__(self, **kwargs):
     super(AddScreen, self).__init__(**kwargs)
     self.name = "add"
     self.root = GridLayout(rows=2)
     self.inputStack = StackLayout(orientation='lr-tb', size_hint=(1, .8))
     self.inputStack.add_widget(
         Label(text="Name", size_hint=(.6, .1), color=[0, 0, 0, 1]))
     self.inputStack.add_widget(
         Label(text="Expiry Date", size_hint=(.4, .1), color=[0, 0, 0, 1]))
     for key, x_pos in zip(["name", "expiry"], [.6, .4]):
         textInput = TextInput(id=key + "input",
                               multiline=False,
                               size_hint=(x_pos, .1))
         textInput.bind(text=self.check_input)
         self.inputStack.add_widget(textInput)
     for key, x_pos in zip(["name", "expiry"], [.6, .4]):
         validateLabel = ValidateLabel(id=key + "label",
                                       size_hint=(x_pos, .1),
                                       shorten=True,
                                       color=[0, 0, 0, 1])
         self.validateLabelList.append(validateLabel)
         self.inputStack.add_widget(validateLabel)
     self.buttonStack = StackLayout(orientation='bt-lr', size_hint=(1, .2))
     self.root.add_widget(self.inputStack)
     self.buttonStack.add_widget(
         FoodButton(text="Back", size_hint=(1, .5), color=[0, 0, 0, 1]))
     self.root.add_widget(self.buttonStack)
     self.add_widget(
         Image(source=background_img,
               size_hint=(1, 1),
               keep_ratio=False,
               allow_stretch=True))
     self.add_widget(self.root)
 def __init__(self, **kwargs):
     super(ResizableWidgetDemo, self).__init__(**kwargs)
     self.stack0 = StackLayout(size_hint=(1, 1))
     self.sidebar = ResizableSideBar(size_hint=(None, 1),
                                     width=cm(4.5),
                                     orientation='vertical')
     self.stack1 = StackLayout(size_hint=(None, 1),
                               width=self.width - cm(4.5))
     self.stack2 = ResizableStackLayout(
         # [0.8, 0.33, 0.33, 1], size_hint=(1, None),
         # height=cm(5), resizable_down=True)
         from_rgb(51, 107, 135),
         size_hint=(1, None),
         height=cm(5),
         resizable_down=True)
     self.stack3 = ResizableStackLayout(from_rgb(42, 49, 50),
                                        size_hint=(1, None))
     rbutton = ResizableButton(
         text='down, left resizable button \n in resizable stacklayout',
         resizable_right=True,
         resizable_down=True,
         size_hint=(None, None),
         size=(cm(6), cm(4)),
         on_release=lambda x: print('ON_RELASE()'))
     sidelabel = ResizableLabel(
         text='Reizable button \nin resizable sidebar',
         resizable_down=True,
         size_hint=(1, None),
         height=cm(1),
     )
     r4sides = ResizableButton(
         text='4 sides resizable,\n floating button\n with size limit',
         resizable_right=True,
         resizable_left=True,
         resizable_up=True,
         resizable_down=True,
         size_hint=(None, None),
         min_resizable_width=cm(3),
         min_resizable_height=cm(3),
         max_resizable_width=cm(10),
         max_resizable_height=cm(10),
         resizable_border_offset=14,
         size=(cm(6), cm(6)),
         on_release=lambda x: print('ON_RELASE()'))
     self.add_widget(self.stack0)
     self.stack0.add_widget(self.sidebar)
     self.stack0.add_widget(self.stack1)
     self.sidebar.add_widget(sidelabel)
     self.stack1.add_widget(self.stack2)
     self.stack1.add_widget(self.stack3)
     self.stack2.add_widget(rbutton)
     self.add_widget(r4sides)
     self.sidebar.after_init()
     self.sidebar.bind(size=lambda obj, val: setattr(
         self.stack1, 'width', self.width - val[0]))
     self.stack2.bind(size=lambda obj, val: setattr(self.stack3, 'height',
                                                    self.height - val[1]))
 def fetchData(self, tab):
     tab.clear_widgets()
     cur.execute("SELECT id,name,due,amount FROM RECORDS")
     rows = cur.fetchall()
     rows.insert(0, ["Inv No", "Name", "Due Date", "Amount"])
     temp = ScrollView()
     root1 = StackLayout(size_hint_y=None, spacing=0, orientation="lr-tb")
     root1.bind(minimum_height=root1.setter('height'))
     i = 0
     for row in rows:
         for col in row:
             if i == 0:
                 root1.add_widget(
                     MDLabel(text=str(col),
                             height=30,
                             size_hint_x=1 / 4,
                             size_hint_y=None,
                             halign="center",
                             font_style="Body1"))
             else:
                 root1.add_widget(
                     MDLabel(text=str(col),
                             height=30,
                             size_hint_x=1 / 4,
                             size_hint_y=None,
                             halign="center",
                             font_style="Body2"))
         if i == 0:
             root1.add_widget(MDSeparator())
         i = i + 1
     temp.add_widget(root1)
     tab.add_widget(temp)
Esempio n. 5
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)
  def __init__(self, i32ctt, direccion_mac, endpoints, **kwargs):
    super(VentanaPrincipal, self).__init__(orientation = 'vertical', **kwargs)

    #Se crea el layout con los botones superiores y se agrega a la ventana principal
    self.layout_botones = StackLayout(orientation = 'rl-tb', size_hint = (1.0, 0.1))
    self.add_widget(self.layout_botones)

    #Se crean los botones
    self.boton_endpoint_manual = Button(text = 'Manual', size_hint = (None, 1.0))
    self.boton_endpoint_automatico = Button(text = 'Automatico', size_hint = (None, 1.0))
    self.boton_endpoint_sensores = Button(text = 'Sensores', size_hint = (None, 1.0))

    #Se agregan los botones al layout correspondiente
    #TODO: Habilitar una vez este implementado
    #self.layout_botones.add_widget(self.boton_endpoint_sensores)
    self.layout_botones.add_widget(self.boton_endpoint_automatico)
    self.layout_botones.add_widget(self.boton_endpoint_manual)

    #Se asocian los eventos de click de los botones con la funcion correspondiente
    self.boton_endpoint_manual.bind(on_press = self.__boton_presionado)
    self.boton_endpoint_automatico.bind(on_press = self.__boton_presionado)
    self.boton_endpoint_sensores.bind(on_press = self.__boton_presionado)

    #Se crean los layouts con las interfases de los endpoints
    self.layout_endpoint_manual = LayoutEndpointManual(i32ctt, direccion_mac, endpoints[0])
    self.layout_endpoint_automatico = LayoutEndpointAutomatico(i32ctt, direccion_mac, endpoints[1])
    self.layout_endpoint_sensores = LayoutEndpointSensores(i32ctt, direccion_mac, endpoints[2])

    #Se asocia la propiedad de layout actual a la funcion que actualiza sus cambios
    self.bind(layout_actual = self.__actualizar_layout)

    #Se selecciona el layout de control manual por defecto
    self.layout_actual = self.layout_endpoint_manual
Esempio n. 7
0
        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)
    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. 9
0
    def ShowList(self):
        """ Shows the discover results """
        # create the popup
        oContent         = GridLayout(cols=1, spacing='5dp')
        oScrollview      = ScrollView( do_scroll_x=False)
        self.oScrollContent   = StackLayout(size_hint=(None, None))
        self.oPopup   = oPopup = Popup(content=oContent, title=ReplaceVars('$lvar(5028)'), size_hint=(0.9, 0.9),  auto_dismiss=False)

        #we need to open the popup first to get the metrics
        oPopup.open()
        #Add some space on top
        oContent.add_widget(Widget(size_hint_y=None, height=dp(2)))
        aDiscoverScripts=Globals.oScripts.GetScriptListForScriptType("DEVICE_DISCOVER")
        aScrollContent=[]
        for uDiscoverScriptName in aDiscoverScripts:
            oScrollContentSingle   = GridLayout(size_hint=(None, None),size=(oPopup.width, dp(10)))
            aScrollContent.append(oScrollContentSingle)
            oScrollContentSingle.bind(minimum_height=oScrollContentSingle.setter('height'))
            Globals.oScripts.RunScript(uDiscoverScriptName,**{'createlist':1,'oGrid':oScrollContentSingle})
            self.oScrollContent.add_widget(cLabel(text=Globals.oScripts.dScripts[uDiscoverScriptName].uSubType, background_color=[0.2, 0.2, 0.2, 1.0], color=[0.2, 0.9, 0.9, 1.0], size=(oPopup.width, dp(30)),size_hint=(None, None), halign='center'))
            self.oScrollContent.add_widget(oScrollContentSingle)
            self.oScrollContent.add_widget(SettingSpacer())

        # finally, add a cancel button to return on the previous panel
        oScrollview.add_widget(self.oScrollContent)
        oContent.add_widget(oScrollview)
        oContent.add_widget(SettingSpacer())

        oBtn = Button(text=ReplaceVars('$lvar(5000)'), size=(oPopup.width, dp(50)),size_hint=(1, None))
        oBtn.bind(on_release=self.On_Cancel)
        oContent.add_widget(oBtn)

        #resize the Scrollcontent to fit to all Childs. Needs to be done, after the popup has been shown
        Clock.schedule_once(self.SetScrollSize, 0)
Esempio n. 10
0
    def __init__(self, **kwargs):
        super(NoteScreen, self).__init__(**kwargs)
        self.name = 'notescreen'
        self.box = 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._update_button = UpdateButton()
        self.update_button = self._update_button.button
        self._delete_button = DeleteButton()
        self.delete_button = self._delete_button.button
        self.actionview.add_widget(self._update_button)
        self.actionview.add_widget(self._delete_button)
        self.actionview.add_widget(self.actionprevious)
        self.scroll = Text2()
        self.txt = self.scroll.children[0]

        self.box.add_widget(self.actionbar)
        self.box.add_widget(self.scroll)

        self.add_widget(self.box)
        self.dropdown = drop()
        self.actionview.add_widget(self.dropdown._main, -2)
Esempio n. 11
0
    def __init__(self, title, message, true_handler=None, false_handler=None):
        self.outcome = None
        self.content = StackLayout(orientation='lr-tb', spacing=dp(5))
        self.content.add_widget(
            Label(text=message,
                  size_hint=(None, None),
                  size=(dp(272), dp(84)),
                  halign='center'))
        yes_button = Button(text='yes',
                            size_hint=(None, None),
                            size=(dp(134), dp(20)))
        no_button = Button(text='no',
                           size_hint=(None, None),
                           size=(dp(134), dp(20)))
        self.content.add_widget(yes_button)
        self.content.add_widget(no_button)
        Popup.__init__(self,
                       title=title,
                       content=self.content,
                       size_hint=(None, None),
                       size=(dp(300), dp(170)),
                       auto_dismiss=False)
        self.minimum_width = dp(272)
        self.true_handler_func = true_handler if true_handler != None else self.dismiss_pass
        self.false_handler_func = false_handler if false_handler != None else self.dismiss_pass

        yes_button.bind(on_release=self.dismiss_true)
        no_button.bind(on_release=self.dismiss_false)
Esempio n. 12
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. 13
0
    def bangla_game(self):
        root = StackLayout(orientation='rl-bt')
        '''
        self.ques_lbl = Label(text=self.bl.gen_question, 
                font_name='fonts/Hind_Siliguri/HindSiliguri-Regular.ttf', 
                font_size='50sp',
                )   
        
        self.btn1 = Button(text=self.bl.mult_choice[0], size_hint=(1, .1)) 
        self.btn2 = Button(text=self.bl.mult_choice[1], size_hint=(1, .1)) 
        self.btn3 = Button(text=self.bl.mult_choice[2], size_hint=(1, .1))
        self.btn4 = Button(text=self.bl.mult_choice[3], size_hint=(1, .1))  
        
        self.btn1.bind(on_press=self.callback)
        self.btn2.bind(on_press=self.callback) 
        self.btn3.bind(on_press=self.callback) 
        self.btn4.bind(on_press=self.callback)
        
        self.redx1 = Image(source="images/greyx.png", size_hint=(None, 0.10))  
        self.redx2 = Image(source="images/greyx.png", size_hint=(None, 0.10))
        self.redx3 = Image(source="images/greyx.png", size_hint=(None, 0.10))

        root.add_widget(self.btn1)
        root.add_widget(self.btn2) 
        root.add_widget(self.btn3)
        root.add_widget(self.btn4)
          
        root.add_widget(self.ques_lbl)
 
        self.btn_list = [self.btn1, self.btn2, self.btn3, self.btn4] 
        '''
        return root
Esempio n. 14
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     Config.set('graphics', 'resizable', False)
     Config.set('graphics', 'width', str(WINDOW_WIDTH))
     Config.set('graphics', 'height', str(WINDOW_HEIGHT))
     self.layout = StackLayout(size=(WINDOW_WIDTH, WINDOW_HEIGHT), spacing=10, orientation='tb-lr')
     
     self.weatherLabel = Label(text='abc', color=textColor, width=WINDOW_WIDTH, size_hint=(1, 0.33))
     self.calendarLabel = Label(text='def', color=textColor, width=WINDOW_WIDTH, size_hint=(1, 0.33))
     self.timeLabel = Label(text='ghi', color=textColor, width=WINDOW_WIDTH, size_hint=(1, 0.33))
     
     self.layout.add_widget(self.timeLabel)
     self.layout.add_widget(self.weatherLabel)
     self.layout.add_widget(self.calendarLabel)
     
     self.update_CALENDAR_weather()
     self.update_time()
     
     #for i in range(25):
     #btn = Button(text=str(i), width=40 + i * 5, size_hint=(None, 0.15))
         #self.layout.add_widget(btn)
     
     # Schedule task to refresh the widgets
     Clock.schedule_interval(self.update_time, UPDATE_INTERVAL_TIME)
     Clock.schedule_interval(self.update_CALENDAR_weather, UPDATE_INTERVAL_WEATHER_CALENDAR)
Esempio n. 15
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. 16
0
 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. 17
0
 def on_enter(self):
     popup = Popup(title='Dish Options', size_hint=(1,1))
     layout1 = StackLayout(orientation='lr-bt') #This time the options are layed out in a stack layout, so that I can have multiple options in a small space
     closebutton = Button(text='I want to make a different dish', size_hint=(0.9,0.05)) #This is a button that will make a different dish for the user
     closebutton.bind(on_press= popup.dismiss)                                           #The size_hint is the x and y co-ordinate score of how much percentage of the screen the button will have (with 1 being all the screen)
     closebutton.bind(on_release = self.change_page)
     scrlv = ScrollView(size_hint=(0.9,0.95)) #This adds a scrollable bar to the list of dishes, if there are lots of them
     slid = Slider(min=0, max=1, value=25, orientation='vertical', step=0.01, size_hint=(0.1, 0.95)) #The slid is the physical slider used, which calles the scrlv
     #step is the percentage of the screen it takes up, min and max are always 1 and 0 as they show the ful percentage of the screen covered by the bar
     scrlv.bind(scroll_y=partial(self.slider_change, slid))
     #what this does is, whenever the slider is dragged, it scrolls the previously added scrollview by the same amount the slider is dragged
     slid.bind(value=partial(self.scroll_change, scrlv))
     layout2 = GridLayout(cols=4, size_hint_y=None) #This is another grdi layout used within the popup
     layout2.bind(minimum_height=layout2.setter('height')) #Bind the height of the layout to the minimum height so that the scroll bar functions
     for txt in choices:
         btn = Button(text=txt, size_hint_y=None, height=80, valign='middle', font_size=12) # Add a button for each dish
         btn.text_size = (btn.size) #set the buttons so that their size changes depending on the screen size
         btn.bind(on_press = self.find_dish) #When the button is pressed, call the find_dish subroutine
         btn.bind(on_release = popup.dismiss) #Close the popup if they click the button
         layout2.add_widget(btn) # Add the buttons to the layout
     scrlv.add_widget(layout2)
     layout1.add_widget(closebutton) #Add the close button to the layout
     layout1.add_widget(scrlv) # Add the scroll bar to the layout
     layout1.add_widget(slid)  #Add the slider to the layout for the scroll bar
     popup.content = layout1
     popup.open()
     if len(choices) == 0:
         popup.dismiss()
         sm.current = "main" #This changes the screen back to the original "main" screen if there are no dishes, which allows the users to choose another dish
Esempio n. 18
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. 19
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. 20
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)
    def build(self):
        n = int(input("How big do you want the board to be ?"))
        self.n = n
        OPP_marker = str(input("Do you want to be X or O ?"))
        while OPP_marker != 'X' and OPP_marker != 'O':
            print(OPP_marker)
            OPP_marker = str(
                input(
                    "Do you want to be X or O ? \nPlease select a valid input !!..."
                ))

        self.OPP_marker = OPP_marker
        self.AI_marker = 'X' if OPP_marker == 'O' else 'O'
        self.title = 'Tic Tac Toe'
        self.board = Board(self.n, self.OPP_marker)
        self.game_over = False
        self.boardBtns = []

        diam = 150 * self.n
        Config.set('graphics', 'width', str(diam))
        Config.set('graphics', 'height', str(diam))
        Config.set('graphics', 'resizable', False)

        self.layout = StackLayout()
        for x in range(self.n**2):
            bt = Button(text='',
                        font_size=120,
                        width=150,
                        height=150,
                        size_hint=(None, None),
                        id=str(x))
            bt.bind(on_release=self.btn_pressed)
            self.boardBtns.append(bt)
            self.layout.add_widget(bt)
        return self.layout
    def build(self):

    
        layout = StackLayout()

        slider_bar.bind(value = TestApp.OnSliderValueChange)

        slider_bar_dB.bind(value = TestApp.OnSliderValueChange_dB)
        
        btn_record = Button(background_color=(155/255,28/255,13/255,1), text='Record Audio',size_hint=(0.5,0.3))
        btn_record.bind(on_press = TestApp.btn_record_event)
        
        btn_play = Button(background_color=(15/255,69/255,130/255,1), text='Play Audio',size_hint=(0.5,0.3))
        btn_play.bind(on_press = TestApp.btn_play_event)


        
        
        layout.add_widget(label_slider)
        layout.add_widget(Label(text='Autoplay',size_hint=(0.15,0.15)))
        layout.add_widget(slider_bar)
        layout.add_widget(checkbox)
        layout.add_widget(label_slider_dB)
        layout.add_widget(slider_bar_dB)
        layout.add_widget( btn_record )
        layout.add_widget(btn_play)
        layout.add_widget(label_status)


        return layout
Esempio n. 23
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. 24
0
    def __init__(self):
        self.user_name = None
        self.user_data = {}
        self.orientation = "tb-lr"
        super(ContactDetails, self).__init__()

        self.form = StackLayout(size_hint=(1, .7),
                                padding=[30, 30, 30, 30],
                                spacing=[5, 5])
        for text in [x[0] for x in phonebook.contactManager.retrieve_fields()]:
            self.form.add_widget(ContactFieldEditable(fieldname=text,
                                                      value=""))

        self.buttons = BoxLayout(size_hint=(1, None),
                                 size=(300, 30),
                                 orientation="horizontal")
        self.buttons.add_widget(
            Button(text="Update",
                   size_hint=(.5, None),
                   size=(300, 30),
                   on_press=lambda x: self.update()))
        self.buttons.add_widget(
            Button(text="Delete",
                   background_color=(.8, .4, .4, 1),
                   size_hint=(.5, None),
                   size=(300, 30),
                   on_press=lambda x: self.delete()))
        self.add_widget(self.buttons)
        self.add_widget(self.form)

        print([x for x in self.children])

        self.draw_contact_details()
Esempio n. 25
0
    def __init__(self, dataList):
        self.name = "editabletable"
        super(ROTable, self).__init__()
        parent_layout = StackLayout()
        scroll_layout = ScrollView(size_hint=(1, None), size=(Window.width, Window.height))
        table_layout = GridLayout(cols=6, size_hint_y=None, spacing=5)
        table_layout.bind(minimum_height=table_layout.setter('height'))
        length = len(dataList[0])

        sizes = [0] * length

        # for record in dataList:
        #
        #     for p, column in enumerate(record):
        #         if len(str(column)) > sizes[p]:
        #             sizes[p] = len(str(column)) + 3



        for row_n, row_data in enumerate(dataList):
            for i, row in enumerate(row_data.reverse()):
                if i <= len(row_data) - 2:
                    t = Label(hint_text=row, size_hint_y=None, height=40, font_size='20sp')
                    table_layout.add_widget(t, index=i)
                else:
                    btn = Button(text="Update", size_hint_y=None, height=40)
                    table_layout.add_widget(btn, index=i)

        scroll_layout.add_widget(table_layout)
        self.add_widget(parent_layout)
        self.add_widget(scroll_layout)
Esempio n. 26
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. 27
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()
Esempio n. 28
0
    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. 29
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. 30
0
    def __init__(self, **kwargs):
        super(KivyWindow, self).__init__(**kwargs)
        self.ids.chat_scroll.add_widget(
            StackLayout(orientation='tb-lr', size_hint=[1, None]))
        Window.bind(on_request_close=self.exit_check)
        # self.member_list_current = self.ids.togglebutton_filehelper

        # 绑定静音chekbox
        self.ids.title_checkbox_is_mute.bind(
            active=self.title_checkbox_is_mute_active)

        self.kivy_config.read("KivyConfig.ini")

        # 读取静音数据
        # 返回mute_array的是list格式,写入ini文件是str格式,要做转换
        self.mute_array = self.kivy_config.get('Lists',
                                               'chat_mute_array').split(',')

        # 读取布局数据
        self.kivy_config_layout.update({
            'LayoutSize': {
                'left_size':
                int(self.kivy_config.get('LayoutSize', 'left_size')),
                'right_size':
                int(self.kivy_config.get('LayoutSize', 'right_size'))
            }
        })

        pass