示例#1
1
    def layout(self):
        self.user = ''

        def on_text_email(instance, value):
            self.user = str(value)
            setButtonColor()

        layout = BoxLayout(
                        orientation= 'vertical',
                        padding= (dp(48),2*dp(48)),
                        spacing= dp(48),
                        )

        userField = MDTextField()
        userField.hint_text = "Enter user ID"
        userField.bind(text=on_text_email)
        layout.add_widget(userField)

        proceedButton = MDRaisedButton(text='Enter Information', size_hint=(None, None),size= (4*dp(48),dp(48)))
        proceedButton.md_bg_color = [0.9, 0, 0, 0.9]
        app = App.get_running_app()

        def setButtonColor():
            if self.user != '':
                proceedButton.text = 'Proceed'
                proceedButton.md_bg_color = app.theme_cls.primary_color
                proceedButton.bind(on_press=lambda x: self.processInformation())

        proceedAnchor = AnchorLayout(anchor_x='center',anchor_y='center')
        proceedAnchor.add_widget(proceedButton)
        layout.add_widget(proceedAnchor)

        return layout
示例#2
0
	def build(self):
		global root
		root = BoxLayout(orientation="vertical")
		
		#some art/whatsoever
		root.add_widget(Label(text="Whirl it Away"))
		
		#enable Facebook
		fb = Button(text="Login to Facebook")
		fb.bind(on_press = self.login_facebook)
		root.add_widget(fb)
		
		#enable Twitter
		twit = Button(text="Login to Twitter")
		twit.bind(on_press = self.login_twitter)
		root.add_widget(twit)
		
		login_button_area = AnchorLayout(anchor_x = 'right', anchor_y='bottom')
		login_button = Button(text="Let's go")
		login_button.bind(on_press = self.login)
		login_button_area.add_widget(login_button)
		
		
		root.add_widget(login_button_area)
		
		return root
示例#3
0
    def add_meaning_full(self, row):

        """
        Add a meaning row on the GUI to let the user add his own meaning
        :param instance:
        :return:
        """

        self.found_numb += 1
        self.counter += 1
        bl = BoxLayoutH50(id='bl'+str(self.found_numb))
        al = AnchorLayout(anchor_x='center', anchor_y='center', size_hint_x=0.05, size_hint_y=None, height=self.app.row_height)
        al.add_widget(IconButtonDel(id='btn'+str(self.found_numb), on_press=self.remove_line))
        bl.add_widget(al)
        al2 = AnchorLayout(anchor_x='center', anchor_y='center', size_hint_x=0.05, size_hint_y=None, height=self.app.row_height)
        btn_ref = IconButtonRefresh(id='btn_ref'+str(self.found_numb))
        btn_ref.bind(on_press=self.update_wiki)
        al2.add_widget(btn_ref)
        bl.add_widget(al2)
        bl.add_widget(TextInputH50(id='found', text=row.found, size_hint_x=0.25))
        bl.add_widget(TextInputH50(id='url'+str(self.found_numb), text=row.url, size_hint_x=0.3))
        if row.disambiguation_url == 1:
            bl.add_widget(CheckBoxH50(id='dis'+str(self.found_numb), size_hint_x=0.15, active=True))
        else:
            bl.add_widget(CheckBoxH50(id='dis'+str(self.found_numb), size_hint_x=0.15))
        bl.add_widget(CheckBoxH50(id='approved'+str(self.found_numb), size_hint_x=0.1, active=True))
        bl.add_widget(CheckBoxH50(id='chosen'+str(self.found_numb), group='chosen', size_hint_x=0.1))
        self.grid_row.add_widget(bl)
示例#4
0
    def add_meaning_empty(self, instance):

        """
        Add a meaning row on the GUI to let the user add his own meaning
        :param instance:
        :return:
        """
        self.grid_row.remove_widget(self.addmore)

        self.found_numb += 1
        self.counter += 1
        bl = BoxLayoutH50(id='bl'+str(self.found_numb))
        al = AnchorLayout(anchor_x='center', anchor_y='center', size_hint_x=0.05, size_hint_y=None, height=self.app.row_height)
        al.add_widget(IconButtonDel(id='btn'+str(self.found_numb), on_press=self.remove_line))
        bl.add_widget(al)
        bl.add_widget(TextInputH50(id='found'+str(self.found_numb), text='', size_hint_x=0.3))
        bl.add_widget(TextInputH50(id='url'+str(self.found_numb), text='', size_hint_x=0.3))
        bl.add_widget(CheckBoxH50(id='dis'+str(self.found_numb), size_hint_x=0.15))
        bl.add_widget(CheckBoxH50(id='approved'+str(self.found_numb), size_hint_x=0.1))
        if self.found_numb == 1:
            bl.add_widget(CheckBoxH50(id='chosen'+str(self.found_numb),
                                   group='chosen', size_hint_x=0.1, active=True))
        else:
            bl.add_widget(CheckBoxH50(id='chosen'+str(self.found_numb),
                                   group='chosen', size_hint_x=0.1))
        self.grid_row.add_widget(bl)
        self.grid_row.add_widget(self.addmore)
 def update_jobdata(self, *args):
     data = check_all_job_status().get('Jobs', [])
     for idx, job in enumerate(data):
         if job[1] == "Finished":
             job[1] = ("checkbox-marked-circle",
                       [39 / 256, 174 / 256, 96 / 256, 1], "Finished")
         else:
             job[1] = ("alert-circle", [1, 0, 0, 1], "Running")
         job.append(("information", [255 / 256, 165 / 256, 0, 1], ""))
     if len(data) == 1:
         data.append(data[0])
     self.job_data.clear_widgets()
     layout = AnchorLayout()
     data_tables = MDDataTable(
         size_hint=(0.9, 0.9),
         use_pagination=True,
         check=True,
         column_data=[
             ("Jobname", dp(50), self.sort_on_jobname),
             ("Progress", dp(30)),
             ("Status", dp(30)),
             ("Get information", dp(30)),
         ],
         row_data=data,
     )
     data_tables.bind(on_row_press=self.show_jobdata_info)
     # TODO: Rework color settings for better readability
     layout.add_widget(data_tables)
     self.job_data.add_widget(layout)
     self.job_table = data_tables
     return
示例#6
0
    def build(self):
        self.root = NavigationDrawer()
        self.root.side_panel_opacity = 0
        self.root.separator_image_width = sp(0)
        menu = BoxLayout(orientation='vertical')

        resetButton = Factory.GreenButton(text='New Game')
        settingsButton = Factory.OrangeButton(text='Settings')
        helpButton = Factory.PurpleButton(text='Help')
        menu.add_widget(resetButton)
        menu.add_widget(settingsButton)
        menu.add_widget(helpButton)
        resetButton.bind(on_press=self.reset)

        self.root.add_widget(menu)

        content = AnchorLayout(anchor_x='right', anchor_y='bottom', paddind=sp(5))



        toggleButton = IconButton (icon="atlas://img/icon/iconatlas/icon-menu", size_hint=(.15, .1),
            background_normal='atlas://img/button/buttonatlas/red',
            background_down='atlas://img/button/buttonatlas/orange')
        toggleButton.bind(on_press=lambda j: self.root.toggle_state())

        content.add_widget(sm)
        content.add_widget(toggleButton)
        self.root.add_widget(content)
        sm.current = 'titleScreen'
        return self.root
示例#7
0
    def __init__(self, **kwargs):
        super(viewDayPopup, self).__init__(**kwargs)

        box = BoxLayout(orientation='vertical', spacing=10)
        get_input_box = BoxLayout(size_hint=(1, None), height=30)
        self.day_input = TextInput(multiline=False)
        self.month_input = TextInput(multiline=False)
        self.year_input = TextInput(multiline=False)
        day_lbl = Label(text='Ngày')
        month_lbl = Label(text='Tháng')
        year_lbl = Label(text='Năm')

        submit_btn = Button(text='OK', size_hint=(.2, 1), halign='center')
        anchor_submit_layout = AnchorLayout(anchor_x='center')
        anchor_submit_layout.add_widget(submit_btn)

        get_input_box.add_widget(day_lbl)
        get_input_box.add_widget(self.day_input)
        get_input_box.add_widget(month_lbl)
        get_input_box.add_widget(self.month_input)
        get_input_box.add_widget(year_lbl)
        get_input_box.add_widget(self.year_input)

        box.add_widget(get_input_box)
        box.add_widget(anchor_submit_layout)

        self.add_widget(box)
        self.day_input.focus = True
        self.day_input.bind(on_text_validate=self.dayValidate)
        self.month_input.bind(on_text_validate=self.monthValidate)
        self.year_input.bind(on_text_validate=self.yearValidate)
        submit_btn.bind(on_release=self.update)
