Пример #1
0
    def __init__(self, **kwargs):
        super(ProgramPanel, self).__init__(**kwargs)
        self.cols = 1

        g = GridLayout(cols=2)
        g.height = 60
        g.size_hint_y = None
        title = HeadingItem()
        g.add_widget(title)
        self.my_title = title

        bg = GridLayout(cols=3)
        bg.padding = [8, 6]

        b = Button(text='1. program')
        b.bind(on_release=self.my_select_block_dialog)
        bg.add_widget(b)
        self.my_block_button = b
        self.my_set_select()

        b = Button(text='read')
        b.bind(on_release=self.my_read_block_dialog)
        bg.add_widget(b)

        b = Button(text='write')
        b.bind(on_release=self.my_write_block_dialog)
        bg.add_widget(b)

        g.add_widget(bg)
        self.add_widget(g)

        g = GridLayout(cols=2)
        g.height = 40
        g.size_hint_y = None
        g.padding = [8, 6]

        self.current_path = '/coderoot/packages'

        self.my_path = TextInput(text=self.current_path,
                                 multiline=False,
                                 write_tab=False)
        g.add_widget(self.my_path)
        self.my_fname = TextInput(text='', multiline=False, write_tab=False)
        g.add_widget(self.my_fname)

        self.add_widget(g)

        self.my_file_chooser = MyFileChooser(path=self.current_path,
                                             size_hint=(1, 1),
                                             dirselect=True)
        self.add_widget(self.my_file_chooser)

        self.my_file_chooser.bind(selection=lambda *x: self.my_select(x[1:]))
        self.my_file_chooser.bind(path=lambda *x: self.my_set_path(x[1:]))

        self.stream = None
        self.popup = None
        self.writing = False
Пример #2
0
    def __init__(self, **kwargs):
        super(PlaylistWidget, self).__init__(**kwargs)
        self.playlist = ClientManeger.server_songs.songs

        self.bar_width = 30
        self.size_hint = (1, 0.71)
        self.scroll_type = ['bars']
        self.bar_inactive_color = (5, 20, 10, 0.5)
        self.bar_color = (5, 10, 15, .9)
        self.do_scroll_x = False
        self.do_scroll_y = True

        grid = GridLayout()
        grid.height = 0
        grid.size_hint_y = None
        grid.cols = 1
        grid.padding = (5, 5)

        for song in self.playlist:
            widg = SongWidget(song)
            widg.size_hint_y = None
            grid.size_hint_x = 1.0

            # increment grid height
            grid.height += widg.height

            grid.add_widget(widg)

        self.add_widget(grid)
Пример #3
0
 def __init__(self, target, **kwargs):
     super(BattleMenuState, self).__init__(target, **kwargs)
     print('battle menu state here, how ya doin', self, target)
     overlay = App.get_running_app().overlay
     self.move_button = Button(
         text='Move', on_release=lambda dt: self.change(SelectMoveState))
     self.attack_button = Button(
         text='Attack',
         on_release=lambda dt: self.change(SelectAttackState))
     self.wait_button = Button(text='Wait',
                               on_release=lambda dt: self.change(TurnEnd))
     menu = GridLayout(cols=1,
                       size_hint=(None, None),
                       row_force_default=True,
                       row_default_height=40)
     menu.width = dp(100)
     menu.height = menu.minimum_height
     buttons = [self.move_button, self.attack_button, self.wait_button]
     for button in buttons:
         menu.add_widget(button)
     menu.y = dp((Window.height / 2) + (menu.height / 2))
     menu.x = dp(40)
     self.menu = menu
     overlay.add_widget(self.menu)
     self.target.game.set_focus_target(self.target)
Пример #4
0
 def clickSendDivision(self):
     """
         called by clicking on <Send Division>
         assigns division to mat
     """
     
     try:
         box = GridLayout(orientation='vertical', height='130sp', cols=2, spacing=10, padding=5, size_hint=(1,None))
         scroll = ScrollView()
         scroll.add_widget(box)
         popup = Popup(title ='Select where to send division', content = scroll,
                       size_hint = (None, None), size=(500, 500))
         mList = ["Mat_1","Mat_2","Mat_3","Mat_4","Mat_5","Mat_6"]
         for i in sorted(mList):
             txt = i.replace("_"," ")
             btn = OSButton(text=txt, title='select where to send division',
                             identity = i, on_press=self.sendDivision, on_release=popup.dismiss)
             box.add_widget(btn)
         
         h = 0
         n = len(box.children)
         for c in box.children: h += c.height
         box.height = (h/2 + n*5)
         
         popup.open()
     except Exception as e: print "{} exception: {}".format(self, e)
