Пример #1
0
    def __init__(self, gui):
        self.gui = gui
        self.working = True
        self.freqOrg = [50.00, 100.00, 200.00, 0.01]
        self.freq = [50.00, 100.00, 200.00, 0.01]
        self.status = "off"
        self.targetHdg = 0
        self.tilerPos = 0.0
        self.burstRunning = False
        self.on_updateSettings()

        self.driverQRL = None

        self.cMin = 0.0
        self.cPlus = 0.0
        self.clickSize = 0.15

        self.Kp = 0.025
        self.Ki = 0.01
        self.Kd = 0.1
        self.pid = PID(self.Kp, self.Ki, self.Kd, setpoint=0, auto_mode=True)
        self.pid.proportional_on_measurement = True

        self.driverType = self.gui.config['apDriver']
        self.sDriTyp = Spinner(
            values=['driver9 3kts', 'driver9 11kts', 'PID'],
            text=self.driverType,
        )
        self.gui.rl.ids.blAutDri.add_widget(self.sDriTyp)
        self.sDriTyp.bind(text=self.on_driverChange)

        _thread.start_new(self.sinWatchDog, ())
Пример #2
0
    def print_lhand(self):
        self.head.clear_widgets()
        self.spinner = Spinner(text='Left Hand',
                               values=map(str, self.eq_n),
                               size_hint=(None, None),
                               size=(150, 44),
                               pos_hint={
                                   'center_x': .5,
                                   'center_y': .5
                               })

        def show_selected_value(spinner, text):
            print('The spinner', self.spinner, 'have text', text)
            print(self.eq_n.index(text))
            index = self.eq_n.index(text)
            #
            try:
                if self.all_same(self.eq_weapon, Hero.Magni.lhand_weapon):
                    Hero.Magni.remove_weapon("left", self.old_weapon,
                                             Hero.Magni)
                Hero.Magni.add_weapon("left", self.eq_weapon[index],
                                      Hero.Magni)
                self.old_weapon = self.eq_weapon[index]
                Hero.Magni.print_eq2()
            except:
                print("errror")

        self.spinner.bind(text=show_selected_value)
        self.head.add_widget(self.spinner)
Пример #3
0
class Options(GridLayout):
    def __init__(self, **kwargs):
        super(Options, self).__init__(**kwargs)
        self.rows = 1
        self.spinner = Spinner(text='Easy',values=('Easy', 'Medium', 'Hard'))
        self.add_widget(self.spinner)
        self.spinner.bind(text=self.show_selected_value)
        startBtn = Button(text = "start")
        self.add_widget(startBtn)
        startBtn.bind(on_release=self.start)
        stopBtn = Button(text = "stop")
        self.add_widget(stopBtn)
        stopBtn.bind(on_press=self.stop)

    def stop(self,*args):
        App.get_running_app().root.children[1].stop()

    def start(self,ins,*args):
        app = App.get_running_app().root.children[1]
        if ins.text == "continue":
            app.continue_move()
        elif ins.text == "start":
            app.start()
            ins.text = "continue"


    def show_selected_value(self, ins,text):
        if text == 'Easy':
            pass
        elif text == 'Medium':
            pass
        elif text == 'Hard':
            pass
Пример #4
0
    def build(self):
        layout = FloatLayout()

        # configure spinner object and add to layout
        spinner = Spinner(
            text='What do you believe your intelligence level is at?',
            # available values
            values=(str(10 * i) +
                    ' %' if i <= 10 else 'Yes' if i == 11 else 'No'
                    for i in range(13)),
            # just for positioning in our example
            size_hint=(None, None),
            size=(250, 44),
            pos_hint={
                'center_x': .5,
                'center_y': .5
            })

        layout.add_widget(spinner)
        spinner.bind(text=self.on_spinner_select)

        # add a label displaying the selection from the spinner
        self.spinnerSelection = Label()
        layout.add_widget(self.spinnerSelection)
        self.spinnerSelection.pos_hint = {'x': 0, 'y': .1}

        return layout
Пример #5
0
    def createTrialLayout(self):
        self.trialPanel = BoxLayout(orientation='vertical',
                                    padding=50,
                                    spacing=50)
        self.trialName = TextInput(hint_text="Trial Name (e.g. CST)", multiline=False,\
                                   on_text_validate=self.setName, size_hint_y=0.1, size_hint_x=0.5,\
                                   pos_hint = {'center_x':0.5, 'center_y':0.5}, padding=50)
        stateNameInfo = BoxLayout(orientation='horizontal', size_hint_y=0.1)
        stateNameLabel = Label(text="Add states to trial:",
                               size_hint_y=0.1,
                               pos_hint={'center_y': 0.5})
        self.stateName = TextInput(hint_text="State Name (e.g. start)",
                                   multiline=False,
                                   on_text_validate=self.setStateName)
        self.addStateButton = Button(text="Add State",
                                     on_release=self.addState)
        stateNameInfo.add_widget(stateNameLabel)
        stateNameInfo.add_widget(self.stateName)
        stateNameInfo.add_widget(self.addStateButton)
        self.addStateButton.disabled = True

        startStateSelection = BoxLayout(orientation="horizontal", size_hint_y=0.1, spacing=50,\
                                        padding=50)
        selectStartLabel = Label(text="Select start state:")
        self.startStateName = Spinner(values=[])
        self.startStateName.bind(text=self.setStartState)
        startStateSelection.add_widget(selectStartLabel)
        startStateSelection.add_widget(self.startStateName)

        self.trialPanel.add_widget(self.trialName)
        self.trialPanel.add_widget(stateNameInfo)
        self.trialPanel.add_widget(startStateSelection)
Пример #6
0
    def createHapticsPanel(self):
        self.hapticsPanel = BoxLayout(orientation='vertical', size_hint_y=0.4)

        hapticIntro = BoxLayout(orientation='horizontal', size_hint_y=0.1)
        hapticLabel = Label(text="Haptics")
        self.hapticEffectName = TextInput(
            hint_text="Effect Name (e.g. viscousField)", multiline=False)
        hapticIntro.add_widget(hapticLabel)
        hapticIntro.add_widget(self.hapticEffectName)

        hapticType = BoxLayout(orientation='horizontal', size_hint_y=0.1)
        hapticTypeLabel = Label(text="Effect Type:")
        self.hapticTypeSpinner = Spinner(values=["HAPTICS_SET_STIFFNESS", "HAPTICS_CONSTANT_FORCE_FIELD",\
                                                 "HAPTICS_VISCOSITY_FIELD"])
        self.hapticTypeSpinner.bind(text=self.getHapticParameters)
        hapticType.add_widget(hapticTypeLabel)
        hapticType.add_widget(self.hapticTypeSpinner)

        hapticParams = BoxLayout(orientation='horizontal', size_hint_y=0.3)
        hapticParamLabel = Label(text="Haptic Parameters")
        self.hapticEffectParams = TreeView(hide_root=True)
        hapticParams.add_widget(hapticParamLabel)
        hapticParams.add_widget(self.hapticEffectParams)

        self.hapticsPanel.add_widget(hapticIntro)
        self.hapticsPanel.add_widget(hapticType)
        self.hapticsPanel.add_widget(hapticParams)
Пример #7
0
    def __init__(self, **kwargs):
        super(MenuWidget, self).__init__(**kwargs)

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

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

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

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

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

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

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

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

        self.add_widget(layout)

        if platform == 'win' or platform == 'linux' or platform == 'macosx':
            Window.bind(on_key_up=self._on_keyboard_up)
    def __init__(self, **kwargs):
        """
            Installing all the required widgets for the layout of kivy app
        """
        super().__init__(**kwargs)
        self.song_list = SongList()

        #   Bottom status label and Top count label
        self.top_label = Label(text="", id="count_label")
        self.status_label = Label(text="")

        # layout widget left part
        self.sort_label = Label(text="Sort by:")
        # Putting default sort method as Artist
        self.spinner = Spinner(text='Artist',
                               values=('Artist', 'Title', 'Year', 'Required'))
        self.add_song_label = Label(text="Add New Song...")
        self.title_label = Label(text="Title:")
        self.title_text_input = TextInput(write_tab=False, multiline=False)
        self.artist_label = Label(text="Artist:")
        self.artist_text_input = TextInput(write_tab=False, multiline=False)
        self.year_label = Label(text="Year:")
        self.year_text_input = TextInput(write_tab=False, multiline=False)

        # To add and clear for the bottom widget
        self.add_song_button = Button(text='Add Song')
        self.clear_button = Button(text='Clear')
Пример #9
0
    def __init__(self):
        super().__init__()
        self.place_list = PlacesCollection()
        self.sort_label = Label(text="Sort by:")

        # sort by country, priority and visited
        self.spinner = Spinner(text="Name",
                               values=("Country", "Priority", "Visited"))

        # adding a new place
        self.add_label = Label(text="New Place:")

        # input the name
        self.name_label = Label(text="Name: ")
        self.name_input = TextInput(write_tab=False, multiline=False)

        # input the country
        self.country_label = Label(text="Country: ")
        self.country_input = TextInput(write_tab=False, multiline=False)

        # input the priority
        self.priority_label = Label(text="Priority: ")
        self.priority_input = TextInput(write_tab=False, multiline=False)

        # add button for 'add place' and 'clear fields
        self.add_button = Button(text="Add place")
        self.top_label = Label(id="count_place_label")
        self.clear_button = Button(text="Clear Fields")
