Пример #1
0
    def create_button(self, dic, line, layout, id, group):
        line = line.replace('\n', '')
        dic[line] = 0

        btn = ToggleButton(text='%s' % line, group=group)
        btn.id = id

        layout.add_widget(btn)
Пример #2
0
    def __init__(self, **kwargs):
        super(MainScreen, self).__init__(**kwargs)
        self.cols = 2

        
        
        gov_file = open("gov_names.txt", 'r')
        att_gen_file = open("att_gen_names.txt", 'r')
        sup_court_file = open("sup_court_names.txt", 'r')
        
        v_layout = BoxLayout(padding=10, orientation="vertical")
        v_layout.add_widget(Label(text = 'Governor/Lt. Governor'))

        for line in gov_file:
            line = line.replace('\n', '')
            self.gov_names[line] = 0
            
            btn = ToggleButton(text = '%s' % (line), group='gov')
            btn.id = "gov_btn"
                
            v_layout.add_widget(btn)

        v_layout2 = BoxLayout(padding=10, orientation="vertical")
        v_layout2.add_widget(Label(text= 'Attorney General'))

        for line in att_gen_file:
            line = line.replace('\n', '')
            self.att_gen_names[line] = 0
            
            btn = ToggleButton(text = '%s' % (line), group='att_gen')
            btn.id = "att_gen_btn"
            
                
            v_layout2.add_widget(btn)

        v_layout3 = BoxLayout(padding=10, orientation="vertical")
        v_layout3.add_widget(Label(text= 'Supreme Court Justice\n       (choose 3)'))

        for line in sup_court_file:
            line = line.replace('\n', '')
            self.sup_court_names[line] = 0
            
            btn = ToggleButton(text = '%s' % (line))
            btn.id = "sup_court_btn"
                
            v_layout3.add_widget(btn)


        h_layout = BoxLayout(padding=20, orientation="horizontal")

        vote_btn = Button(text="Vote")
        vote_btn.bind(on_press=self.vote_clicked)
        h_layout.add_widget(vote_btn)
        
        clear_btn = Button(text="Clear")
        clear_btn.bind(on_press=self.clear_clicked)
        h_layout.add_widget(clear_btn)

        done_btn = Button(text='Print Votes')
        done_btn.bind(on_press=self.exit_event)
        h_layout.add_widget(done_btn)
        
        
        self.add_widget(v_layout)
        self.add_widget(v_layout2)
        self.add_widget(v_layout3)
        self.add_widget(h_layout)