Пример #5
0
    def _create_popup(self, _instance):
        # create the popup
        content = BoxLayout(orientation='vertical', spacing='5dp', size_hint=(1, None))
        scroll_content = ScrollView()
        scroll_content.add_widget(content)
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            content=scroll_content, title=self.title, size_hint=(None, 0.75),
            width=popup_width)
        content.height = len(self.options)/3 * dp(55) + dp(100)

        # add all the options
        content.add_widget(Widget(size_hint_y=None, height=1))
        grid_content = GridLayout(cols=3, spacing='5dp', size_hint=(1, None))
        grid_content.height = len(self.options)/3 * dp(55)
        content.add_widget(grid_content)
        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, size_hint_y=None, height=dp(50))
            btn.bind(on_release=self._set_option)
            grid_content.add_widget(btn)

        # finally, add a cancel button to return on the previous panel
        content.add_widget(Widget())
        btn = Button(text='Cancel', size_hint_y=None, height=dp(50))
        btn.bind(on_release=popup.dismiss)
        content.add_widget(btn)

        # and open the popup !
        popup.open()
Пример #6
0
    def _create_popup(self, instance):
        mod_name, func_name = self.function_string.rsplit('.', 1)
        mod = importlib.import_module(mod_name)
        func = getattr(mod, func_name)
        self.options = func()
        # create the popup
        content = BoxLayout(orientation='vertical')
        grid = GridLayout(cols=1, spacing='2dp', size_hint_y=None)
        scroll = ScrollView()

        for option in self.options:
            btn = Button(text=option, size_hint_y=None, height=40)
            btn.bind(on_press=self._set_option)
            print(btn.text)
            grid.add_widget(btn)

        okbutton = Button(text="Cancel", size_hint_y=0.1)

        grid.height = len(self.options) * 40
        scroll.add_widget(grid)
        content.add_widget(scroll)
        content.add_widget(okbutton)

        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(content=content,
                                   title=self.title,
                                   size_hint=(None, None),
                                   size=(popup_width, '400dp'))
        okbutton.bind(on_press=self.popup.dismiss)
        popup.height = Window.height
        grid.bind(minimum_height=content.setter('height'))
        popup.open()
Пример #7
0
 def clickJoinFighter(self):
     """
         called by clicking on <Move Fighter>
     """
     try:
         box = GridLayout(orientation='vertical', height='130sp', cols=2, spacing=10, padding=5, size_hint=(1,None))
         scroll = ScrollView()
         scroll.add_widget(box)
         popup = Popup(title ='Select where to send division', content = scroll,
                       size_hint = (None, None), size=(600, 600))
         dList = []
         divs = db.execute('SELECT DivisionID FROM Event')
         for d in divs:
             did = d[0]
             if did not in dList and did != self.div: 
                 dList.append(did)
         
         for i in sorted(dList):
             txt = i.replace(";","\n")
             txt = txt.replace("_"," ")
             btn = OSButton(text=txt, title='select where to move fighter', height=('60sp'), size_hint=(1, None),
                             identity = i, on_press=self.joinFighter, on_release=popup.dismiss)
             box.add_widget(btn)
         
         h = 0
         n = len(box.children)
         for c in box.children: h += c.height
         box.height = (h/2 + n*5)
         
         popup.open()
     except Exception as e: print "{} exception: {}".format(self, e)