Пример #10
0
class CustomLevel(Menu):
    buttonList = ['Ok', 'Cancel']

    def __init__(self, **kwargs):
        super(CustomLevel, self).__init__(**kwargs)

        def selected_value_r(spinner_row, text):
            print 'Cust Value:%s' % text
            self.number = int(text)
            print 'Cust Num:%s' % self.number
            self.custom_row = self.number

        def selected_value_c(spinner_column, text):
            print 'Cust Value:%s' % text
            self.number = int(text)
            print 'Cust Num:%s' % self.number
            self.custom_column = self.number

        self.spinner_row = Spinner(text='Number of Rows',
                                   values=('2', '4', '6'))
        self.spinner_row.bind(text=selected_value_r)
        self.layout.add_widget(self.spinner_row)

        self.spinner_column = Spinner(text='Number of Columns',
                                      values=('1', '3', '5'))
        self.spinner_column.bind(text=selected_value_c)
        self.layout.add_widget(self.spinner_column)
    def titlebar(self):
        layout=BoxLayout(padding='2sp',size_hint=(1,None),height='65sp')
        layout.orientation='horizontal'

        #credentials = self.accept_credentials()
        self.submit_popup = Popup(title='Enter credentials',content=self.accept_credentials(),size_hint=(0.6, 0.35))
        #credentials.children[1].bind(on_press=self.submit_popup.dismiss)

        submit = Button(text='Submit',size_hint=(0.4,1))
        if self.element.read_token(self):
            submit.bind(on_press=partial(self.submit_assignment))
        else:
            submit.bind(on_press=self.submit_popup.open)

        run = Button(text='Run',size_hint=(0.4,1))
        run.bind(on_press=self.run)

        ex_dropdown = Spinner(text=self.current_ex,size_hint=(1,1))
        ex_dropdown.values = os.listdir('./res/')
        ex_dropdown.bind(text=self.updateExercise)

        layout.add_widget(run)
        layout.add_widget(ex_dropdown)
        layout.add_widget(submit)

        return layout
Пример #12
0
    def __init__(self, monster, *args, **kwargs):
        self.monster = monster
        super(MonsterType, self).__init__(*args, **kwargs)

        spinner = Spinner(font_size=FONT_XLARGE,
                          text=self.monster.monster_type or '',
                          values=[
                              monster_type.name
                              for monster_type in session.query(Monster)
                          ])

        def view_details(_):
            monster_type = self.monster.monster_type or ''
            details = Popup(size_hint=(.8, .8), title=monster_type)
            monster_type = (session.query(Monster).filter(
                Monster.name == monster_type).scalar())
            if monster_type:
                text = monster_type.get_details()
            else:
                text = "Monster_Type '%s' not found" % monster_type

            details.add_widget(RstDocument(text=text))
            details.open()

        spinner.bind(text=self.update)
        self.add_widget(spinner)
        self.add_widget(
            Button(text="Details",
                   font_size=FONT_XLARGE,
                   on_press=view_details))
Пример #13
0
 def show_personal_info(self):
     content = BoxLayout(orientation='vertical')
     scroll_view = ScrollView(do_scroll_x=False)
     self.personal_info_bottom_layout = GridLayout(
         cols=2,
         spacing='5dp',
         size_hint_x=1,
         size_hint_y=None,
         row_default_height='30dp',
         row_force_default=True)
     self.personal_info_bottom_layout.bind(
         minimum_height=self.personal_info_bottom_layout.setter('height'))
     key_dropdown = Spinner(
         values=[key['public'] for key in json.load(open('api_keys.json'))],
         size_hint=(1, None),
         height=50,
         text='Choose an API Key')
     key_dropdown.bind(text=self.load_personal_info)
     content.add_widget(key_dropdown)
     scroll_view.add_widget(self.personal_info_bottom_layout)
     content.add_widget(scroll_view)
     button_layout = BoxLayout(size_hint=(1, 0.1))
     button = Button(text=self.PlungeApp.get_string('Close'),
                     size_hint=(1, None),
                     height=50)
     button_layout.add_widget(button)
     content.add_widget(button_layout)
     title = "Personal Stats"
     self.info = Popup(title=title,
                       content=content,
                       auto_dismiss=False,
                       size_hint=(.7, .7))
     button.bind(on_press=self.close_info)
     self.info.open()
     return
Пример #14
0
    def print_armor(self):
        self.armor.clear_widgets()
        self.a_spinner = Spinner(text='Armor',
                                 values=map(str, self.eq_armor_n),
                                 size_hint=(None, None),
                                 size=(150, 44),
                                 pos_hint={
                                     'center_x': .5,
                                     'center_y': .5
                                 })

        def show_selected_value(spinner, text):
            print('The spinner', self.spinner, 'have text', text)
            print(self.eq_armor_n.index(text))
            index = self.eq_armor_n.index(text)
            try:
                if self.all_same(self.eq_armor, Hero.Magni.armory):
                    Hero.Magni.remove_armor(self.old_arm, Hero.Magni)
                Hero.Magni.add_armor(self.eq_armor[index], Hero.Magni)
                self.old_arm = self.eq_armor[index]
                Hero.Magni.print_armor()
            except:
                print("d")

        self.a_spinner.bind(text=show_selected_value)
        self.armor.add_widget(self.a_spinner)
Пример #15
0
class DrpDwnList(BoxLayout):

    def __init__(self, caption, values, action=None, s_text='..select..',
                 **kwargs):
        self.values = values
        self.action = action
        super(DrpDwnList, self).__init__(padding=0, spacing=0,
                                         size_hint=(1,None),
                                         orientation='vertical', **kwargs)
        lbl = Label(
            # height: 10
            # font_size: 12
            size_hint=(1, .5), text=caption)
        self.add_widget(lbl)
        self.spinner = Spinner(
            # default value shown
            text=s_text,
            # available values
            values=values,
            # just for positioning in our example
            size_hint=(1, .5),
            #size=(100, 44),
            #pos_hint={'center_x': .5, 'center_y': .5}
                )
        if action is not None:
            self.spinner.bind(text=self.use_selected_value)
        self.add_widget(self.spinner)

    def use_selected_value(self, spinner, text):
        self.action(text)
Пример #16
0
    def show_settings_manager(self):
        ''' Rebuild and display settings screen
		'''

        self.clear_widgets()
        self.add_widget(Label(size_hint=(1, None), height=dp(90)))
        hb = BoxLayout(size_hint=(1, None), height=dp(35))
        hb.add_widget(Label(size_hint=(1, 1)))
        self.spinner = Spinner(text=self.current_panel,
                               values=self.instances.keys(),
                               size_hint=(None, 1),
                               width=dp(200),
                               font_size='20sp')
        self.spinner.bind(text=self.setting_panel_changed)
        hb.add_widget(self.spinner)
        hb.add_widget(Label(size_hint=(1, 1)))
        self.add_widget(hb)
        self.panel = BoxLayout(orientation='vertical', size_hint=(1, 1))
        self.add_widget(self.panel)
        self.show_panel()

        # done button
        hb = BoxLayout(size_hint=(1, None), height=dp(30))
        hb.add_widget(Label(size_hint=(1, 1)))
        hb.add_widget(
            Button(size_hint=(None, 1),
                   width=dp(100),
                   text='close',
                   on_press=self.hide))
        hb.add_widget(Label(size_hint=(1, 1)))
        self.add_widget(hb)

        self.add_widget(Label(size_hint=(1, None), height=dp(90)))
Пример #17
0
    def __init__(self, character, *args, **kwargs):
        self.character = character
        super(CharacterClass, self).__init__(*args, **kwargs)

        spinner = Spinner(
            font_size=FONT_XLARGE,
            text=self.character.class_ or '',
            values=[class_.name for class_ in session.query(Class)])

        spinner.bind(text=self.update)

        def view_details(_):
            details = Popup(size_hint=(.8, .8), title=self.character.class_)
            class_ = (session.query(Class).filter(
                Class.name == self.character.class_).scalar())
            if class_:
                text = class_.details
            else:
                text = "Class_ '%s' not found" % self.character.class_

            details.add_widget(RstDocument(text=text))
            details.open()

        self.add_widget(spinner)
        self.add_widget(
            Button(text="Class details",
                   font_size=FONT_XLARGE,
                   on_press=view_details))
