Пример #1
0
class Test(MDApp):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.screen = MDScreen()

        # self.cust = MDRaisedButton(text="I AM A BUTTON")
        self.cust = MDRaisedButton(text="I AM A BUTTON", on_release=self.custom_func)

        self.menu_items = [
            {
                "text": f"Item {i}",
                "viewclass": "OneLineListItem",
                "on_release": lambda x=f"Item {i}": self.menu_callback(x),
            } for i in range(5)
        ]

        self.menu = MDDropdownMenu(
            caller=self.cust,
            items=self.menu_items,
            width_mult=4,
        )

        # self.cust.on_release=self.custom_func
        self.screen.add_widget(self.cust)


    def custom_func(self, *args, **kwargs):
        self.menu.open()

    def menu_callback(self, text_item):
        print(text_item)

    def build(self):
        return self.screen
Пример #2
0
 def __init__(self, **kwargs):
     super(OneUIBrowserRulesListItem, self).__init__(**kwargs)
     self.menu = MDDropdownMenu(caller=self.ids.rule_item,
                                items=self.menu_items,
                                width_mult=3,
                                selected_color=[0, 0, 0, .3])
     self.menu.bind(on_release=self.menu_callback)
Пример #3
0
    def PrintDataItem2(self):

        if len(df) == 0:
            self.show_confirmation_dialog("Veuillez charger votre fichier")

        else:
            try:
                NumRows = df.shape[0]

                menu_items = [{
                    "text":
                    f"Example {i}",
                    "viewclass":
                    "OneLineListItem",
                    "on_release":
                    lambda x=f"Example {i}": self.set_item2(x),
                } for i in range(NumRows)]

                self.menu2 = MDDropdownMenu(
                    caller=self.screen.ids.dropdown_item2,
                    items=menu_items,
                    width_mult=3,
                )
                self.menu2.bind()

            except Exception as e:
                self.show_confirmation_dialog("Veuillez charger votre fichier")
Пример #4
0
 def on_kv_post(self, base_widget):
     self.dropdown = MDDropdownMenu(
         caller=self,
         items=[{"text": "+24"}, {"text": "-24"}, {"text": "+1"}, {"text": "-1"}],
         width_mult=4,
         callback=self.update_amount
     )
Пример #5
0
    def __init__(self, id, *args, **kwargs):
        super().__init__(**kwargs)
        if id:
            person = next(
                (obj for obj in app.persons.person_list if obj['id'] == id),
                None)
        else:
            person = {
                "id":
                app.persons.person_list[len(app.persons.person_list) - 1]["id"]
                + 1,
                "name":
                "",
                "state":
                "Stát"
            }
            print(person)

        self.ids.person_name.text = person['name']

        STATES = [
            'CAN', 'CZE', 'FIN', 'GBR', 'GER', 'JAP', 'NOR', 'POL', 'RUS',
            'SVK', 'SWE', 'USA'
        ]
        menu_items = [{"icon": "git", "text": f"{state}"} for state in STATES]
        self.menu = MDDropdownMenu(
            caller=self.ids.state_item,
            items=menu_items,
            position="center",
            width_mult=4,
        )
        self.ids.state_item.set_item(person['state'])
        self.menu.bind(on_release=self.set_item)
class HomeScreen(MDScreen):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        items = [
            "New group",
            "New broadcasts",
            "WhatsApp Web",
            "Starred messages",
            "Payments",
            "Settings",
        ]
        menu_items = [{
            "text":
            item,
            "viewclass":
            "OneLineListItem",
            "height":
            dp(54),
            "divider":
            None,
            "on_release":
            self.menu_callback if item == "Settings" else lambda *args: None,
        } for item in items]
        self.menu = MDDropdownMenu(
            items=menu_items,
            width_mult=3,
            radius=[
                dp(2),
            ],
        )

    def open_menu(self, button):
        self.menu.caller = button
        self.menu.open()

    def menu_callback(self):
        self.manager.set_screen("settings")
        self.menu.dismiss()

    def on_tab_switch(self, *args):
        if args[3] == "[b]CHATS[/b]":
            self.ids.float_btn.icon = "android-messages"
        elif args[3] == "[b]STATUS[/b]":
            self.ids.float_btn.icon = "camera"
        elif args[3] == "[b]CALLS[/b]":
            self.ids.float_btn.icon = "phone-plus"

        self.toggle_pencil_btn(args[3])

    def toggle_pencil_btn(self, current_tab):
        if current_tab == "[b]STATUS[/b]":
            anim = Animation(d=0.1,
                             y=self.ids.float_btn.y +
                             (self.ids.float_btn.height + dp(10)))
            self.ids.pencil_btn.disabled = False
        else:
            anim = Animation(d=0.1, y=self.ids.float_btn.y)
            self.ids.pencil_btn.disabled = True

        anim.start(self.ids.pencil_btn)