Пример #8
0
 def build(self):
     layout = GridLayout(cols=2)
     layout.height = layout.minimum_height
     settings = Settings()
     adapter = WebOSClientAdapter(settings)
     settings.load(str(Path().home() / '.lgtv.yaml'))
     layout.add_widget(LeftGrid(adapter, settings))
     layout.add_widget(DPad(adapter))
     return layout
    def __init__(self, app, game_controller, user_interaction, *args,
                 **kwargs):
        super().__init__(*args, **kwargs)
        '''
        params:-
            app : Visualliser : Object that has spawned this one
            game_controller : Game assigned to this board
            user_interaction : bool : True if you want the user to be able to interact with the visuals else False
        '''
        self.rows = 2

        board_grid = GridLayout()

        self.app = app
        self.game_controller = game_controller

        # will hold all squares created by below function for later callback
        self.squares = []

        board_map = game_controller.get_map()

        # Makes a vertical board
        board_grid.rows = board_map._size[0]
        board_grid.cols = board_map._size[1] * board_map._size[2]

        # Loops through all map coords
        for x, z, y in loops(range(board_map._size[0]),
                             range(board_map._size[2]),
                             range(board_map._size[1])):

            current = board_map.get_gridpoi(x, y, z)

            temp = Square(app, game_controller, x, y, z)
            temp.update_square(x, y, z, current)
            self.squares.append(temp)

            board_grid.add_widget(temp)

        self.add_widget(board_grid)

        if user_interaction:
            attack_board_ui = GridLayout()
            attack_board_ui.size_hint_y = None
            attack_board_ui.height = 50

            attack_board_ui.rows = len(board_map._get_attack_board_array()[0])
            attack_board_ui.cols = len(board_map._get_attack_board_array())

            for x, y in loops(
                    range(len(board_map._get_attack_board_array()[0])),
                    range(len(board_map._get_attack_board_array()))):

                temp = Square(app, game_controller, x, y, 'AttackBoard')
                attack_board_ui.add_widget(temp)

            self.add_widget(attack_board_ui)
Пример #10
0
    def on_commands(self, inst, newcommands):

        self.orientation = 'vertical'
        self.cols = 1

        self.clear_widgets()

        if newcommands == None:
            return

        for source in newcommands:
            commands = newcommands[source]

            commandbox = GridLayout(rows=1)
            commandbox.size_hint_y = None
            commandbox.height = 50

            for command in commands:

                if command['action'] == 'divider':
                    self.add_widget(commandbox)
                    commandbox = GridLayout(rows=1)
                    commandbox.size_hint_y = None
                    commandbox.height = 50
                else:
                    btn = Button()
                    btn.text = command['name']

                    if 'confirm' in command and (command['confirm'] != "" or
                                                 command['confirm'] != None):
                        btn.background_color = (2, .5, .5, 1)

                    btn.on_press = lambda source=command[
                        'source'], action=command[
                            'action']: App.get_running_app(
                            ).client.sendCommand(
                                'api/system/commands/' + str(source) + '/' +
                                str(action), '')
                    commandbox.add_widget(btn)

            self.add_widget(commandbox)
Пример #11
0
def generate_GUI(menus):
    app_gui = TabbedPanel()
    app_gui.clear_tabs()
    app_gui.orientation = "vertical"
    app_gui.do_default_tab = False
    app_gui.tab_width = 150

    for menu_key, sub_menu in menus.items():
        main_menu = TabbedPanelHeader(text=menu_key)
        scroll_pane = ScrollView()
        scroll_pane.scroll_type = ['bars', 'content']
        scroll_pane.bar_pos_y = 'left'
        scroll_pane.bar_width = 6
        scroll_pane.do_scroll_y = True
        scroll_pane.do_scroll_x = False
        scroll_pane.scroll_y = 1

        menu_grid = GridLayout(cols=1, spacing=2, size_hint_y=None)
        menu_grid.orientation = "vertical"
        menu_grid.padding = 10
        menu_grid.row_default_height = 1
        menu_height = 0

        print(">>>" + menu_key)
        for sub_menu_key, items in sub_menu.items():
            menu_grid.add_widget(
                Label(text="     " + sub_menu_key, size_hint=(None, None), font_size=14, halign="left",
                      valign="middle"))
            print("\t" + sub_menu_key)
            for option in items:

                if "Name" in option:
                    print("\t\t" + option["Name"])
                    btn = Button(text=option["Name"], size_hint=(0.1, None), background_color=(0.2, 1, 1, 0.8))
                    btn.bind(on_press=lambda x: webbrowser.open(option["URL"]))
                else:
                    print("\t\t" + "<EMPTY>")
                    btn = Button(text="<EMPTY>", size_hint=(0.1, None), background_color=(0.2, 1, 1, 0.8))
                    btn.bind(on_press=lambda x: webbrowser.open(option["URL"]))
                btn.width = 250
                btn.height = 50
                menu_grid.add_widget(btn)
                menu_height += 80
            menu_height += 51
        menu_grid.height = menu_height
        scroll_pane.add_widget(menu_grid)
        main_menu.content = scroll_pane
        main_menu.orientation = "vertical"

        # Adding headers to main layout
        app_gui.add_widget(main_menu)
    return app_gui