示例#8
0
    def search(self, instance):

        def close(instance):
            popup.dismiss()


        author = self.author_input.text
        # if not author:
        #     author = '*'
        name = self.name_input.text
        # if not author:
        #     name = '*'
        year = self.year_input.text
        # if not author:
        #     year = '*'


        text = '\n'.join(list(' '.join(i) for i in self.db.find(author, name, year)))

        content = AnchorLayout()
        bl = BoxLayout(orientation="vertical", spacing=5)

        bl.add_widget(Label(text=text))
        bl.add_widget(Button(text="close", on_press=close, size_hint=(1, .4)))

        content.add_widget(bl)



        popup = Popup(title='search result: ', content=content, size_hint=(None, None), size=(500, 800))
        popup.open()
示例#9
0
	def __init__(self, **kwargs):
		super(viewDayPopup, self).__init__(**kwargs)

		box = BoxLayout(orientation='vertical', spacing=10)
		get_input_box = BoxLayout(size_hint=(1, None), height=30)
		self.day_input = TextInput(multiline=False)
		self.month_input = TextInput(multiline=False)
		self.year_input = TextInput(multiline=False)
		day_lbl = Label(text='Ngày')
		month_lbl = Label(text='Tháng')
		year_lbl = Label(text='Năm')

		submit_btn = Button(text='OK', size_hint=(.2, 1), halign='center')
		anchor_submit_layout = AnchorLayout(anchor_x='center')
		anchor_submit_layout.add_widget(submit_btn)

		get_input_box.add_widget(day_lbl)
		get_input_box.add_widget(self.day_input)
		get_input_box.add_widget(month_lbl)
		get_input_box.add_widget(self.month_input)
		get_input_box.add_widget(year_lbl)
		get_input_box.add_widget(self.year_input)

		box.add_widget(get_input_box)
		box.add_widget(anchor_submit_layout)

		self.add_widget(box)
		self.day_input.focus = True
		self.day_input.bind(on_text_validate=self.dayValidate)
		self.month_input.bind(on_text_validate=self.monthValidate)
		self.year_input.bind(on_text_validate=self.yearValidate)
		submit_btn.bind(on_release=self.update)
    def make(self):
        self.orientation = 'vertical'

        self.add_widget(
            Label(text="Select the level of detail",
                  color=(0, 0, 0, 1),
                  height=40,
                  size_hint_y=None))

        slider_centerer = AnchorLayout(anchor_x='center', anchor_y='bottom')
        self.slider = Slider(min=0,
                             max=8,
                             value=4,
                             step=1,
                             width=180,
                             height=100,
                             size_hint_x=None,
                             size_hint_y=None)
        slider_centerer.add_widget(self.slider)

        label_bottomer = AnchorLayout(anchor_y='bottom')
        value_text = Label(text="4", color=(0, 0, 0, 1))

        def UpdateValueText(instance, value):
            value_text.text = str(int(value))

        self.slider.bind(value=UpdateValueText)
        label_bottomer.add_widget(value_text)

        self.add_widget(label_bottomer)
        self.add_widget(slider_centerer)

        self.switch_button = Button(text="OK")
        self.add_widget(self.switch_button)
示例#11
0
文件: ПЗ34.py 项目: Designeed/DoMA
 def build(self):
     al = AnchorLayout()
     bl = BoxLayout(orientation="vertical",
                    size_hint=[None, None],
                    size=[200, 300],
                    spacing=5)
     bl.add_widget(
         TextInput(text="Логин",
                   font_size=32,
                   background_color=[.18, .57, .39, 1]))
     bl.add_widget(
         TextInput(text="Пароль",
                   font_size=32,
                   background_color=[.18, .57, .39, 1]))
     bl.add_widget(
         Button(text="Войти",
                font_size=32,
                background_color=[.17, .84, .53, 1]))
     bl.add_widget(
         Button(text="Регистрация",
                font_size=32,
                background_color=[.17, .84, .53, 1],
                on_press=self.btn_press))
     bl.add_widget(MyCheckbox())
     bl.add_widget(Label(text='забыли пароль?', font_size=16))
     al.add_widget(bl)
     return al
示例#12
0
    def __init__(self, **kwargs):  # defines initial properties of the GUI.
        super(BaseGUI,
              self).__init__(**kwargs)  # this has to be here, trust me...
        self.rows = 2
        self.add_widget(
            Button(text="Screen Manager\n    Placeholder", size_hint_y=5))

        # adds empty toolbar to bottom row.
        toolbar = FloatLayout()
        self.add_widget(toolbar)

        # anchored toolbar buttons to centre of toolbar.
        toolbarButtonsAnchor = AnchorLayout(anchor_x="center",
                                            anchor_y="center")
        toolbar.add_widget(toolbarButtonsAnchor)

        # created gridlayout for 5 toolbar buttons.
        toolbarButtons = GridLayout(size_hint=(0.5, 0.5))
        toolbarButtons.cols = 5
        toolbarButtonsAnchor.add_widget(toolbarButtons)

        #Create the toolbar buttons
        shuffleBtn = Button(text="Shuffle")
        backBtn = Button(text="Back")
        playBtn = Button(text="Play")
        forwardBtn = Button(text="Forward")
        loopBtn = Button(text="Loop")

        #adding buttons to the toolbar
        toolbarButtons.add_widget(shuffleBtn)
        toolbarButtons.add_widget(backBtn)
        toolbarButtons.add_widget(playBtn)
        toolbarButtons.add_widget(forwardBtn)
        toolbarButtons.add_widget(loopBtn)
示例#13
0
    def details(self, pos, size):
        anchor_layout = AnchorLayout(pos=pos,
                                     size=size,
                                     anchor_x='center',
                                     anchor_y='center')
        pet = Label(
            padding=(dp(15), dp(15)),
            size_hint=(1, 1),
            halign='left',
            valign='top',
            markup=True,
            text='[color=150470][size=' + str(int(dp(20))) +
            '][font=assets/Inter-SemiBold.ttf]' + self._name[0] + '\n[size=' +
            str(int(dp(18))) + '][font=assets/Inter-Medium.ttf]' +
            self._gender[0] + '\n[size=' + str(int(dp(16))) +
            '][font=assets/Inter-Regular.ttf]' + self._date.split(':')[0])
        pet.bind(size=pet.setter('text_size'))
        time = Label(padding=(dp(15), dp(15)),
                     halign='right',
                     valign='bottom',
                     markup=True,
                     text='[color=150470][size=' + str(int(dp(18))) +
                     '][font=assets/Feather.ttf]юд▓[size=' + str(int(dp(18))) +
                     '][font=assets/Inter-Medium.ttf] 5 Hours Ago')
        time.bind(size=time.setter('text_size'))
        anchor_layout.add_widget(pet)
        anchor_layout.add_widget(time)

        return anchor_layout
示例#14
0
    def create(self, data, author):
        screen_manager = ScreenManager(transition=SlideTransition(),
                                       size_hint=(1, 1))
        grid_layout = GridLayout(cols=1)
        anchor_layout = AnchorLayout(size_hint=(1, 0.9),
                                     padding=(dp(20), dp(0), dp(20), dp(0)))
        rv2 = self.ProfileRV(pets_list=data,
                             author=author,
                             smooth_scroll_end=dp(10),
                             root=anchor_layout,
                             screen_manager=screen_manager,
                             size_hint=(1, 1),
                             effect_cls=ScrollEffect,
                             bar_inactive_color=(0, 0, 0, 0),
                             bar_color=(0, 0, 0, 0))

        anchor_layout.add_widget(rv2)
        grid_layout.add_widget(MainProfileHeader())
        grid_layout.add_widget(anchor_layout)
        rv_screen = Screen(name='RV2')
        rv_screen.add_widget(grid_layout)
        screen_manager.add_widget(rv_screen)

        reported_screen = self.CustomScreen(name='Profile')
        reported_screen.add_widget(screen_manager)

        return reported_screen