Пример #7
0
    def __init__(self, id, *args, **kwargs):
        super().__init__(**kwargs)
        if id:
            book = vars(app.books.database.read_by_id(id))
        else:
            book = {
                "id": "",
                "name": "Název knihy",
                "year": "",
                "author": "Autor",
                "genre": "Žánr"
            }

        self.ids.book_name.text = book['name']
        authors = app.books.database.read_authors()
        #genres = app.books.database.read_genres()
        menu_items_authors = [{
            "viewclass":
            "OneLineListItem",
            "text":
            f"{author.name}",
            "on_release":
            lambda x=f"{author.name}": self.set_item(x)
        } for author in authors]
        """menu_items_genres = [{"viewclass": "OneLineListItem", "text": f"{genre.name}",
                       "on_release": lambda x=f"{genre.name}": self.set_item(x)} for genre in genres]"""
        self.menu_authors = MDDropdownMenu(
            caller=self.ids.author_item,
            items=menu_items_authors,
            position="center",
            width_mult=5,
        )
        self.ids.author_item.set_item(book['author'])
        self.ids.author_item.text = book['author']
        """self.menu_genres = MDDropdownMenu(
Пример #8
0
    def __init__(self, master, **kwargs):
        super().__init__(**kwargs)
        self.master = master
        self.input_bar = self.ids.SearchFieldID
        self.input_bar.focus = True
        self.downloader_sites = [
            "manganelo", "kissmanga", "rawdevart", "senmanga"
        ]

        # Side menu
        icons = iter([
            resource_path("./DATA/manga_nelo_icon.png"),
            resource_path("./DATA/kissmanga_logo.png"),
            resource_path("./DATA/rawdevart_logo.png"),
            resource_path("./DATA/sen_manga_logo.png")
        ])
        menu_items = [{
            "height": "70dp",
            "right_content_cls": RightContentCls(site),
            "icon": next(icons),
            "text": site
        } for site in self.downloader_sites]
        self.btn = MDRaisedButton(text="Manga sites",
                                  pos_hint={
                                      "center_x": .85,
                                      "center_y": .5
                                  },
                                  on_release=lambda x: self.menu.open())
        self.menu = MDDropdownMenu(caller=self.btn,
                                   items=menu_items,
                                   width_mult=4)
        self.menu.bind(on_release=self.menu_callback)
        self.add_widget(self.btn)
Пример #9
0
class UdajeZamestnanec(BoxLayout):
    def __init__(self, id, *args, **kwargs):
        super().__init__(**kwargs)
        if id:
            zamestnanec = vars(app.zamestnanci.database.read_zamestnanec_by_id(id))
        else:
            zamestnanec = {"id":"", "jmeno":"","pozice":"","firma":""}

        self.ids.zamestnanec_jmeno.text = zamestnanec['jmeno']
        firmy = app.zamestnanci.database.read_firma()
        menu_items = [{"viewclass": "OneLineListItem", "text": f"{firma.nazev}", "on_release": lambda x=f"{firma.nazev}": self.set_item(x)} for firma in firmy]
        self.menu_firmy = MDDropdownMenu(
            caller=self.ids.firma_nazev,
            items=menu_items,
            position="center",
            width_mult=5,
        )
        self.ids.nazev.set_item(zamestnanec['firma'])
        self.ids.pozice.text = zamestnanec['pozice']

    def set_item(self, text_item):
        self.ids.nazev.set_item(text_item)
        self.ids.nazev.text = text_item
        # Zavření menu
        self.menu_firmy.dismiss()
Пример #10
0
    def __init__(self, id, *args, **kwargs):
        super().__init__(**kwargs)
        if id:
            animal = vars(app.animals.database.read_animal_by_id(id))
        else:
            animal = {"id": "", "name": "", "typee": "Type"}

        self.ids.animal_name.text = animal['name']

        types = app.animals.database.read_types()

        menu_items = [{
            "viewclass":
            "OneLineListItem",
            "text":
            f"{typee.full_name}",
            "on_release":
            lambda x=f"{typee.full_name}": self.set_item(x)
        } for typee in types]

        self.menu_types = MDDropdownMenu(
            caller=self.ids.type_item,
            items=menu_items,
            position="center",
            width_mult=5,
        )

        self.ids.type_item.set_item(animal['typee'])
        self.ids.type_item.text = animal['typee']
Пример #11
0
class Test(MDApp):
    submenu = None

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.screen = Builder.load_string(KV)
        menu_items = [{
            "icon": "git",
            "text": f"Item {i}" if i != 3 else "Open submenu",
        } for i in range(5)]
        self.menu = CustomDrop(caller=self.screen.ids.button,
                               items=menu_items,
                               width_mult=4,
                               selected_color=self.theme_cls.bg_darkest)
        self.menu.bind(on_enter=self.check_item)

    def check_item(self, menu, item):
        if item.text == "Open submenu" and not self.submenu:
            menu_items = [{"text": f"Item {i}"} for i in range(5)]
            self.submenu = MDDropdownMenu(
                caller=item,
                items=menu_items,
                width_mult=4,
                selected_color=self.theme_cls.bg_darkest,
            )
            self.submenu.bind(on_dismiss=self.set_state_submenu)
            self.submenu.open()

    def set_state_submenu(self, *args):
        self.submenu = None

    def build(self):
        return self.screen
Пример #12
0
class ModalEdit(ModalView):
    def __init__(self, root):
        super(ModalEdit, self).__init__()
        menu_items = [{
            "text": str(i[1])
        } for i in root.DB.type_name_db.select_all()]
        self.root_app = root
        self.menu = MDDropdownMenu(
            caller=self.ids.p_type,
            items=menu_items,
            position="bottom",
            width_mult=4,
        )
        self.menu.bind(on_release=self.set_item)

    def ok_sw(self, root_app):
        name = self.ids.name.text
        p_type = self.ids.p_type.text
        about = self.ids.about.text
        price = self.ids.price.text
        root_app.DB.product_db.insert_date(
            ('name', 'p_type', 'about', 'price'), (name, p_type, about, price))
        self.dismiss()

    def set_item(self, instance_menu, instance_menu_item):
        def set_item(interval):
            assert interval == interval
            self.ids.p_type.text = instance_menu_item.text
            instance_menu.dismiss()

        Clock.schedule_once(set_item, 0.5)
Пример #13
0
 def load_page(self, greg):
     ContentNavigationDrawer.populateNavDrawerValues(self)
     query = "SELECT ORG_ID,NAME,REGISTRATION,DESC FROM ORG WHERE REGISTRATION='" + greg + "'"
     # run direct SQL
     stmt = ibm_db.exec_immediate(connection.conn, query)
     userrow = ibm_db.fetch_tuple(stmt)
     org_id = ""
     org_name = ""
     org_reg = ""
     org_desc = ""
     if userrow != False:
         org_id = userrow[0]
         org_name = userrow[1]
         org_reg = userrow[2]
         org_desc = userrow[3]
     globalvariables.var_org_id = org_id
     self.ids['gname'].text = org_name
     self.ids['greg'].text = org_reg
     self.ids['gdesc'].text = org_desc
     #USED TO POPULATE DROP DOWN OF ACTIVITY FOR PAYMENTS FOR NON JOINERS
     query = "SELECT ACTIVITY_ID,NAME FROM ACTIVITY WHERE ORG_ID=" + str(
         globalvariables.var_org_id)
     stmt = ibm_db.exec_immediate(connection.conn, query)
     act = ibm_db.fetch_both(stmt)
     actlist = []
     while (act):
         actlist.append(str(act[1]))
         act = ibm_db.fetch_both(stmt)
     self.menu = MDDropdownMenu(caller=self.ids['activity_item'],
                                position="center",
                                width_mult=5,
                                callback=self.set_item)
     for i in actlist:
         self.menu.items.append({"text": str(i)})
    def __init__(self, *args, **kwargs):
        super().__init__(**kwargs)

        self.user = None
        if (len(args) > 0):
            self.user = args[0].get('user', None)

        if (self.user == None):
            self.user = User(None, '', '', '', UserRole.person.value)

        self.ids.username.text = self.user.username
        self.ids.fullname.text = self.user.fullname

        if (self.user.password == None):
            self.ids.password.text = ''
        else:
            self.ids.password.text = self.user.password

        if (self.user.userRole != None):
            self.ids.user_role.text = self.user.userRole
            self.ids.user_role.current_item = self.user.userRole

        role_items = [{"text": str(i.value)} for i in UserRole]
        self.role_menu = MDDropdownMenu(
            caller=self.ids.user_role,
            items=role_items,
            position="center",
            width_mult=4,
            callback=self.set_item,
        )
 def create_dropdown(self, caller, item, callback):
     menu = MDDropdownMenu(caller=caller,
                           items=item,
                           position="center",
                           width_mult=20)
     menu.bind(on_release=callback)
     return menu
Пример #16
0
    def on_enter(self):
        ele_menu_items = [{
            "icon": "thermometer",
            "text": "Temperature"
        }, {
            "icon": "water",
            "text": "Moisture"
        }, {
            "icon": "weather-windy",
            "text": "Wind"
        }]

        self.ele_menu = MDDropdownMenu(
            caller=self.ids.ele_drop_item,
            items=ele_menu_items,
            position="bottom",
            width_mult=4,
        )
        self.ele_menu.bind(on_release=self.ele_set_item)

        per_menu_items = [{
            "icon": "calendar-today",
            "text": "Daily"
        }, {
            "icon": "calendar-clock",
            "text": "Interannual"
        }]

        self.per_menu = MDDropdownMenu(
            caller=self.ids.per_drop_item,
            items=per_menu_items,
            position="bottom",
            width_mult=4,
        )
        self.per_menu.bind(on_release=self.per_set_item)
Пример #17
0
 def drop(self,option,this):
     self.menu = MDDropdownMenu(
         caller=this,
         items=option,
         width_mult=2,
     )
     self.menu.open()
Пример #18
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        menu_items = [
            {
                "text":
                "Monthly",
                "viewclass":
                "OneLineListItem",
                "on_release":
                lambda x="monthly": self.menu_callback(self.key_map[x], x),
            },
            {
                "text":
                "Mid-Term",
                "viewclass":
                "OneLineListItem",
                "on_release":
                lambda x="mid_term": self.menu_callback(self.key_map[x], x),
            },
            {
                "text":
                "Final",
                "viewclass":
                "OneLineListItem",
                "on_release":
                lambda x="final": self.menu_callback(self.key_map[x], x),
            },
        ]
        self.gtype_menu = MDDropdownMenu(
            caller=self.ids.gtype,
            items=menu_items,
            width_mult=4,
        )
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     items = [
         "New group",
         "New broadcasts",
         "WhatsApp Web",
         "Starred messages",
         "Payments",
         "Settings",
     ]
     menu_items = [{
         "text":
         item,
         "viewclass":
         "OneLineListItem",
         "height":
         dp(54),
         "divider":
         None,
         "on_release":
         self.menu_callback if item == "Settings" else lambda *args: None,
     } for item in items]
     self.menu = MDDropdownMenu(
         items=menu_items,
         width_mult=3,
         radius=[
             dp(2),
         ],
     )
Пример #20
0
    def build(self):
        menu_items = [
            {
                "icon_right": None,
                "text": "online"
            },
            {
                "icon": "mail",
                "text": "offline"
            },
            {
                "icon": "email",
                "text": "happy"
            },
            {
                "icon": "git",
                "text": "sad"
            },
            {
                "icon": "git",
                "text": "away"
            },
        ]
        self.menu = MDDropdownMenu(
            caller=self.profilescreen.ids.status,
            items=menu_items,
            position="bottom",
            callback=self.set_item,
            width_mult=3,
        )

        tag_menu_items = [
            {
                "text": "coffee"
            },
            {
                "text": "coding"
            },
            {
                "text": "chilling"
            },
            {
                "text": "dancing"
            },
            {
                "text": "music"
            },
        ]
        self.tag_menu = MDDropdownMenu(
            caller=self.profilescreen.ids.tags,
            items=tag_menu_items,
            position="bottom",
            callback=self.set_item_tag,
            width_mult=3,
        )
        self.theme_cls.primary_palette = "Blue"
        self.theme_cls.primary_hue = '600'
        self.theme_cls.theme_style = "Light"

        return self.profilescreen
Пример #21
0
class LongPressButton(MDRaisedButton, TouchBehavior):
    def __init__(self, **kwargs):
        super(LongPressButton, self).__init__(**kwargs)
        self.long_pressed = False

    def on_kv_post(self, base_widget):
        self.dropdown = MDDropdownMenu(
            caller=self,
            items=[{"text": "+24"}, {"text": "-24"}, {"text": "+1"}, {"text": "-1"}],
            width_mult=4,
            callback=self.update_amount
        )

    def update_amount(self, instance):
        amount = int(instance.text)
        index = int(self.name[-1]) - 1
        MDApp.get_running_app().root.ids.screen_manager.get_screen("turflist").update(index,amount)

    def on_long_touch(self, *args):
        self.long_pressed = True
        self.dropdown.open()

    def on_release(self):
        if self.long_pressed:
            self.long_pressed = False
            return
        index = int(self.name[-1]) - 1
        MDApp.get_running_app().root.ids.screen_manager.get_screen("turflist").update(index, -1)
Пример #22
0
 def __init__(self, mock: data.Mock = data.Mock()):
     super(OneUIMockServerList, self).__init__()
     self.server = mock
     self.menu = MDDropdownMenu(caller=self.ids.mock_server_option_button,
                                items=self.options,
                                width_mult=3)
     self.menu.bind(on_release=self.selected_option)
Пример #23
0
    def open_menu_for_demo_apps(self, instance):
        """
        Called when you click the "Click me" button on the start screen.
        Creates and opens a list of demo applications.

        :type instance: <kivymd.uix.button.MDRaisedButton object>

        """

        if not self.instance_menu_demo_apps:
            menu_for_demo_apps = []
            for name_item in self.demo_apps_list:
                menu_for_demo_apps.append({
                    "viewclass":
                    "OneLineListItem",
                    "text":
                    name_item,
                    "on_release":
                    lambda x=name_item: self.show_demo_apps(x),
                })
            self.instance_menu_demo_apps = MDDropdownMenu(
                items=menu_for_demo_apps,
                max_height=dp(260),
                width_mult=4,
                _center=True,
            )
        self.instance_menu_demo_apps.open(instance)
Пример #24
0
class MainScreen(Screen):
    usernamev = ObjectProperty(None)
    total_scorev = ObjectProperty(None)
    stats = ObjectProperty(None)

    def on_enter(self, *args):
        MainApp().getValues()
        self.usernamev.text = player.usernamev
        self.total_scorev.text = "ExP = " + player.total_scorev

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        menu_main = [{
            "icon": "",
            "text": "Log out"
        }, {
            "icon": "",
            "text": "Change username"
        }]
        self.menu1 = MDDropdownMenu(caller=self.ids.menubtn,
                                    items=menu_main,
                                    width_mult=4,
                                    callback=self.menu_callbackM)

    def menu_callbackM(self, instance):
        option_menu = instance.text
        print(option_menu)
        self.menu1.dismiss()
        if option_menu == "Log out":
            MainApp().show_LogoutM()
        if option_menu == "Change username":
            MainApp().show_change()
Пример #25
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.theme_cls.colors = 'Red'
        self.theme_cls.primary_palette = "Red"
        self.root = Builder.load_string(kv)


        menu_items = [
            {"icon": "application-settings",
            "text": "Setting"},

            {"icon": "account",
            'text': "About"},
        ]
        open_position = self.root.get_screen('main').ids.right_button
        self.menu = MDDropdownMenu(caller=open_position, items=menu_items, width_mult=3)
        self.menu.bind(on_release = self.menu_callback)
        



        Window.bind(on_keyboard=self.events)
        self.manager_open = False
        self.file_manager = MDFileManager(
            exit_manager=self.exit_manager,
            select_path=self.select_path,
        )
Пример #26
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.image_source = 'normalpp.png'
     menu_enemy = [{
         "viewclass": "MDMenuItem",
         "text": "Enemy uses revive",
         "icon": ""
     }, {
         "viewclass": "MDMenuItem",
         "text": "Adje solidair",
         "icon": ""
     }, {
         "viewclass": "MDMenuItem",
         "text": "Enemy has won",
         "icon": ""
     }]
     menu_menu = [{
         "icon": "",
         "text": "Log out"
     }, {
         "icon": "",
         "text": "Change username"
     }, {
         "icon": "",
         "text": "Give Up"
     }]
     self.menu2 = MDDropdownMenu(caller=self.ids.enemybtn,
                                 items=menu_enemy,
                                 width_mult=4,
                                 callback=self.menu_callback)
     self.menu3 = MDDropdownMenu(caller=self.ids.menubtn,
                                 items=menu_menu,
                                 position="auto",
                                 width_mult=4,
                                 callback=self.menu_callback)
 def create_dropdown(self, caller, item):
     menu = MDDropdownMenu(caller=caller,
                           items=item,
                           position='bottom',
                           width_mult=20)
     menu.bind()
     return menu
Пример #28
0
        def __init__(self, master, **kwargs):
            super().__init__(**kwargs)
            self.master = master

            icons = iter([
                "../manga_nelo_icon.png", "../rawdevart_logo.png",
                "../kissmanga_logo.png", "../manga_nelo_icon.png"
            ])
            menu_items = [{
                "right_content_cls": RightContentCls(site),
                "icon": next(icons),
                "text": site
            } for site in ["manganelo", "rawart", "kissmanga", "idk"]]
            self.btn = MDRaisedButton(text="press me",
                                      pos_hint={
                                          "center_x": .5,
                                          "center_y": .5
                                      })
            self.btn.bind(on_press=lambda x: self.menu.open())

            self.menu = MDDropdownMenu(caller=self.btn,
                                       items=menu_items,
                                       width_mult=4)
            self.menu.bind(on_release=self.menu_callback)
            self.add_widget(self.btn)
Пример #29
0
 def create_menu(self, interval):
     menu = []
     for text in (
             "Search by extension",
             "Search by name",
             "All over the disk",
     ):
         menu.append({
             "text":
             f"[size=14]{text}[/size]",
             "viewclass":
             "OneLineListItem",
             "height":
             dp(36),
             "top_pad":
             dp(4),
             "bot_pad":
             dp(10),
             "divider":
             None,
             "on_release":
             lambda x=f"[size=14]{text}[/size]": self.set_type_search(x),
         })
     self.context_menu_search_field = MDDropdownMenu(
         caller=self.ids.lbl_icon_right,
         items=menu,
         width_mult=4,
         background_color=self.theme_cls.bg_dark,
         max_height=dp(240),
     )
Пример #30
0
    def __init__(self, id, *args, **kwargs):
        super().__init__(**kwargs)
        if id:
            game = vars(app.games.database.read_by_id(id))
        else:
            game = {"id": "", "name": "", "platform1": "Platforma"}

        self.ids.game_name.text = game['name']
        platforms = app.games.database.read_platforms()
        menu_items = [{
            "viewclass":
            "OneLineListItem",
            "text":
            f"{platform.name}",
            "on_release":
            lambda x=f"{platform.name}": self.set_item(x)
        } for platform in platforms]
        self.menu_platforms = MDDropdownMenu(
            caller=self.ids.platform_item,
            items=menu_items,
            position="center",
            width_mult=5,
        )
        self.ids.platform_item.set_item(game['platform1'])
        self.ids.platform_item.text = game['platform1']