Пример #12
0
    def buildList(self, b=None):

        self.clear_widgets()

        wordsObj = Word()

        obj = WordUseage().getCounts()
        words = sorted(wordsObj.readFindString(self.qString))

        for wordTemp in words:

            word = wordsObj.getRowByWord(wordTemp)
            row = GridLayout()
            row.rows = 1
            row.height = 40
            row.size_hint_y = None

            row.add_widget(
                Label(text=f'{word["word"]}', size_hint_y=None, height=40))

            countValue = 0
            if word['id'] in obj.keys():
                countValue = obj[word['id']]
            t = 0
            if WordWeighting().wightingExists(word['id']):
                t = WordWeighting().get(word['id'])['value_id']

            textbox = TextInput(text=str(t),
                                size_hint_y=None,
                                height=40,
                                size_hint_x=None,
                                width=30,
                                multiline=False)

            textbox.wordId = word['id']

            textbox.bind(text=self.changeWeighting)

            row.add_widget(
                Label(text=str(countValue), size_hint_y=None, height=40))

            row.add_widget(textbox)

            btn = Button(text=f'delete',
                         size_hint_y=None,
                         height=40,
                         on_press=self.deleteCb)
            btn.rowId = word['id']
            btn.word = word['word']

            row.add_widget(btn)
            self.add_widget(row)
Пример #13
0
    def menu(self):
        grid = GridLayout(cols=1, spacing='2dp', size_hint_y=None)
        content = ScrollView(size=(200, 500))
        grid.bind(minimum_height=content.setter('height'))
        grid.height = 1500
        self.options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]
        for option in self.options:
            btn = Button(text=str(option), size_hint_y=None, height=50)
            grid.add_widget(btn)

        content.add_widget(grid)
        menu_sc = BoxLayout()
        menu_sc.add_widget(content)
        return menu_sc
def format_airtable_data(header):
		# Gridlayout to host menu options and URL buttons
		formated_data = GridLayout(cols=1, spacing=10, size_hint_y=None)
		formated_data.orientation = "vertical"
		formated_data.padding = 10
		formated_data.row_default_height = 1

		rows = 0 # needed to track the number of items inside the gridlayout
		
		# Converting airtable data into usable Kivy GUI labels and Buttons
		for item in tab_menus:
			if item["id"] == header:
				# Creating the Labels
				if str(item["menu"]) != "N/A":
					formated_data.add_widget(Label(text=item["menu"],size_hint=(.7,.5))) # Creating a menu option as a Label
					rows += 1
				else: # For menu options that have yet to be given a name
					formated_data.add_widget(Label(text="Menu name pending",size_hint=(.7,.5)))
					rows += 1

				# Creating the URL Buttons that belong bellow each Label
				for link in item["link"]:
					url_name = str(link).split('!')[0]	
					url = str(link).split('!')[1]

					# Creaing the Button without refrences
					if  url_name != "N/A":
						button = Button(text=url_name, size_hint=(None, None))
					else: # For URL links with no assigned names
						button = Button(text="Unknown Link", size_hint=(None, None))

					button.width = 250
					button.height = 50

					# Assign each Button a refrence to a created function with their respective URL links
					# This is equivalent to Kivy script: 	on_press: root.open_link('www.your_url_link.com')
					button.bind(on_press=lambda x:Resonance().open_link(url))

					formated_data.add_widget(button)
					rows += 1
					
				formated_data.add_widget(Label())
				rows += 1

		# Formating the gridlayout to fit the sum of items created
		# Necessary to indicate to Scrollview if scroll is needed 
		# if grid size > window size allow scroll 
		formated_data.height = rows * 50  
		
		return formated_data
Пример #15
0
 def __init__(self, target, **kwargs):
     super(BattleMenuState, self).__init__(target, **kwargs)
     print('battle menu state here, how ya doin', self, target)
     overlay = App.get_running_app().overlay
     self.move_button = Button(text='Move', on_release=lambda dt: self.change(SelectMoveState))
     self.attack_button = Button(text='Attack', on_release=lambda dt: self.change(SelectAttackState))
     self.wait_button = Button(text='Wait', on_release=lambda dt: self.change(TurnEnd))
     menu = GridLayout(cols=1, size_hint=(None, None), row_force_default=True, row_default_height=40)
     menu.width = dp(100)
     menu.height = menu.minimum_height
     buttons = [self.move_button, self.attack_button, self.wait_button]
     for button in buttons:
         menu.add_widget(button)
     menu.y = dp((Window.height / 2) + (menu.height / 2))
     menu.x = dp(40)
     self.menu = menu
     overlay.add_widget(self.menu)
     self.target.game.set_focus_target(self.target)
Пример #16
0
    def __init__(self, assembly_type, **kwargs):
        super(LinearCameraItem, self).__init__(**kwargs)
        self.assembly_type = assembly_type
        self.cols = 1

        self.height = self.minimum_height = 400
        self.size_hint_y = None
        self.bind(height=self.setter('height'))

        g = GridLayout(cols=2)
        g.height = 60
        g.size_hint_y = None
        title = HeadingItem()
        g.add_widget(title)
        self.my_title = title

        graph_display = self.make_graph_display()
        self.add_widget(graph_display)
Пример #17
0
    def constroi_titulo2(self):
        x, y = self.width / 300, self.height / 650

        padding = (5 * x, 0 * y, 10 * x, 10 * y)
        grid = GridLayout(cols=3, padding=(5, 0, 5, 0), spacing=x * 10)
        grid.size_hint_y = None
        grid.height = self.height * .1

        btn_ok = OkButton(size_hint_x=None, width=self.width * .1)
        btn_voltar = VoltarButton(size_hint_x=None, width=self.width * .1)
        label = Label(text=self.titulo)
        label.font_size = self.fonte_padrao

        grid.add_widget(btn_voltar)
        grid.add_widget(label)
        grid.add_widget(btn_ok)
        self.add_widget(grid)

        self.ids[f"{self.nome_tela}_botao_ok"] = btn_ok
        self.ids[f"{self.nome_tela}_botao_voltar"] = btn_voltar
Пример #18
0
    def constroi_titulo2(self):
        x, y = self.width / 300, self.height / 650

        padding = (5 * x, 0 * y, 10 * x, 10 * y)
        grid = GridLayout(cols=3, padding=(5, 0, 5, 0), spacing=x * 10)
        grid.size_hint_y = None
        grid.height = self.height * .1

        branco = LimpaDadosButton(size_hint_x=None,
                                  width=self.width * .1,
                                  on_press=self.button_fecha)
        btn_voltar = VoltarButton(size_hint_x=None, width=self.width * .1)
        label = Label(text=self.titulo, bold=True)
        label.font_size = self.fonte_padrao * 1.5

        grid.add_widget(btn_voltar)
        grid.add_widget(label)
        grid.add_widget(branco)
        self.add_widget(grid)

        self.ids[f"historico_botao_voltar"] = btn_voltar
        self.ids["historico_botao_fechar"] = btn_voltar
Пример #19
0
 def make_menu(self):
     self.ids["grid"].clear_widgets()
     myLayout = GridLayout(cols=1, size_hint_y=None)
     myLayout.height = Window.height / 4 * (self.unlocked_level + 1)
     background_colors = ["images/grey1.PNG", "images/grey2.PNG"]
     for x in range(self.max_level):
         if x <= self.unlocked_level:
             if self.level_button_color(x) and not (
                     x + 1) in self.challenges_beaten:
                 self.ids["grid"].add_widget(
                     Button(bold=True,
                            text=str(x + 1),
                            on_release=self.intro))  #self.press
             else:
                 self.ids["grid"].add_widget(
                     Button(bold=True,
                            text=str(x + 1),
                            on_release=self.intro,
                            color=[1, 1, 1, 1],
                            background_color=[1, 1, 1, .75]))
         if x > self.unlocked_level:
             self.ids["grid"].add_widget(Button(text="Locked"))
    def __init__(self, height: int, backCallback: callable, homeCallback: callable, **kwargs):
        super(BottomBar, self).__init__(**kwargs)

        bottomBack = Image()
        bottomBack.color = [0, 0, 0, 1]
        bottomBack.width = Window.size[0]
        bottomBack.height = height
        self.add_widget(bottomBack)

        btnGrid = GridLayout()
        btnGrid.cols = 5
        btnGrid.rows = 1
        btnGrid.width = Window.size[0]
        btnGrid.height = height
        self.add_widget(btnGrid)

        btnBack = Button(text="Back")
        btnBack.bind(on_press=lambda instance: backCallback())
        btnGrid.add_widget(btnBack, 0)

        btnHome = Button(text="Home")
        btnHome.bind(on_press=lambda instance: homeCallback())
        btnGrid.add_widget(btnHome, 1)
Пример #21
0
 def add_dist_time_interval( self,
                             current_training_screen,
                             hint_dist = '1.0',
                             hint_time = '4:00',
                             index_in_layout = 0 ):
     interval_layout = GridLayout( rows = 1, spacing = 30 )
     interval_layout.height = 30
     pos_shift = Label( text='' )
     interval_layout.add_widget( pos_shift )
     distance = TextInput( hint_text = str( hint_dist ) )
     interval_layout.add_widget( distance )
     time = TextInput( hint_text = str( hint_time ) )
     interval_layout.add_widget( time )        
     distance.bind(
         text =
         current_training_screen.update_training_from_user_input )
     time.bind(
         text =
         current_training_screen.update_training_from_user_input )
     del_button = Button( text = "Del Int", size_hint_x = 0.3 )
     del_button.on_press = lambda: self.remove_interval_widget(
         current_training_screen, interval_layout )
     interval_layout.add_widget( del_button )
     self.add_widget( interval_layout, index = index_in_layout )
 def add_reps_weights_set( self,
                           current_training_screen,
                           hint_reps = '10',
                           hint_weights = '50',
                           index_in_layout = 0 ):
     set_layout = GridLayout( rows = 1, spacing = 30 )
     set_layout.height = 30
     pos_shift = Label( text='' )
     set_layout.add_widget( pos_shift )
     reps = TextInput( hint_text = str( hint_reps ) )
     set_layout.add_widget( reps )
     weights = TextInput( hint_text = str( hint_weights ) )
     set_layout.add_widget( weights )        
     reps.bind(
         text =
         current_training_screen.update_training_from_user_input )
     weights.bind(
         text =
         current_training_screen.update_training_from_user_input )
     del_button = Button( text = "Del Set", size_hint_x = 0.3 )
     del_button.on_press = lambda: self.remove_set_widget(
         current_training_screen, set_layout )
     set_layout.add_widget( del_button )
     self.add_widget( set_layout, index = index_in_layout )
Пример #23
0
	def planupdate(self):
		self.bigheight=0
		thescroll=ScrollView(size= self.size, bar_pos_x="top")
		bigbox=GridLayout(
                cols=1,
                orientation='vertical',
                #height=self.minimum_height,
                #height=root.bigheight,
                #padding= (thescroll.width * 0.02, thescroll.height * 0.02),
                #spacing= (thescroll.width * 0.02, thescroll.height * 0.02),
                size_hint_y= None,
                size_hint_x= 1,
                do_scroll_x= False,
                do_scroll_y= True,
                )
		#self.linelen=self.ids.bigbox.width/sp(self.fontheight)
		try:
			self.ids.checkboxes.clear_widgets()
			self.ids.megabox.clear_widgets()
		except:
			pass
		for i in range(0,9):
			if self.fontheight*(len(self.qlist[i])/self.linelen) > self.fontheight :
				qheight=0*self.fontheight+self.fontheight*(len(self.qlist[i])/self.linelen)
			else:
				qheight=self.fontheight
			newq=Label(color=(0,0,0,1), size_hint_y=None, size_hint_x=1, size=(bigbox.width, "%ssp"%str(qheight)))#, font_size=self.fontheight)
			newq.bind(width=lambda s, w:
				   s.setter('text_size')(s, (self.width, None)))
			newq.bind(height=newq.setter('texture_size[1]')) 
			newq.bind(height=newq.setter('self.minimum_height'))	
			newbox=Button(id="box%s"%str(i))
			txt=''
			if self.bttns[i]==1:
				txt=str(self.valuetuple[i])
				newbox.color=(1,1,1,1)
			elif self.bttns[i]==0:
				txt="*"
				newbox.color=(0,0,0,1)
			newbox.text=txt
			if i==self.nownr:
				newbox.background_color= (.25, .75, 1.0, 1.0)
				newq.text=str("%s"%self.qlist[i])
				self.bigheight=self.bigheight+2*newq.height
				bigbox.add_widget(newq)
				for j in range(0,7):
					if self.fontheight*(len(self.dscrptn[i][j])/self.linelen) > 3*self.fontheight :
						bttnheight=2*self.fontheight+self.fontheight*(len(self.dscrptn[i][j])/self.linelen)
					else:
						bttnheight=3*self.fontheight
					smallLabel=Button(text="%s"%self.dscrptn[i][j],size_hint=(1,None), height="%ssp"%str(bttnheight))#, font_size=self.fontheight)
					smallLabel.bind(width=lambda s, w:
						s.setter('text_size')(s, (self.width-100, None)))
					smallLabel.bind(height=smallLabel.setter('texture_size[1]'))
					smallLabel.bind(height=smallLabel.setter('self.minimum_height'))
					smallLabel.bind(on_press=partial(self.radiobox, i, j))
					if self.valuetuple[i] == j and self.bttns[i]==1:
						smallLabel.background_color = (.25, .75, 1.0, 1.0)
					else:
						smallLabel.background_color = (1.0, 1.0, 1.0, 1.0)
					bigbox.add_widget(smallLabel)
					self.bigheight=self.bigheight+smallLabel.height
		
			newbox.bind(on_release=partial(self.chng_bttn, i))
			self.ids.checkboxes.add_widget(newbox)
		
		bigbox.height=self.bigheight
		
		thescroll.bar_pos_x="top"
		thescroll.add_widget(bigbox)
		self.ids.megabox.add_widget(thescroll)
		
		sendbox=Button(id="sendbox", text=">>")
		sendbox.bind(on_release=(lambda store_btn: self.Submit()))
		self.ids.checkboxes.add_widget(sendbox)