示例#15
0
    def build(self):
        # Anchor Layout1
        anchorLayout1 = AnchorLayout(anchor_x='left', anchor_y='bottom')
        button1 = Button(text='test', size_hint=(0.3, 0.3))

        def callback(instance):
            print('The button <%s> is being pressed' % instance.text)
            publish.single("test", hostname="192.168.1.11")

        button1.bind(on_press=callback)
        anchorLayout1.add_widget(button1)

        # Anchor Layout2
        anchorLayout2 = AnchorLayout()
        anchorLayout2.anchor_x = 'right'
        anchorLayout2.anchor_y = 'top'

        # Add the anchor layouts to a box layout
        vid = Video(source="http://192.168.1.11:8081/", play=True)
        anchorLayout2.add_widget(vid)

        # Create a box layout
        boxLayout = BoxLayout()

        # Add both the anchor layouts to the box layout
        boxLayout.add_widget(anchorLayout1)
        boxLayout.add_widget(anchorLayout2)

        # Return the boxlayout widget
        return boxLayout
示例#16
0
    def add_input(self):
        input_num = self.ids.PermTextInput.text
        spots_num = self.ids.PermSpotsInput.text
        try:
            spots_num = int(spots_num)
            permed_num = Permute(input_num, spots_num)
        except ValueError:
            permed_num = Permute(input_num)
        if isinstance(spots_num, int):
            output_num = str(input_num + '/' + str(spots_num) + ' spots: ' +
                             permed_num)
            font_size = 60
        else:
            font_size = 70
            output_num = str(input_num + ': ' + permed_num)
        label_text = self.add_newlines(output_num)

        output_label = ScaleLabel(text=label_text,
                                  size_hint=[0.8, .5],
                                  pos_hint={
                                      'right': 0.91,
                                      'top': .79
                                  },
                                  font_size=font_size)

        layout_wrapper = AnchorLayout(anchor_x='center', anchor_y='center')
        layout_wrapper.add_widget(output_label)
        self.ids.PermOutputGrid.add_widget(layout_wrapper)
示例#17
0
class MainScreen(Screen):
    buttons = {'main':['alarm']}
    settings = commonFunc.getYaml('settings')
    def __init__(self, **kwargs):
        self.bgImage = kwargs['background']
        super(MainScreen, self).__init__(**kwargs)
    def on_enter(self):
        grid = GridLayout()
        self.grid2 = AnchorLayout()
        self.bg = ImgButton(size=(800,480)) #CONFIG
        self.bg.source = self.bgImage.image()
        self.bg.bind(on_press=partial(app.change_view,'main'))
        self.grid2.add_widget(self.bg)
        for btn in self.buttons[self.name]:
            button = MainButton(text=btn,pos=getPos())
            button.bind(on_press=partial(app.change_view,btn,''))
            grid.add_widget(button)
        self.add_widget(self.grid2)
        self.add_widget(grid)
        Clock.schedule_interval(self.callback,self.settings['timeOut']) #CONFIG

    def on_leave(self):
        Clock.unschedule(self.callback)
        self.remove_widget(self.grid2)

    def callback(self,instalnce):
        self.bg.source=self.bgImage.nextImage()
    def __init__(self, txt, list, existing=None, **kwargs):
        super(CheckboxModal, self).__init__(**kwargs)
        self.size_hint = (None, None)

        gridSize = len(list) * 75
        self.size = (600, 200 + gridSize)
        self.auto_dismiss = False
        g = GridLayout(cols=4)

        self.checked_values = {}
        g.add_widget(Label(text='Req #'))
        g.add_widget(Label(text='High'))
        g.add_widget(Label(text='Medium'))
        g.add_widget(Label(text='Low'))
        for item in list:
            if existing and item in existing:
                self.add_check_box_group(g, item, existing[item])
            else:
                self.add_check_box_group(g, item)

        layout = BoxLayout(orientation='vertical')
        layout.add_widget(
            Label(text=txt, size_hint=(None, None), size=(600, 100)))
        layout.add_widget(g)
        content = Button(text='Ok', size_hint=(None, None), size=(100, 30))
        cancel = Button(text='Cancel', size_hint=(None, None), size=(100, 30))
        layout2 = BoxLayout(orientation='horizontal')
        layout2.add_widget(content)
        layout2.add_widget(cancel)
        anchor_lc = AnchorLayout(anchor_x='center', anchor_y='bottom')
        anchor_lc.add_widget(layout2)
        layout.add_widget(anchor_lc)
        self.add_widget(layout)
        content.bind(on_press=self.close)
        cancel.bind(on_press=self.dismiss)
示例#19
0
    def __init__(self, scroll_view=None):
        super(MyNavigationLayout, self).__init__()
        self.content_nav_drawer = ContentNavigationDrawer(self)
        self.drawer_open = False
        self.scroll_view = scroll_view

        self.add_widget(self.content_nav_drawer)
        toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.toolbar = MDToolbar()
        self.toolbar.anchor_title = 'center'
        self.toolbar.elevation = 0
        self.toolbar.theme_text_color = 'Custom'
        self.toolbar.text_color = [1, 1, 1, 1]
        self.toolbar.md_bg_color = App.get_running_app(
        ).theme_cls.primary_color
        self.toolbar.left_action_items = [[
            'menu', lambda x: self.toggle_nav_drawer()
        ]]
        toolbar_anchor.add_widget(self.toolbar)
        self.add_widget(toolbar_anchor)

        # This is here because on scroll views the buttons behind the nav bar
        # will count as being pressed instead of the nav drawer buttons
        if self.scroll_view:
            Clock.schedule_interval(self.disable_scroll_buttons, 0.1)
示例#20
0
    def build(self):

        al = AnchorLayout()

        bl_search = BoxLayout(spacing=5, orientation="vertical", size_hint=[.6, .5])
        gl_search = GridLayout(cols=2, padding=[30], spacing=3)

        self.author_input = TextInput()
        self.name_input = TextInput()
        self.year_input = TextInput()
        self.button_search = Button(text="search", on_press=self.search)
        self.button_add = Button(text="add", on_press=self.add)


        gl_search.add_widget(Label(text="Author:"))
        gl_search.add_widget(self.author_input)

        gl_search.add_widget(Label(text="Book name:"))
        gl_search.add_widget(self.name_input)

        gl_search.add_widget(Label(text="Year:"))
        gl_search.add_widget(self.year_input)


        bl_search.add_widget(gl_search)
        bl_search.add_widget(self.button_search)
        bl_search.add_widget(self.button_add)

        al.add_widget(bl_search)

        return al
def create_welcome_layout(screen_manager):
    """ Bring together items for the general_layout in the welcome screen.

    :param screen_manager: The manager for screens in the application.
    :return: A general_layout containing the welcome screen.
    """
    general_layout = generate_layout()

    author_layout = AnchorLayout(anchor_x="center", anchor_y="bottom")
    author = create_author()
    author_layout.add_widget(author)

    button_title_layout = BoxLayout(orientation="vertical")
    title = create_title()
    subtitle = create_subtitle()
    continue_btn = create_menu_button(screen_manager)
    button_title_layout.add_widget(title)
    button_title_layout.add_widget(subtitle)
    button_title_layout.add_widget(continue_btn)

    version_layout = AnchorLayout(anchor_x="center", anchor_y="bottom")
    version = create_version()
    version_layout.add_widget(version)

    general_layout.add_widget(author_layout)
    general_layout.add_widget(button_title_layout)
    general_layout.add_widget(version_layout)

    return general_layout
示例#22
0
 def build(self):
     anchor_layout = AnchorLayout(anchor_x='center', anchor_y='center')
     open_button = Button(text='Open',
                          size_hint=(.4, .4),
                          on_press=self.send_sms)
     anchor_layout.add_widget(open_button)
     return anchor_layout
