Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for ComboBox (i.e., Dropdown combined with text input field) #1219

Closed
burque505 opened this issue Mar 25, 2023 · 3 comments
Closed

Comments

@burque505
Copy link

Please Describe The Problem To Be Solved

Very new to flet (it's up to me to solve that part of it :))
I have an app with many dropdowns, cloned from similar apps using other frameworks. The dropdowns all have options that are commonly needed, but users often need to be able to specify their own option, one not contained in the Dropdown options.

I don't know much Dart or Flutter, which does not help, admittedly - but there appears from my searches to be little information on ComboBoxes (as opposed to Dropdowns), so perhaps there is no Dart/Flutter widget that could be ported. I have seen a Medium page that claims to create a ComboBox with Flutter: Combo Box in Flutter

Thank you for considering this.

@burque505
Copy link
Author

burque505 commented Mar 26, 2023

W.I.P. workaround, please pardon the * import:

import flet as ft
from flet import *

def main(page: Page):
    page.title = "ComboBox Test"
    page.window_width = 600
    page.window_height = 300
    
    def dropdown_changed(e):
        dd_input.value = cbox_status.value
        cbox_status.key = None
        cbox_status.visible = False
        dd_input.visible = True
        cbox_button.visible = True
        page.update()
        pass
    
    def select_clicked(e):
        cbox_status.visible = True
        dd_input.visible = False
        cbox_button.visible = False
        page.update()

    cbox_button = FloatingActionButton(
        icon=icons.ARROW_DROP_DOWN_CIRCLE, on_click=select_clicked)
    
    cbox_status = Dropdown(
            visible = False,
            on_change=dropdown_changed,
            width=500,
            options=[
                dropdown.Option("Option Number One"),
                dropdown.Option("Another option, kind of useless"),
                dropdown.Option("a married primate dealing in its sole and separate property"),            
            ]                                                                
    )

    dd_input = TextField(
        label='ComboBox test',
        width = 500
    )

    row = Row(
        controls=[
            dd_input,
            cbox_button
        ],
        alignment="left",
    )
    
    row2 = Row(
    controls=[
        cbox_status
    ],
    alignment="left"
    )


    page.controls.append(row)
    page.controls.append(row2)

    page.update()


flet.app(target=main)

cbox_test

@FeodorFitsner
Copy link
Contributor

DropdownMenu

@burque505
Copy link
Author

Very nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants