def issues(self): if self.others is False: frame = MDBoxLayout(orientation='vertical', size_hint_y=None, height=150) scroll = ScrollView() list_view = MDList() scroll.add_widget(list_view) remarks = [ 'Awaiting Result', 'Token not found', 'Passport Uploaded', 'Wrong result uploaded', 'No results uploaded', 'Card limit exceeded', 'Invalid card', 'Result not uploaded', 'Incomplete Result', 'Result not visible', 'Invalid pin', 'Invalid serial', 'Result checker has been used', 'Pin for Neco not given', 'Wrong result uploaded', 'Incomplete result', 'Token linked to another candidate', 'Others' ] for x in remarks: list_view.add_widget( OneLineListItem(text=x, on_press=self.get_selection)) self.chooser = MDDialog(title='Select Remark', size_hint=(.5, .4), type='custom', content_cls=frame) frame.add_widget(scroll) # self.chooser.set_normal_height() self.chooser.open()
def build(self): self.operators = ["^", " / ", " * ", " + ", " - "] # operators /,*,+,- are added with leading and trailing space to make # identification possible between that and negative numbers self.last_was_operator = None self.last_button = None main_layout = MDBoxLayout(orientation="vertical") self.solution = MDTextFieldRect(multiline=False, readonly=True, size_hint=[1, None], halign="right", height="80sp", font_size='55sp') main_layout.add_widget(self.solution) buttons = [["", "C", "<-", "^"], ["", "", "", " / "], ["7", "8", "9", " * "], ["4", "5", "6", " - "], ["1", "2", "3", " + "], ["+/-", "0", ".", "="]] for row in buttons: h_layout = MDBoxLayout() for label in row: button = MDRectangleFlatButton(text=label, pos_hint={ "center_x": 0.5, "center_y": 0.5 }, size_hint=(1, 1), font_size='20sp') button.bind(on_press=self.on_button_press) h_layout.add_widget(button) main_layout.add_widget(h_layout) return main_layout
def __init__(self, **kwargs): super().__init__(**kwargs) # In this small block, books are generated from the json file. # (from the task) self.books = [] json_books = BooksProvider.load_books_from_json() for json_book in json_books: self.books.append(Book(**json_book)) add_book_button = MDFloatingActionButton( icon="plus", on_release=self.open_book_adder_screen) # Creating layout where all inner parts will be placed # (such as the foundation of the house) self.layout = MDBoxLayout(orientation="vertical") self.search_field = SearchField() # ScrollView allows to scroll list that was put inside of whis view. # If there is no ScrollView, the user will not be able to see list # items that are outside of the screen. self.scroll_view = ScrollView() # Books are put in the books_list # (the book_list is put in the scroll_view, this is realized in the # `load_books_list` method) self.load_books_list(self.books) # Search field and scroll view are put into the layout self.layout.add_widget(self.search_field) self.layout.add_widget(self.scroll_view) # And the layout is put into this screen self.add_widget(self.layout) self.add_widget(add_book_button)
def install_tesseract_dialog(): def close_dialog(instance, *args): instance.parent.parent.parent.parent.dismiss() layout = MDBoxLayout(orientation="horizontal", adaptive_height=True) layout.add_widget( OneLineListItem( text= "Tesseract wasn't found on the system. You can install it now or set" "the right path in the settings-menu. (Restart required)")) dialog = MDDialog( title="Installing tesseract?", type='custom', auto_dismiss=False, content_cls=layout, buttons=[ MDFlatButton(text="INSTALL", on_release=partial(install_tesseract)), MDFlatButton(text="DISCARD", on_release=close_dialog), ], ) if get_app()._platform not in ['win32', 'win64']: # TODO: Focus function seems buggy in win dialog.content_cls.focused = True dialog.open()
def __init__(self, **kwargs): super().__init__(**kwargs) self.layout = MDBoxLayout(orientation="vertical") self.load_content() self.add_widget(self.layout)
def table_screen(self): """Bind this to the top table-show button to scroll to the Table Screen""" self.layout_showSummary = MDBoxLayout(size_hint_y=None, height=400) self.tablec = MDDataTable( column_data=[("UP TIME", dp(30)), ("DOWN TIME", dp(30)), ("UP TICKETS", dp(30)), ("DOWN TICKETS", dp(30)), ("TOTAL PASSANGERS", dp(30)), ("TOTAL MONEY", dp(30))], row_data=[(self.UP_TIME[0], self.DOWN_TIME[0], self.UP_TICKET[0], self.DOWN_TICKET[0], self.TOTAL_PASSENGERS_[0], self.TOTAL_MONEY[0]), (self.UP_TIME[1], self.DOWN_TIME[1], self.UP_TICKET[1], self.DOWN_TICKET[1], self.TOTAL_PASSENGERS_[1], self.TOTAL_MONEY[1]), (self.UP_TIME[2], self.DOWN_TIME[2], self.UP_TICKET[2], self.DOWN_TICKET[2], self.TOTAL_PASSENGERS_[2], self.TOTAL_MONEY[2]), (self.UP_TIME[3], self.DOWN_TIME[3], self.UP_TICKET[3], self.DOWN_TICKET[3], self.TOTAL_PASSENGERS_[3], self.TOTAL_MONEY[3])]) self.layout_showSummary.add_widget(self.tablec) if not self.dialog3: self.dialog_2 = MDDialog(title="Table", type="custom", content_cls=self.layout_showSummary) self.dialog_2.open()
def __init__(self, **kwargs): super(LoginScreenBase, self).__init__(**kwargs) self.previous = "registered" self.emailTextField = self.create_email_field() self.contentBox.add_widget(self.emailTextField) self.passwordTextField = self.create_password_field() self.contentBox.add_widget(self.passwordTextField) self.submitButton = Builder.load_string(standard_button) self.submitButton.text = "Login" self.submitButton.bind(on_press=partial(self.verify_and_submit_values)) self.backButton = Builder.load_string(standard_button) self.backButton.text = "Back" self.backButton.bind(on_press=partial(self.goto_previous_screen)) self.buttonBox = MDBoxLayout(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.buttonBox.orientation = 'horizontal' self.buttonBox.adaptive_height = False self.buttonBox.add_widget(self.backButton) self.buttonBox.add_widget(self.submitButton) self.contentBox.add_widget(self.buttonBox)
def build(self): bl = MDBoxLayout(orientation="vertical") i = ScreenERWSWid(size_hint=[None, None], size=[512, 512]) self.can = i.canvas bl.add_widget(i) return bl
def build(self): self.tmp_outer_box = MDBoxLayout(orientation='vertical') self.tmp_toolbar = MDToolbar(title="Example Tabs") self.tmp_tabs = MDTabs() self.tmp_outer_box.add_widget(self.tmp_toolbar) self.tmp_outer_box.add_widget(self.tmp_tabs) return self.tmp_outer_box
def __init__(self, simulacion, **kwargs): super(ResultadoScreenLayout, self).__init__(**kwargs) self.orientation = 'vertical' boxtitular = BoxLayout(size_hint=(1.0, None), height=40) boxtitular.orientation = 'horizontal' boxtitular.add_widget( Label(text="Resultado General:", size_hint=(1.0, None), height=20, color=textcolor)) boxtitular.barraderesultado = BoxLayout() boxtitular.barraderesultado.orientation = 'vertical' boxtitular.barraderesultado.add_widget( Label(text="Barra", size_hint=(1.0, None), height=20)) boxtitular.barraderesultado.add_widget( Label(text="Porcentaje", size_hint=(1.0, None), height=20)) boxtitular.add_widget(boxtitular.barraderesultado) boxtitular.add_widget( Label(text="Usuario", size_hint=(1.0, 1.0), height=20)) self.add_widget(boxtitular) self.add_widget(TabbedPanelResultados(simulacion)) btn = WidgetCreator.newbutton("Volver") btn.bind(on_press=self.callback_volver) self.add_widget(btn) self.guardarsimulacionalsalir = True
def __init__(self): super(Main, self).__init__() self.theme_cls.primary_palette = "Amber" self.title = "Four in a row" self.root = Builder.load_file("style.kv") self.current_widget = MDBoxLayout() self.start_widget = StartWidget(self.start_game, self.change_theme) self.theme_widget = ThemeWidget(self, self.return_back) self.current_widget.add_widget(self.start_widget)
class LoginScreenBase(GenericFormScreen): def __init__(self, **kwargs): super(LoginScreenBase, self).__init__(**kwargs) self.previous = "registered" self.emailTextField = self.create_email_field() self.contentBox.add_widget(self.emailTextField) self.passwordTextField = self.create_password_field() self.contentBox.add_widget(self.passwordTextField) self.submitButton = Builder.load_string(standard_button) self.submitButton.text = "Login" self.submitButton.bind(on_press=partial(self.verify_and_submit_values)) self.backButton = Builder.load_string(standard_button) self.backButton.text = "Back" self.backButton.bind(on_press=partial(self.goto_previous_screen)) self.buttonBox = MDBoxLayout(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.buttonBox.orientation = 'horizontal' self.buttonBox.adaptive_height = False self.buttonBox.add_widget(self.backButton) self.buttonBox.add_widget(self.submitButton) self.contentBox.add_widget(self.buttonBox) def verify_inputs(self): found_error = [False] self.verify_email(self.emailTextField, found_error) self.verify_password(self.passwordTextField, found_error) return not found_error[0] def get_form_values(self): loginDict = { "Email": self.emailTextField.text, "Password": self.passwordTextField.text } return loginDict def submit_form(self, values): thread = Thread(target=database_login, args=( self, values, )) thread.start()
def __init__(self, **kwargs): # Giving main text and icon to this tab super().__init__(name="graph", text="Graph", icon="graphql", **kwargs) layout = MDBoxLayout(orientation="vertical") tabs = MDTabs(text_color_active=(1, 1, 1, 1), text_color_normal=(1, 1, 1, 1)) screens = (GraphScreen(text='Graph'), PieScreen(text='Pie Chart')) for screen in screens: tabs.add_widget(screen) layout.add_widget(tabs) self.add_widget(layout)
def __init__(self, **kwargs): self.type = "custom" if hasattr(self, "overlay_color"): self.overlay_color = (0, 0, 0, 0) else: self.background_color = (0, 0, 0, 0) # A box in which text, buttons and icons will be placed of window. self.content_cls = MDBoxLayout( adaptive_height=True, orientation="vertical", padding=("24dp", "68dp", "24dp", "24dp"), spacing="24dp", ) self.opacity = 0 self.bind( on_open={"pulse": self.anim_open_dialog_pulse}.get(self.animation_type), on_dismiss={"pulse": self.anim_close_dialog_pulse}.get(self.animation_type), ) self._scale_x = 0 self._scale_y = 0 super().__init__(**kwargs) # Creating and adding control buttons (close/collapse/expand) # in the window header. if self.window_control_buttons: button_box = RelativeLayout() self.add_widget(button_box) if self.window_control_buttons == "close": button = MDIconButton( icon="close", pos_hint={"top": 1}, x=self.width - self.content_cls.padding[0] - dp(32), ) if self.window_control_callback: button.bind(on_release=self.window_control_callback) button_box.add_widget(button) elif self.window_control_buttons == "mac-style": # Color and padding of buttons. data = {"#eb5b53": 8, "#f5bc48": 28, "#64ca43": 48} for color in data: button = MacOSWindowHeaderButton( text_color=get_color_from_hex(color), x=data[color], ) if self.window_control_callback: button.bind(on_release=lambda x=button: self. window_control_callback(x)) button_box.add_widget(button) Window.bind(on_resize=lambda *args: self.dismiss())
def __init__(self, **kwargs): super(ChatBox, self).__init__(**kwargs) self.do_scroll_x = False self.do_scroll_y = True new_box = BoxLayout(size_hint_y=None, orientation='vertical', padding=chatboxpadding, spacing=10) new_box.bind(minimum_height=new_box.setter('height')) with self.canvas.before: Color(subdivisionColor[0], subdivisionColor[1], subdivisionColor[2]) self.rect = RoundedRectangle(size=self.size, pos=self.pos, radius=[10]) # listen to size and position changes self.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) self.content = new_box self.add_widget(self.content)
def build(self): self.content = EventContent(size_hint_y=None, height=400).create(2021, 4, 29) self.layout = MDBoxLayout(orientation='vertical') self.textfield = MDTextField(hint_text="Type Here") self.button = MDFlatButton(text="Change Date", on_release=self.changedate) self.layout.add_widget(self.textfield) self.layout.add_widget(self.button) self.layout.add_widget(self.content) return self.layout
def getRowForGui(self, name): rb = MDBoxLayout(orientation='horizontal') vl = MDTextField() rb.add_widget(vl) #rb.add_widget( Label(text=" {}:".format(name) ) ) #vl = Label(text="- - -") #rb.add_widget(vl) vl.hint_text = "{}:".format(name) vl.text = "- - -" vl.disabled = True return vl, rb
def __init__(self, start_game, change_theme): super(StartWidget, self).__init__() self.add_widget( MDLabel(text=MDApp.get_running_app().title, font_style="H4", size_hint=(1, 1), halign="left")) buttons_box = MDBoxLayout(orientation="vertical", size_hint=(1, None), spacing=4) theme_cls = MDApp.get_running_app().theme_cls buttons_box.add_widget( MDRaisedButton(text="Start game", on_press=lambda _: start_game(), md_bg_color=theme_cls.primary_color)) buttons_box.add_widget( MDRaisedButton(text="Change theme", on_press=lambda _: change_theme(), md_bg_color=theme_cls.primary_color)) buttons_box.add_widget( MDRaisedButton(text="Exit", on_press=self.exit_game, md_bg_color=theme_cls.primary_color)) self.add_widget(buttons_box)
class MyApp(MDApp): def __init__(self): super(MyApp, self).__init__() self.boxlayout1 = MDBoxLayout(orientation="vertical") toolbar = MDToolbar(title="DEMO APP") toolbar.left_action_items = [["menu", "This is the navigation"]] toolbar.right_action_items = [[ "dots-vertical", lambda x: self.callback_1(x) ], ["clock"]] self.boxlayout1.add_widget(toolbar) self.boxlayout2 = MDBoxLayout() self.boxlayout1.add_widget(self.boxlayout2) from kivymd.uix.navigationrail import MDNavigationRail, MDNavigationRailItem self.navigationrail = MDNavigationRail( md_bg_color=get_color_from_hex("#ffffff"), # color_normal = get_color_from_hex("#718089"), #crash the app when clicking on an item, don't understand why... color_active=get_color_from_hex("#f3ab44"), visible="Persistent") self.item1 = MDNavigationRailItem(navigation_rail=self.navigationrail, text="Detection", icon='video-stabilization') self.item2 = MDNavigationRailItem(navigation_rail=self.navigationrail, text="Dashboard", icon='desktop-mac-dashboard') self.item3 = MDNavigationRailItem(navigation_rail=self.navigationrail, text="Settings", icon='cog-outline') self.navigationrail.add_widget(self.item1) self.navigationrail.add_widget(self.item2) self.navigationrail.add_widget(self.item3) self.boxlayout2.add_widget(self.navigationrail) def callback_1(self, *args, **kwargs): sl = MDStackLayout() sl.add_widget(MDTextField(hint_text='Enter something')) sl.add_widget(MDRaisedButton(text="I AM A BUTTON")) self.boxlayout2.add_widget(sl) def build(self): Clock.schedule_once(self.set_width) return self.boxlayout1 def set_width(self, interval): self.navigationrail.size_hint_x = None self.navigationrail.width = dp(120) #self.navigationrail.md_bg_color = (1, 1, 1, 1) self.item1.size_hint_x = None self.item1.width = dp(120) self.item2.size_hint_x = None self.item2.width = dp(120) self.item3.size_hint_x = None self.item3.width = dp(120)
def makeDiscoveryPage(self): # Discovery Page screen = Screen(name='Discovery') self.discoveryScreen = screen layout = BoxLayout(orientation='vertical', spacing=10) screen.add_widget(layout) label = Label( size_hint=(1, None), halign="center", text= 'Browsing your local network.\nWarning: anyone on your network\ncan advertise a site with any title they want.' ) layout.add_widget(self.makeBackButton()) layout.add_widget(label) self.discoveryScroll = ScrollView(size_hint=(1, 1)) self.discoveryListbox = BoxLayout(orientation='vertical', size_hint=(1, None)) self.discoveryListbox.bind( minimum_height=self.discoveryListbox.setter('height')) self.discoveryScroll.add_widget(self.discoveryListbox) layout.add_widget(self.discoveryScroll) return screen
class Example(MDApp): def build(self): self.tmp_outer_box = MDBoxLayout(orientation='vertical') self.tmp_toolbar = MDToolbar(title="Example Tabs") self.tmp_tabs = MDTabs() self.tmp_outer_box.add_widget(self.tmp_toolbar) self.tmp_outer_box.add_widget(self.tmp_tabs) return self.tmp_outer_box def on_start(self): for i in range(40): self.tmp_tabs.add_widget(Tab(title=f"Tab {i}"))
def __init__(self, **kwargs): super(SimulacionScreenLayout, self).__init__(**kwargs) self.padding = [10, 10, 10, 10] self.orientation = 'vertical' self.faselabel = WidgetCreator.newlabel("Nombre de Fase", size_hint=(1.0, None)) self.add_widget(self.faselabel) chat = BoxLayout(orientation="horizontal", size_hint=(1, 1), spacing=10) chat.add_widget(WidgetCreator.newimage('assets/BotFace.jpg')) self.chatbox = ChatBox(size_hint=(1, 1)) chat.add_widget(self.chatbox) self.add_widget(chat) self.camara = Image(size_hint=(1, 1), pos_hint={'top': 1}) self.soundwave = FigureCanvasKivyAgg(AudioController().fig) self.userinputbox = UserInputBox(self.camara, self.soundwave, padding=[10, 10, 10, 10], spacing=10) self.add_widget(self.userinputbox) Clock.schedule_interval(self.update, 1.0 / 30.0)
class OneUIHeaders(MDGridLayout): __headers = MDBoxLayout() def __init__(self, **kwargs): super(OneUIHeaders, self).__init__(**kwargs) self.rows = 2 self.spacing = 5 self.__headers.orientation = "vertical" self.md_bg_color = [0.3, 0.3, 0.1, 1] __add_new = MDFlatButton() __add_new.text = "Add New" __add_new.bind(on_release=lambda x: self.add()) super().add_widget(self.__headers) super().add_widget(__add_new) def add(self): __header = OneUIHeader() self.__headers.add_widget(__header) def delete_header(self, widget): self.__headers.remove_widget(widget) def add_widget(self, widget, index, canvas): self.__headers.add_widget(widget)
def __init__(self, solver, **kwargs): super().__init__(**kwargs) self.text = 'Gallery Solver' self.icon = 'folder-image' # -- UI self.__big_layout = MDBoxLayout(padding=20, spacing=20, orientation="vertical") self.add_widget(self.__big_layout) self.__big_layout.add_widget( MDLabel(text='Gallery Solver', halign='center', font_style="H5", size_hint_y=0.15)) # - Image Layout self.__image_layout = MyImageWidget(size_hint_y="0.75", id="image", source='uix/assets/AI.png') self.__big_layout.add_widget(self.__image_layout) # - File Manager for image selection # Window.bind(on_keyboard=self.events) self.manager_open = False self.file_manager = MDFileManager( exit_manager=self.exit_manager, select_path=self.select_path, # preview=True, ) self.__image_selection_button = MDRoundFlatIconButton( on_release=self.file_manager_open, pos_hint={ "top": 0.4, "center_x": 0.5 }) self.__image_selection_button.text = "Select An Image !" self.__image_selection_button.icon = "image" # self.__actual_image_path = None self.__big_layout.add_widget(self.__image_selection_button) # - Solver self.__solver = solver
def __init__(self, **args): super().__init__(**args) self.app = App.get_running_app() try: with open(self.app.get_path('capture_scripts.json'), 'r') as f: self.scripts = json.load(f) except: # any problem loading => set up afresh self.scripts = {} for s in all_scripts: self.scripts[s] = { 'exposure': .1 if s in faf_scripts else 1, 'filter': ['dark' if s in {'bias', 'dark'} else 'L'] } self.scripts['bias']['exposure'] = .001 self.scripts['seq']['nsubs'] = 4 self.scripts['seq']['filter'] = ['B', 'G', 'R', 'L'] self.save() self.chooser = MDBoxLayout(orientation='vertical', size_hint=(None, None), size=(dp(100), dp(240)), pos_hint={ 'center_x': 10, 'center_y': .5 }) self.app.gui.add_widget(self.chooser) self.script_buttons = {} for s in all_scripts: if s in faf_scripts: col = .75, .65, .65, 1 elif s in light_scripts: col = .75, .75, .65, 1 else: col = .65, .75, .65, 1 but = self.script_buttons[s] = MDTextButton( text=s, text_color=col, theme_text_color='Custom', font_size='18sp', on_press=self.script_chosen) self.chooser.add_widget(but) # initialise via current script once dependencies have been built Clock.schedule_once(self.on_current_script, 0)
def __init__(self, **kwargs): # Giving main text and icon to this tab super().__init__(name="graph", text="Graph", icon="graphql", **kwargs) layout = MDBoxLayout(orientation="vertical") self.add_widget(layout)
def build(self): # box around evertying box_global = MDBoxLayout() box_global.orientation = 'vertical' # add the toolbar box_global.add_widget(MDToolbar(title = 'buba')) # add the tabs tabs = MDTabs() box_global.add_widget(tabs) # The search tab # tab = MDTabsBase() tab = Tab(size = box_global.size) tab.text = 'search' tabs.add_widget(tab) # box = MDBoxLayout() # tab.add_widget(box) # box.orientation = 'vertical' # # button = MDFlatButton() # tab.add_widget(StartDateContainer()) tab.add_widget(SelectDateButton()) self.start_date_text = StandardTextField() self.start_date_text.hint_text = 'mm/dd/yyyy' # tab.add_widget(self.start_date_text) tab.add_widget(SaveButton(padding = 3)) tab.add_widget(SaveButton()) tab.add_widget(SaveButton()) tab.padding_top = 3 # tab.add_widget(Widget()) return box_global
def build(self): # box around evertying box_global = MDBoxLayout() box_global.orientation = 'vertical' # add the toolbar box_global.add_widget(MDToolbar(title='buba')) # add the tabs tabs = MDTabs() box_global.add_widget(tabs) # The search tab # tab = MDTabsBase() tab = Tab() # tab.size_hint = (None,None) tab.size = box_global.size tab.spacing = 10 tab.text = 'search' tabs.add_widget(tab) tab.add_widget(StandardLabel(text='Check-in')) tab.add_widget(SelectDateButton()) tab.add_widget(StandardDateField()) tab.add_widget(StandardLabel(text='Check-out')) tab.add_widget(SelectDateButton()) tab.add_widget(StandardDateField()) tab.add_widget(SaveButton()) tab.add_widget(SearchButton()) # tab.padding_top = 3 # tab.add_widget(Widget()) return box_global
def build(self): # box around evertying box_global = MDBoxLayout() box_global.orientation = 'vertical' # add the toolbar box_global.add_widget(MDToolbar(title = 'buba')) # add the tabs tabs = MDTabs() box_global.add_widget(tabs) # The search tab # tab = MDTabsBase() tab = Tab(size = box_global.size) tab.text = 'search' tabs.add_widget(tab) # box = MDBoxLayout() # tab.add_widget(box) # box.orientation = 'vertical' # # button = MDFlatButton() tab.add_widget(StartDateContainer()) tab.add_widget(SaveButton()) tab.add_widget(Widget()) return box_global
def add_actions_buttons(self, instance_box: MDBoxLayout, data: list) -> None: """ Adds buttons to the banner. :param data: ['NAME BUTTON', <function>]; """ if data: name_action_button, function_action_button = data action_button = MDFlatButton( text=f"[b]{name_action_button}[/b]", theme_text_color="Custom", text_color=self.theme_cls.primary_color, on_release=function_action_button, ) action_button.markup = True instance_box.add_widget(action_button)