示例#23
0
    def __init__(self, app, **kwargs):
        super().__init__(**kwargs)
        self.app = app

        self.orientation = "horizontal"
        self.padding = (5, 0)
        self.adaptive_height = True

        self.label = MDLabel()
        self.label.halign = "center"
        self.add_widget(self.label)

        self.check1 = Check(self.update_value1)
        self.add_widget(self.check1)

        self.check2 = Check(self.update_value2)
        self.check2.size = ("36dp", "36dp")
        checkAnchor = AnchorLayout()
        checkAnchor.add_widget(self.check2)
        checkAnchor.anchor_x = "center"
        self.add_widget(checkAnchor)
        checkAnchor.size_hint_x = 0.2

        self.check3 = Check(self.update_value3)
        self.add_widget(self.check3)

        self.bind(text=self.update_text)
    def __init__(self, **kwargs):
        # 父类构造方法
        super().__init__(**kwargs)

        # 设置背景颜色(可忽略)
        with self.canvas:
            # 背景颜色
            Color(1, 1, 1, 1)
            # 浮动布局矩形 = 矩形(位置=布局位置,大小=布局大小)
            self.rect = Rectangle(pos=self.pos, size=self.size)
            # 浮动布局绑定(位置=布局矩形位置,大小=设置背景尺寸)
            self.bind(pos=self.update_rect, size=self.update_rect)

        # 锚点布局,左上角
        anchor_first = AnchorLayout(anchor_x='left', anchor_y='top')
        # 锚点布局,加按钮
        anchor_first.add_widget(Button(text='左上角', size_hint=[.3, .2]))

        # 锚点布局,右下角
        anchor_second = AnchorLayout(anchor_x='right', anchor_y='bottom')
        # 锚点布局,加按钮
        anchor_second.add_widget(Button(text='右下角', size_hint=[.3, .2]))

        # 加组件(锚点布局,左上角)
        self.add_widget(anchor_first)
        # 加组件(锚点布局,右下角)
        self.add_widget(anchor_second)
示例#25
0
    def circular_image(self, pos, size):
        card_x, card_y = pos
        card_width, card_height = size
        padding = dp(15)

        x = card_x + card_width - (dp(110) + padding)
        y = card_y + card_height - (dp(110) + padding)

        border = self.Border(pos=(x, y), size=(dp(110), dp(110)))
        border.prepare()

        circle = self.Circle(source=self._image[0], pos=border.pos)
        if circle.image_ratio < 1:
            circle.size_hint = (circle.image_ratio + 1, circle.image_ratio + 1)
        else:
            circle.size_hint = (circle.image_ratio, circle.image_ratio)
        circle.prepare()

        anchor_layout = AnchorLayout(pos=border.pos,
                                     anchor_x='center',
                                     anchor_y='center',
                                     size=border.size)
        anchor_layout.add_widget(circle)

        border.add_widget(anchor_layout)
        return border
示例#26
0
	def build(self):
		Builder.load_file('screens/login.kv')
		Builder.load_file('screens/home.kv')
		Builder.load_file('screens/scenarios.kv')
		Builder.load_file('main.kv')
		
		self.body.add_widget(Login(LoginMenu, 'loginmenu', None, name = 'login'))
		self.body.add_widget(Home(HomeMenu, 'homemenu', None, name = 'home'))
		self.body.add_widget(Scenarios(ScenariosMenu, 'scenariosmenu', 'home', name = 'scenarios'))
		self.body.add_widget(NewScenario(NewScenarioMenu, 'newscenariomenu', 'scenarios', name = 'newscenario'))
		self.body.current = 'login'
		
		self.menu.height = '48dp'
		self.menu.size_hint_y = None
		self.use_kivy_settings = False
		self.settings_cls = SettingsWithSidebar
		
		screen =  AnchorLayout(anchor_x='right', anchor_y='top')
		screen.add_widget(self.body)
		screen.add_widget(self.menu)
		
# 		screen = BoxLayout(orientation='vertical')
# 		screen.add_widget(self.menu)
# 		screen.add_widget(self.body)
				
		return screen
示例#27
0
 def handle_waitready(self, message):
     self.container.clear_widgets()
     btn = Label(label='En attente...', cls=['pentabtn', 'ready'],
             size=(200, 100))
     anchor = AnchorLayout(size=self.container.size)
     anchor.add_widget(btn)
     self.container.add_widget(anchor)
示例#28
0
def show_recommendation_popup(rec_list):
    '''
    Responsible for create and preform the pop window for error message
    :param rec_list: list of end station recommendations
    '''
    layout = GridLayout(cols=1, rows=2, padding=10)
    if len(rec_list) == 0:
        text = "Sorry, no locations \nwere found"
    else:
        text = '\n'.join(rec_list)
    popupLabel = Label(text=text,
                       halign="center",
                       valign="middle",
                       size_hint=(1.0, 1.0),
                       padding=(5, 5))
    anchorLayout = AnchorLayout(size_hint_y=None, height=50)
    closeButton = Button(text="Close me!", height=20)
    anchorLayout.add_widget(closeButton)
    layout.add_widget(popupLabel)
    layout.add_widget(anchorLayout)
    # Instantiate the modal popup and display
    popup = Popup(title='Recommended Locations',
                  content=layout,
                  size_hint=(None, None),
                  size=(200, 320))
    popup.open()
    # Attach close button press with popup.dismiss action
    closeButton.bind(on_press=popup.dismiss)
示例#29
0
    def build(self):
        layout = AnchorLayout(anchor_x='right', anchor_y='center')

        btn1 = Button(text="Button 1")
        btn2 = Button(text="Button 2")
        btn3 = Button(text="Button 3")
        btn4 = Button(text="Button 4")
        btn5 = Button(text="Button 5")

        layout.add_widget(btn1)

        layout.anchor_x = 'center'
        layout.anchor_y = 'center'
        layout.add_widget(btn2)

        layout.anchor_x = 'left'
        layout.anchor_y = 'center'
        layout.add_widget(btn3)

        layout.anchor_x = 'right'
        layout.anchor_y = 'bottom'
        layout.add_widget(btn4)

        layout.anchor_x = 'center'
        layout.anchor_y = 'bottom'
        layout.add_widget(btn5)
        return layout
示例#30
0
def HelpMenu(instance):
	window = instance.parent.parent
	window.clear_widgets()
	
	textLayout = AnchorLayout(anchor_x='center', anchor_y='center')
			
	buttonLayout = AnchorLayout(anchor_x='right', anchor_y='top', padding=5)		
	btn = Button(text='Main Menu', background_color=(0.2,0.32,1.8,1), size_hint=(0.1,0.1))
	btn.bind(on_press=clickSoundPlay)
	btn.bind(on_release=mainMenu)
		
	DescObjLabel = Label(text='[b]Description[/b]\n\nQuarto is a game played by two players on a 4x4,' 
	'16 space board. There are 16 different pieces that can be constructed\n in any combination of ' 
	'four characteristics (Size, Color, Shape, Hole) in an attempt to win the game.\n\n[b]Objective[/b]'
	'\n\nTo win the game a line of pieces with matching characteristics (Four big pieces, four little, '
	'four dark, four light, four with a hole,\nor four without a hole) must be constructed. '
	'These pieces can be layed out horizontally, vertically, or diagonally.\n\n'
	'[b]Gameplay[/b]\n\nPlayers move alternatively, placing one piece on the board at a time. ' 
	'Note that once a piece has been placed on the board it \ncannot be moved again. '
	'Perhaps the most unique aspect of Quarto is that the choice of the piece to be placed on the board\n'
	'is not decided by the player placing the piece, but by the opponent. Each turn consists of two actions:\n\n'
	'     [b]1.[/b] Place the piece given by the opponent on the board.\n\n     [b]2.[/b] Give the opponent the '
	'piece to be played on the next move\n\nTo start the game the player needs only to select the piece for '
	'his opponent to play.', markup=True)
		
	textLayout.add_widget(DescObjLabel)
	buttonLayout.add_widget(btn)
		
	window.add_widget(textLayout)
	window.add_widget(buttonLayout)
