Exemplo n.º 1
0
    def on_text(self, instance, value):
        if value != self.prev and value != '':
            self.suggestion_text = ''
            val = value[value.rfind(' ') + 1:]
            self.prev = value
            if value != '':
                matches = [
                    self.word_list[i] for i in range(len(self.word_list))
                    if value in self.word_list[i][:len(value)]
                ]
            else:
                matches = []
            self.matches = matches
            #self.text_input = TextInput(multiline=False, size_hint=(1, 0.1), pos_hint={'center_x': 0.5, 'center_y': 0.95})
            #self.text_input.bind(text=self.on_text)
            #main_layout_1 = BoxLayout(orientation="vertical")
            if len(matches) != 0:
                self.clear_widgets()
                self.main_layout.clear_widgets()
                main_layout_1 = BoxLayout(orientation="vertical")
                self.text_input_1 = TextInput(
                    multiline=False,
                    size_hint=(1, 0.1 * (self.font_size / 20)),
                    font_size=self.font_size,
                    pos_hint={
                        'center_x': 0.5,
                        'center_y': 0.95
                    })
                self.text_input_1.bind(text=self.on_text)
                self.main_layout.add_widget(self.text_input)
                if self.find:
                    self.btn_5 = Button(text=self.translator.translate(
                        'Look for {}'.format(self.find)),
                                        background_color=(0, 1, 1, 1),
                                        font_size=self.font_size,
                                        color=(1, 1, 1, 1),
                                        size_hint_y=None,
                                        height=40)
                else:
                    self.btn_5 = Button(text=self.translator.translate('Exit'),
                                        background_color=(0, 1, 1, 1),
                                        color=(1, 1, 1, 1),
                                        font_size=self.font_size,
                                        size_hint_y=None,
                                        height=40)
                self.btn_5.bind(on_press=self.start)

                main_layout = BoxLayout(orientation="vertical")
                for i in matches:
                    self.btn = Button(text=i,
                                      background_color=(1, 1, 1, 1),
                                      color=(1, 1, 1, 1),
                                      font_size=self.font_size,
                                      size_hint_y=None,
                                      height=40)

                    # bind() use to bind the button to function callback
                    self.btn.bind(on_press=self.Pressbtn)
                    main_layout.add_widget(self.btn)
                self.main_layout.add_widget(main_layout)

                self.main_layout.add_widget(self.btn_5)
                self.add_widget(self.main_layout)
                #self.add_widget(main_layout_1)
                return
            else:
                return
            if not val:
                return
            try:
                word = [
                    word for word in self.word_list if word.startswith(val)
                ][0][len(val):]
                if not word:
                    return
                self.suggestion_text = word
            except IndexError:
                print('Index Error.')
Exemplo n.º 2
0
    def build(self):
        SettingsScreen = Screen(name="settings")
        sm.add_widget(NotificationsMainScreen.build(self))
        sm.add_widget(SecurityPage.build(self))
        sm.add_widget(AccessibilityPage.build(self))
        sm.add_widget(DispensingPage.build(self))

        def GoTonotifications(self):
            sm.transition = NoTransition()
            sm.current = 'notifications'
            sm.transition = SlideTransition()

        def GoTosecurity(self):
            sm.transition = NoTransition()
            sm.current = 'security'
            sm.transition = SlideTransition()

        def GoTodispensing(self):
            sm.transition = NoTransition()
            sm.current = 'dispensing'
            sm.transition = SlideTransition()

        def GoToaccessibility(self):
            sm.transition = NoTransition()
            sm.current = 'accessibility'
            sm.transition = SlideTransition()

        SettingsScreenLayout = BoxLayout(orientation='vertical',
                                         size_hint_y=None,
                                         height=1000,
                                         pos=(0, 25),
                                         padding=10)

        NotificationsButton = Button(text="Notifications",
                                     color=White,
                                     font_size=40,
                                     font_name=DefaultFont,
                                     size_hint_y=None,
                                     height=60,
                                     background_color=Black)
        NotificationsButton.bind(on_press=GoTonotifications)
        SecurityButton = Button(text="Security",
                                color=White,
                                font_size=40,
                                font_name=DefaultFont,
                                size_hint_y=None,
                                height=60,
                                background_color=Black)
        SecurityButton.bind(on_press=GoTosecurity)
        DispensingButton = Button(text="Dispensing",
                                  color=White,
                                  font_size=40,
                                  font_name=DefaultFont,
                                  size_hint_y=None,
                                  height=60,
                                  background_color=Black)
        DispensingButton.bind(on_press=GoTodispensing)
        AccessibilityButton = Button(text="Accessibility",
                                     color=White,
                                     font_size=40,
                                     font_name=DefaultFont,
                                     size_hint_y=None,
                                     height=60,
                                     background_color=Black)
        AccessibilityButton.bind(on_press=GoToaccessibility)

        SettingsScreenLayout.add_widget(NotificationsButton)
        SettingsScreenLayout.add_widget(SecurityButton)
        SettingsScreenLayout.add_widget(DispensingButton)
        SettingsScreenLayout.add_widget(AccessibilityButton)
        SettingsScreen.add_widget(SettingsScreenLayout)

        return SettingsScreen
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        super(Display, self).__init__(**kwargs)

        #Recursive function that searches through all widgets for a given ID
        def findByID(screen, ID):
            findByID.selectedChild = None

            def findID(screen, ID):
                if screen.children:
                    for child in screen.children:
                        if str(child.id) == ID:
                            findByID.selectedChild = child
                            return 1
                        else:
                            findID(child, ID)

            findID(screen, ID)
            return findByID.selectedChild

        #Screens are their own classes, formed within the initialization of the display itself

        class Screen_One(Screen):
            def __init__(self, **kwargs):
                super(Screen_One, self).__init__(**kwargs)
                self.name = 'One'

                #Different colors convey different chip statuses
                rimg = Image(source='red.png')
                gimg = Image(source='green.png')
                yimg = Image(source='yellow.png')
                bimg = Image(source='gray.png')
                curimg = bimg

                #Do not run test by default
                killedAlready = True

                #Checks the state of .txt file
                def docheck(obj, *args):
                    checkval = 10
                    if abs(myChip.count) < checkval or keep.active == True:
                        nonlocal curimg
                        curimg = myChip.check(rimg, gimg, yimg, bimg)
                        Fimg.clear_widgets()
                        Fimg.add_widget(begEcho)
                        Fimg.add_widget(curimg)
                    else:
                        if myChip.testtime:
                            os.system('./killall_measurements')
                            myChip.testtime = False

                #Set voltage on voltage suppl(y/ies)
                def setVoltage(obj):
                    if findByID(s1, '6state1').active:
                        mySupply.setSequence('P6V',
                                             findByID(s1, '6sup1').text,
                                             mySupply.curmax)
                        time.sleep(0.2)
                    if findByID(s1, '25state1').active:
                        mySupply.setSequence('P25V',
                                             findByID(s1, '25sup1').text,
                                             mySupply.curmax)

                #Boxes that contain voltage supply-setting elements
                class Vbox(BoxLayout):
                    def __init__(self, **kwargs):
                        # make sure we aren't overriding any important functionality
                        super(Vbox, self).__init__(**kwargs)

                        with self.canvas.before:
                            Color(
                                0, .2, .3, 1
                            )  # green; colors range from 0-1 instead of 0-255
                            self.rect = Rectangle(size=self.size, pos=self.pos)

                            self.bind(size=self._update_rect,
                                      pos=self._update_rect)

                    def _update_rect(self, instance, value):
                        self.rect.pos = instance.pos
                        self.rect.size = instance.size

                #Nested layouts
                Fouter = BoxLayout(orientation='horizontal',
                                   padding=[0, 0, 0, 0])
                Finner = BoxLayout(orientation='vertical',
                                   padding=[50, 50, 50, 50],
                                   spacing=40)
                Finner2 = BoxLayout(orientation='vertical',
                                    padding=[30, 30, 30, 30],
                                    spacing=20)
                Finner3 = BoxLayout(orientation='vertical',
                                    padding=[30, 30, 30, 30],
                                    spacing=20)
                Fvwrite = BoxLayout(orientation='horizontal',
                                    padding=[0, 0, 0, 0],
                                    spacing=0,
                                    size_hint_y=None,
                                    height=45)
                #FINNER2
                #Power supply control sections
                vlay = Vbox(orientation='vertical',
                            padding=[10, 10, 10, 10],
                            spacing=10)
                vlay2 = Vbox(orientation='vertical',
                             padding=[10, 10, 10, 10],
                             spacing=10)

                #Blit voltage-controlling elements onto the screen
                def blitVolt(vallist):
                    Finner2.remove_widget(Finner3)
                    Finner3.clear_widgets()
                    vlay.clear_widgets()
                    vlay2.clear_widgets()

                    mySupply.row1 = []
                    mySupply.row2 = []
                    mySupply.rows = [mySupply.row1, mySupply.row2]

                    #Use saved voltage values if present
                    if os.path.exists('voltagelog.txt'):
                        file1 = open('voltagelog.txt', 'r')
                        i = 0
                        for value in mySupply.values:
                            mySupply.values[i] = file1.readline().rstrip()
                            i += 1

                    #Create rows
                    mySupply.addrow('+6', 0, '6sup1', '6state1',
                                    mySupply.values[0])
                    mySupply.addrow('+25', 0, '25sup1', '25state1',
                                    mySupply.values[1])
                    mySupply.addrow('-25', 0, '-25sup1', '-25state1',
                                    mySupply.values[2])
                    mySupply.addrow('+6', 1, '6sup2', '6state2',
                                    mySupply.values[3])
                    mySupply.addrow('+25', 1, '25sup2', '25state2',
                                    mySupply.values[4])
                    mySupply.addrow('-25', 1, '-25sup2', '-25state2',
                                    mySupply.values[5])

                    #Add supply 1 rows to voltage box
                    vlay.add_widget(Label(text='Supply 1'))
                    for row in mySupply.rows[0]:
                        vlay.add_widget(row)

                    #Add supply 2 rows to voltage box
                    vlay2.add_widget(Label(text='Supply 2'))
                    for row in mySupply.rows[1]:
                        vlay2.add_widget(row)

                    #Joining sections
                    Finner3.add_widget(vlay)
                    Finner3.add_widget(vlay2)
                    Finner2.add_widget(Finner3, index=2)

                #Button to set power supply settings
                initiate = Button(size_hint_y=None,
                                  height=45,
                                  text='Set Voltages',
                                  id='initiate')
                initiate.bind(on_press=setVoltage)

                #Buttons to write and read voltage values from .txt file
                write = Button(size_hint_y=None, height=45, text='Save')
                read = Button(size_hint_y=None, height=45, text='Read')
                Fvwrite.add_widget(write)
                write.bind(on_press=mySupply.save)
                Fvwrite.add_widget(read)
                read.bind(on_press=blitVolt)

                #Joining sections
                Finner2.add_widget(Finner3)
                Finner2.add_widget(initiate)
                Finner2.add_widget(Fvwrite)

                #Run manually the first time; runs again each time the read button is pushed
                blitVolt(mySupply.values)
                #FINNER1

                #Buttons to run and kill testing script
                begEcho = Button(height=10, text='Connect to Chip', id='echo')
                kill = Button(height=10,
                              text='Kill All',
                              id='kill',
                              background_color=(1, 0, 0, 1))
                begEcho.bind(on_press=myChip.keepEcho)
                kill.bind(on_press=myChip.killer)
                choose = Button(height=10, text='Choose Chip', id='choose')
                setsup = Button(height=10, text='Set Supply', id='set')
                setsup.bind(on_press=mySupply.serialSet)

                #Run check every 1/2 sec
                Clock.schedule_interval(docheck, 0.5)

                #Checkbox Section 1
                Fbox = BoxLayout(orientation='horizontal',
                                 padding=[0, 0, 0, 0])
                ck = Label(text='Bist (Not Direct)')
                bist = Switch(active=True)
                Fbox.add_widget(ck)
                Fbox.add_widget(bist)
                Finner.add_widget(Fbox)

                #Image Section
                Fimg = BoxLayout(orientation='horizontal',
                                 padding=[0, 0, 0, 0],
                                 spacing=0)
                Fimg.add_widget(begEcho)
                Fimg.add_widget(curimg)
                Finner.add_widget(Fimg)

                #Checkbox Section 2
                Fkeep = BoxLayout(orientation='horizontal',
                                  padding=[0, 0, 0, 0],
                                  spacing=0)
                clab = Label(text='Continue echo')
                keep = Switch(active=False)
                Fkeep.add_widget(clab)
                Fkeep.add_widget(keep)
                Finner.add_widget(Fkeep)

                #Joining sections
                Finner.add_widget(kill)
                Finner.add_widget(setsup)
                Finner.add_widget(choose)
                Fouter.add_widget(Finner)
                Fouter.add_widget(Finner2)
                self.add_widget(Fouter)

        class Screen_Two(Screen):
            def __init__(self, **kwargs):
                super(Screen_Two, self).__init__(**kwargs)
                self.name = 'Two'

        class Screen_Three(Screen):
            def __init__(self, **kwargs):

                super(Screen_Three, self).__init__(**kwargs)
                self.name = 'Three'

        class Screen_Four(Screen):
            def __init__(self, **kwargs):
                super(Screen_Four, self).__init__(**kwargs)
                self.name = 'Four'

        #Advanced Settings Screen
        class Screen_Five(Screen):
            def __init__(self, **kwargs):

                super(Screen_Five, self).__init__(**kwargs)
                self.name = 'Five'

                #Set current and device variables for the Screen 1 tests; still needs work
                def setVals(obj):
                    mySupply.deviceName = findByID(s5, 'dev').text
                    mySupply.curmax = findByID(s5, 'max').text

                #Layout elements and nested layouts
                outer = BoxLayout(orientation='horizontal',
                                  padding=[50, 50, 50, 50])
                inner = BoxLayout(orientation='vertical')
                empty = Image(source='blank.png')

                advrows = []

                #Adding input rows
                def addrow(lab, txt, myID):
                    lab = Label(text=lab)
                    valLay = AnchorLayout(anchor_x='right', anchor_y='center')
                    val = TextInput(size_hint=(1, None),
                                    height=31,
                                    multiline=False,
                                    text=txt,
                                    id=myID)
                    valLay.add_widget(val)

                    advrows.append(BoxLayout())
                    advrows[-1].add_widget(lab)
                    advrows[-1].add_widget(valLay)

                #If present, load saved 'advanced settings' values
                if os.path.exists('advlog.txt'):
                    file1 = open('advlog.txt', 'r')
                    mySupply.deviceName = file1.readline().rstrip()
                    mySupply.curmax = file1.readline().rstrip()

                #Add rows
                addrow('Supply 1 Location', mySupply.deviceName, 'dev')
                addrow('Maximum Current', mySupply.curmax, 'max')
                for row in advrows:
                    inner.add_widget(row)

                submit = Button(text='Submit', size_hint_y=None, height=50)
                submit.bind(on_press=setVals)
                inner.add_widget(submit)

                #Join sections together
                outer.add_widget(inner)
                outer.add_widget(empty)
                self.add_widget(outer)

        #Begin adding elements to main display: includes screens and navigation buttons
        layout = BoxLayout(orientation='vertical')
        self.add_widget(layout)

        btnBar = BoxLayout(orientation='horizontal',
                           size_hint=(1, None),
                           height='48dp')

        with self.canvas.before:
            Color(0, 0.05, 0.15)
            Rectangle(pos=(0, 0), size=(2000, 2000))

        #Create screens (as instances of the above classes) and buttons to navigate between them
        s1 = Screen_One()
        s2 = Screen_Two()
        s3 = Screen_Three()
        s4 = Screen_Four()
        s5 = Screen_Five()

        btn1 = Button(text='GENERAL', on_press=lambda a: sm.switch_to(s1))
        btn2 = Button(text='BIST', on_press=lambda a: sm.switch_to(s2))
        btn3 = Button(text='DIRECT', on_press=lambda a: sm.switch_to(s3))
        btn4 = Button(text='DEMO', on_press=lambda a: sm.switch_to(s4))
        btn5 = Button(text='ADVANCED', on_press=lambda a: sm.switch_to(s5))

        buttonlist = [btn1, btn2, btn3, btn4, btn5]
        screenlist = [s1, s2, s3, s4, s5]
        sm = ScreenManager()
        for i in range(0, 5):
            btnBar.add_widget(buttonlist[i])
            sm.add_widget(screenlist[i])
        layout.add_widget(btnBar)
        layout.add_widget(sm)