Пример #18
0
    def __init__(self, **kwargs):
        """
        Install all the needed widgets for the interface of kivy app
        """
        super().__init__(**kwargs)
        self.place_list = PlaceList()

        # Top place status label and bottom place status label
        self.top_place_status_label = Label(text="", id="count_label")
        self.bottom_place_status_label = Label(text="")
        # Sorting label
        self.sort_by_label = Label(text="Sort by:")
        # Make Country as the default sorting method
        self.spinner = Spinner(text='Country',
                               values=('Country', 'Place', 'Priority',
                                       'Visited'))
        self.add_new_place_label = Label(text="Add New Place...")
        self.place_name_label = Label(text="Name:")
        self.place_name_text_input = TextInput(write_tab=False,
                                               multiline=False)
        self.place_country_label = Label(text="Country:")
        self.place_country_text_input = TextInput(write_tab=False,
                                                  multiline=False)
        self.place_priority_label = Label(text="Priority:")
        self.place_priority_text_input = TextInput(write_tab=False,
                                                   multiline=False)

        # Add place and clear labels
        self.add_place_button = Button(text='Add Place')
        self.clear_button = Button(text='Clear')
Пример #19
0
    def __init__(self, **kwargs):
        super(MainLayout, self).__init__(**kwargs)
        self.Interpreter = Interpreter()
        self.command_stack = []

        self.cols = 2
        self.orientation = "vertical"
        self.padding = 10

        self.workspace = Workspace()
        self.command_panel = CommandPanel(self.workspace)
        self.output = Output()

        self.spn_menu = Spinner(text='Menu', values=('New', 'Save', 'RUN', 'Exit'), size_hint =(None, None), size=(200, 44), pos_hint={'x': .1, 'y': .9})
        self.spn_menu.bind(text=self.menu_option_selected_event)
        
        self.command_panel.draw(self.spn_menu)
        self.command_panel.add_expression_btn('LET')
        self.command_panel.add_expression_btn('PRINT')
        self.command_panel.add_expression_btn('GOTO')
        self.command_panel.add_expression_btn('IF')
        self.command_panel.add_expression_btn('GOSUB')
        self.command_panel.add_expression_btn('RETURN')
        self.command_panel.add_expression_btn('END')
        self.add_widget(self.command_panel)

        self.orientation = "horizontal"
        self.workspace.draw()
        self.add_widget(self.workspace)
        
        self.output.draw()
        self.add_widget(self.output)
Пример #20
0
    def build_interface(self):
        self.label = Label(
            text=self.label_text,
            text_size=(self.width * 4, None),
            halign='left',
            valign='middle'
        )

        if self.setting_type == 'number':
            self.changer = Slider(
                min=self.setting_min,
                max=self.setting_max,
                value=self.setting_value
            )
            self.changer.bind(value=self.change_value)
        elif self.setting_type == 'bool':
            self.changer = RealToggleButton(
                './media/icons/delete.png',
                './media/icons/check.png',
                self.change_value,
                source='./media/icons/delete.png',
                always_release=True
            )
        elif self.setting_type == 'select':
            self.changer = Spinner(
                text='Something',
                values=self.items
            )
            self.changer.bind(text=self.change_value)

        self.add_widget(self.label)
        self.add_widget(self.changer)
Пример #21
0
    def __init__(self, **kwargs):
        super(MyBox, self).__init__(orientation='vertical')
        #변수에 어린이이름/전체엑셀데이터 추가
        self.kidName = '배주현'
        self.kidData = pd.read_csv(f"{dirname(__file__)}/temp.csv",
                                   encoding='cp949')
        self.make = Make()
        #데이터에서 유니크날짜뽑아서 스피너 꾸미기
        date_list = list(self.kidData['date'].unique())
        self.kidClass = self.kidData.loc[self.kidData['name'] == self.kidName,
                                         ['class']]
        self.kidClass_list = list(self.kidClass['class'].unique())
        self.kidClass2 = self.kidClass_list[0]
        self.mySpinner = Spinner(text=date_list[-1], values=(date_list))
        self.mySpinner.size_hint = (0.3, 0.05)
        self.mySpinner.background_color = [250, 250, 250, 1]
        self.mySpinner.color = [0, 0, 0, 1]

        self.mySpinner.pos_hint = {'right': 1, 'top': 1}
        #스피너에 함수추가
        self.mySpinner.bind(text=self.spinner_change)
        #박스에 스피너추가
        self.add_widget(self.mySpinner)

        #그래프추가
        self.graph = Make().make_graph(self.kidName, self.kidData,
                                       self.mySpinner.text, self.kidClass2)
        self.add_widget(self.graph)
Пример #22
0
    def titlebar(self):
        layout = BoxLayout(padding='2sp', size_hint=(1, None), height='65sp')
        layout.orientation = 'horizontal'

        #credentials = self.accept_credentials()
        self.submit_popup = Popup(title='Enter credentials',
                                  content=self.accept_credentials(),
                                  size_hint=(0.6, 0.35))
        #credentials.children[1].bind(on_press=self.submit_popup.dismiss)

        submit = Button(text='Submit', size_hint=(0.4, 1))
        if self.element.read_token(self):
            submit.bind(on_press=partial(self.submit_assignment))
        else:
            submit.bind(on_press=self.submit_popup.open)

        run = Button(text='Run', size_hint=(0.4, 1))
        run.bind(on_press=self.run)

        ex_dropdown = Spinner(text=self.current_ex, size_hint=(1, 1))
        ex_dropdown.values = os.listdir('./res/')
        ex_dropdown.bind(text=self.updateExercise)

        layout.add_widget(run)
        layout.add_widget(ex_dropdown)
        layout.add_widget(submit)

        return layout
Пример #23
0
    def __init__(self, character, *args, **kwargs):
        self.character = character
        super(CharacterRace, self).__init__(*args, **kwargs)

        spinner = Spinner(font_size=FONT_XLARGE,
                          text=self.character.race or '',
                          values=[race.name for race in session.query(Race)])

        def view_details(_):
            details = Popup(size_hint=(.8, .8), title=self.character.race)
            race = (session.query(Race).filter(
                Race.name == self.character.race).scalar())
            if race:
                text = race.details
            else:
                text = "Race '%s' not found" % self.character.race

            details.add_widget(RstDocument(text=text))
            details.open()

        spinner.bind(text=self.update)
        self.add_widget(spinner)
        self.add_widget(
            Button(text="Race details",
                   font_size=FONT_XLARGE,
                   on_press=view_details))
Пример #24
0
    def __init__(self, section, item_name, item_value, options):
        super(BoxLayoutItemOption, self).__init__(section, item_name,
                                                  item_value)

        self.item_value = Spinner(text=item_value, values=options)
        self.add_widget(self.item_value)
        self.item_value.bind(text=self.choice_made)
Пример #25
0
    def __init__(self, **kwargs):
        super(date_selection, self).__init__(**kwargs)
        self.cols = 3

        l1 = Label(text="day", font_size=20)
        self.add_widget(l1)
        l2 = Label(text="month", font_size=20)
        self.add_widget(l2)
        l3 = Label(text="year", font_size=20)
        self.add_widget(l3)

        self.day = Spinner(text="12",
                           values=("1", "2", "3", '4', '5', '6', '7', '8', '9',
                                   '10', '11', '12', '13', '14', '15', '16',
                                   '17', '18', '19', '20', '21', '22', '23',
                                   '24', '25', '26', '27', '28', '29', '30',
                                   '31'))
        self.day.size_hint = (0.333, 1.0)
        self.add_widget(self.day)

        self.month = Spinner(text="1",
                             values=("1", "2", "3", '4', '5', '6', '7', '8',
                                     '9', '10', '11', '12'))
        self.month.size_hint = (0.333, 1.0)
        self.add_widget(self.month)

        now = datetime.datetime.now()
        self.year_now = now.year
        self.year = Spinner(text="%s" % str(self.year_now),
                            values=("%s" % str(self.year_now),
                                    "%s" % str(self.year_now + 1)))
        self.year.size_hint = (0.333, 1.0)
        self.add_widget(self.year)
Пример #26
0
    def build(self):

        self.db_conf = DBWindow()

        self.connect()

        self.ex_conf = ExampleWindow(self.age_model)

        self.layout = GridLayout(cols=2)
        self.reference_column = None
        self.query_column = None

        self.db_popup = Popup(title="Database configuration",
                              content=self.db_conf.layout,
                              size_hint=(None, None),
                              size=(400, 400))
        self.db_conf.close_button.bind(on_press=self.db_popup.dismiss)

        self.ex_popup = Popup(title="Example data",
                              content=self.ex_conf.layout,
                              size_hint=(None, None),
                              size=(400, 400))
        self.ex_conf.close_button.bind(on_press=self.ex_popup.dismiss)

        self.reference_column_spinner = Spinner(
            text="Choose column",
            values=self.age_model.get_column_names_from_db(),
            size_hint=(None, None),
            size=(125, 42))

        self.query_column_spinner = Spinner(
            text="Choose column",
            values=self.age_model.get_column_names_from_db(),
            size_hint=(None, None),
            size=(125, 42))

        self.reference_column_spinner.bind(text=self.select_reference_column)
        self.query_column_spinner.bind(text=self.select_query_column)

        self.lbl = Label(text='Welcome to Querio')
        self.exmpl = Button(text="View Example")
        self.exmpl.bind(on_press=self.button3)

        self.btn1 = Button(text='This is a button')
        self.btn1.bind(on_press=self.button1)

        self.input = TextInput(text='Insert Value', multiline=False)

        self.spinner_layout = GridLayout(cols=2)
        self.spinner_layout.add_widget(self.query_column_spinner)
        self.spinner_layout.add_widget(self.reference_column_spinner)
        self.layout.add_widget(self.exmpl)
        self.layout.add_widget(self.create_db_layout())
        self.layout.add_widget(self.spinner_layout)
        self.layout.add_widget(self.input)
        self.layout.add_widget(self.lbl)
        self.layout.add_widget(self.btn1)

        return self.layout