示例#31
0
    def __init__(self, info, manager, **kwargs):
        super().__init__(**kwargs)
        self.info = info
        self.manager = manager
        self.elevation = 10

        box_container = BoxLayout()
        title = MDLabel(text=info[1],
                        font_style="H6",
                        halign="center",
                        font_size=9)
        distance = MDLabel(
            text=str(info[15]) + " Miles",
            font_style="H6",
            halign="center",
            font_size=9,
        )
        box_container.add_widget(title)
        box_container.add_widget(distance)

        background_button = Button(background_color=[0, 0, 0, 0],
                                   on_release=self.enter_info_screen)

        anchor = AnchorLayout()
        anchor.add_widget(background_button)
        anchor.add_widget(box_container)

        self.add_widget(anchor)
示例#32
0
    def __init__(self, **kw):
        super(MainScreen, self).__init__(**kw)

        ModeRoadButton = Button(text='Детектирование дорожной разметки',
                                on_press=lambda x: detect_line(),
                                font_size=14)

        ModeSignButton = Button(text='Детектирование дорожных знаков',
                                on_press=lambda x: detect_sign(),
                                font_size=14)

        MainLayout = AnchorLayout()
        ControlLayout = BoxLayout(orientation='vertical',
                                  size_hint=[.7, .9],
                                  padding=100,
                                  spacing=10)
        ControlLayout.add_widget(
            Label(text="Выберите режим работы приложения",
                  font_size=14,
                  size_hint=[1, .2]))
        ControlLayout.add_widget(Widget())
        ControlLayout.add_widget(ModeRoadButton)
        ControlLayout.add_widget(ModeSignButton)
        MainLayout.add_widget(ControlLayout)
        self.add_widget(MainLayout)
示例#33
0
    def setLayout(self):
        self.size = (1500, 1000)

        with self.canvas:
            Color(.532345, 1.0, .742, 1.0)
            Rectangle(size=self.size)

        sound_board_layout = AnchorLayout()
        sound_board_layout.anchor_x = "center"
        sound_board_layout.anchor_y = "top"
        sound_board_layout.size = self.size
        sound_board_layout.pos = self.pos
        sound_board_layout.size_hint = (1.0, 1.0)
        sound_board_layout.spacing = 50

        self.title_layout.orientation = "vertical"
        self.title_layout.size_hint = (1.0, 1.0)
        self.title_layout.spacing = 10

        title_label = Label()
        title_label.text = "Soundboard"
        title_label.color = [.6, .2, 1, .5]
        title_label.font_size = 50
        title_label.font_name = "C:\\Windows\\Fonts\\Arial"
        title_label.size_hint = (1, 1)
        self.title_layout.add_widget(title_label)

        self.set_settings_layout()

        self.set_sounds()

        self.title_layout.add_widget(self.grid_layout)
        sound_board_layout.add_widget(self.title_layout)

        self.add_widget(sound_board_layout)
示例#34
0
    def create(self, **kwargs):
        """ 
        Creates this row as a BoxLayout containing the widgets
        """
        new_args = {
            'size_hint': (None, None),
            'width': SCREEN_SIZE[0] * self.rel_size[0],
            'height': SCREEN_SIZE[1] * self.rel_size[1],
            'orientation': 'horizontal'
        }
        for var, val in new_args.items():
            if var not in kwargs:
                kwargs[var] = val

        box = BoxLayout(**kwargs)
        for item in self.items:
            if self.h_alignment == 'center':
                anchor = AnchorLayout(size_hint=(item.rel_size[0] /
                                                 self.rel_size[0], 1),
                                      anchor_x=self.h_alignment)
                anchor.add_widget(item.widget)
                box.add_widget(anchor)
            elif self.h_alignment == 'left':
                item.widget.pos_hint = {'top': 1}
                box.add_widget(item.widget)
        return box
示例#35
0
class Results(GridLayout):
    def __init__(self, sn_root, **kwargs):
        super().__init__(**kwargs)
        self.sn_root = sn_root
        self.cols = 2

        self.ans_text = Label(markup=True)

        self.df_text = Label()

        self.pro_image = Image()

        self.button_layout = AnchorLayout(anchor_x='left', anchor_y='bottom')
        home_button = Button(text="Home", size_hint=(0.3, .3))
        home_button.bind(on_press=self.go_home)
        self.button_layout.add_widget(home_button)

    def go_home(self, instance):
        self.sn_root.go_home()

    def print_results(self, direc):
        df, ans, img = self.sn_root.rrun(img_path=direc)
        dfs = df.to_string()
        self.ans_text.text = '[size=40][b]' + ans + '[/b][/size]' + "           "
        self.df_text.text = dfs
        self.pro_image.source = img
        self.add_widget(self.ans_text)
        self.add_widget(self.df_text)
        self.add_widget(self.button_layout)
        self.add_widget(self.pro_image)
示例#36
0
class HomePage(PageBase):
    """HomePage of the App.

    This is the first page that the user will see."""

    def __init__(self, app):
        """Constructor"""
        # Call the base.
        super(HomePage, self).__init__(app)

        # Load the backend
        self.backend = SpecialBackend(FlatfileBackend())

        # Create a body manually, overriding the default.
        self.body = AnchorLayout(anchor_x='center', anchor_y='center')
        stack_layout = StackLayout(size_hint=(0.95, 0.6))
        self.body.add_widget(stack_layout)

        text_layout =  BoxLayout(anchor_x='left', anchor_y='center', size_hint=(0.8, None))
        text_layout.height = '35px'
        stack_layout.add_widget(text_layout)

        def on_enter(sender):
            self._on_search(sender, self.query.text)
        self.query = TextInput(text='', multiline=False, hint_text='Type here...')
        self.query.bind(on_text_validate=on_enter)
        text_layout.add_widget(self.query)


        button_layout =  BoxLayout(anchor_x='right', anchor_y='center', size_hint=(0.2, None))
        button_layout.height = '35px'
        stack_layout.add_widget(button_layout)

        def on_search_press(sender):
            self._on_search(self.query, self.query.text)
        search = Button(text='Search!')
        search.width = '50px'
        search.bind(on_press=on_search_press)
        button_layout.add_widget(search)

        self.search_results = RichPage.get_page(app, [self], self.backend, 'search')

        def on_category_press(sender):
            RichPage.get_page(app, [self], self.backend, 'categories').show(self)
            self.hide()
        category = Button(text='Categories', size_hint=(None, None), height='35px')
        category.width = '100px'
        category.bind(on_press=on_category_press)        
        self.body.add_widget(category)

    def _on_search(self, sender, value):
        """Called when the user trys to search."""
        query = value
        self.query.text = ''

        self.backend.cached_search(query)
        self.search_results.reload()

        self.hide()
        self.search_results.show(self)
    def popup_dictionary(self, dictionary, instance):

        lay_minmax_words = BoxLayout(orientation='vertical', spacing=6)
        lay_center_minmaxbtn = AnchorLayout(anchor_x='center',
                                            anchor_y='center',
                                            size_hint=(1, .3))

        self.popup = Popup(title="Create my dictionary",
                           content=lay_minmax_words,
                           size=(400, 370),
                           size_hint=(None, None))
        inp_min_len = TextInput(text='',
                                hint_text='minimum length',
                                size_hint=(1, .4))
        inp_max_len = TextInput(text='',
                                hint_text='maximum length',
                                size_hint=(1, .4))
        filename = TextInput(text='', hint_text='file name', size_hint=(1, .4))

        self.progressbar = ProgressBar(max=1100, size_hint=(1, .2))
        self.update_bar = Clock.create_trigger(self.update_bar_event)

        btn_minmax_submit = Button(text="Submit",
                                   size_hint=(.5, 1),
                                   on_press=partial(self.submit_dictionary,
                                                    dictionary, inp_min_len,
                                                    inp_max_len, filename,
                                                    self.update_bar_event))
        self.progressbar.value = 0
        lay_center_minmaxbtn.add_widget(btn_minmax_submit)

        lay_minmax_words.add_widget(
            Label(text='File Name:', size_hint=(1, .2), font_size='16sp'))
        lay_minmax_words.add_widget(
            Label(text='(For default length leave empty):',
                  size_hint=(1, .2),
                  font_size='14sp'))
        lay_minmax_words.add_widget(filename)
        lay_minmax_words.add_widget(
            Label(text='Words minimum length:',
                  size_hint=(1, .2),
                  font_size='16sp'))
        lay_minmax_words.add_widget(
            Label(text='(For default length leave empty):',
                  size_hint=(1, .2),
                  font_size='14sp'))
        lay_minmax_words.add_widget(inp_min_len)
        lay_minmax_words.add_widget(
            Label(text='Words maximum length:',
                  size_hint=(1, .2),
                  font_size='16sp'))
        lay_minmax_words.add_widget(
            Label(text='(For default length leave empty):',
                  size_hint=(1, .2),
                  font_size='14sp'))
        lay_minmax_words.add_widget(inp_max_len)
        lay_minmax_words.add_widget(self.progressbar)
        lay_minmax_words.add_widget(lay_center_minmaxbtn)

        self.popup.open()
    def on_enter(self, *args):

        x = self.input_img.children[0].norm_image_size[
            0] / self.progressbar.parent.size[0]
        self.progressbar_size = (x, 1)

        imga = DownloadableAsyncImage(size_hint=(1, 1),
                                      keep_ratio=True,
                                      mipmap=True,
                                      source='http://asjdfjl')
        al = AnchorLayout()
        al.add_widget(imga)
        self.styled_img.add_widget(al)

        # self.send_request()
        self.show_progress()
        self.request()
        # t1 = threading.Thread(target=self.request)
        # t2 = threading.Thread(target=self.progress)
        # t1.start()
        # t2.start()
        # t1.join()
        # t1.join()
        # t = threading.Thread(target=self.request).start()
        print('enter output_screen')