Exemplo n.º 4
0
    def touched_down(self, number, id):

        def restart():
            clear_board()
            key_logger.clear()
            turn.clear()
            turn.append("X")
            turn.append("O")
            for button_id in button_ids:
                button_changes = self.ids[button_id]
                button_changes.text = ""

        if number not in key_logger:
            key_logger.append(number)

            button_change = self.ids[button_ids[id]]
            button_change.text = turn[0]
            button_change.font_size = 70

            game = main(number, turn[0])

            if game == 1:
                layout = BoxLayout(center_x=True, center_y=True, height="10dp", orientation="vertical")
                buttons = GridLayout()

                popupLabel = Label(text=f"{turn[0]} is the winner", font_size=70)

                win_size = Window.size

                closeButton = Button(text='Quit', size=(300, 100), pos=(win_size[0]*0.5625, win_size[1]*0.3333), on_release=self.exit_code)
                restartButton = Button(text="Play Again", pos=(win_size[0]*0.0625, win_size[1]*0.33333), size=(300, 100), on_release= lambda *args: restart(), on_press=lambda *args: popup.dismiss())

                layout.add_widget(popupLabel)

                buttons.add_widget(closeButton)
                buttons.add_widget(restartButton)

                layout.add_widget(buttons)

                popup = Popup(title="Gameover", content=layout, height="10dp")
                popup.open()


            elif game == 0:
                print("Game was a draw")
                layout = BoxLayout(center_x=True, center_y=True, height="10dp", orientation="vertical")
                buttons = GridLayout()

                popupLabel = Label(text="Game was a draw", font_size=70)

                win_size = Window.size

                closeButton = Button(text='Quit', size=(300, 100), pos=(win_size[0] * 0.5625, win_size[1] * 0.3333),
                                     on_release=self.exit_code)
                restartButton = Button(text="Play Again", pos=(win_size[0] * 0.0625, win_size[1] * 0.33333),
                                       size=(300, 100), on_release=lambda *args: restart(),
                                       on_press=lambda *args: popup.dismiss())

                layout.add_widget(popupLabel)

                buttons.add_widget(closeButton)
                buttons.add_widget(restartButton)

                layout.add_widget(buttons)

                popup = Popup(title="Gameover", content=layout, height="10dp")
                popup.open()

            turn[0], turn[1] = turn[1], turn[0]
        else:

            print("Already selected")
Exemplo n.º 5
0
class SolutionLayout(GridLayout):

    table = GridLayout(cols=3, size_hint_y=None, spacing=5)
    graph = Graph(xlabel='X',
                  ylabel='Y',
                  x_ticks_minor=0,
                  x_ticks_major=0.1,
                  y_ticks_major=0.1,
                  y_grid_label=True,
                  x_grid_label=True,
                  padding=10,
                  x_grid=True,
                  y_grid=True,
                  xmin=-0,
                  xmax=50,
                  ymin=-1,
                  ymax=1)

    boxlayout = BoxLayout(orientation='vertical')
    scrollview = ScrollView()

    backbutton = Button(text='BACK TO CALCULATOR',
                        size_hint=(1, 0.1),
                        background_color=[0, 0, 0, 1])

    def setup_widget(self):

        self.table.bind(minimum_height=self.table.setter('height'))
        self.backbutton.on_press = self.back

        self.scrollview.add_widget(self.table)
        self.boxlayout.add_widget(self.graph)
        self.boxlayout.add_widget(self.backbutton)

        self.add_widget(self.scrollview)
        self.add_widget(self.boxlayout)

    def refresh_datatable(self, data):
        self.table.clear_widgets()
        roots, fxs = data
        i = 0
        self.table.add_widget(
            Button(text="Steps",
                   size_hint_y=None,
                   height=100,
                   size_hint=(0.2, None)))
        self.table.add_widget(
            Button(text="x",
                   size_hint_y=None,
                   height=100,
                   size_hint=(0.4, None)))
        self.table.add_widget(
            Button(text="f(x)",
                   size_hint_y=None,
                   height=100,
                   size_hint=(0.4, None)))

        for x in roots:
            self.table.add_widget(
                Button(text=str(i + 1), height=40, size_hint=(0.2, None)))
            self.table.add_widget(
                Button(text=str(round(x, 4)),
                       background_color=[0, 0, 0, 1],
                       height=40,
                       size_hint=(0.4, None)))
            self.table.add_widget(
                Button(text='{:f}'.format(fxs[i]),
                       background_color=[0, 0, 0, 1],
                       height=40,
                       size_hint=(0.4, None)))
            i = i + 1

    def back(self):
        screen_manager.current = 'calculator'