Пример #27
0
 def makeBreakdownMsgPanel(self):
     self.makeBreakdownPanel = BoxLayout(orientation='horizontal')
     msgTypelabel = Label(text="Choose message type:")
     msgTypes = inspect.getmembers(md)
     self.breakdownMsgTypeSpinner = Spinner(values=MSG_TYPES)
     self.breakdownMsgTypeSpinner.bind(text=self.makeBreakdownMessage)
     self.makeBreakdownPanel.add_widget(msgTypelabel)
     self.makeBreakdownPanel.add_widget(self.breakdownMsgTypeSpinner)
Пример #28
0
 def on_spinner_layout(self, instance, value):
     self.spinner_layout.add_widget(Label(text='T&RH Sample Rate'))
     self.sample_rate_spinner = Spinner(
         values=self.serial.available_temp_rh_sample_rates)
     self.spinner_layout.add_widget(self.sample_rate_spinner)
     self.spinner_layout.add_widget(Label(text='T&RH Repeatability'))
     self.rep_spinner = Spinner(values=['Low', 'Med', 'High'])
     self.spinner_layout.add_widget(self.rep_spinner)
Пример #29
0
class MenuWidget(FloatLayout):
    def __init__(self, **kwargs):
        super(MenuWidget, self).__init__(**kwargs)

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

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

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

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

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

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

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

        self.add_widget(layout)

    def show_selected_value(self, spinner, value):
        self.description_label.text = self.choices[value]

    def on_run(self, instance, value):
        if self.parent:
            parent = self.parent
            parent.remove_widget(self)

            state = None
            exec(
                "state = %s.create(float(Window.width), float(Window.height), float(tile_size))"
                % self.spinner.text)

            parent.add_widget(ScreenWidget(state))
Пример #30
0
class AddNewEstimatorLayout(RelativeLayout):
    def __init__(self, **kwargs):
        super(AddNewEstimatorLayout, self).__init__(**kwargs)

        n = 16
        idx = 14

        self.add_widget(
            Label(text='Select type :',
                  bold=True,
                  italic=True,
                  size_hint=(0.20, 1 / n),
                  pos_hint={
                      'x': 0.30,
                      'y': 1 / n * idx
                  }))
        self.spinner_estimator_type = Spinner(text='Regression',
                                              values=('Regression',
                                                      'Classification'),
                                              size_hint=(0.20, 1 / n),
                                              pos_hint={
                                                  'x': 0.50,
                                                  'y': 1 / n * idx
                                              })
        self.add_widget(self.spinner_estimator_type)

        idx -= 1
        self.add_new_estimator_screen_manager = AddNewEstimatorScreenManager(
            size_hint=(1, 1 / n * 11),
            pos_hint={
                'x': 0,
                'y': 1 / n * (idx - 11)
            })
        self.add_widget(self.add_new_estimator_screen_manager)

        idx -= 10
        self.add_widget(
            Button(text='Cancel',
                   italic=True,
                   on_release=self.btn_cancel_do,
                   size_hint=(0.15, 1 / n),
                   pos_hint={
                       'x': 0.02,
                       'y': 1 / n * idx
                   }))

        self.spinner_estimator_type.bind(text=self.spinner_estimator_type_bind)

    def spinner_estimator_type_bind(self, *args):
        t = self.spinner_estimator_type.text
        if t == 'Regression':
            self.add_new_estimator_screen_manager.go_to_regression_screen()
        elif t == 'Classification':
            self.add_new_estimator_screen_manager.go_to_classification_screen()

    def btn_cancel_do(self, *args):
        self.parent.parent.parent.dismiss()