示例#39
0
    def build(self, func):

        root = BoxLayout(orientation='vertical',
                         padding='5dp',
                         size_hint=(1, None))
        root.size_y = '100dp'
        with root.canvas:
            Color(.88, .88, .88)
            Rectangle(pos=root.pos, size=root.size)
        b0 = BoxLayout()
        a1 = AnchorLayout(size_hint=(1, 1))
        # короткое имя
        btn = Button(size_hint=(1, 1),
                     text='Add ' + self.short,
                     on_press=func,
                     id=self.short)
        a1.add_widget(btn)

        # содержит картинку
        a2 = AnchorLayout(anchor_x='right', anchor_y='center')
        i1 = Image(size_hint=(None, None),
                   source=paths.images + 'flags/{}.png'.format(self.short))
        i1.width = '60dp'
        i1.height = '60dp'
        a2.add_widget(i1)
        b0.add_widget(a1)
        b0.add_widget(a2)

        root.add_widget(b0)

        return root
示例#40
0
 def set_layout(self):
     
     #anchor_left = AnchorLayout(anchor_x='left', anchor_y='bottom')
     boxlayout1 = BoxLayout(orientation='horizontal', size_hint=(None, None), size=(Window.width, '%sdp' % self._height)) #, size=('350dp', 0))
     button_menu = Button(size_hint=(None, None), size=('127dp', '51dp'), border=(0, 0, 0, 0), 
                          background_normal='resources/interface/menu.png',
                          background_down='resources/interface/menu-pressed.png',
                          background_disabled_normal='resources/interface/menu.png',
                          background_color=(1, 1, 1, 1),
                          on_release=self.go_to_menu
                          )
     self.button_menu = button_menu
     #button_save = Button(size_hint=(None, None), size=('132dp', '57dp'), border=(0, 0, 0, 0),
     #                     background_normal='resources/interface/save.png',
     #                     background_down='resources/interface/save-pressed.png',
     #                     background_color=(1, 1, 1, 1))
     button_play = Button(size_hint=(None, None), size=('68dp', '51dp'), border=(0, 0, 0, 0),
                          background_normal='resources/interface/pause.png',
                          background_down='resources/interface/pause-pressed.png',
                          background_disabled_normal='resources/interface/pause.png',
                          on_release=GameContext.game.pause,
                          background_color=(1, 1, 1, 1))
     boxlayout1.add_widget(button_menu)
     #boxlayout1.add_widget(button_save)
     boxlayout1.add_widget(button_play)
     
     self.button_play = button_play
     self.button_play.set_paused = self.set_paused
     self.button_play.set_resumed = self.set_resumed
     
     #anchor_left.add_widget(boxlayout1)
     
     anchor_center = AnchorLayout(anchor_x='center', anchor_y="bottom", size_hint=(1, 1))
     #size=(Window.width, '%sdp' % self._height))
     steps = Label(text="STEPS:0", font_size="31dp", font_name=FONT_NAME) #, font_name="resources/Intro.ttf")
     self.steps = steps
     anchor_center.add_widget(steps)
     
     boxlayout1.add_widget(anchor_center)
     
     #anchor_right = AnchorLayout(anchor_x='right', anchor_y="bottom", size_hint=(None, None),
     #                             size=(Window.width, '%sdp' % self._height))
     boxlayout2 = BoxLayout(orientation='horizontal', size_hint=(None, 1), size=('120dp', 0))
     button_trees = Button(size_hint=(None, None), size=('68dp', '57dp'), border=(0, 0, 0, 0),
                          background_normal='resources/interface/trees.png',
                          background_down='resources/interface/trees.png',
                          background_disabled_normal='resources/interface/trees_press.png',
                          background_color=(1, 1, 1, 1),
                          on_release=GameContext.game.switch_to_plant_tree
                          )
     number_of_trees = Label(text='x5', font_size="31dp", font_name=FONT_NAME)
     boxlayout2.add_widget(button_trees)
     boxlayout2.add_widget(number_of_trees)
     
     self.button_trees = button_trees
     self.number_of_trees = number_of_trees
     
     boxlayout1.add_widget(boxlayout2)
     self.add_widget(boxlayout1)
示例#41
0
 def _greeting(dt):
     
     anchor = AnchorLayout(anchor_x='center', anchor_y='center', size=(Window.width, Window.height))
     label = Label(text='TAP TO START', font_size='50dp', bold=True, font_name=FONT_NAME)
     anchor.add_widget(label)
     anchor.bind(on_touch_up=self.close_greeting)
     self.greeting_msg = anchor
     self.add_widget(self.greeting_msg)
示例#42
0
    def test_anchorlayout_default(self):
        from kivy.uix.anchorlayout import AnchorLayout
        r = self.render
        b = self.box

        layout = AnchorLayout()
        layout.add_widget(b(1, 0, 0))
        r(layout)
    def handleGoal(self):
        def go_next_callback(instance):
            self.popup.dismiss()
            main.switchLevel()
            return False
            
        if self.isToolOnGoal and self.isPersonOnGoal:
            if self.activeTool.isGoal and self.activePerson.isGoal:
                print "FINISHED? ",isFinished
                while not isFinished: #notwendig, weil sonst 2 mal aufgerufen (touch_events feuern alle 2 mal)
                    global isFinished
                    isFinished = True
                    
                    btnBGSource = ''
                         
                    if currentLevel <= len(levels)-1:
                        btnBGSource = unichr(61518)
                    else:
                        btnBGSource = unichr(61470)
                                           
                    box = AnchorLayout(size_hint=(1, 1), anchor_x= "right", anchor_y= "bottom")     
                    btn = Button(font_size=100, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0.7])
                    btn.bind(on_press=go_next_callback)
                    
                    #vid = Video(source=self.levelInfos[levelProps[3]], play=True)                    
                    #box.add_widget(vid)
                    
                    #instead of laggy video insert just an image
                    img = Image(source=self.levelInfos[levelProps[3]])
                    img.allow_stretch = True
                    box.add_widget(img)
                    imgBtn = Button(font_size=60, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0], size_hint= (0.15, 0.15))
                    imgBtn.bind(on_press=go_next_callback)
                    box.add_widget(imgBtn)
                    
                    def end_of_vid(video, eos):
                        logging.info("endofvid")
                        #video.play=False #not working on android...
                        box.add_widget(btn)
                        #video.unload() #not working on android...
                        #logging.info("video unloaded")
                        
                    def showit():
                        print "showing video popup"
                        self.popup.open()
                        if self.winSound:
                            self.winSound.play()

                    #vid.bind(loaded=lambda foo,bar: showit())
                    #vid.bind(eos=lambda video,eos:end_of_vid(video,eos))
                                                                          
                         
                    self.popup = Popup(content=box,size_hint=(0.8, 0.7),auto_dismiss=False)
                    
                    self.hidePopupTitle(self.popup)
                    
                    showit()
                    Clock.schedule_once(lambda wumpe:box.add_widget(btn), 8)