Exemplo n.º 6
0
    def __init__(self, app, dict):
        super(QuestionsForm, self).__init__()
        self.the_app = app
        with self.canvas.before:
            self.rect = Rectangle(source='back4.png')
            self.bind(size=self._update_rect, pos=self._update_rect)

        self.answers = {}
        self.questions = dict['ques']
        num_questions = len(dict['ques'].keys())

        layoutup = BoxLayout(orientation='vertical')
        layoutup.add_widget(BoxLayout(size_hint_y=0.7))
        layoutup.add_widget(
            Label(text=dict['qu_title'],
                  font_size=50,
                  font_name="fonts/the_font.ttf",
                  halign='right',
                  size_hint_y=0.4,
                  size_hint_x=1.5,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(BoxLayout(size_hint_y=0.1))
        layoutup.add_widget(
            Label(text=dict['qu_description']['d1'],
                  font_name="fonts/the_font.ttf",
                  font_size=36,
                  halign='right',
                  size_hint_y=0.15,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(
            Label(text=dict['qu_description']['d2'],
                  font_name="fonts/the_font.ttf",
                  font_size=36,
                  halign='right',
                  size_hint_y=0.15,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(
            Label(text=dict['qu_description']['d3'],
                  font_name="fonts/the_font.ttf",
                  font_size=36,
                  halign='right',
                  size_hint_y=0.15,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(BoxLayout(size_hint_y=0.2))

        # question matrix
        layout = GridLayout(cols=len(dict['ans']) + 2,
                            rows=len(dict['ques']) + 1,
                            row_default_height=400 / num_questions)

        dict['ques'] = collections.OrderedDict(sorted(dict['ques'].items()))

        q_counter = 0
        for ques, values in dict['ques'].items():
            layout.add_widget(BoxLayout(size_hint_x=0.05))
            q_counter += 1
            if q_counter == 1:
                for ans in dict['ans']:
                    layout.add_widget(
                        Label(size_hint_x=0.1,
                              text=dict['ans'][ans],
                              font_name="fonts/the_font.ttf",
                              font_size=25,
                              halign='right',
                              color=[0, 0, 0, 1]))
                layout.add_widget(
                    Label(text="תולאש",
                          font_name="fonts/the_font.ttf",
                          font_size=42,
                          halign='right',
                          orientation='vertical',
                          color=[0, 0, 0, 1]))
                layout.add_widget(
                    BoxLayout(size_hint_x=0.1, name='space_between'))

            for ans in dict['ans']:
                ab = AnswerButton(size_hint_x=0.15,
                                  text="",
                                  group=str(q_counter))
                ab.name = str(ques) + "," + str(ans)
                ab.question = ques
                ab.answer = ans
                ab.form = self
                self.ans_button.append(ab)
                layout.add_widget(ab)

            # CHECK ID AND KEEP THE CLICK VALUE
            layout.add_widget(
                Label(halign='right',
                      text=dict['ques'][ques],
                      font_name="fonts/the_font.ttf",
                      orientation='vertical',
                      font_size=36,
                      color=[0, 0, 0, 1]))

        layoutup.add_widget(layout)
        layoutup.add_widget(BoxLayout())
        layoutbuttons = BoxLayout(size_hint_y=0.2)
        self.next_button = Button(on_press=self.next,
                                  background_color=(0, 0.71, 1., 1),
                                  background_normal="",
                                  size_hint_x=0.3,
                                  text=dict['next_button'],
                                  font_name="fonts/the_font",
                                  font_size=20,
                                  disabled=True)

        layoutbuttons.add_widget(BoxLayout(size_hint_x=0.2))
        layoutbuttons.add_widget(self.next_button)
        layoutbuttons.add_widget(BoxLayout())
        layoutbuttons.add_widget(BoxLayout(size_hint_x=0.7))

        layoutup.add_widget(layoutbuttons)
        layoutup.add_widget(BoxLayout(size_hint_y=0.1))
        self.add_widget(layoutup)
Exemplo n.º 7
0
    def build(self):
        self.savelog = False
        self.start_screen = FloatLayout(size_hint=(1, 1),
                                        pos_hint={
                                            'center_x': 0.5,
                                            'center_y': 0.5
                                        })

        background_image = Image(source=INITIAL_BACKGROUND,
                                 size_hint=[1, 1],
                                 pos_hint={
                                     'center_x': 0.5,
                                     'center_y': 0.5
                                 },
                                 allow_stretch=True)

        game_label = LabelB(text='Chess game',
                            size_hint=[0.15, 0.1],
                            pos_hint={
                                'center_x': 0.7,
                                'center_y': 0.8
                            },
                            color=[0, 0, 0, 1],
                            bcolor=[0, 0, 0, 0],
                            font_name=FONT,
                            font_size=100)

        self.buttons = BoxLayout(orientation='vertical',
                                 spacing=10,
                                 size_hint=(0.3, 0.4),
                                 pos_hint={
                                     'center_x': 0.7,
                                     'center_y': 0.4
                                 })

        start_game_button = Button(text='Start game',
                                   on_press=self.c_game_mode,
                                   background_normal='',
                                   background_color=INITIAL_BUTTON_COLOR,
                                   color=[0, 0, 0, 1])

        settings_button = Button(text='Settings',
                                 on_press=self.show_settings,
                                 background_normal='',
                                 background_color=INITIAL_BUTTON_COLOR,
                                 color=[0, 0, 0, 1])

        exit_button = Button(text='Quit',
                             on_press=self.leave,
                             background_normal='',
                             background_color=INITIAL_BUTTON_COLOR,
                             color=[0, 0, 0, 1])

        self.buttons.add_widget(start_game_button)
        self.buttons.add_widget(settings_button)
        self.buttons.add_widget(exit_button)

        self.start_screen.add_widget(background_image)
        self.start_screen.add_widget(game_label)

        self.start_screen.add_widget(self.buttons)
        self.main_layout = FloatLayout()
        self.main_layout.add_widget(self.start_screen)

        return self.main_layout
Exemplo n.º 8
0
    def show_objects(self):
        """
        Create the entire layout for all profiles present in the database
        :return: None
        """
        list_of_objects = self.interface_call.sql_to_object_screen()
        parent_widget = self.objects_holder

        parent_widget.clear_widgets()

        for item in list_of_objects:
            layout = GridLayout(cols=1,
                                size_hint=(1, parent_widget.size_hint_y * 10),
                                id=item['Title'])

            widg_1 = Label(text=item['Title'], size_hint=(1, .5))

            widg_2 = BoxLayout()
            widg_2_1 = Label(text='Creator: ' + item['Creator'])
            widg_2_2 = GridLayout(cols=1)
            shp_2_2 = Label(text='Shp Name: ' + item['ShpName'])
            dbf_2_2 = Label(text='Dbf Name: ' + item['DbfName'])
            widg_2_2.add_widget(shp_2_2)
            widg_2_2.add_widget(dbf_2_2)
            widg_2_3 = Label(text='Date: ' + item['Date'])

            widg_2.add_widget(widg_2_1)
            widg_2.add_widget(widg_2_2)
            widg_2.add_widget(widg_2_3)

            widg_3 = BoxLayout()

            widg_3_1 = BubbleButton(id=item['Title'],
                                    text='2D',
                                    color=[0, 0, 0, 1],
                                    size_hint=(1.0, .5),
                                    background_normal='',
                                    background_color=[1, 1, 1, 1])
            widg_3_1.bind(on_press=self.visual_screen_instance_2d)

            widg_3_2 = BubbleButton(id=item['Title'],
                                    text='3D',
                                    color=[0, 0, 0, 1],
                                    size_hint=(1.0, .5),
                                    background_normal='',
                                    background_color=[1, 1, 1, 1])
            widg_3_2.bind(on_press=self.visual_screen_instance_3d)

            widg_3_3 = BubbleButton(text='VR',
                                    color=[0, 0, 0, 1],
                                    size_hint=(1.0, .5),
                                    background_normal='',
                                    background_color=[1, 1, 1, 1])

            widg_3.add_widget(widg_3_1)
            widg_3.add_widget(widg_3_2)
            widg_3.add_widget(widg_3_3)

            layout.add_widget(widg_1)
            layout.add_widget(widg_2)
            layout.add_widget(widg_3)

            parent_widget.add_widget(layout)
Exemplo n.º 9
0
    def build(self):

        ## main and data settings layout
        btn_run = Button(text='Run',
                         on_press=partial(self.async_train, self.canvas,
                                          self.output))

        self.spinner_func.bind(text=self.set_func)
        self.draw_base_func()

        slider_layout_points = BoxLayout(orientation='vertical')
        slider_points = Slider(min=5,
                               max=200,
                               value=50,
                               step=1,
                               value_track=True,
                               id='points')
        slider_points.bind(value=self.OnSliderValueChange)

        slider_layout_points.add_widget(slider_points)
        slider_layout_points.add_widget(self.label_points)

        slider_layout_noise = BoxLayout(orientation='vertical')
        slider_noise = Slider(min=0,
                              max=10,
                              value=3,
                              step=0.1,
                              value_track=True,
                              id='noise')
        slider_noise.bind(value=self.OnSliderValueChange)

        slider_layout_noise.add_widget(slider_noise)
        slider_layout_noise.add_widget(self.label_noise)

        self.output.readonly = True
        self.output.text += "Press 'Run' to train the Neural Network\nLOG:\n"

        ## Neural network settings layout

        spinner_activation = Spinner(text='ELU',
                                     values=('ELU', 'Sigmoid', 'Softplus',
                                             'Tanh'),
                                     id='activ')
        spinner_out_activation = Spinner(text='Linear',
                                         values=('ELU', 'Linear', 'Sigmoid',
                                                 'Softplus', 'Tanh'),
                                         id='out_activ')
        spinner_activation.bind(text=self.set_activation)
        spinner_out_activation.bind(text=self.set_activation)

        slider_layout_epochs = BoxLayout(orientation='vertical')
        slider_epochs = Slider(min=1000,
                               max=50000,
                               value=self.EPOCHS,
                               step=200,
                               value_track=True,
                               id='epochs')
        slider_epochs.bind(value=self.OnSliderValueChange)
        slider_layout_epochs.add_widget(slider_epochs)
        slider_layout_epochs.add_widget(self.label_epochs)

        slider_layout_learning = BoxLayout(orientation='vertical')
        slider_learning = Slider(min=0.0001,
                                 max=0.01,
                                 value=self.LEARNING_RATE,
                                 step=0.0001,
                                 value_track=True,
                                 id='learning_rate')
        slider_learning.bind(value=self.OnSliderValueChange)
        slider_layout_learning.add_widget(slider_learning)
        slider_layout_learning.add_widget(self.label_learning)

        slider_layout_lambda = BoxLayout(orientation='vertical')
        slider_lambda = Slider(min=0.0,
                               max=0.5,
                               value=self.LAMBDA,
                               step=0.0001,
                               value_track=True,
                               id='lambda')
        slider_lambda.bind(value=self.OnSliderValueChange)
        slider_layout_lambda.add_widget(slider_lambda)
        slider_layout_lambda.add_widget(self.label_lambda)

        ## all layouts added to root lyout

        layout = BoxLayout(size_hint=(1, 0.25))
        layout.add_widget(self.nn_shape)
        layout.add_widget(self.spinner_func)
        layout.add_widget(slider_layout_points)
        layout.add_widget(slider_layout_noise)
        layout.add_widget(btn_run)

        layout_nn = BoxLayout(size_hint=(1, 0.25))

        layout_nn.add_widget(spinner_activation)
        layout_nn.add_widget(spinner_out_activation)
        layout_nn.add_widget(slider_layout_epochs)
        layout_nn.add_widget(slider_layout_learning)
        layout_nn.add_widget(slider_layout_lambda)

        root = BoxLayout(orientation='vertical')
        root.add_widget(self.canvas)
        root.add_widget(layout)
        root.add_widget(layout_nn)
        root.add_widget(self.output)

        return root
Exemplo n.º 10
0
 def build(self):
     b = BoxLayout()
     b.add_widget(MyW(), MyW1(), MyW2())
     return b
Exemplo n.º 11
0
    def build(self):
        # Label
        label = Label(text='This is Batman.',
                      font_size='20sp',
                      bold=True,
                      color=(1, 1, 1, 1))

        # ---------------------------------------------------------------------
        card = MDCard()

        # ---------------------------------------------------------------------

        # Button                                    widht, height
        button = Button(text='Print this',
                        size_hint=(0.15, 0.15),
                        font_size='20sp',
                        pos_hint={
                            'center_x': 0.5,
                            'center_y': 0.5
                        },
                        on_press=self.printpress,
                        on_release=self.printrelease)

        # DEFAULT: HORIZONTAL
        btn1 = Button(text='Button1')
        btn2 = Button(text='Button2')
        btn3 = Button(text='Button3')

        layout_button = BoxLayout(orientation='vertical',
                                  spacing=10,
                                  padding=10)
        layout_button.add_widget(btn1)
        layout_button.add_widget(btn2)
        layout_button.add_widget(btn3)

        return layout_button

        # ---------------------------------------------------------------------

        # Images + Box Layout
        img = Image(source='cute.png')
        btn_img = Button(text='Login',
                         size_hint=(None, None),
                         width=100,
                         height=50,
                         pos_hint={'center_x': 0.5})

        layout_img = BoxLayout(orientation='vertical', spacing=100, padding=50)
        layout_img.add_widget(img)
        layout_img.add_widget(btn_img)

        # return layout_img

        # ---------------------------------------------------------------------

        # Grid System

        layout_grid = GridLayout(cols=2,
                                 row_force_default=True,
                                 row_default_height=40)
        btn1_grid = Button(text='Hello 1',
                           size_hint=(None, None),
                           width=100,
                           height=40)
        btn2_grid = Button(text='World 1')

        btn3_grid = Button(text='Hello 2',
                           size_hint=(None, None),
                           width=100,
                           height=40)
        btn4_grid = Button(text='World 2')

        layout_grid.add_widget(btn1_grid)
        layout_grid.add_widget(btn2_grid)
        layout_grid.add_widget(btn3_grid)
        layout_grid.add_widget(btn4_grid)

        # return layout_grid

        # ---------------------------------------------------------------------

        # Text Input
        self.weight = TextInput(text='Enter Weight Here')
        self.height = TextInput(text='Enter Height Here')

        button_input = Button(text='Submit', on_press=self.submit)

        layout_input = GridLayout(cols=2,
                                  row_force_default=True,
                                  row_default_height=40,
                                  spacing=10,
                                  padding=20)

        layout_input.add_widget(self.weight)
        layout_input.add_widget(self.height)
        layout_input.add_widget(button_input)
Exemplo n.º 12
0
    def __init__(self, **kwargs):
        super(Test, self).__init__(**kwargs)

        self.click = 0

        # rect_color = Color(1,0,0,1)
        # rect_color1 = Color(0,1,1,0.6)
        # rect = Rectangle(pos=(100,10), size=(400,300))
        # rect1 = Rectangle(pos=(400,50), size=(400,300))

        # self.wid = Widget()
        self.progress_bar = MDProgressBar()
        self.popup = Popup(title='數據加載中,請稍後!', content=self.progress_bar)
        self.popup.title_size = 30
        self.popup.title_font = 'msjhbd.ttc'
        self.popup.size_hint = [0.5, 0.5]
        self.popup.background_color = [0.5, 0.5, 0.5, 0.75]
        self.progress_bar.value = 1
        self.popup.bind(on_open=self.puopen)

        # 主畫面切成左右兩欄
        self.cols = 3
        #self.origin = MDGridLayout(cols=2, padding=[35, 0, 35, 0])

        # 左欄是一個Gridlayout,有四列
        self.left = MDGridLayout(rows=5, size_hint=[0.4, 1], spacing=[0, 3])
        # 創建地圖
        self.map = FarmersMapView()

        # 左欄最上方要來做店租範圍
        self.left.one = MDGridLayout(size=[590, 657],
                                     rows=2,
                                     size_hint=[1, 0.2],
                                     md_bg_color=[0.39, 0.4, 0.72, 1],
                                     padding=[35, -20, 35, -20],
                                     spacing=[0, -30])
        # 把標籤裝進去最上層
        self.left.one.add_widget(
            Label(text='選擇店租範圍',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  size_hint_y=0.18))
        # 新增一層容器準備裝三個東西
        self.left.one.box = BoxLayout(spacing=8, size_hint_y=0.15)
        # 盒子裝進一個下限input、一上限input、一個'-'tag
        self.lower_bound = MDTextFieldRect(x=275,
                                           hint_text="$下限",
                                           font_name='msjhbd.ttc',
                                           pos_hint={'y': 0.45},
                                           size_hint=[1, 0.5],
                                           use_bubble=True,
                                           use_handles=True)
        self.upper_bound = MDTextFieldRect(hint_text="$上限",
                                           font_name='msjhbd.ttc',
                                           pos_hint={'y': 0.45},
                                           center_x=275.76,
                                           center_y=508.20,
                                           size_hint=[1, 0.5],
                                           use_bubble=True,
                                           use_handles=True)
        self.dash_sign = MDFlatButton(text='-',
                                      font_size=30,
                                      size_hint=[1, 0.49],
                                      pos_hint={'y': 0.45})
        self.dash_sign.md_bg_color = [1, 1, 1, 1]
        self.left.one.box.add_widget(self.lower_bound)
        self.left.one.box.add_widget(self.dash_sign)
        self.left.one.box.add_widget(self.upper_bound)
        # 盒子裝回上層
        self.left.one.add_widget(self.left.one.box)

        # 這裡是畫面左欄第二格
        self.left.two = MDGridLayout(rows=2,
                                     size_hint=[1, None],
                                     size=[365, 180],
                                     md_bg_color=[0.39, 0.4, 0.72, 1])
        #self.left.two.center_y = 400
        # 把"指標排序"標籤裝進第二格子的上方
        self.left.two.add_widget(
            Label(text='指標排序',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.1]))
        # 左欄第二格下方增加一個grid容器
        self.left.two.grid = MDGridLayout(rows=3,
                                          size_hint=[1, 0.26],
                                          padding=[30, 0, 20, 0])
        self.left.two.grid.size_hint = [1, 0.26]
        self.left.two.add_widget(self.left.two.grid)
        # 準備三個box放入此grid
        self.left.two.box1 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.box2 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.box3 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.grid.add_widget(self.left.two.box1)
        self.left.two.grid.add_widget(self.left.two.box2)
        self.left.two.grid.add_widget(self.left.two.box3)
        # 處理第一個box的標籤(全用按鈕取代)、輸入
        self.left.two.btn1 = MDRaisedButton(text='      人口特性      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn1.md_bg_color = [0.55, 0.63, 0.99, 1]
        self.left.two.input1 = MDTextFieldRect(hint_text='排序:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input1.size_hint_x = None
        self.left.two.input1.width = 120
        #self.left.two.input1.right = 310
        self.left.two.box1.add_widget(self.left.two.btn1)
        self.left.two.box1.add_widget(self.left.two.input1)

        # self.left.two.btn2 = MDRaisedButton(text='薪資所得', font_name='msjhbd.ttc', font_size='16sp')
        # self.left.two.btn2.md_bg_color =  [0.48, 0.81, 0.78, 1]
        # self.left.two.input2 = TextInput(hint_text='排序:', size_hint=[1,None], size=[94,37], font_name='msjhbd.ttc')
        # self.left.two.box1.add_widget(self.left.two.btn2)
        # self.left.two.box1.add_widget(self.left.two.input2)
        # 處理第二個box的標籤(全用按鈕取代)、輸入
        self.left.two.btn3 = MDRaisedButton(text='      薪資所得      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn3.md_bg_color = [0.68, 0.82, 0.96, 1]
        self.left.two.input3 = MDTextFieldRect(hint_text='排序:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input3.size_hint_x = None
        self.left.two.input3.width = 120
        self.left.two.box2.add_widget(self.left.two.btn3)
        self.left.two.box2.add_widget(self.left.two.input3)

        # self.left.two.btn4 = MDRaisedButton(text='生活指數', font_name='msjhbd.ttc', font_size='16sp')
        # self.left.two.btn4.md_bg_color =  [0.62, 0.84, 0.51, 1]
        # self.left.two.input4 = TextInput(hint_text='排序:', size_hint=[1,None], size=[94,37], font_name='msjhbd.ttc')
        # self.left.two.box2.add_widget(self.left.two.btn4)
        # self.left.two.box2.add_widget(self.left.two.input4)
        # 處理第三個box的標籤(全用按鈕取代)、輸入
        self.left.two.btn5 = MDRaisedButton(text='      人口消長      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn5.md_bg_color = [0.5, 0.87, 0.98, 1]
        self.left.two.input5 = MDTextFieldRect(hint_text='排序:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input5.size_hint_x = None
        self.left.two.input5.width = 120
        self.left.two.box3.add_widget(self.left.two.btn5)
        self.left.two.box3.add_widget(self.left.two.input5)

        # self.left.two.btn6 = MDRaisedButton(text='薪資所得', font_name='msjhbd.ttc', font_size='16sp')
        # self.left.two.btn6.md_bg_color =  [0.81, 0.88, 0.39, 1]
        # self.left.two.input6 = TextInput(hint_text='排序:', size_hint=[1,None], size=[94,37], font_name='msjhbd.ttc')
        # self.left.two.box3.add_widget(self.left.two.btn6)
        # self.left.two.box3.add_widget(self.left.two.input6)

        # 這裡是畫面左欄第三格
        self.left.three = MDGridLayout(rows=2,
                                       md_bg_color=[0.39, 0.4, 0.72, 1],
                                       size_hint=[1, 0.57])
        # 把"指標排序"標籤裝進第二格子的上方
        self.left.three.add_widget(
            Label(text='選擇競爭對手',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.06]))

        # 左欄第三格下方增加一個grid容器
        self.left.three.grid = MDGridLayout(rows=5,
                                            size_hint=[1, 0.26],
                                            spacing=3,
                                            padding=[30, 0, 40, 0])
        self.left.three.add_widget(self.left.three.grid)
        # 準備五個box放入此grid
        self.left.three.box1 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box2 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box3 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box4 = BoxLayout(size_hint=[1, 0.05])
        #self.left.three.box5 = BoxLayout(size_hint=[1, 0.4])
        self.left.three.box6 = BoxLayout()
        self.left.three.grid.add_widget(self.left.three.box1)
        self.left.three.grid.add_widget(self.left.three.box2)
        self.left.three.grid.add_widget(self.left.three.box3)
        self.left.three.grid.add_widget(self.left.three.box4)
        #self.left.three.grid.add_widget(self.left.three.box5)
        #self.left.three.grid.add_widget(self.left.three.box6)

        # 處理第一個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn1 = MDRaisedButton(text='       早餐店         ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn1.md_bg_color = [0.55, 0.63, 0.99, 1]
        self.left.three.input1 = MDCheckbox()
        self.left.three.input1.x = 140
        #self.left.three.input1.color = [1,1,1,2]
        self.left.three.input1.selected_color = (1, 1, 1, 1)
        self.left.three.input1.unselected_color = (1, 1, 1, 1)
        self.left.three.box1.add_widget(self.left.three.btn1)
        self.left.three.box1.add_widget(self.left.three.input1)
        # 處理第二個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn2 = MDRaisedButton(text='便當、自助餐店',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn2.md_bg_color = [0.48, 0.81, 0.78, 1]
        self.left.three.input2 = MDCheckbox()
        self.left.three.input2.x = 140
        #self.left.three.input2.color = [1,1,1,2]
        self.left.three.input2.selected_color = (1, 1, 1, 1)
        self.left.three.input2.unselected_color = (1, 1, 1, 1)
        self.left.three.box2.add_widget(self.left.three.btn2)
        self.left.three.box2.add_widget(self.left.three.input2)
        # 處理第三個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn3 = MDRaisedButton(text='麵店、小吃店    ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn3.md_bg_color = [0.68, 0.82, 0.96, 1]
        self.left.three.input3 = MDCheckbox()
        self.left.three.input3.x = 140
        #self.left.three.input3.color = [1,1,1,2]
        self.left.three.input3.selected_color = (1, 1, 1, 1)
        self.left.three.input3.unselected_color = (1, 1, 1, 1)
        self.left.three.box3.add_widget(self.left.three.btn3)
        self.left.three.box3.add_widget(self.left.three.input3)
        # 處理第四個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn4 = MDRaisedButton(text='      餐館餐廳      ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn4.md_bg_color = [0.62, 0.84, 0.51, 1]
        self.left.three.input4 = MDCheckbox()
        self.left.three.input4.x = 140
        #self.left.three.input4.color = [1,1,1,2]
        self.left.three.input4.selected_color = (1, 1, 1, 1)
        self.left.three.input4.unselected_color = (1, 1, 1, 1)
        self.left.three.box4.add_widget(self.left.three.btn4)
        self.left.three.box4.add_widget(self.left.three.input4)
        # 處理第五個box的標籤(全用按鈕取代)、勾選
        # self.left.three.btn5 = MDRaisedButton(text='咖啡館', font_name='msjhbd.ttc', size_hint=[None, 1], font_size='16sp')
        # self.left.three.btn5.md_bg_color = [0.62, 0.84, 0.51, 1]
        # self.left.three.input5 = CheckBox()
        # self.left.three.input5.color = [1,1,1,2]
        # self.left.three.box5.add_widget(self.left.three.btn5)
        # self.left.three.box5.add_widget(self.left.three.input5)

        self.run_button = MDRaisedButton(text='Run')
        #self.left.three.box6.add_widget(self.run_button)

        # 製作廟宇按鈕
        self.left.four = MDGridLayout(rows=2,
                                      size_hint=[1, None],
                                      size=[365, 110],
                                      md_bg_color=[0.39, 0.4, 0.72, 1])
        self.left.four.add_widget(
            Label(text='廟宇出現與否',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.04]))
        self.left.four.box = BoxLayout(size_hint=[1, 0.035],
                                       padding=[30, 0, 40, 0])
        self.left.four.add_widget(self.left.four.box)
        self.left.four.btn = MDRaisedButton(text='          廟宇          ',
                                            font_name='msjhbd.ttc',
                                            size_hint=[None, 1],
                                            font_size='16sp')
        self.left.four.input = MDCheckbox()
        self.left.four.input.selected_color = (1, 1, 1, 1)
        self.left.four.input.unselected_color = (1, 1, 1, 1)
        self.left.four.box.add_widget(self.left.four.btn)
        self.left.four.box.add_widget(self.left.four.input)

        # 把每一層加回去
        self.left.add_widget(self.left.one)
        self.left.add_widget(self.left.two)
        self.left.add_widget(self.left.three)
        self.left.add_widget(self.left.four)
        self.add_widget(self.left)
        self.add_widget(self.map)

        #self.add_widget(self.right)
        #self.add_widget(self.right)

        # 測試用的按鈕
        #self.run_button = MDRaisedButton(text='Run')
        self.run_button.bind(on_release=self.popup.open)
        self.left.add_widget(self.run_button)
Exemplo n.º 13
0
    def update(self, dt):
        # display image from cam in opencv window
        global counter, meme_counter, meme, alarm, lookaway, memescreen, alarm_sound, notif_sound, meme_threshold, lookaway_threshold
        ret, frame = self.capture.read()
        cv2.imshow("CV2 Image", frame)
        # convert it to texture
        buf1 = cv2.flip(frame, 0)
        buf = buf1.tostring()
        texture1 = Texture.create(size=(frame.shape[1], frame.shape[0]),
                                  colorfmt='bgr')
        texture1.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
        # display image from the texture
        self.img1.texture = texture1

        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        faces = face_cascade.detectMultiScale(gray, 1.3, 5)

        # display meme
        if (meme):
            ## load meme here
            idx = random.randint(0, 4)
            meme_src = src_path + meme_dict[idx]
            box = BoxLayout(padding=10, orientation='vertical')
            subbox1 = BoxLayout(padding=10, size_hint=(1, 0.8))
            subbox2 = BoxLayout(padding=10, size_hint=(1, 0.2))

            subbox1.add_widget(Image(source=meme_src))
            dismiss_btn = Button(text='Back to work!')

            subbox2.add_widget(dismiss_btn)

            box.add_widget(subbox1)
            box.add_widget(subbox2)
            popup = Popup(title='MEME', content=box, size=(400, 400))

            dismiss_btn.bind(on_press=popup.dismiss)
            popup.open()

            # play sound. set to repeat on half the length.
            if (notif_sound):
                notif_sound.play()
            print("meme loaded!")
            meme = False
            meme_counter = meme_counter / 2

        # play alarm noise. repeat every half length
        if (alarm):
            print("WAKE UP!")
            if (alarm_sound):
                alarm_sound.play()
            alarm = False
            counter = counter / 2

        if (lookaway):
            counter += 1
            print("lookaway:", counter)

        ## find faces. find eyes and smiles within faces.
        for (x, y, w, h) in faces:
            roi_gray = gray[y:y + h, x:x + w]
            roi_color = frame[y:y + h, x:x + w]

            eyes = eye_cascade.detectMultiScale(roi_gray)
            eyes = list(eyes)

            smile = smile_cascade.detectMultiScale(roi_gray, 1.8, 8)
            smile = list(smile)

            if (len(eyes) == 2):
                for (ex, ey, ew, eh) in eyes:
                    #print("eyes")
                    cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh),
                                  (0, 255, 0), 2)
                counter = 0

            if (len(smile) >= 1):
                for (sx, sy, sw, sh) in smile:
                    cv2.rectangle(roi_color, (sx, sy), (sx + sw, sy + sh),
                                  (0, 0, 255), 2)
                meme_counter = 0
                meme = False

            else:
                if (len(eyes) > 1):
                    if (memescreen):
                        print("meme counter: ", meme_counter)
                        meme_counter += 1
                    #print(meme_counter)

        if (lookaway):
            if (counter > lookaway_threshold):
                alarm = True

        if (memescreen):
            if (meme_counter > meme_threshold):
                print("Loading meme... ")
                meme = True
Exemplo n.º 14
0
notif_sound = SoundLoader.load('sounds/notif.mp3')


# Update value of global thresholds whenever text entry is edited
def on_text1(instance, value):
    global lookaway_threshold
    lookaway_threshold = int(value) * 33


def on_text2(instance, value):
    global meme_threshold
    meme_threshold = int(value) * 33


# Global popup setup for settings page
settingslayout = BoxLayout(padding=10, orientation='vertical')
set_subbox1 = BoxLayout(padding=10, size_hint=(1, 0.4), orientation='vertical')
set_subbox2 = BoxLayout(padding=10, size_hint=(1, 0.4), orientation='vertical')
set_subbox3 = BoxLayout(padding=10,
                        size_hint=(1, 0.2),
                        orientation='horizontal')

alarm_input = TextInput(text="Enter wait time (s)", multiline=False)
alarm_label = Label(text="Enter time to wait for lookaway:")
meme_input = TextInput(text="Enter wait time (s)", multiline=False)
meme_label = Label(text="Enter time to wait for memescreen:")

alarm_input.bind(text=on_text1)
meme_input.bind(text=on_text2)

set_btn = Button(text="Save")
Exemplo n.º 15
0
 def build(self):
     #Layout principal y camara
     self.rows = 2
     self.cols = 1
     self.orientation = 'vertical'
     self.capture = cv2.VideoCapture(0)
     #self.my_camera = KivyCamera(capture=self.capture, fps=60)
     self.capture.set(cv2.CAP_PROP_FRAME_WIDTH,1280);
     self.capture.set(cv2.CAP_PROP_FRAME_HEIGHT,720);
     self.camera = KivyCamera(capture=self.capture, fps=60)
     
     self.add_widget(KivyCamera(capture=self.capture, fps=60))
     #Down Part of the frame
     LayoutBotonCaptura = FloatLayout(size_hint_x=1, size_hint_y =.4)
     #Main button to capture image
     btnCaptura = Button(text='Tomar Foto',
                        size_hint=(.15, .15),
                        pos=(20,110))
     btnCaptura.bind(on_press=self.auth)
     #Group of buttons to select the color of the image:
     LayoutBotonesColor = BoxLayout(size_hint=(.2, .8),
                                    pos=(150, 60))
     LayoutBotonesColor.orientation = 'vertical'
     lblTitleColor = Label(text='Selección de color:')
     btnColorFull = ToggleButton(text='A color', group='color', state='down')
     btnColorBN = ToggleButton(text='B/N', group='color')
     btnColorBin = ToggleButton(text='Binarizada', group='color')
     LayoutBotonesColor.add_widget(lblTitleColor)
     LayoutBotonesColor.add_widget(btnColorFull)
     LayoutBotonesColor.add_widget(btnColorBN)
     LayoutBotonesColor.add_widget(btnColorBin)
     #Group of buttons to select the format to save the image:
     LayoutBotonesFormato = BoxLayout(size_hint=(.2, .8),
                                    pos=(310, 60))
     LayoutBotonesFormato.orientation = 'vertical'
     lblTitleFormato = Label(text='Selección de formato:')
     btnColorPNG = ToggleButton(text='PNG', group='format', state='down')
     btnColorJPG = ToggleButton(text='JPG', group='format')
     btnColorGIF = ToggleButton(text='GIF', group='format')
     btnColorBMP = ToggleButton(text='BMP', group='format')
     LayoutBotonesFormato.add_widget(lblTitleFormato)
     LayoutBotonesFormato.add_widget(btnColorPNG)
     LayoutBotonesFormato.add_widget(btnColorJPG)
     LayoutBotonesFormato.add_widget(btnColorGIF)
     LayoutBotonesFormato.add_widget(btnColorBMP)
     #Group of buttons to select the size
     LayoutBotonesRes = BoxLayout(size_hint=(.2, .8),
                                    pos=(500, 60))
     LayoutBotonesRes.orientation = 'vertical'
     lblTitleRes = Label(text='Resolucion:')
     btnColor720 = ToggleButton(text='1280x720', group='size', state='down')
     btnColor480 = ToggleButton(text='800x600', group='size')
     btnColor360 = ToggleButton(text='640x360', group='size')
     LayoutBotonesRes.add_widget(lblTitleRes)
     LayoutBotonesRes.add_widget(btnColor720)
     LayoutBotonesRes.add_widget(btnColor480)
     LayoutBotonesRes.add_widget(btnColor360)
     #Adding Layouts to lower layout
     LayoutBotonCaptura.add_widget(btnCaptura)
     LayoutBotonCaptura.add_widget(LayoutBotonesColor)
     LayoutBotonCaptura.add_widget(LayoutBotonesFormato)
     LayoutBotonCaptura.add_widget(LayoutBotonesRes)
     self.add_widget(LayoutBotonCaptura)
     return self
Exemplo n.º 16
0
    def set_page(self, task, result, result_type='text', footer='time'):
        '''Creates a :mod:`main.PageBox` for a result. The header consists of the
        :ref:`task`'s name, the footer is by default the time when the result
        was created and the content depends on `result_type` which can be -
        text, image(path to image) or widget. If `result_type == 'widget'`,
        result has to be an instance of a widget (obviously containing the
        output), e.g.::

            b = Button(text='my output')
            set_page('MyTask', b, result_type='widget')

        .. note:: When exporting pages, everything is converted into images
           (pngs), therefore making fancy behaving widgets is irrelevant.

        .. versionadded:: 0.2.0

        .. versionchanged:: 0.3.2
           Added tables as a result type.
        '''
        page = PageBox()
        head = PaperLabel(text=task, size_hint_y=None, height='30dp')

        if result_type == 'text':
            content = PaperLabel(text=result)
        elif result_type in ['image', 'import']:
            content = Image(source=result)
        elif 'table' in result_type:
            # result == list of values
            box = BoxLayout(orientation='vertical')
            grid = ResultGrid(cols=int(result_type.strip('table')),
                              padding=1, spacing=1, size_hint=[0.95, None],
                              pos_hint={'center_x': 0.5})
            grid.bind(minimum_height=grid.setter('height'))

            for value in result:
                if isinstance(value, (float, int)):
                    val = repr(value)
                else:
                    val = str(value)
                grid.add_widget(Wrap(text=val, color=[0, 0, 0, 1],
                                     background_color=[1, 1, 1, 1],
                                     padding_x=3))

            box.add_widget(Widget())
            box.add_widget(grid)
            box.add_widget(Widget())
            content = box

        elif result_type == 'widget':
            content = result

        # turn off with footer=None
        if result_type == 'import':
            pass
        elif not footer:
            foot = PaperLabel(size_hint_y=None, height='30dp')
        else:
            if footer == 'time':
                t = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
                foot = PaperLabel(text=t,
                                  size_hint_y=None,
                                  height='30dp')
            else:
                foot = PaperLabel(text=footer, size_hint_y=None,
                                  height='30dp')

        if not result_type == 'import':
            page.add_widget(head)
            page.add_widget(content)
            page.add_widget(foot)
        else:
            page.add_widget(content)
        self.ids.results.add_widget(page, 1)

        panel = self.ids.resultspanel
        if panel.width == panel.min_size:
            panel.width = panel.max_size
Exemplo n.º 17
0
    def build(self):

        self.pantalla = GridLayout(orientation='vertical',
                                   spacing=10,
                                   padding=10,
                                   rows=5)
        self.cintillo = BoxLayout(orientation='horizontal')
        label_cintillo = Label(text="Buscando...", font_size=40)
        self.cintillo.add_widget(label_cintillo)
        self.pantalla.add_widget(self.cintillo)

        self.cintillo2 = BoxLayout(orientation='horizontal')
        label_cedula = Label(text="Cédula:", font_size=20)
        text_cedula = TextInput(multiline=False, font_size=30)
        self.cintillo2.add_widget(label_cedula)
        self.cintillo2.add_widget(text_cedula)
        self.pantalla.add_widget(self.cintillo2)

        self.cintillo3 = BoxLayout(orientation='vertical')
        label_salida1 = Label(text="", font_size=20)
        self.cintillo3.add_widget(label_salida1)
        label_salida2 = Label(text="", font_size=20)
        self.cintillo3.add_widget(label_salida2)
        self.pantalla.add_widget(self.cintillo3)

        self.cintillo_botones = BoxLayout(orientation='horizontal')
        btn_imprimir = Button(text="Imprimir")
        btn_buscar = Button(text="Buscar")
        btn_cerrar = Button(text="Cerrar")
        btn_limpiar = Button(text="Limpiar")
        self.cintillo_botones.add_widget(btn_limpiar)
        self.cintillo_botones.add_widget(btn_imprimir)
        self.cintillo_botones.add_widget(btn_buscar)
        self.cintillo_botones.add_widget(btn_cerrar)
        self.pantalla.add_widget(self.cintillo_botones)

        def buscar(text):
            a = str(text_cedula.text)
            if a == "":
                texto_error = '''
\nChequee el dato cédula en campo correspondiente\nPosiblemente nos sea correcto
o este vacio\n\n\n\nclic fuera de este mensaje para volver'''
                popup = Popup(title=' Datos Incompletos...Chequee por favor ',
                              content=Label(text=texto_error),
                              size_hint=(None, None),
                              size=(400, 350))
                popup.open()
            else:
                cursor.execute(
                    "SELECT cedula, nombre_apellido from datos WHERE cedula ='"
                    + a + "'")
                #text_cedula.text=""
                cnn_db.commit()
                for raw in cursor:
                    label_salida1.text = ("Cédula: " + str(raw[0]))
                    label_salida2.text = ("Nombre y Apellido: " + raw[1])

        btn_buscar.bind(on_press=buscar)

        def Imprimir(Button):
            ver = str(label_salida1.text)
            if ver == "":
                texto_error = '''
\nChequee la busqueda correspondiente\nno hay datos que imprimir\n\n\n\nclic fuera de este mensaje para volver'''
                popup = Popup(title=' Error ',
                              content=Label(text=texto_error),
                              size_hint=(None, None),
                              size=(400, 350))
                popup.open()
            else:
                salida_texto1 = text_cedula.text
                salida_texto2 = label_salida2.text
                print(salida_texto1)
                print(salida_texto2)
                documento = canvas.Canvas("salida.pdf")

                def generar(documento):
                    documento.drawString(100, 700, "Resultado de la Búsqueda")
                    documento.drawString(100, 680,
                                         "En esta sección se muestran")
                    documento.drawString(100, 660,
                                         "_____________________________")
                    documento.drawString(100, 640, "Los Dato Son...")
                    documento.drawString(100, 620,
                                         "la cedula es: " + salida_texto1)
                    documento.drawString(100, 600, salida_texto2)
                    documento.drawString(100, 580,
                                         "______________________________")

                generar(documento)
                documento.showPage()
                documento.save()
                text_cedula.text = ""
                label_salida1.text = ""
                label_salida2.text = ""
                return os.popen("/usr/bin/evince-previewer salida.pdf")

        btn_imprimir.bind(on_press=Imprimir)

        #falta colocar datos aqui del pdf creado e imprimir

        def limpiar(self):
            text_cedula.text = ""
            label_salida1.text = ""
            label_salida2.text = ""

        btn_limpiar.bind(on_release=limpiar)

        def cancel(self):
            cnn_db.close()
            print("Close DataBase")
            registroApp().stop()
            sys.exit()

        btn_cerrar.bind(on_press=cancel)

        return self.pantalla
Exemplo n.º 18
0
class DatasetApp(App):
    img1 = Image(source = 'main.png')
    layout = BoxLayout(orientation='vertical')
    img1.pos = (0,layout.height)
    img_vector = []
    proporcao = 0
    dropped = False
    count = 0
    tl = []
    br = []
    labels = []
    save_result = {}
    the_path = 0
    ipt1 = TextInput(size_hint_y=None,
                         height = 40,
                         font_size = 25)
    btn1 = Button(text="Pular Imagem", height=40, size_hint_y=None)
    btn2 = Button(text="Save", height=40, size_hint_y = None)
    btn3 = Button(text="Voltar", height=40, size_hint_y = None)
    First = True

    def build(self):
        Window.bind(on_dropfile=self._on_file_drop)
        Window.bind(on_motion=self.on_motion)
        self.btn1.bind(on_press=self._update_image)
        self.btn2.bind(on_press=self.save)
        self.btn3.bind(on_press=self.volta)

        h, w, channels = scipy.ndimage.imread('main.png').shape
        ratio = w/h
        Window.size = (ratio*500, 500 + _DOWN_)

        self.layout.add_widget(self.img1)
        self.layout.add_widget(self.ipt1)
        self.layout.add_widget(self.btn1)
        self.layout.add_widget(self.btn3)
        self.layout.add_widget(self.btn2)
        return self.layout

    def _on_file_drop(self, window, file_path):
        self.count = 0
        path = file_path.decode("utf-8")
        self.the_path = path
        for filename in os.listdir(path):
            if filename.endswith(".jpg"):
                self.img_vector.append(path+'/'+filename)
        self.dropped = True
        if os.path.isfile(path+'/labels.txt'):
            with open(path+'/img_vector.txt', "rb") as input:
                self.img_vector = pickle.load(input)
            with open(path+'/labels.txt', "rb") as input:
                self.labels = pickle.load(input)
            with open(path+'/tl.txt', "rb") as input:
                self.tl = pickle.load(input)
            with open(path+'/br.txt', "rb") as input:
                self.br = pickle.load(input)
            self.count = len(self.labels)
            print(self.count, self.labels, self.tl, self.br, self.img_vector)
        self._update_image()
        return

    def _update_image(self, *args):
        if(self.count <= len(self.img_vector) and self.dropped):
            if (self.count < len(self.img_vector)):
                self.img1.source = self.img_vector[self.count]

                h, w, channels = scipy.ndimage.imread(self.img_vector[self.count]).shape
                ratio = w/h
                Window.size = (ratio*500, 500 + _DOWN_)
                self.proporcao = h/500

            if self.First:
                self.First = False
            else:
                if (len(self.tl) < self.count):
                    self.tl.append((0,0))
                    self.br.append((0,0))
                    self.labels.append(0)

            self.count = self.count+1
            print(self.count)
        else:
            print("Cabou imagens!")
        return

    def on_motion(self, etype, motionevent, *args):
        if((etype.mouse_pos[1] >= _DOWN_) and not self.First):
            x = etype.mouse_pos[0]
            y = etype.mouse_pos[1] - _DOWN_

            if (motionevent == 'begin'):
                self.tl.append((int(x*self.proporcao), int(y*self.proporcao)))
            if (motionevent == 'end'):
                self.br.append((int(x*self.proporcao), int(y*self.proporcao)))
                self.labels.append(self.ipt1.text)
                self._update_image()
                print("DEU BOM!")
        return

    def save(self, *args):
        print(self.img_vector, self.labels, self.tl, self.br)
        for i in range(len(self.labels)):
            save = {i: {'location':self.img_vector[i],'label': self.labels[i], 'topleft': {'x': self.tl[i][0], 'y': self.tl[i][1]}, 'bottomright': {'x': self.br[i][0], 'y': self.br[i][1]}} }
            self.save_result.update(save)
        with open(self.the_path+'/img_vector.txt', 'wb') as f:
            pickle.dump(self.img_vector, f)
        with open(self.the_path+'/labels.txt', 'wb') as f:
            pickle.dump(self.labels, f)
        with open(self.the_path+'/tl.txt', 'wb') as f:
            pickle.dump(self.tl, f)
        with open(self.the_path+'/br.txt', 'wb') as f:
            pickle.dump(self.br, f)
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(self.save_result)
        return

    def volta(self, *args):
        self.count = self.count - 2
        self._update_image()
        self.img_vector.insert(self.count, self.img_vector[self.count-1])
        self.count = self.count + 1
        return
    def build(self):
        """Build the user interface."""

        wid = Widget()
        self.myWid = MyWidget()
        wid.add_widget(self.myWid)

        self.counter = Label(text="0")
        labelA = Label(text=self.get_scores()[0])
        labelB = Label(text=self.get_scores()[1])
        labels = (labelA, labelB)
        self.labels = labels
        self.wid = wid

        self.agentA_spinner = Spinner(
            text='Agent A',
            text_size=(95, None),
            haligh="center",
            shorten=True,
            values=sorted([agent
                           for agent in ALL_AGENTS.keys()]) + ["Agent A"],
            size=(100, 44))

        agentB_spinner = Spinner(
            text='Agent B',
            text_size=(95, None),
            shorten=True,
            values=sorted([agent
                           for agent in ALL_AGENTS.keys()]) + ["Agent B"],
            size=(100, 44))

        self.maps_spinner = Spinner(
            text='Maps',
            text_size=(95, None),
            shorten=True,
            values=sorted([map for map in ALL_MAPS.keys()]) + ["Maps"],
            size=(100, 44))

        self.agentA_spinner.bind(text=self.select_agent_A)
        agentB_spinner.bind(text=self.select_agent_B)
        self.maps_spinner.bind(text=self.select_map)

        btn_load = Button(text='Load',
                          on_press=partial(self.load_env, labels, wid))

        btn_step = Button(text='Step >',
                          on_press=partial(self.btn_step, labels, wid))

        self.btn_100step = ToggleButton(text='100 Step >',
                                        on_press=partial(
                                            self.btn_100step,
                                            self.running_step, labels, wid))

        self.btn_run = ToggleButton(text='Run >>',
                                    on_press=partial(self.btn_run,
                                                     self.running_step, labels,
                                                     wid))

        btn_stop = Button(text='Stop [ ]',
                          on_press=partial(self.btn_stop, self.running_step))

        self.partial_reset = partial(
            self.reset_all, labels,
            (self.agentA_spinner, agentB_spinner, self.maps_spinner), wid)

        btn_reset = Button(text='Reset', on_press=self.partial_reset)

        Window.bind(on_resize=self.on_resize)

        action_layout = BoxLayout(size_hint=(1, None), height=50)
        action_layout.add_widget(btn_load)
        action_layout.add_widget(btn_step)
        action_layout.add_widget(self.btn_100step)
        action_layout.add_widget(self.counter)
        action_layout.add_widget(self.btn_run)
        action_layout.add_widget(btn_stop)
        action_layout.add_widget(btn_reset)

        agents_layout = BoxLayout(size_hint=(1, None), height=50)
        agents_layout.add_widget(self.agentA_spinner)
        agents_layout.add_widget(labelA)
        agents_layout.add_widget(agentB_spinner)
        agents_layout.add_widget(labelB)
        agents_layout.add_widget(self.maps_spinner)

        root = BoxLayout(orientation='vertical')
        root.add_widget(wid)
        root.add_widget(action_layout)
        root.add_widget(agents_layout)

        return root
Exemplo n.º 20
0
    def build(self):

        global loaded

        city = BoxLayout(orientation='vertical',
                         size=(ttLength, ttLength),
                         size_hint=(None, None))
        window = Widget(size_hint=(1, 1))

        for x in range(0, citySize):
            row = BoxLayout(orientation='horizontal',
                            size=(ttLength, roadWidth * abs(x % 2 - 1) +
                                  roadLength * 40 * 2 * (x % 2)),
                            size_hint=(None, None))
            currentMat.append([])
            for y in range(0, citySize):
                if x % 2 == 0 and y % 2 == 0:  # intersec
                    currentMat[x + 1][y + 1] = [[{}, {}, {}, {}],
                                                [{}, {}, {}, {}],
                                                [{}, {}, {}, {}],
                                                [{}, {}, {}, {}]]
                    inter = Intersec(roadWidth=roadWidth,
                                     xPos=x + 1,
                                     yPos=y + 1)
                    row.add_widget(inter)
                    caseClasses[x][y] = inter
                elif y % 2 == 1 and x % 2 == 0:  # horizontal road
                    currentMat[x + 1][y + 1] = [[{}, {}], [{}, {}]]
                    for road in currentMat[x + 1][y + 1]:
                        for way in road:
                            for i in range(roadLength):
                                way[i] = None
                            way[roadLength - 1] = {0: None}
                    hRoad = HorizRoad(roadWidth=roadWidth,
                                      roadLength=roadLength,
                                      xPos=x + 1,
                                      yPos=y + 1)
                    row.add_widget(hRoad)
                    caseClasses[x][y] = hRoad
                elif x % 2 == 1 and y % 2 == 0:  # vertical road
                    currentMat[x + 1][y + 1] = [[{}, {}], [{}, {}]]
                    for road in currentMat[x + 1][y + 1]:
                        for way in road:
                            for i in range(roadLength - 1):
                                way[i] = None
                            way[roadLength - 1] = {0: None}
                    vRoad = VertRoad(roadWidth=roadWidth,
                                     roadLength=roadLength,
                                     xPos=x + 1,
                                     yPos=y + 1)
                    row.add_widget(vRoad)
                    caseClasses[x][y] = vRoad
                else:
                    currentMat[x + 1][y + 1] = "Empty"
                    row.add_widget(
                        Grass(size=(roadLength * 40 * 2, roadLength * 40 * 2)))
            city.add_widget(row)
        loaded = True
        scatter = Scatter(do_rotation=False,
                          scale=0.5,
                          auto_bring_to_front=False,
                          size=(ttLength, ttLength))
        scatter.add_widget(city)
        statWidget = Stats()
        window.add_widget(statWidget, 0)
        window.add_widget(scatter, 1)
        Clock.schedule_interval(partial(self.doStuff, scatter, statWidget),
                                1 / 120)
        threading.Thread(target=self.initGraph).start()
        return window
Exemplo n.º 21
0
    def build(self):
        self.formula = '0'
        bl = BoxLayout(orientation='vertical')
        gl = GridLayout(cols=4, rows=6, padding=[5], spacing=3, row_force_default=True, row_default_height=52.65)

        self.lbl = Label(text='0',
                         font_size=40,
                         halign='right',
                         size_hint=(1, .4),
                         text_size=(300 - 10, 400 * .4 - 10),
                         valign='center')
        gl.add_widget(
            Button(text='\u00a8', on_press=self.menu, background_color=[.65, .65, .65, 1], background_normal='',
                   font_size=35))
        gl.add_widget(
            Button(text='√', on_press=self.add_operation, background_color=[1, .58, 0, 1], background_normal='',
                   font_size=21))
        gl.add_widget(
            Button(text='÷', on_press=self.add_operation, background_color=[1, .58, 0, 1], background_normal='',
                   font_size=21))
        gl.add_widget(
            Button(text='\u00ab', on_press=self.clear_one, background_color=[1, .58, 0, 1], background_normal='',
                   font_size=25))

        gl.add_widget(Button(text='7', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(Button(text='8', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(Button(text='9', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(
            Button(text='x', on_press=self.add_operation, background_color=[1, .58, 0, 1], background_normal='',
                   font_size=21))

        gl.add_widget(Button(text='4', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(Button(text='5', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(Button(text='6', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(
            Button(text='-', on_press=self.add_operation, background_color=[1, .58, 0, 1], background_normal='',
                   font_size=30))

        gl.add_widget(Button(text='1', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(Button(text='2', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(Button(text='3', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(
            Button(text='+', on_press=self.add_operation, background_color=[1, .58, 0, 1], background_normal='',
                   font_size=21))

        gl.add_widget(
            Button(text='00', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                   font_size=21))
        gl.add_widget(Button(text='0', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(Button(text='.', on_press=self.add_number, background_color=[.2, .2, .2, 1], background_normal='',
                             font_size=21))
        gl.add_widget(
            Button(text='=', on_press=self.result, background_color=[1, .58, 0, 1], background_normal='', font_size=21))

        bl.add_widget(self.lbl)
        bl.add_widget(gl)
        return bl
Exemplo n.º 22
0
    def build(self):
        mainlayout = BoxLayout(orientation='vertical',padding=10,spacing=5)
        layout= GridLayout(cols=4)

        self.label = Label(text="")
        layout.add_widget(self.label)
        label= Label(text="BMI", font_size='40sp')
        layout.add_widget(label)
        label0= Label(text="Calculator", font_size='40sp')
        layout.add_widget(label0)
        self.label = Label(text="")
        layout.add_widget(self.label)
        mainlayout.add_widget(layout)


        self.label = Label(text="")
        mainlayout.add_widget(self.label)

        layout= GridLayout(cols=4)
        self.label = Label(text="")
        layout.add_widget(self.label)
        self.label1 = Label(text="Weight")
        layout.add_widget(self.label1)
        self.wt= TextInput(text='', multiline=False)
        layout.add_widget(self.wt)
        self.label2 = Label(text="kg")
        layout.add_widget(self.label2)
        mainlayout.add_widget(layout)

        layout= GridLayout(cols=4)
        self.label = Label(text="")
        layout.add_widget(self.label)
        self.label3 = Label(text="Height")
        layout.add_widget(self.label3)
        self.ht= TextInput(text='', multiline=False)
        layout.add_widget(self.ht)
        self.label4 = Label(text="cm")
        layout.add_widget(self.label4)
        mainlayout.add_widget(layout)

        self.label = Label(text="")
        mainlayout.add_widget(self.label)

        layout= GridLayout(cols=5)
        self.label = Label(text="")
        layout.add_widget(self.label)
        self.label = Label(text="")
        layout.add_widget(self.label)
        btn_calc = Button(text="Calculate BMI")
        btn_calc.background_normal=""
        btn_calc.background_color=[0,1,0,0.5]
        btn_calc.bind(on_press=self.calc)
        layout.add_widget(btn_calc)
        self.label = Label(text="")
        layout.add_widget(self.label)
        self.label = Label(text="")
        layout.add_widget(self.label)
        mainlayout.add_widget(layout)

        layout= GridLayout(cols=4)
        self.label = Label(text="")
        layout.add_widget(self.label)
        self.label5=Label(text="Your Body Mass Index is :")
        layout.add_widget(self.label5)
        self.label7 = Label(text="")
        layout.add_widget(self.label7)
        self.label = Label(text="")
        layout.add_widget(self.label)
        mainlayout.add_widget(layout)

        layout= GridLayout(cols=4)
        self.label = Label(text="")
        layout.add_widget(self.label)
        self.label6=Label(text="You are :")
        layout.add_widget(self.label6)
        self.label9 = Label(text="")
        layout.add_widget(self.label9)
        self.label = Label(text="")
        layout.add_widget(self.label)
        mainlayout.add_widget(layout)

        self.label = Label(text="")
        mainlayout.add_widget(self.label)
        self.label = Label(text="")
        mainlayout.add_widget(self.label)
        
        return mainlayout
Exemplo n.º 23
0
    except:
        return False


def compute_size(maxs, imgw, imgh):
    if imgw > imgh:
        return maxs, maxs * imgh / imgw
    else:
        return maxs * imgw / imgh, maxs


if __name__ == "__main__":
    from kivy.base import runTouchApp
    from kivy.uix.boxlayout import BoxLayout
    from kivy.uix.label import Label

    box = BoxLayout(orientation="vertical", width=800, height=480)
    fileChooser = FileChooserThumbView(thumbsize=64, size_hint=(1.0, 0.8))
    label = Label(markup=True, size_hint=(1, 0.2))
    fileChooser.mylabel = label

    box.add_widget(fileChooser)
    box.add_widget(label)

    def setlabel(instance, value):
        instance.mylabel.text = "[b]Selected:[/b] {0}".format(value)

    fileChooser.bind(selection=setlabel)

    runTouchApp(box)
Exemplo n.º 24
0
    def build(self):
        self.container = ContainerLayout()

        self.grid = MainLayout()
        self.grid.cols = 1
        self.connect_layout = BoxLayout(orientation="horizontal",
                                        size_hint_y=None,
                                        height=30)
        # top part
        server_label = ServerLabel()
        self.connect_layout.add_widget(server_label)
        self.server_connect_bar = ConnectBarTextInput(text="archipelago.gg",
                                                      size_hint_y=None,
                                                      height=30,
                                                      multiline=False,
                                                      write_tab=False)
        self.server_connect_bar.bind(
            on_text_validate=self.connect_button_action)
        self.connect_layout.add_widget(self.server_connect_bar)
        self.server_connect_button = Button(text="Connect",
                                            size=(100, 30),
                                            size_hint_y=None,
                                            size_hint_x=None)
        self.server_connect_button.bind(on_press=self.connect_button_action)
        self.connect_layout.add_widget(self.server_connect_button)
        self.grid.add_widget(self.connect_layout)
        self.progressbar = ProgressBar(size_hint_y=None, height=3)
        self.grid.add_widget(self.progressbar)

        # middle part
        self.tabs = TabbedPanel(size_hint_y=1)
        self.tabs.default_tab_text = "All"
        self.log_panels["All"] = self.tabs.default_tab_content = UILog(
            *(logging.getLogger(logger_name)
              for logger_name, name in self.logging_pairs))

        for logger_name, display_name in self.logging_pairs:
            bridge_logger = logging.getLogger(logger_name)
            panel = TabbedPanelItem(text=display_name)
            self.log_panels[display_name] = panel.content = UILog(
                bridge_logger)
            self.tabs.add_widget(panel)

        self.grid.add_widget(self.tabs)

        if len(self.logging_pairs) == 1:
            # Hide Tab selection if only one tab
            self.tabs.clear_tabs()
            self.tabs.do_default_tab = False
            self.tabs.current_tab.height = 0
            self.tabs.tab_height = 0

        # bottom part
        bottom_layout = BoxLayout(orientation="horizontal",
                                  size_hint_y=None,
                                  height=30)
        info_button = Button(height=30, text="Command:", size_hint_x=None)
        info_button.bind(on_release=self.command_button_action)
        bottom_layout.add_widget(info_button)
        self.textinput = TextInput(size_hint_y=None,
                                   height=30,
                                   multiline=False,
                                   write_tab=False)
        self.textinput.bind(on_text_validate=self.on_message)

        def text_focus(event):
            """Needs to be set via delay, as unfocusing happens after on_message"""
            self.textinput.focus = True

        self.textinput.text_focus = text_focus
        bottom_layout.add_widget(self.textinput)
        self.grid.add_widget(bottom_layout)
        self.commandprocessor("/help")
        Clock.schedule_interval(self.update_texts, 1 / 30)
        self.container.add_widget(self.grid)
        return self.container
 def build(self):
     return BoxLayout()
Exemplo n.º 26
0
    "background": ""
}

environ['KIVY_GL_BACKEND'] = 'pygame'

Config.set("kivy", "log_enable", 0)
Config.write()


class MyLayout(BoxLayout):
    def __init__(self, *args, **kwargs):
        BoxLayout.__init__(self, *args, **kwargs)


###   ###   ###   ###   ###  Export confirmation popup ###   ###   ###   ###   ###
export_layout = BoxLayout(orientation="vertical", padding=[0.1, 0.1, 0.1, 0.1])
eBtn_layout = BoxLayout(orientation="horizontal", size_hint=(1, 0.4))
eLabl = Label(text="Export selected document to pdf?", size_hint=(1, 0.6))
eBtn1 = Button(text="Yes", size_hint=(0.5, 1))
eBtn2 = Button(text="No", size_hint=(0.5, 1))
export_layout.add_widget(eLabl)
eBtn_layout.add_widget(eBtn1)
eBtn_layout.add_widget(eBtn2)
export_layout.add_widget(eBtn_layout)

export_popup = Popup(title="Export to pdf",
                     content=export_layout,
                     size_hint=(None, None),
                     size=(400, 200))
###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###   ###
Exemplo n.º 27
0
        def build(self):
            b = BoxLayout(orientation='vertical')
            # example of a custom theme
            colors = itertools.cycle(
                [rgb('7dac9f'),
                 rgb('dc7062'),
                 rgb('66a8d4'),
                 rgb('e5b060')])
            graph_theme = {
                'label_options': {
                    'color': rgb('444444'),
                    'bold': True
                },
                'background_color': rgb('f8f8f2'),
                'tick_color': rgb('808080'),
                'border_color': rgb('808080')
            }

            graph = Graph(xlabel='Cheese',
                          ylabel='Apples',
                          x_ticks_minor=5,
                          x_ticks_major=25,
                          y_ticks_major=1,
                          y_grid_label=True,
                          x_grid_label=True,
                          padding=5,
                          xlog=False,
                          ylog=False,
                          x_grid=True,
                          y_grid=True,
                          xmin=-50,
                          xmax=50,
                          ymin=-1,
                          ymax=1,
                          **graph_theme)

            plot = SmoothLinePlot(color=next(colors))
            plot.points = [(x / 10., sin(x / 50.)) for x in range(-500, 501)]
            graph.add_plot(plot)

            plot = MeshLinePlot(color=next(colors))
            plot.points = [(x / 10., cos(x / 50.)) for x in range(-600, 501)]
            graph.add_plot(plot)
            self.plot = plot

            plot = MeshStemPlot(color=next(colors))
            graph.add_plot(plot)
            plot.points = [(x, x / 50.) for x in range(-50, 51)]

            Clock.schedule_interval(self.update_points, 1 / 60.)

            graph2 = Graph(xlabel='Position (m)',
                           ylabel='Time (s)',
                           x_ticks_minor=0,
                           x_ticks_major=1,
                           y_ticks_major=10,
                           y_grid_label=True,
                           x_grid_label=True,
                           padding=5,
                           xlog=False,
                           ylog=False,
                           xmin=0,
                           ymin=0,
                           **graph_theme)
            b.add_widget(graph)

            if np is not None:
                omega = 2 * pi / 30
                k = (2 * pi) / 2.0

                npoints = 100
                data = np.ones((npoints, npoints))

                position = [ii * 0.1 for ii in range(npoints)]
                time = [ii * 0.6 for ii in range(npoints)]

                for ii, t in enumerate(time):
                    for jj, x in enumerate(position):
                        data[ii, jj] = sin(k * x + omega * t) + sin(-k * x +
                                                                    omega * t)

                # This is required to fit the graph to the data extents
                graph2.xmax = max(position)
                graph2.ymax = max(time)

                plot = ContourPlot()
                plot.data = data
                plot.xrange = [min(position), max(position)]
                plot.yrange = [min(time), max(time)]
                plot.color = [1, 0.7, 0.2, 1]
                graph2.add_plot(plot)

                b.add_widget(graph2)

            return b
Exemplo n.º 28
0
    def questionnaire(self, dictionary, lbl, instance):

        # ============== questionnaire form ==============
        lay_quest = BoxLayout(orientation='horizontal')

        popup = Popup(title="Questionnaire", content=lay_quest, size=(400, 400), size_hint=(None, None))

        lay_quest_lbls = BoxLayout(orientation='vertical')
        lay_quest_lbls.add_widget(Label(text='First name:'))
        lay_quest_lbls.add_widget(Label(text='Last name:'))
        lay_quest_lbls.add_widget(Label(text='Date of birth:'))
        lay_quest_lbls.add_widget(Label(text='Phone number:'))
        lay_quest_lbls.add_widget(Label(text='Work place'))
        lay_quest_lbls.add_widget(Label(text='Family members:'))
        lay_quest_lbls.add_widget(Label(text='College:'))
        lay_quest_lbls.add_widget(Label(text='School:'))
        lay_quest_lbls.add_widget(Label(text='Email:'))

        lay_quest_fields = BoxLayout(orientation='vertical')

        self.qst_fname = TextInput(text='', size_hint=(1, .05), multiline=False,
                                   on_text_validate=partial(self.on_dismiss_quest, dictionary))
        self.qst_lname = TextInput(text='', size_hint=(1, .05), multiline=False,
                                   on_text_validate=partial(self.on_dismiss_quest, dictionary))
        self.qst_dateofbirth = TextInput(text='', size_hint=(1, .05), multiline=False,
                                         on_text_validate=partial(self.on_dismiss_quest, dictionary))
        self.qst_phone_number = TextInput(text='', size_hint=(1, .05), multiline=False,
                                          on_text_validate=partial(self.on_dismiss_quest, dictionary))
        self.qst_workplace = TextInput(text='', size_hint=(1, .05), multiline=False,
                                       on_text_validate=partial(self.on_dismiss_quest, dictionary))
        # add a button to add a member
        self.qst_family_members = TextInput(text='', size_hint=(1, .05), multiline=False,
                                            on_text_validate=partial(self.on_dismiss_quest, dictionary))
        self.qst_college = TextInput(text='', size_hint=(1, .05), multiline=False,
                                     on_text_validate=partial(self.on_dismiss_quest, dictionary))
        self.qst_school = TextInput(text='', size_hint=(1, .05), multiline=False,
                                    on_text_validate=partial(self.on_dismiss_quest, dictionary))
        self.qst_email = TextInput(text='', size_hint=(1, .05), multiline=False,
                                   on_text_validate=partial(self.on_dismiss_quest, dictionary))
        lay_quest_fields.add_widget(self.qst_fname)
        lay_quest_fields.add_widget(self.qst_lname)
        lay_quest_fields.add_widget(self.qst_dateofbirth)
        lay_quest_fields.add_widget(self.qst_phone_number)
        lay_quest_fields.add_widget(self.qst_workplace)
        lay_quest_fields.add_widget(self.qst_family_members)
        lay_quest_fields.add_widget(self.qst_college)
        lay_quest_fields.add_widget(self.qst_school)
        lay_quest_fields.add_widget(self.qst_email)

        lay_quest_btns = StackLayout(orientation='bt-lr', spacing=10, padding=[10, 10])
        btn_ok_quest = Button(text='Submit',
                              size_hint=(1, .1),
                              on_press=partial(self.on_dismiss_quest, dictionary, popup, lbl))
        btn_cancel_quest = Button(text='Cancel',
                                  size_hint=(1, .1),
                                  on_press=lambda *x: popup.dismiss())
        lay_quest_btns.add_widget(btn_cancel_quest)
        lay_quest_btns.add_widget(btn_ok_quest)

        lay_quest.add_widget(lay_quest_lbls)
        lay_quest.add_widget(lay_quest_fields)
        lay_quest.add_widget(lay_quest_btns)

        popup.open()
Exemplo n.º 29
0
            def __init__(self, **kwargs):
                super(Screen_One, self).__init__(**kwargs)
                self.name = 'One'

                #Different colors convey different chip statuses
                rimg = Image(source='red.png')
                gimg = Image(source='green.png')
                yimg = Image(source='yellow.png')
                bimg = Image(source='gray.png')
                curimg = bimg

                #Do not run test by default
                killedAlready = True

                #Checks the state of .txt file
                def docheck(obj, *args):
                    checkval = 10
                    if abs(myChip.count) < checkval or keep.active == True:
                        nonlocal curimg
                        curimg = myChip.check(rimg, gimg, yimg, bimg)
                        Fimg.clear_widgets()
                        Fimg.add_widget(begEcho)
                        Fimg.add_widget(curimg)
                    else:
                        if myChip.testtime:
                            os.system('./killall_measurements')
                            myChip.testtime = False

                #Set voltage on voltage suppl(y/ies)
                def setVoltage(obj):
                    if findByID(s1, '6state1').active:
                        mySupply.setSequence('P6V',
                                             findByID(s1, '6sup1').text,
                                             mySupply.curmax)
                        time.sleep(0.2)
                    if findByID(s1, '25state1').active:
                        mySupply.setSequence('P25V',
                                             findByID(s1, '25sup1').text,
                                             mySupply.curmax)

                #Boxes that contain voltage supply-setting elements
                class Vbox(BoxLayout):
                    def __init__(self, **kwargs):
                        # make sure we aren't overriding any important functionality
                        super(Vbox, self).__init__(**kwargs)

                        with self.canvas.before:
                            Color(
                                0, .2, .3, 1
                            )  # green; colors range from 0-1 instead of 0-255
                            self.rect = Rectangle(size=self.size, pos=self.pos)

                            self.bind(size=self._update_rect,
                                      pos=self._update_rect)

                    def _update_rect(self, instance, value):
                        self.rect.pos = instance.pos
                        self.rect.size = instance.size

                #Nested layouts
                Fouter = BoxLayout(orientation='horizontal',
                                   padding=[0, 0, 0, 0])
                Finner = BoxLayout(orientation='vertical',
                                   padding=[50, 50, 50, 50],
                                   spacing=40)
                Finner2 = BoxLayout(orientation='vertical',
                                    padding=[30, 30, 30, 30],
                                    spacing=20)
                Finner3 = BoxLayout(orientation='vertical',
                                    padding=[30, 30, 30, 30],
                                    spacing=20)
                Fvwrite = BoxLayout(orientation='horizontal',
                                    padding=[0, 0, 0, 0],
                                    spacing=0,
                                    size_hint_y=None,
                                    height=45)
                #FINNER2
                #Power supply control sections
                vlay = Vbox(orientation='vertical',
                            padding=[10, 10, 10, 10],
                            spacing=10)
                vlay2 = Vbox(orientation='vertical',
                             padding=[10, 10, 10, 10],
                             spacing=10)

                #Blit voltage-controlling elements onto the screen
                def blitVolt(vallist):
                    Finner2.remove_widget(Finner3)
                    Finner3.clear_widgets()
                    vlay.clear_widgets()
                    vlay2.clear_widgets()

                    mySupply.row1 = []
                    mySupply.row2 = []
                    mySupply.rows = [mySupply.row1, mySupply.row2]

                    #Use saved voltage values if present
                    if os.path.exists('voltagelog.txt'):
                        file1 = open('voltagelog.txt', 'r')
                        i = 0
                        for value in mySupply.values:
                            mySupply.values[i] = file1.readline().rstrip()
                            i += 1

                    #Create rows
                    mySupply.addrow('+6', 0, '6sup1', '6state1',
                                    mySupply.values[0])
                    mySupply.addrow('+25', 0, '25sup1', '25state1',
                                    mySupply.values[1])
                    mySupply.addrow('-25', 0, '-25sup1', '-25state1',
                                    mySupply.values[2])
                    mySupply.addrow('+6', 1, '6sup2', '6state2',
                                    mySupply.values[3])
                    mySupply.addrow('+25', 1, '25sup2', '25state2',
                                    mySupply.values[4])
                    mySupply.addrow('-25', 1, '-25sup2', '-25state2',
                                    mySupply.values[5])

                    #Add supply 1 rows to voltage box
                    vlay.add_widget(Label(text='Supply 1'))
                    for row in mySupply.rows[0]:
                        vlay.add_widget(row)

                    #Add supply 2 rows to voltage box
                    vlay2.add_widget(Label(text='Supply 2'))
                    for row in mySupply.rows[1]:
                        vlay2.add_widget(row)

                    #Joining sections
                    Finner3.add_widget(vlay)
                    Finner3.add_widget(vlay2)
                    Finner2.add_widget(Finner3, index=2)

                #Button to set power supply settings
                initiate = Button(size_hint_y=None,
                                  height=45,
                                  text='Set Voltages',
                                  id='initiate')
                initiate.bind(on_press=setVoltage)

                #Buttons to write and read voltage values from .txt file
                write = Button(size_hint_y=None, height=45, text='Save')
                read = Button(size_hint_y=None, height=45, text='Read')
                Fvwrite.add_widget(write)
                write.bind(on_press=mySupply.save)
                Fvwrite.add_widget(read)
                read.bind(on_press=blitVolt)

                #Joining sections
                Finner2.add_widget(Finner3)
                Finner2.add_widget(initiate)
                Finner2.add_widget(Fvwrite)

                #Run manually the first time; runs again each time the read button is pushed
                blitVolt(mySupply.values)
                #FINNER1

                #Buttons to run and kill testing script
                begEcho = Button(height=10, text='Connect to Chip', id='echo')
                kill = Button(height=10,
                              text='Kill All',
                              id='kill',
                              background_color=(1, 0, 0, 1))
                begEcho.bind(on_press=myChip.keepEcho)
                kill.bind(on_press=myChip.killer)
                choose = Button(height=10, text='Choose Chip', id='choose')
                setsup = Button(height=10, text='Set Supply', id='set')
                setsup.bind(on_press=mySupply.serialSet)

                #Run check every 1/2 sec
                Clock.schedule_interval(docheck, 0.5)

                #Checkbox Section 1
                Fbox = BoxLayout(orientation='horizontal',
                                 padding=[0, 0, 0, 0])
                ck = Label(text='Bist (Not Direct)')
                bist = Switch(active=True)
                Fbox.add_widget(ck)
                Fbox.add_widget(bist)
                Finner.add_widget(Fbox)

                #Image Section
                Fimg = BoxLayout(orientation='horizontal',
                                 padding=[0, 0, 0, 0],
                                 spacing=0)
                Fimg.add_widget(begEcho)
                Fimg.add_widget(curimg)
                Finner.add_widget(Fimg)

                #Checkbox Section 2
                Fkeep = BoxLayout(orientation='horizontal',
                                  padding=[0, 0, 0, 0],
                                  spacing=0)
                clab = Label(text='Continue echo')
                keep = Switch(active=False)
                Fkeep.add_widget(clab)
                Fkeep.add_widget(keep)
                Finner.add_widget(Fkeep)

                #Joining sections
                Finner.add_widget(kill)
                Finner.add_widget(setsup)
                Finner.add_widget(choose)
                Fouter.add_widget(Finner)
                Fouter.add_widget(Finner2)
                self.add_widget(Fouter)
Exemplo n.º 30
0
    def start(self, event):
        try:
            self.capture.release()
        except:
            pass
        self.main_layout = BoxLayout(orientation="vertical")
        self.counter = 0
        self.prev = ''
        self.net = cv2.dnn.readNet('yolov3.weights', 'yolov3.cfg')
        self.clear_widgets()
        self.title = "KivyMD Examples - Progress Loader"

        self.Start = True
        try:
            if self.find != '':
                self.find = self.find
            else:
                self.find = ''
        except:
            self.find = ''
        self.text_input = TextInput(multiline=False,
                                    size_hint=(1, 0.1 * (self.font_size / 20)),
                                    font_size=self.font_size,
                                    pos_hint={
                                        'center_x': 0.5,
                                        'center_y': 0.95
                                    })
        self.text_input.bind(text=self.on_text)
        self.text_input_1 = TextInput(multiline=False,
                                      size_hint=(1,
                                                 0.1 * (self.font_size / 20)),
                                      font_size=self.font_size,
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.95
                                      })
        self.text_input_1.bind(text=self.on_text)
        self.text_input_2 = TextInput(multiline=False,
                                      size_hint=(1,
                                                 0.1 * (self.font_size / 20)),
                                      font_size=self.font_size,
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.95
                                      })
        self.text_input_2.bind(text=self.on_text)
        self.text_input_4 = TextInput(multiline=False,
                                      size_hint=(1,
                                                 0.1 * (self.font_size / 20)),
                                      font_size=self.font_size,
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.95
                                      })
        self.text_input_4.bind(text=self.on_text)
        self.second = Button(text="Second")
        self.final = Label(text="Hello World")
        self.single = False
        self.lab = 'Показывать один объект'
        self.img1 = Image(size_hint=(2, 2),
                          pos_hint={
                              'center_x': 0.5,
                              'center_y': 0.8
                          })

        self.btn = Button(text=self.translator.translate("Aloud"),
                          font_size=self.font_size,
                          background_color=(1, 1, 1, 1),
                          color=(1, 1, 1, 1),
                          size=(32, 32),
                          size_hint=(.2, .5),
                          pos=(300, 300))

        self.btn.bind(on_press=self.callback_1)

        self.btn_2 = ToggleButton(text=self.translator.translate('One'),
                                  font_size=self.font_size,
                                  background_color=(1, 1, 1, 1),
                                  color=(1, 1, 1, 1),
                                  size=(32, 32),
                                  size_hint=(.2, .5),
                                  pos=(300, 250))
        self.btn_3 = ToggleButton(text=self.translator.translate('Fast'),
                                  font_size=self.font_size,
                                  background_color=(1, 1, 1, 1),
                                  color=(1, 1, 1, 1),
                                  size=(32, 32),
                                  size_hint=(.2, .5),
                                  pos=(300, 250))
        self.fast = False
        self.btn_2.bind(on_press=self.callback_2)

        self.btn_3.bind(on_press=self.callback_3)
        self.first = Button(text=self.translator.translate("Look for"),
                            font_size=self.font_size,
                            background_color=(1, 1, 1, 1),
                            color=(1, 1, 1, 1),
                            size=(32, 32),
                            size_hint=(.2, .5),
                            pos=(20, 25))

        if self.find:
            self.btn5 = Button(text=self.translator.translate(
                'Look for {}'.format(self.find)),
                               background_color=(0, 1, 1, 1),
                               font_size=self.font_size,
                               color=(1, 1, 1, 1),
                               size_hint_y=None,
                               height=40)
        else:
            self.btn5 = Button(text=self.translator.translate('Exit'),
                               background_color=(0, 1, 1, 1),
                               color=(1, 1, 1, 1),
                               font_size=self.font_size,
                               size_hint_y=None,
                               height=40)
        self.btn5.bind(on_press=self.start)
        if self.find:
            self.btn_5 = Button(text=self.translator.translate(
                'Look for {}'.format(self.find)),
                                background_color=(0, 1, 1, 1),
                                color=(1, 1, 1, 1),
                                font_size=self.font_size,
                                size_hint_y=None,
                                height=40)
        else:
            self.btn_5 = Button(text=self.translator.translate('Exit'),
                                background_color=(0, 1, 1, 1),
                                color=(1, 1, 1, 1),
                                font_size=self.font_size,
                                size_hint_y=None,
                                height=40)
        self.btn_5.bind(on_press=self.start)
        self.first.bind(on_press=self.show_second)
        self.capture = cv2.VideoCapture(0)

        self.bind(on_load=self.cb_loaded)
        self.matches = []
        self.main_layout = BoxLayout(orientation="vertical")
        self.main_layout_1 = BoxLayout(orientation="horizontal")
        if not self.find:
            self.clear_widgets()
            self.main_layout.clear_widgets()
            self.main_layout.add_widget(self.img1)
            self.main_layout_1.add_widget(self.btn)
            self.main_layout_1.add_widget(self.btn_2)
            self.main_layout_1.add_widget(self.first)
            self.main_layout_1.add_widget(self.btn_3)
            self.main_layout.add_widget(self.main_layout_1)
            self.add_widget(self.main_layout)
            self.btn8 = Button(text=self.translator.translate('Main'),
                               background_color=(0, 1, 1, 1),
                               color=(1, 1, 1, 1),
                               size_hint_y=None,
                               height=40,
                               font_size=self.font_size)
            self.btn8.bind(on_press=self.__init__)
            self.main_layout.add_widget(self.btn8)
            Clock.schedule_interval(self.update, 1.0 / 33.0)
        else:
            if self.Start:
                self.clear_widgets()
                self.main_layout.clear_widgets()
                self.Stop = False
                self.p = 0
                self.btn_6 = Button(text=self.translator.translate('Finish'),
                                    background_color=(1, 1, 1, 1),
                                    color=(1, 1, 1, 1),
                                    font_size=self.font_size,
                                    size_hint_y=None,
                                    height=40)
                self.btn_6.bind(on_press=self.stop)
                self.net = cv2.dnn.readNet('yolov3.weights', 'yolov3.cfg')
                self.clear_widgets()
                self.main_layout.add_widget(self.img1)
                self.main_layout.add_widget(self.btn_6)
                self.add_widget(self.main_layout)
                Clock.schedule_interval(self.update, 1.0 / 33.0)