Пример #31
0
 def init_child_widgets(self):
     self.scroll_layout = ScrollView()
     self.root_layout = GridLayout(cols=2,
                                   padding=[50, 10, 50, 10],
                                   spacing=10)
     self.book_label = Label(text='Book', font_size=self.app.font_size)
     self.root_layout.add_widget(self.book_label)
     self.book_spinner = Spinner(
         text='Genesis',
         background_color=(1, 0, 1),
         font_size=self.app.font_size,
         values=('Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy',
                 'Joshua', 'Judges', 'Ruth', '1 Samuel', '2 Samuel',
                 '1 Kings', '2 Kings', '1 Chronicles', '2 Chronicles',
                 'Ezra', 'Nehemiah', 'Esther', 'Job', 'Psalm', 'Proverbs',
                 'Ecclesiastes', 'Song of Solomon', 'Isaiah', 'Jeremiah',
                 'Lamentations', 'Ezekiel', 'Daniel', 'Hosea', 'Joel',
                 'Amos', 'Obadiah', 'Jonah', 'Micah', 'Nahum', 'Habakkuk',
                 'Zephaniah', 'Haggai', 'Zechariah', 'Malachi', 'Matthew',
                 'Mark', 'Luke', 'John', 'Acts', 'Romans', '1 Corinthians',
                 '2 Corinthians', 'Galatians', 'Ephesians', 'Philippians',
                 'Colossians', '1 Thessalonians', '2 Thessalonians',
                 '1 Timothy', '2 Timothy', 'Titus', 'Philemon', 'Hebrews',
                 'James', '1 Peter', '2 Peter', '1 John', '2 John',
                 '3 John', 'Jude', 'Revelation'))
     self.root_layout.add_widget(self.book_spinner)
     self.chapter_label = Label(text='Chapter',
                                font_size=self.app.font_size)
     self.root_layout.add_widget(self.chapter_label)
     self.chapter_spinner = Spinner(
         text='1',
         background_color=(1, 0, 1),
         font_size=self.app.font_size,
         values=('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                 '12', '13', '14', '15', '16', '17', '18', '19', '20'))
     self.root_layout.add_widget(self.chapter_spinner)
     self.verse_label = Label(text='Verse', font_size=self.app.font_size)
     self.root_layout.add_widget(self.verse_label)
     self.verse_spinner = Spinner(
         text='1',
         background_color=(1, 0, 1),
         font_size=self.app.font_size,
         values=('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                 '12', '13', '14', '15', '16', '17', '18', '19', '20'))
     self.root_layout.add_widget(self.verse_spinner)
     self.back_button = Button(text='Back',
                               background_normal='buttongold.jpg',
                               font_size=self.app.font_size)
     self.back_button.bind(on_press=self.on_press)
     self.add_button = Button(text='Add',
                              background_normal='buttongold.jpg',
                              font_size=self.app.font_size)
     self.add_button.bind(on_press=self.on_press)
     self.root_layout.add_widget(self.back_button)
     self.root_layout.add_widget(self.add_button)
     self.scroll_layout.add_widget(self.root_layout)
     self.add_widget(self.scroll_layout)
Пример #32
0
 def createStateTypePanel(self):
     self.stateTypePanel = BoxLayout(orientation="horizontal",
                                     size_hint_y=0.1)
     stateTypeLabel = Label(text="Select state type", padding=(20, 20))
     self.stateTypeSpinner = Spinner(values=STATE_TYPES)
     self.stateTypeSpinner.bind(text=self.getStateTypeParams)
     self.stateTypeParams = TreeView(hide_root=True)
     self.stateTypePanel.add_widget(stateTypeLabel)
     self.stateTypePanel.add_widget(self.stateTypeSpinner)
     self.stateTypePanel.add_widget(self.stateTypeParams)
Пример #33
0
    def build_spinner(self, initial_text, values_list, func):
        spinner = Spinner(text=initial_text,
                          values=values_list,
                          pos_hint={
                              'center_x': .5,
                              'center_y': .5
                          })

        spinner.bind(text=func)
        return spinner
Пример #34
0
class MenuWidget(FloatLayout):
        def __init__(self, **kwargs):
                super(MenuWidget, self).__init__(**kwargs)

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

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

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

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

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

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

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

                self.add_widget(layout)

        def show_selected_value(self, spinner, value):
                self.description_label.text = self.choices[value]

        def on_run(self, instance, value):
                if self.parent:
                        parent = self.parent
                        parent.remove_widget(self)

                        state = None
                        exec("state = %s.create(float(Window.width), float(Window.height), float(tile_size))" % self.spinner.text)

                        parent.add_widget(ScreenWidget(state))
Пример #35
0
    def print_lhand(self):
        self.head.clear_widgets()
        self.spinner = Spinner(
            text='Left Hand',
            values=map(str, self.eq_n),
            size_hint=(None, None),
            size=(150, 44),
            pos_hint={'center_x': .5, 'center_y': .5})

        def show_selected_value(spinner, text):
            print('The spinner', self.spinner, 'have text', text)
            print(self.eq_n.index(text))
            index = self.eq_n.index(text)
         #
            try:
                if self.all_same(self.eq_weapon, Hero.Magni.lhand_weapon ):
                    Hero.Magni.remove_weapon("left", self.old_weapon, Hero.Magni)
                Hero.Magni.add_weapon("left", self.eq_weapon[index], Hero.Magni)
                self.old_weapon = self.eq_weapon[index]
                Hero.Magni.print_eq2()
            except:
                print("errror")

        self.spinner.bind(text=show_selected_value)
        self.head.add_widget(self.spinner)
Пример #36
0
    def __init__(self, **kwargs):

        super(AbstractPanel, self).__init__(kwargs=kwargs, orientation='vertical')

        self.panels_to_choose = {}
        self.pannels_instants = []
        self.panel = ScreenManager()

        self.custom_config()
        text, values = self.loadClases()

        self.name_label = Label(text=self.get_name(),size_hint=(1, None), size = (1,44))

        self.spinner = Spinner(
            # default value shown
            text=text,
            # available values
            values=values,
            # just for positioning in our example
            size_hint=(1, None),
            size = (1,44)
        )

        self.spinner.bind(text=self.show_selected_value)

        self.add_widget(self.name_label)
        self.add_widget(self.spinner)
        self.add_widget(self.panel)
Пример #37
0
    def __init__(self, arg):
        self.hight_component = 30
        super(ArgsGUI, self).__init__(orientation='horizontal', size_hint=(1,None), size=(1,self.hight_component))

        self.arg_name = arg
        arg_name = Label(text=arg,size_hint=(0.3,None), size=(1,self.hight_component))

        self.spinner_options = ('from roach', 'free input')
        self.arg_type = Spinner(
                # default value shown
                text=self.spinner_options[0],
                # available values
                values=self.spinner_options,
                # just for positioning in our example
                size_hint=(0.3, None),
                size = (1,self.hight_component)
            )
        self.arg_type.bind(text=self.change_input)

        self.arg_roach_spinner = Spinner(
                # default value shown
                text='',
                # available values
                values=['global_data', 'save_data', 'current_channel', 'fpga'],
                # just for positioning in our example
                size_hint=(0.4, None),
                size = (1,self.hight_component)
            )
        self.roach_input = True
        self.free_input = TextInput(size_hint=(0.4,None), size=(1,self.hight_component))

        self.add_widget(arg_name)
        self.add_widget(self.arg_type)
        self.add_widget(self.arg_roach_spinner)
Пример #38
0
    def bestellung(self, widget):
        App.my_index = -1
        
        TischNr = widget.id
        PopupFloatLayout = FloatLayout(size_hint=(1, 1))
        
        self.PopupScrollview = CustomScrollviewPopupContent()
        self.PopupScrollviewItem = CustomButton2()
        
        App.AuswahlHauptliste = App.HauptListeDictonaries
        self.PopupScrollview.data = App.AuswahlHauptliste
        
        
        #content = self.PopupScrollview.ids.content
        #item = self.PopupScrollviewItem
               
        popup = Popup(title='Bestellung für Tisch ' + str(TischNr),
                      content= PopupFloatLayout)
       
             

        BoxTop = BoxLayout(size_hint= [0.52,0.065],pos_hint={'x': 0.5, 'y': 1.005}, spacing = 5)
        ButtonExit = Button(text="Exit",
                            #pos_hint={'x': 0.825, 'y': 1.005},
                            #size_hint = [0.2,0.065],
                            size_hint = [0.3,1],
                            #on_release = self.zeromyindex,
                            
                            on_release = popup.dismiss)
        #myindexzero = 0
        #ButtonExit.bind(on_release=ButtonExit.setter('myindexzero'))
        #print App.my_index

        self.ButtonSpinner =Spinner(text= "Alle",
                               values= ("Mittag-Essen", "Getraenke", "AlcGetraenke", "Essen Alltime", "Alle"),
                               size_hint= [0.7,1],
                               #pos_hint={'x': 0.625, 'y': 1.005}
                               )
        self.ButtonSpinner.bind(text=self.show_selected_value)        
        #halign: 'right'
        #valign: 'top'

        #PopupFloatLayout.add_widget(ButtonExit)
        #PopupFloatLayout.add_widget(ButtonSpinner)
        
        BoxTop.add_widget(self.ButtonSpinner)
        BoxTop.add_widget(ButtonExit)
        PopupFloatLayout.add_widget(BoxTop)
        
        self.PopupScrollview.size_hint = [1.05,1.017]
        self.PopupScrollview.center = popup.center
        PopupFloatLayout.add_widget(self.PopupScrollview)
        for i in App.ScrollviewButtons:
            i.ids.customID.on_release = self.Optionsfenster
        
       
        popup.open()
        print App.ScrollviewButtons
Пример #39
0
    def __init__(self, *args, **kwargs):
        super(MapBrowser, self).__init__(**kwargs)

        mapview = MapView(lat=50.6394,
                          lon=3.057,
                          zoom=8,
                          cache_dir="cache")
        
        self.add_widget(mapview)

        mapview.add_widget(MapMarker(lat=50.6394, lon=3.057))
        mapview.add_widget(MapMarker(lat=-33.867, lon=151.206))

        top_bar = Toolbar(pos_hint={'top': 1})

        def center_on(lat, lon, instance):
            mapview.center_on(lat, lon)
            label_lat.text = "Latitude: {}".format(mapview.lat)
            label_lon.text = "Longitude: {}".format(mapview.lon)

        btn_lille = Button(text="Move to Lille, France")
        btn_lille.bind(on_release=partial(center_on, 50.6394, 3.057))
        top_bar.add_widget(btn_lille)

        btn_sydney = Button(text="Move to Sydney, Autralia")
        btn_sydney.bind(on_release=partial(center_on, -33.867, 151.206))
        top_bar.add_widget(btn_sydney)

        spinner_src = Spinner(text="mapnik", values=MapSource.providers.keys())
        def set_source(instance, selected_text):
            mapview.map_source = selected_text
        spinner_src.bind(text=set_source)
        top_bar.add_widget(spinner_src)

        bottom_bar = Toolbar()
        label_lon = Label(text="Longitude: {}".format(mapview.lon))
        label_lat = Label(text="Latitude: {}".format(mapview.lat))
        bottom_bar.add_widget(label_lon)
        bottom_bar.add_widget(label_lat)

        self.add_widget(top_bar)
        self.add_widget(bottom_bar)
Пример #40
0
 def show_personal_info(self):
     content = BoxLayout(orientation='vertical')
     scroll_view = ScrollView(do_scroll_x=False)
     self.personal_info_bottom_layout = GridLayout(cols=2, spacing='5dp', size_hint_x=1, size_hint_y=None,
                                                   row_default_height='30dp', row_force_default=True)
     self.personal_info_bottom_layout.bind(minimum_height=self.personal_info_bottom_layout.setter('height'))
     key_dropdown = Spinner(values=[key['public'] for key in json.load(open('api_keys.json'))], size_hint=(1, None),
                            height=50, text='Choose an API Key')
     key_dropdown.bind(text=self.load_personal_info)
     content.add_widget(key_dropdown)
     scroll_view.add_widget(self.personal_info_bottom_layout)
     content.add_widget(scroll_view)
     button_layout = BoxLayout(size_hint=(1, 0.1))
     button = Button(text=self.PlungeApp.get_string('Close'), size_hint=(1, None), height=50)
     button_layout.add_widget(button)
     content.add_widget(button_layout)
     title = "Personal Stats"
     self.info = Popup(title=title, content=content, auto_dismiss=False, size_hint=(.7, .7))
     button.bind(on_press=self.close_info)
     self.info.open()
     return
Пример #41
0
    def __init__(self, **kwargs):
        kwargs['orientation'] = 'vertical'
        super(MainWindow, self).__init__(**kwargs)

        spinner = Spinner(
            # default value shown
            text='Home',
            # available values
            values=('Home', 'Test', 'AddWord'),
            # just for positioning in our example
            size_hint=(1, None),
            size=(100, 44),
            pos_hint={'center_x': .5, 'center_y': .5})

        spinner.bind(text=self.set_page_vidget)

        self.add_widget(spinner)

        self.work_area = BoxLayout()
        self.work_area.add_widget(Home())
        self.add_widget(self.work_area)
Пример #42
0
 def __init__(self, **kwargs):
     super(Options, self).__init__(**kwargs)
     self.rows = 1
     self.spinner = Spinner(text='Easy',values=('Easy', 'Medium', 'Hard'))
     self.add_widget(self.spinner)
     self.spinner.bind(text=self.show_selected_value)
     startBtn = Button(text = "start")
     self.add_widget(startBtn)
     startBtn.bind(on_release=self.start)
     stopBtn = Button(text = "stop")
     self.add_widget(stopBtn)
     stopBtn.bind(on_press=self.stop)
Пример #43
0
    def getUI(self):
        """get the ui element"""
        if 'enum' in self._typeInfo:
            result = Spinner()
            result.values = self._typeInfo['enum']
        elif self._typeInfo['type'].lower() == 'boolean':
            result = Spinner()
            result.values = ['true', 'false']
        else:
            result = TextInput()
        if self.value:
            result.text = self.value.lower()
        skin = sm.getSkin('text', self.asset)
        result.size = sm.getControlSize(skin, self.asset)

        self.uiEl = result
        self.prepareUiElement()
        result.bind(text=self.value_changed)
        return result
Пример #44
0
    def __init__(self, **kwargs):
        super(MainLayout, self).__init__(**kwargs)  
        self.command_stack = []
        self.cols = 2
        self.orientation = "vertical"
        self.padding = 10
        self.y_pos= .8
       
        self.left_layout = GridLayout(cols=1,  pos=(5,-10))      

        self.spinner = Spinner( text = 'Menu', values =('New', 'Save', 'Clear Message Box','Exit'), size_hint =(None, None), size=(200,44), pos_hint={'x':.1, 'y':.9})
        self.left_layout.add_widget(self.spinner)

        self.let_button = Button(text="LET", size_hint =(None, None), size=(200,44),pos_hint={'x':.1, 'y':.7})
        self.left_layout.add_widget(self.let_button)
        
        self.print_button = Button(text="PRINT", size_hint =(None, None), size=(200,44),pos_hint={'x':.1, 'y':.6})
        self.left_layout.add_widget(self.print_button) 

        self.run_button = Button(text="RUN", size_hint =(None, None), size=(200,44),pos_hint={'x':.1, 'y':.6})
        self.left_layout.add_widget(self.run_button)
         
        self.add_widget(self.left_layout)

        self.orientation = "horizontal"

        self.grid_layout = GridLayout(cols=1,  padding=10, spacing=10, size_hint=(None, None), width=500)
        self.grid_layout.bind(minimum_height=self.grid_layout.setter('height'))
        self.right_layout = ScrollView(size_hint=(None, None),size=(500, 380), pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False, do_scroll_y=True)
        self.add_widget(self.right_layout)
        
       
        self.right_layout.add_widget(self.grid_layout)
        
        #self.right_layout = FloatLayout(pos=(200, -10) ,  size_hint=(.5,1))
        #self.right_layout = GridLayout(cols=1, pos=(300,-10))  
        #self.add_widget(self.right_layout)

        self.bottom_layout = GridLayout()
        self.comment = TextInput(text='Output is shown here..', width= 800, height=200)    
        
        self.bottom_layout.add_widget(self.comment)
        #self.bottom_layout.add_widget(TextInput())
        
        self.add_widget(self.bottom_layout)       
        
        self.let_button.bind(on_press =self.add_let)
        self.print_button.bind(on_press = self.add_print)
        self.spinner.bind(text = self.new_program_option)
        self.run_button.bind(on_press = self.run_app)
Пример #45
0
        def __init__(self, **kwargs):
                super(MenuWidget, self).__init__(**kwargs)

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

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

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

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

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

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

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

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

                self.add_widget(layout)

                if platform == 'win' or platform == 'linux' or platform == 'macosx':
                        Window.bind(on_key_up=self._on_keyboard_up)
Пример #46
0
    def add_row(self, instance):
        """
        Add a row to the main exchange screen
        :param instance:
        :return:
        """
        self.num_rows += 1
        keys_button = Button(text='Keys', size_hint_x=0.2, id='%d' % self.num_rows)
        keys_button.bind(on_release=self.enter_keys)
        self.content.add_widget(keys_button)
        self.keys_button.append(keys_button)
        address = TextInput(size_hint_x=0.2, padding=[6, 10, 6, 10],
                            multiline=False, font_size=18, id='%d' % self.num_rows)
        address.bind(text=self.check_address)
        self.content.add_widget(address)
        self.address.append(address)
        unit = Spinner(values=self.currencies, text=self.currencies[0], size_hint_x=0.2, id='%d' % self.num_rows)
        self.selected_unit = self.currencies[0]
        unit.bind(text=self.set_unit)
        self.content.add_widget(unit)
        self.unit.append(unit)
        rates = Button(text='Rates', size_hint_x=0.2, id='%d' % self.num_rows)
        rates.bind(on_release=self.enter_rates)
        self.content.add_widget(rates)
        self.rates.append(rates)
        bot = Spinner(values=self.bots, text=self.bots[0], size_hint_x=0.2, id='%d' % self.num_rows)
        self.selected_bot = self.bots[0]
        bot.bind(text=self.set_bot)
        self.content.add_widget(bot)
        self.bot.append(bot)

        if isinstance(instance, dict):
            keys_button.text = instance['public'][:8] + ' / ' + instance['secret'][:8]
            address.text = instance['address']
            unit.text = instance['unit']
            rates.text = instance['ask'] + ' | ' + instance['bid']
            bot.text = instance['bot']
Пример #47
0
 def enter_keys(self, instance):
     """
     Show a pop-up in which previously entered api keys can be selected from a drop down
     There are edit and add buttons on the bottom which fire other methods
     :param instance:
     :return:
     """
     self.calling_keys_button = instance
     content = BoxLayout(orientation='vertical', spacing=10)
     top = BoxLayout(orientation='vertical', size_hint=(1, 0.7))
     top.add_widget(Label(text='API Key Pair', size_hint=(1, None), height='70dp'))
     self.api_key_spinner = Spinner(size_hint=(1, None), height='40dp')
     top.add_widget(self.api_key_spinner)
     self.api_key_spinner.bind(text=self.enable_edit)
     top.add_widget(BoxLayout())
     btnlayout = BoxLayout(spacing='5dp', size_hint=(1, 0.15))
     btn = Button(text='Ok', size_hint_y=None, height='50dp')
     btn.bind(on_release=self.close_api_keys_popup)
     btnlayout.add_widget(btn)
     btn = Button(text='Cancel', size_hint_y=None, height='50dp')
     btn.bind(on_release=self.close_api_keys_popup)
     btnlayout.add_widget(btn)
     self.edit_keys_button = Button(text='Edit Keys', size_hint_y=None, height='50dp', disabled=True)
     self.edit_keys_button.bind(on_release=self.edit_keys)
     btnlayout.add_widget(self.edit_keys_button)
     self.add_keys_button = Button(text='Add Keys', size_hint_y=None, height='50dp')
     self.add_keys_button.bind(on_release=self.add_keys)
     btnlayout.add_widget(self.add_keys_button)
     content.add_widget(top)
     content.add_widget(SettingSpacer())
     content.add_widget(btnlayout)
     popup_width = min(0.95 * Window.width, dp(500))
     self.enter_keys_popup = Popup(title='API Keys', content=content, auto_dismiss=False,
                                   size_hint=(None, None), size=(popup_width, '250dp'))
     self.update_api_spinners()
     if instance.text != 'Keys':
         self.api_key_spinner.text = instance.text
     self.enter_keys_popup.open()
Пример #48
0
    def print_armor(self):
        self.armor.clear_widgets()
        self.a_spinner = Spinner(
            text='Armor',
            values=map(str, self.eq_armor_n),
            size_hint=(None, None),
            size=(150, 44),
            pos_hint={'center_x': .5, 'center_y': .5})

        def show_selected_value(spinner, text):
            print('The spinner', self.spinner, 'have text', text)
            print(self.eq_armor_n.index(text))
            index = self.eq_armor_n.index(text)
            try:
                if self.all_same(self.eq_armor, Hero.Magni.armory):
                    Hero.Magni.remove_armor(self.old_arm, Hero.Magni)
                Hero.Magni.add_armor(self.eq_armor[index], Hero.Magni)
                self.old_arm = self.eq_armor[index]
                Hero.Magni.print_armor()
            except:
                print("d")

        self.a_spinner.bind(text=show_selected_value)
        self.armor.add_widget(self.a_spinner)
Пример #49
0
    def build_alarm_popup(self):
        layout = BoxLayout(orientation='horizontal')

        hourspin = Spinner(text=str(self.hour), 
                           values=list(map(str, list(range(1, 25)))), 
                           sync_height=True, 
                           font_size=(self.height/4.0), 
                           option_cls=SpinnerButton)

        hourspin.bind(text=self.set_hour)

        minspin = Spinner(text=str(self.minutes), 
                          values=list(map(str, list(range(1, 60)))), 
                          sync_height=True, 
                          font_size=(self.height/4.0), 
                          option_cls=SpinnerButton)

        minspin.bind(text=self.set_minute)

        layout.add_widget(hourspin)
        layout.add_widget(minspin)

        return layout
Пример #50
0
from kivy.uix.spinner import Spinner
from kivy.base import runTouchApp

spinner = Spinner(
    text='Home',
    values=('Home', 'Work', 'Other', 'Custom'),
    size_hint=(None, None), size=(100, 44),
    pos_hint={'center_x': .5, 'center_y': .5})


def show_selected_value(spinner, text):
    print('The spinner', spinner, 'have text', text)


spinner.bind(text=show_selected_value)

runTouchApp(spinner)
Пример #51
0
    def build(self):
        b = BoxLayout(orientation='vertical')
        languages = Spinner(
            text='language',
            values=sorted(['KvLexer', ] + list(lexers.LEXERS.keys())))

        languages.bind(text=self.change_lang)

        menu = BoxLayout(
            size_hint_y=None,
            height='30pt')
        fnt_size = Spinner(
            text='12',
            values=list(map(str, list(range(5, 40)))))
        fnt_size.bind(text=self._update_size)

        fonts = [
            file for file in LabelBase._font_dirs_files
            if file.endswith('.ttf')]

        fnt_name = Spinner(
            text='RobotoMono',
            option_cls=Fnt_SpinnerOption,
            values=fonts)
        fnt_name.bind(text=self._update_font)
        mnu_file = Spinner(
            text='File',
            values=('Open', 'SaveAs', 'Save', 'Close'))
        mnu_file.bind(text=self._file_menu_selected)
        key_bindings = Spinner(
            text='Key bindings',
            values=('Default key bindings', 'Emacs key bindings'))
        key_bindings.bind(text=self._bindings_selected)

        menu.add_widget(mnu_file)
        menu.add_widget(fnt_size)
        menu.add_widget(fnt_name)
        menu.add_widget(languages)
        menu.add_widget(key_bindings)
        b.add_widget(menu)

        self.codeinput = CodeInputWithBindings(
            lexer=KivyLexer(),
            font_size=12,
            text=example_text,
            key_bindings='default',
        )

        b.add_widget(self.codeinput)

        return b
Пример #52
0
 def make_spinner_with_values( values, text, id, callback ): 
     spinner = Spinner(text=text, values=values, id=id)
     find_and_destroy_widget( layout, id )
     spinner.bind(text=callback)
     layout.add_widget( spinner )
     return spinner
Пример #53
0
class MainLayout(GridLayout):
    def __init__(self, **kwargs):
        super(MainLayout, self).__init__(**kwargs)  
        self.command_stack = []
        self.cols = 2
        self.orientation = "vertical"
        self.padding = 10
        self.y_pos= .8
       
        self.left_layout = GridLayout(cols=1,  pos=(5,-10))      

        self.spinner = Spinner( text = 'Menu', values =('New', 'Save', 'Clear Message Box','Exit'), size_hint =(None, None), size=(200,44), pos_hint={'x':.1, 'y':.9})
        self.left_layout.add_widget(self.spinner)

        self.let_button = Button(text="LET", size_hint =(None, None), size=(200,44),pos_hint={'x':.1, 'y':.7})
        self.left_layout.add_widget(self.let_button)
        
        self.print_button = Button(text="PRINT", size_hint =(None, None), size=(200,44),pos_hint={'x':.1, 'y':.6})
        self.left_layout.add_widget(self.print_button) 

        self.run_button = Button(text="RUN", size_hint =(None, None), size=(200,44),pos_hint={'x':.1, 'y':.6})
        self.left_layout.add_widget(self.run_button)
         
        self.add_widget(self.left_layout)

        self.orientation = "horizontal"

        self.grid_layout = GridLayout(cols=1,  padding=10, spacing=10, size_hint=(None, None), width=500)
        self.grid_layout.bind(minimum_height=self.grid_layout.setter('height'))
        self.right_layout = ScrollView(size_hint=(None, None),size=(500, 380), pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False, do_scroll_y=True)
        self.add_widget(self.right_layout)
        
       
        self.right_layout.add_widget(self.grid_layout)
        
        #self.right_layout = FloatLayout(pos=(200, -10) ,  size_hint=(.5,1))
        #self.right_layout = GridLayout(cols=1, pos=(300,-10))  
        #self.add_widget(self.right_layout)

        self.bottom_layout = GridLayout()
        self.comment = TextInput(text='Output is shown here..', width= 800, height=200)    
        
        self.bottom_layout.add_widget(self.comment)
        #self.bottom_layout.add_widget(TextInput())
        
        self.add_widget(self.bottom_layout)       
        
        self.let_button.bind(on_press =self.add_let)
        self.print_button.bind(on_press = self.add_print)
        self.spinner.bind(text = self.new_program_option)
        self.run_button.bind(on_press = self.run_app)
   

    def new_program_option(self, instance, option):
        if option == 'New':
             self.new_program()
             self.spinner.text = 'Menu'
             self.command_stack=[]
        elif option == 'Exit':
            sys.exit()
        elif option == 'Clear Message Box':
            self.spinner.text = 'Menu'
            self.comment.text=""

    def new_program(self):
        self.grid_layout.clear_widgets() # clear just the widgets inside the grid layout
        self.y_pos = .8

    def add_let(self, instance):
        line = len(self.command_stack) + 1
        command = LetLayout(line,size_hint=(None, None),  pos_hint={'x':.2,'y':self.y_pos})
        self.grid_layout.add_widget(command)
        self.y_pos -= .1
        self.command_stack.append(command)

    def add_print(self, instance):
        line = len(self.command_stack) + 1
        command = PrintLayout(line, size_hint=(None, None),  pos_hint={ 'x':.2,'y':self.y_pos})
        self.grid_layout.add_widget(command)
        self.y_pos -= .1
        self.command_stack.append(command)


    def run_app(self, instance):
        i = Interpreter()
        line_number = 1
        for cmd in self.command_stack:
            line = cmd.get_command()
            i.add_line(line_number, line)
            line_number = line_number + 1

        i.run()
        output = i.get_output()
        variables = i.get_variables()

        self.comment.text = ""
        self.comment.insert_text('\n Output : \n')
        for value in output:
            self.comment.insert_text(' ' + str(value)+ '\n')

        self.comment.insert_text('\n Memory: \n')
        self.comment.insert_text(' Variable \t Value \n')
        for var in variables.keys():
            value = ' \t' + var + ' \t\t\t ' + str(variables[var]) + '\n'
            self.comment.insert_text(' ' + str(value))



    def get_command_stack(self):
        return self.command_stack
Пример #54
0
class SettingsSlot(GridLayout):

    logic = ObjectProperty(None)
    label = ObjectProperty(None)
    changer = ObjectProperty(None)
    value = ObjectProperty(None)

    def __init__(self, **kwargs):
        # XXX: strange super() behaviour here!
        # super().__init__()
        GridLayout.__init__(self)
        self.setting_value = kwargs.get('setting_value')
        self.setting_min = kwargs.get('setting_min')
        self.setting_max = kwargs.get('setting_max')
        self.setting_type = kwargs.get('setting_type')
        self.label_text = kwargs.get('label_text')
        self.items = kwargs.get('items', [])
        self.size_hint = kwargs.get('size_hint', (1, None))
        self.rows = 1

        self.build_interface()

    def on_value(self, instance, value):

        if self.setting_type == 'number':
            self.changer.value = value
        elif self.setting_type == 'bool':
            self.changer.pressed = value
            if not value:
                self.changer.source = self.changer.realtexture
                self.changer.reload()
            else:
                self.changer.source = self.changer.realtexture_pressed
                self.changer.reload()
        elif self.setting_type == 'select':
            self.changer.text = value

    def build_interface(self):
        self.label = Label(
            text=self.label_text,
            text_size=(self.width * 4, None),
            halign='left',
            valign='middle'
        )

        if self.setting_type == 'number':
            self.changer = Slider(
                min=self.setting_min,
                max=self.setting_max,
                value=self.setting_value
            )
            self.changer.bind(value=self.change_value)
        elif self.setting_type == 'bool':
            self.changer = RealToggleButton(
                './media/icons/delete.png',
                './media/icons/check.png',
                self.change_value,
                source='./media/icons/delete.png',
                always_release=True
            )
        elif self.setting_type == 'select':
            self.changer = Spinner(
                text='Something',
                values=self.items
            )
            self.changer.bind(text=self.change_value)

        self.add_widget(self.label)
        self.add_widget(self.changer)

    def change_value(self, instance, value=0):
        if self.setting_type == 'number':
            self.value = value
        elif self.setting_type == 'bool':
            self.value = instance  # not self.changer.pressed
        elif self.setting_type == 'select':
            self.value = value
            self.changer.text = value
Пример #55
0
    def show_first_form(self):
        global STORAGE

        ip_tab = []
        if netifaces:
            interfaces = netifaces.interfaces()
            for interface in interfaces:
                if interface[:2] in ('wl', 'en', 'et'):
                    ifaddress = netifaces.ifaddresses(interface)
                    if netifaces.AF_INET in ifaddress:
                        inets = ifaddress[netifaces.AF_INET]
                        for inet in inets:
                            if 'addr' in inet:
                                addr = inet['addr']
                                if len(addr.split('.')) == 4:
                                    ip_tab.append(addr)
        else:
            try:
                ip_address = get_ip_address(b'wlan0')
                ip_tab.append(ip_address)
            except:
                pass

        if ip_tab:
            ip_address = ', '.join(ip_tab)
        else:
            ip_address = '-'

        label = Label(text=f"[size=18sp][color=88f][b]PYTIGON - select the application:[/b][/color][/size]\n[size=15sp][color=448](my ip addresses: {ip_address})[/b][/color][/size]",
                      markup=True, halign = 'center')
        self.add_widget(label)

        if not check_permission(Permission.WRITE_EXTERNAL_STORAGE):
            ret = request_permissions(PERMISSION)
            print("python::pytigon::request_permissions", ret)

        init("_schall", schserw_settings.ROOT_PATH, schserw_settings.DATA_PATH, schserw_settings.PRJ_PATH,
             schserw_settings.STATIC_APP_ROOT, [schserw_settings.MEDIA_ROOT, schserw_settings.UPLOAD_PATH])

        base_apps_path = os.path.join(os.path.join(STORAGE, "pytigon"), "prj")
        l = [pos for pos in os.listdir(base_apps_path) if not pos.startswith('_')]
        apps = []
        for prj in l:
            base_apps_path2 = os.path.join(base_apps_path, prj)
            try:
                x = __import__(prj + ".apps")
                if hasattr(x.apps, 'PUBLIC') and x.apps.PUBLIC:
                    apps.append(prj)
            except:
                print("Error importing module: ", prj + ".apps")

        if len(apps) > 1:
            if len(apps) > MAX_SEL_APP:
                dy = MAX_SEL_APP - 1
            else:
                dy = len(apps)

            for pos in apps[:dy]:
                button = Button(id=pos, text=pos, size_hint=(1, 1))
                button.bind(on_release=self.chose_callback)
                self.add_widget(button)

            if len(apps) > MAX_SEL_APP:
                spinner = Spinner(
                    text='Other applications',
                    values=apps[dy:],
                    size_hint=(.5, 1),
                    pos_hint={'center_x': 0.5, }
                )
                spinner.bind(text=self.spinner_callback)
                self.add_widget(spinner)
        else:
            if len(apps) > 0:
                self.on_app_chosen(apps[0])
            else:
                self.on_app_chosen()
Пример #56
0
	def build(self):
		global notesChange
		global octaveSet
		global keySet
		global scaleSet
		global allScales
		global currentNotes
		
		#the title that appears at the top
		header = Label(text='DJ Slate')
		
		#create binding function to set octave
		#create octave spinner, add four choices
		def setOctaves(spinner, oct):
			global notesChange
			global octaveSet
			octaveSet = int(oct.split(' ')[0]) #get N from 'N Octaves'
			notesChange = True
		
		octaves = Spinner(
			text = '2 Octaves', 
			values = ('1 Octave', '2 Octaves', '3 Octaves', '4 Octaves'),
			background_color = (1,1,1,0)
		)
		
		octaves.bind(text=setOctaves)
		
		#create setKey binding function
		#create key spinner, add keys
		def setKey(spinner, base):
			global notesChange
			global keySet
			keySet = base
			notesChange = True
		
		key = Spinner(
			text = 'C', 
			values = ('C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B'),
			background_color = (1,1,1,0)
		)
		
		key.bind(text=setKey)
		
		#process midi.txt
		list = open('midi.txt').read()
		list = list.splitlines()
		instrumentNames = []
		
		#add instruments to spinner, bind select
		#number = 1, 2, 3, etc..
		#sound = Acoustic Grand Piano, etc...
		#instrumentNames[number-1] = sound
		for item in list:
			item = item.split(' ')
			number = int(item[0])
			sound = ' '.join(item[1:])
			instrumentNames.append(sound)
		
		instrument = Spinner(
			text = instrumentNames[0],
			values = tuple(instrumentNames),
			background_color = (1,1,1,0)
		)
		
		def setInstrument(spinner, inst):
			fluidsynth.set_instrument(1, instrumentNames.index(inst))
		
		instrument.bind(text=setInstrument)
		
		#process scales.txt
		list = open('scales.txt').read()
		list = list.splitlines()
		scaleNames = {}
		rawNames = [] #used to preserve name order
		
		#add scales to spinner, bind select
		#scaleNames[name_of_scale] = [type, notes]
		for item in list:
			item = item.split(' ')
			sname = item[0].replace('_',' ')
			type = item[1]
			notes = item[2:]
			rawNames.append(sname)
			scaleNames[sname] = [type, notes]
		
		scale = Spinner(
			text = 'Major',
			values = tuple(rawNames),
			background_color = (1,1,1,0)
		)
		
		def setScale(spinner, val):
			global notesChange
			global scaleSet
			scaleSet = val
			notesChange = True
		
		allScales = scaleNames
		scale.bind(text=setScale)
		
		#Create three parts of screen
		label = BoxLayout(size_hint=(1, .1))#, pos=(0, Window.height*.9))
		slate = SlateWidget(size_hint=(1, .8))#, pos=(0, Window.height*.2))
		buttons = BoxLayout(size_hint=(1, .1))#,  pos=(0, 0))
		
		#Add subsidiary buttons + slate
		buttons.add_widget(instrument)
		buttons.add_widget(scale)
		label.add_widget(octaves)
		label.add_widget(header)
		label.add_widget(key)
		
		#Add to window and return
		root = BoxLayout(orientation='vertical') #FloatLayout()
		root.add_widget(label)
		root.add_widget(slate)
		root.add_widget(buttons)
		
		'''def reposition(*args):
			labelMove = Animation(x=0, y=Window.height*.9, duration=0.1, t='instant')
			labelMove.start(label)
			
			slateMove = Animation(x=0, y=Window.height*.2, duration=0.1, t='instant')
			slateMove.start(slate)
		
		Window.bind(on_resize=reposition)'''
		
		return root
Пример #57
0
    def build(self):
        b = BoxLayout(orientation='vertical')
        languages = Spinner(
            text='language',
            values=sorted(['KvLexer', ] + list(lexers.LEXERS.keys())))

        languages.bind(text=self.change_lang)

        menu = BoxLayout(
            size_hint_y=None,
            height='30pt')
        fnt_size = Spinner(
            text='12',
            values=list(map(str, list(range(5, 40)))))
        fnt_size.bind(text=self._update_size)
        fnt_name = Spinner(
            text='DroidSansMono',
            option_cls=Fnt_SpinnerOption,
            values=sorted(map(str, fonts.get_fonts())))
        fnt_name.bind(text=self._update_font)
        mnu_file = Spinner(
            text='File',
            values=('Open', 'SaveAs', 'Save', 'Close'))
        mnu_file.bind(text=self._file_menu_selected)

        menu.add_widget(mnu_file)
        menu.add_widget(fnt_size)
        menu.add_widget(fnt_name)
        menu.add_widget(languages)
        b.add_widget(menu)

        self.codeinput = CodeInput(
            lexer=KivyLexer(),
            font_name='data/fonts/DroidSansMono.ttf', font_size=12,
            text=example_text)

        b.add_widget(self.codeinput)

        return b
Пример #58
0
    def start_server(self, dt):
        '''
        initializes the client connection, and gets image data
        '''
        hostname = "0.0.0.0"
        if not self._started:
            count = 0
            while True:  # Keep trying in case server is not up yet
                import socket
                try:
                    from xmlrpclib import ServerProxy
                    # connect to meta server first
                    prox = \
                        ServerProxy("http://" + hostname + ":5007")
                    # get servers address from the meta server
                    self._ros_uri = prox.startProcess()
                    Logger.info('Server Address\n <%s>', self._ros_uri[0])
#                    self._client = \
#                    KeyboardInterface(self._ros_uri,
#                    self._args.image_updates)
                    self._started = True
                    Logger.info('Client Connected...')
                    # use double quote for subscriber name
                    # TODO: convert get_image_data into a list, so
                    # that each key is the image data of a robot
                    self._ros_uri.pop(0)            # remove ROS uri
                    self._im_string = self._ros_uri 
                    val = []     # store las byte of robot's address
                    for i in range(len(self._ros_uri)): 
                        self._robot_id = \
                            self._ros_uri[i].split('.')[3]
                        rospy.Subscriber(
                            "/output/image_raw/compressed"+
                            self._robot_id, CompressedImage,
                            self.get_image_data)
                        val.append(self._robot_id)
                    self._robot_id = val[0]
                    # create a robot selection menu
                    robot_menu = Spinner(
                        # default robot showed
                        text=self._ros_uri[0].split('.')[3],
                        # available robots/values
                        values = val,
                        # just for positioning in our example
                        size_hint=(None, None),
                        size=(100, 44),
                        pos_hint={'center_x': .1, 'center_y': .8})
                    self.add_widget(robot_menu)
                    robot_menu.bind(text=self.selected_robot)
                    robot_menu_label = \
                        Label(text='Select a robot:', 
                        pos_hint={'center_x': .1, 'center_y': .87})
                    self.add_widget(robot_menu_label)
                    from threading import Thread
                    spin_thread = Thread(target=lambda: rospy.spin())
                    spin_thread.start()
                    break
                except socket.error:
                    count += 1
                    import time
                    time.sleep(.5)

                if count > 100:
                    waiting = 'Waiting for meta server at %s'
                    uri="http://" + hostname + ":12345"
                    Logger.info(waiting, uri)