示例#44
0
文件: main.py 项目: GunioRobot/kivy
 def show_accordion(self):
     root = Accordion()
     for x in xrange(5):
         item = AccordionItem(title='Title %d' % x)
         item.add_widget(Label(text='Very big content\n' * 10))
         root.add_widget(item)
     col = AnchorLayout()
     col.add_widget(root)
     return col
示例#45
0
文件: main.py 项目: gravyboat/andcat
    def create_and_add_widgets(self, screen_label=''):
        main_label = AndCatLabel(text='AndCat',
                                 size_hint=(1.0, None,),
                                 height=50)
        logo_container = AnchorLayout(anchor_x='right')
        logo_img = Image(source='logo.png', size_hint=(None, None,), width=50, height=50)

        logo_container.add_widget(logo_img)
        self.add_widget(main_label)
        self.add_widget(logo_container)
示例#46
0
    def __init__(self, app, parent, title, **kw):
        logging.info('PysolAboutDialog:')
        super(PysolAboutDialog, self).__init__()

        self._url = kw['url']
        logging.info('PysolAboutDialog: txt=%s' % title)

        text = kw['text']
        text = text + '\n' + self._url
        logging.info('PysolAboutDialog: txt=%s' % text)

        text = text + '\n\n' + 'Adaptation to Kivy/Android\n' + \
            ' Copyright (C) (2016-17) LB'

        self.parent = parent
        self.app = app
        self.window = None
        self.running = False
        self.status = 1  # -> von help.py so benötigt
        self.button = 0  # -> von help.py so benötigt

        # bestehenden Dialog rezyklieren.

        logging.info('PysolAboutDialog: 1')
        onlyone = PysolAboutDialog.AboutDialog
        if (onlyone and onlyone.running):
            return
        if (onlyone):
            onlyone.parent.pushWork('AboutDialog', onlyone.window)
            onlyone.running = True
            return

        # neuen Dialog aufbauen.

        window = LTopLevel(parent, title, size_hint=(1.0, 1.0))
        window.titleline.bind(on_press=self.onClick)
        self.parent.pushWork('AboutDialog', window)
        self.window = window
        self.running = True
        PysolAboutDialog.AboutDialog = self

        if kw['image']:
            image = LImage(texture=kw['image'].texture)
            image.size_hint = (1, 0.8)
            al = AnchorLayout()
            al.add_widget(image)
            al.size_hint = (1, 0.3)
            window.content.add_widget(al)

        label = FText(text=text, halign='center', size_hint=(1, 1))
        window.content.add_widget(label)

        '''
示例#47
0
    def test_anchor_layout_xy(self):
        from kivy.uix.anchorlayout import AnchorLayout
        r = self.render
        b = self.box

        layout = AnchorLayout(anchor_y='bottom', anchor_x='left')
        layout.add_widget(b(1, 0, 0))
        r(layout)

        layout = AnchorLayout(anchor_y='top', anchor_x='right')
        layout.add_widget(b(1, 0, 0))
        r(layout)
示例#48
0
 def _retrieve_photo(self, *largs):
     ## Select and download the image
     photos = self.photos
     photo_count = len(photos)
     photo = photos[random.randint(0,photo_count-1)]
     title = self.title_cls(text=photo[u'title'], text_size=(200,None), id='title')
     img = self.image_cls(source=photo[u'media'][u'm'], id='img')
     layout = AnchorLayout(anchor_x='center', anchor_y='center')
     btn = ViewerButton(text='Flickr!')
     btn.bind(on_press=self._select_image)
     layout.add_widget(btn)
     return (img,title,layout)
示例#49
0
 def build(self):
   f = FloatLayout()
   
   self.l = Label(text='Hello', font_size=75, valign='top', size_hint=(1,.5))
   labelAnch = AnchorLayout(anchor_x='center', anchor_y='top')
   labelAnch.add_widget(self.l)
   
   b = Button(text='clicky', font_size=75, size_hint=(1,.5), on_press=self.callback)
   buttonAnch = AnchorLayout(anchor_x='center', anchor_y='bottom')
   buttonAnch.add_widget(b)
   f.add_widget(labelAnch)
   f.add_widget(buttonAnch)
   return f
示例#50
0
    def test_anchor_layout_xy(self):
        from kivy.uix.anchorlayout import AnchorLayout

        r = self.render
        b = self.box

        layout = AnchorLayout(anchor_y="bottom", anchor_x="left")
        layout.add_widget(b(1, 0, 0))
        r(layout)

        layout = AnchorLayout(anchor_y="top", anchor_x="right")
        layout.add_widget(b(1, 0, 0))
        r(layout)
示例#51
0
    def __init__(self, **kwargs):
        super(ProductDetailScreen, self).__init__(**kwargs)
        # File name of the beer selected
        # NEEDS TO BE SET
        #bottle_name = ('Coors_Lightbottle.jpg')
        # Beer name from the given bottle name
        #beer_name = re.sub('[^a-zA-Z0-9\n]', ' ', bottle_name)
        #beer_name = beer_name[:-4]
        # Beer text description pulled cfrom the given beer_name
        # NEEDS TO BE SET
        self.descriptionAnchor.add_widget(self.descriptionLabel)
        # self.info_layout.add_widget(self.nameLabel_two)
        # self.info_layout.add_widget(self.locationLabel)
        # self.info_layout.add_widget(self.priceLabel)

        self.info_layout.add_widget(self.descriptionAnchor)
        self.bottleImage_layout.add_widget(self.bottleImage)
        # Get all the tags for the given beer
        # NEEDS TO BE SET
        beer_tags = 'sports football stadium party coors molson light beer mountains'
        tag_list = []
        for i in beer_tags.split():
            tag_list.append(i)
        # Horizontal Scrollable View
        grid_one_layout = GridLayout(cols=30, spacing=5, size_hint_x=None)
        # Make sure the height is such that there is something to scroll.
        grid_one_layout.bind(minimum_width=grid_one_layout.setter('width'))
        for tag_name in tag_list:
            relative_one_layout = AnchorLayout(size_hint_x=None, size_hint_y=None, height=30, width=100)
            btn = Button(size_hint_y=None, size_hint_x=None, height=30, width=100, background_color=[1,1,1,1])
            label = Label(text=tag_name, color=[0,0,0,1], size_hint=(None, None), height=30, width=relative_one_layout.width, halign='center', pos_hint={'x':0,'y':0})
            relative_one_layout.add_widget(btn)
            relative_one_layout.add_widget(label)
            grid_one_layout.add_widget(relative_one_layout)

        scroll_view_one = ScrollView(bar_color=[0,0,0,0], size_hint=(1.0, None), height=30, pos_hint={'x':0.0,'y':0.0})
        scroll_view_one.do_scroll_y=False
        scroll_view_one.do_scroll_x=True
        scroll_view_one.add_widget(grid_one_layout)
        #self.add_widget(scroll_view_one)


        # Add wigets to the product detail page
        self.add_widget(self.logoImage)
        self.add_widget(self.bottleImage_layout)
        self.add_widget(self.nameLabel)

        self.add_widget(self.nameLabel_two)
        self.add_widget(self.locationLabel)
        self.add_widget(self.priceLabel)
        self.add_widget(self.info_layout)
示例#52
0
    def set_list(self):
        #Get all image file name in Images Craft Bottles
        first_list = []
        second_list = []
        if self.query_result is None:
            i = 0
            for name in os.listdir('./images/bottles/'):
                if i%2 == 0:
                    first_list.append(name)
                else:
                    second_list.append(name)
                i = i + 1
            #get all Items
        else:
            i = 0
            for name in self.query_result:
                if i%2 == 0:
                    first_list.append(name+'.jpg')
                else:
                    second_list.append(name+'.jpg')
                i = i + 1
        # Clear widget first
        self.scroll_view_one.clear_widgets()
        self.scroll_view_two.clear_widgets()
        self.remove_widget(self.scroll_view_one)
        self.remove_widget(self.scroll_view_two)
        #First Horizontal Scrollable View
        grid_one_layout = GridLayout(cols=len(first_list), spacing=10, size_hint_x=None)
        #Make sure the height is such that there is something to scroll.
        grid_one_layout.bind(minimum_width=grid_one_layout.setter('width'))
        for file_name in first_list:
            anchor_one_layout = AnchorLayout(size_hint_x=None, size_hint_y=None, height=240, width=200, anchor_x='center', anchor_y='bottom')
            btn = Button(text=file_name, color=[0,0,0,0], size_hint_y=None, size_hint_x=None, height=240, width=200, background_color=[1,1,1,1], background_normal='images/bottles/{f_name}'.format(f_name=file_name))
            btn.bind(on_press=self.on_item_click)
            beer_name = file_name[:-4]
            label = Label(text=beer_name, color=[0,0,0,1], italic=True, font_size='12dp', size_hint=(None, None), height=30, width=anchor_one_layout.width, halign='center', pos_hint={'x':0,'y':0})
            anchor_one_layout.add_widget(btn)
            anchor_one_layout.add_widget(label)
            grid_one_layout.add_widget(anchor_one_layout)

        self.scroll_view_one.add_widget(grid_one_layout)
        self.add_widget(self.scroll_view_one)

        #First Horizontal Scrollable View
        grid_two_layout = GridLayout(cols=len(second_list), spacing=10, size_hint_x=None)
        #Make sure the height is such that there is something to scroll.
        grid_two_layout.bind(minimum_width=grid_two_layout.setter('width'))
        for file_name in second_list:
            anchor_two_layout = AnchorLayout(size_hint_x=None, size_hint_y=None, height=240, width=200, anchor_x='center', anchor_y='bottom')
            btn = Button(text=file_name, color=[0,0,0,0], size_hint_y=None, size_hint_x=None, height=240, width=200, background_color=[1,1,1,1], background_normal='images/bottles/{f_name}'.format(f_name=file_name))
            btn.bind(on_press=self.on_item_click)
            beer_name = file_name[:-4]
            label = Label(text=beer_name, color=[0,0,0,1], italic=True, font_size='12dp', size_hint=(None, None), height=30, width=anchor_two_layout.width, halign='center', pos_hint={'x':0,'y':0})
            anchor_two_layout.add_widget(btn)
            anchor_two_layout.add_widget(label)
            grid_two_layout.add_widget(anchor_two_layout)

        self.scroll_view_two.add_widget(grid_two_layout)
        self.add_widget(self.scroll_view_two)
示例#53
0
文件: main.py 项目: hartym/kivy
 def show_popup(self):
     btnclose = Button(text="Close this popup", size_hint_y=None, height=50)
     content = BoxLayout(orientation="vertical")
     content.add_widget(Label(text="Hello world"))
     content.add_widget(btnclose)
     popup = Popup(
         content=content, title="Modal popup example", size_hint=(None, None), size=(300, 300), auto_dismiss=False
     )
     btnclose.bind(on_release=popup.dismiss)
     button = Button(text="Open popup", size_hint=(None, None), size=(150, 70))
     button.bind(on_release=popup.open)
     popup.open()
     col = AnchorLayout()
     col.add_widget(button)
     return col
示例#54
0
文件: main.py 项目: DanAlbert/kivy
 def show_popup(self):
     btnclose = Button(text='Close this popup', size_hint_y=None, height='50sp')
     content = BoxLayout(orientation='vertical')
     content.add_widget(Label(text='Hello world'))
     content.add_widget(btnclose)
     popup = Popup(content=content, title='Modal popup example',
                   size_hint=(None, None), size=('300dp', '300dp'))
     btnclose.bind(on_release=popup.dismiss)
     button = Button(text='Open popup', size_hint=(None, None),
                     size=('150sp', '70dp'),
                     on_release=popup.open)
     popup.open()
     col = AnchorLayout()
     col.add_widget(button)
     return col
示例#55
0
	def build2(self):
		textinput = TextInput(text='Type the broadcast message here', multiline=False)
		textinput.bind(on_text_validate=self.broadcast_now)
		root.add_widget(textinput)
		
		enable_fb = AnchorLayout(anchor_x = 'right', anchor_y='bottom')
		box1 = BoxLayout(orientation="vertical")
		tick_fb = Label(text="fb")
		box1.add_widget(tick_fb)
		post_to_facebook = CheckBox()
		post_to_facebook.bind(active=self.on_facebook_active)
		box1.add_widget(post_to_facebook)
		enable_fb.add_widget(box1)
		
		enable_twit = AnchorLayout(anchor_x = 'right', anchor_y='bottom')
		box1 = BoxLayout(orientation="vertical")
		tick_fb = Label(text="twtr")
		box1.add_widget(tick_fb)
		post_to_facebook = CheckBox()
		post_to_facebook.bind(active=self.on_twitter_active)
		box1.add_widget(post_to_facebook)
		enable_twit.add_widget(box1)
		
		post_root = BoxLayout(orientation="horizontal")
		post_root.add_widget(enable_fb)
		post_root.add_widget(enable_twit)
		root.add_widget(post_root)
		
		button = Button(text="Submit")
		button.bind(on_press = self.broadcast_now)
		root.add_widget(button)
		
		#Facebook posts
		posts = BoxLayout(orientation="horizontal")
		fb_posts = BoxLayout(orientation="vertical")
		fb_posts_header = Label(text="Status Messages")
		fb_posts.add_widget(fb_posts_header)
		fb_posts.add_widget(self.build3(fb_posts))
		posts.add_widget(fb_posts)
		
		#Twitter posts
		twit_posts = BoxLayout(orientation="vertical")
		twit_posts_header = Label(text="Tweets")
		twit_posts.add_widget(twit_posts_header)
		twit_posts.add_widget(self.build4())
		posts.add_widget(twit_posts)
		
		root.add_widget(posts)
示例#56
0
文件: main.py 项目: Belxjander/Kirito
 def show_invalid_balance_popup(self):
     btnclose = Button(text='Close this popup', size_hint_y=None, height='50sp')
     content = BoxLayout(orientation='vertical')
     row_length = 15
     content.add_widget(Label(text='Not enough money for send.'))
     content.add_widget(btnclose)
     popup = Popup(content=content, title='Not enough...',
                   size_hint=(None, None), size=('300dp', '300dp'))
     btnclose.bind(on_release=popup.dismiss)
     button = Button(text='Open popup', size_hint=(None, None),
                     size=('150sp', '70dp'),
                     on_release=popup.open)
     popup.open()
     col = AnchorLayout()
     col.add_widget(button)
     return col
示例#57
0
文件: main.py 项目: Belxjander/Kirito
 def show_copied_popup(self, address):
     btnclose = Button(text='Close this popup', size_hint_y=None, height='50sp')
     content = BoxLayout(orientation='vertical')
     row_length = 15
     for i in range(0, len(address), row_length):
         content.add_widget(Label(text=address[i:i + row_length]))
     content.add_widget(btnclose)
     popup = Popup(content=content, title='Copied Address',
                   size_hint=(None, None), size=('300dp', '300dp'))
     btnclose.bind(on_release=popup.dismiss)
     button = Button(text='Open popup', size_hint=(None, None),
                     size=('150sp', '70dp'),
                     on_release=popup.open)
     popup.open()
     col = AnchorLayout()
     col.add_widget(button)
     return col
示例#58
0
    def setTopImage(self, image, cw=0, ch=0):
        print('MfxCanvas: setTopImage %s' % image)

        if self.topImage:
            self.clear_widgets([self.topImage])
            self.topImage = None

        if image:
            tex = LImage(texture=image.texture)
            tex.size_hint = (0.4, 0.4)
            lay = AnchorLayout(anchor_y='bottom')
            lay.size = self.size
            lay.add_widget(tex)

            self.topImage = lay
            self.add_widget(self.topImage)

        return 1
示例#59
0
    def build2(self):
        controls = AnchorLayout(anchor_x='right', anchor_y='top', height=200)
        box = BoxLayout(size_hint_y=None, height=50)



        upc_l = Label(text='UPC:', font_size=40, size_hint_x=None, width=100,)
        entry = TextInput(font_size=40, size_hint_x=None, width=350)
        search_b = Button(text='Search', font_size=40, size_hint_x=None,
                          width=200, background_color=[0,1.7,0,1])


        controls.add_widget(box)
        box.add_widget(upc_l)
        box.add_widget(entry)
        box.add_widget(search_b)


        return controls