Пример #24
0
 def cred(self):
     Window.size = (340, 500)
     creds = {}
     credman = Screen(name='credman', id='screen')
     base = BoxLayout(padding=[0, 0, 0, 0],
                      orientation='vertical',
                      id='base',
                      size_hint_y=None,
                      height=500)
     buttons = BoxLayout(padding=[0, 0, 0, 0],
                         orientation='horizontal',
                         id='buttons',
                         height=450)
     buttons.add_widget(
         Button(text='add',
                font_size=15,
                pos=[40, 40],
                size_hint=[1, None],
                height=30,
                on_press=lambda x: self.p_add(credman)))
     buttons.add_widget(
         Button(text='save',
                font_size=15,
                pos=[40, 40],
                size_hint=[1, None],
                height=30,
                on_press=lambda x: self.c_save(credman)))
     buttons.add_widget(
         Button(text='back',
                font_size=15,
                pos=[40, 40],
                size_hint=[1, None],
                height=30,
                on_press=lambda x: self.c_back(credman)))
     # print('yolo')
     with open('cred.bin', 'rb') as f:
         from pickle import load
         creds = load(f)
     i = 0
     layout = GridLayout(cols=1, size_hint=[1, None], height=450)
     # layout.bind(minimum_height=layout.setter('height'))
     for user in creds.keys():
         # print(user)
         usr = TextInput(text=str(user),
                         id=str(str(i) + 'u'),
                         multiline=False,
                         write_tab=False,
                         use_bubble=True,
                         size_hint=[1, None],
                         height=35)
         pwd = TextInput(text=str(creds[user]),
                         id=str(str(i) + 'p'),
                         multiline=False,
                         write_tab=False,
                         password=True,
                         use_bubble=True,
                         size_hint=[1, None],
                         height=35)
         dele = Button(text=str('x'),
                       size_hint=[None, 1],
                       width=20,
                       id=str(i),
                       on_press=lambda i: self.c_dele(credman, i.id),
                       height=35)
         lay = BoxLayout(orientation='horizontal', id=str(i))
         lay.add_widget(usr)
         lay.add_widget(pwd)
         lay.add_widget(dele)
         layout.add_widget(lay)
         i = i + 1
     layout.height = i * 35
     sc = ScrollView(id='list', size_hint=[1, None], height=470)
     sc.add_widget(layout)
     base.add_widget(sc)
     base.add_widget(buttons)
     credman.add_widget(base)
     self.manager.add_widget(credman)
     self.manager.current = 'credman'