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 remove_jobdata_dialog(self, *args): def close_dialog(instance, *args): instance.parent.parent.parent.parent.dismiss() layout = MDBoxLayout(orientation="vertical", adaptive_height=True) layout.add_widget( OneLineListItem(text="You really want to delete these jobs?", font_style="H6")) layout.add_widget( MDTextField(text=" / ".join( set([job[0] for job in self.job_table.get_row_checks()])), multiline=True, readonly=True, mode="rectangle")) dialog = MDDialog( title="Remove jobdata from server", type='custom', auto_dismiss=False, content_cls=layout, buttons=[ MDFlatButton(text="DELETE", on_release=partial(self.remove_jobdata)), MDFlatButton(text="DISCARD", on_release=close_dialog), ], ) if get_app()._platform not in ['win32', 'win64']: dialog.content_cls.focused = True dialog.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)
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 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): # 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 __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)
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 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 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().__init__(**kwargs) self.layout = MDBoxLayout(orientation="vertical") self.load_content() self.add_widget(self.layout)
def overwrite_existing_file_dialog(self, overwrite_func, outputpath): def close_dialog(instance, *args): instance.parent.parent.parent.parent.dismiss() layout = MDBoxLayout(orientation="vertical", adaptive_height=True) layout.add_widget( OneLineListItem(text="Overwrite existing destination file?", font_style="H6")) layout.add_widget( MDTextField(text=str(outputpath.absolute()), multiline=True, readonly=True, mode="rectangle")) dialog = MDDialog( title="", type='custom', auto_dismiss=False, content_cls=layout, buttons=[ MDFlatButton(text="OVERWRITE", on_release=partial(overwrite_func, outputpath)), 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) # 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 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 unlock_folder_dialog(self, folderpath, outputpath, url): def close_dialog(instance, *args): instance.parent.parent.parent.parent.dismiss() layout = MDBoxLayout(orientation="vertical", adaptive_height=True) layout.add_widget( MDTextField( text= "Sudo password to change the rights of the destination folder", font_style="H6")) layout.add_widget( MDTextField(hint_text="Password", password=True, mode="rectangle")) dialog = MDDialog( title="", type='custom', auto_dismiss=False, content_cls=layout, buttons=[ MDFlatButton(text="ENTER", on_release=partial(self.unlock_folder, folderpath, outputpath, url)), 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 download_via_url_dialog(self): def close_dialog(instance, *args): instance.parent.parent.parent.parent.dismiss() layout = MDBoxLayout(orientation="vertical", adaptive_height=True) layout.add_widget( OneLineListItem(text="Options for download via URL", font_style="H6")) layout.add_widget(OneLineListItem(text="URL to model")) layout.add_widget(MDTextField(text="", mode="rectangle")) layout.add_widget(OneLineListItem(text="Downloadpath")) layout.add_widget( MDTextField(text=self.screen.tessdatadir.text, mode="rectangle")) layout.add_widget( OneLineListItem(text="Modelname (default: filename)")) layout.add_widget(MDTextField(text="", mode="rectangle")) dialog = MDDialog( title="", type='custom', auto_dismiss=False, content_cls=layout, buttons=[ MDFlatButton(text="DOWNLOAD", on_release=partial(self.check_download_via_url)), 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 buildGuiForAction(self): print("build gui for action ", self.actionType) if self.actionType == 'start': bl = MDBoxLayout(orientation='vertical', adaptive_height=True, padding=3, spacing=3) #bl.add_widget(MDLabel(text="Widgets wizard")) #bl.add_widget(Button( # text="rebuild!", # on_release=self.sw.rebuildWs # )) bl.add_widget(DLabel(text="Awalable widgets to add to screen:")) wl = self.sw.getWidgetsTypeList() for w in wl: print("w", w) bv = MDBoxLayout(orientation="horizontal", adaptive_height=True, padding=3, spacing=3) bl.add_widget(bv) b = Button( text=w['name'], #height = self.gui.btH, size_hint=[None, None], on_release=self.on_start_addW, size=[cm(3.0), cm(1.0)]) bv.add_widget(b) ki = uixImage( source=("icons/%s" % w['thumb']), size_hint=[None, None], #width = cm(3.0), height=self.gui.btH) bv.add_widget(ki) #bv.add_widget(ki) print("3") for c in self.gui.rl.ids.bl_selWidToAdd.children: self.gui.rl.ids.bl_selWidToAdd.remove_widget(c) self.gui.rl.ids.bl_selWidToAdd.clear_widgets() self.gui.rl.ids.bl_selWidToAdd.add_widget(bl) self.gui.screenChange("SelectWidgetToAdd")
def imprimiralchatbox(self, texto): new_box = MDBoxLayout(size_hint=(0.8, None), orientation='horizontal', height=50, pos_hint={'x': 0.2}) new_box.add_widget(WidgetCreator.newlabel(texto, valign='middle', halign='right', size_hint=(1.0, None))) with new_box.canvas.before: Color(usermessagebubblecolor[0], usermessagebubblecolor[1], usermessagebubblecolor[2]) new_box.rect = RoundedRectangle(size=new_box.size, pos=new_box.pos, radius=[25, 0, 25, 25]) new_box.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) self.layout.chatbox.content.add_widget(new_box)
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 __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): 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 establecerfase(self, fase: Fase): self.layout.faselabel.text = fase.nombre new_box = MDBoxLayout(size_hint=(0.8, None), orientation='horizontal', height=50) new_box.add_widget(WidgetCreator.newlabel(fase.texto, size_hint=(1.0, None), valign='middle')) with new_box.canvas.before: Color(botmessagebubblecolor[0], botmessagebubblecolor[1], botmessagebubblecolor[2]) new_box.rect = RoundedRectangle(size=new_box.size, pos=new_box.pos, radius=[0, 25, 25, 25]) new_box.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) self.layout.chatbox.content.add_widget(new_box)
def start_downloading(self): user_input = self.root.get_screen('main').ids.url_input.text # video = YouTube(user_input) # print(type(video)) if user_input != '' and re.search(r'^(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$', user_input): self.root.current = 'progress' screen_id = self.root.get_screen('progress').ids.video_list for num in range(1): main_layout = MDFloatLayout() flip_card = MDCard(size_hint=(.9, .9), pos_hint={'center_x':.5, 'center_y': .5}) box_1 = MDBoxLayout(orientation='vertical',) box_2 = MDBoxLayout(orientation='vertical', ) box_3 = MDBoxLayout(orientation='vertical', padding=20) img = AsyncImage(source=video.thumbnail_url, size_hint=(.9, .9), pos_hint={'center_x': .5, 'center_y': .5}) box_3.add_widget(img) box_3.add_widget( MDLabel( text=video.title, halign='center', font_style='Body2' ) ) box_2.add_widget(box_3) box_2.add_widget(MDRaisedButton(text='Download', pos_hint={'center_x': .5, 'center_y': .5}, size_hint=(.6, .1), on_release = self.quality_check,)) box_1.add_widget(box_2) advertisement_box = MDBoxLayout(orientation='vertical', size_hint=(1, .2)) advertisement_box.add_widget(MDLabel(text='Advertisement', halign='center')) advertisement_box.add_widget(MDProgressBar(pos_hint={"center_x": .5, })) box_1.add_widget(advertisement_box) flip_card.add_widget(box_1) main_layout.add_widget(flip_card) screen_id.add_widget(main_layout) else: self.show_message('Invalid URL!')
def __init__(self, **kwargs): super(CardArray, self).__init__(**kwargs) self.popup_container = MDBoxLayout(orientation='vertical', spacing=2, padding=2) container = MDBoxLayout(orientation='vertical', spacing=2, padding=2) popup_close_button = MDRoundFlatButton(text='Exit Panel', size_hint_x=.5, on_press=self.close_popup, pos_hint={ "center_x": .5, "center_y": .5 }, md_bg_color=(1, 0, 0, 1), text_color=(1, 0, 1, 1), font_size='18sp') container.add_widget(self.popup_container) container.add_widget(popup_close_button) container.add_widget(MDLabel(text='')) self.popup = Popup(size_hint=(.4, .3), content=container)
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)
def no_trips_message(): nt_message = MDBoxLayout(orientation="vertical") nt_message.add_widget(MDLabel(font_size="300sp", font_style="H1")) nt_message.add_widget( MDLabel(text="NO HAY VIAJES PUBLICADOS", halign="center", font_size="300sp", font_style="H3")) for i in range(2): nt_message.add_widget(MDLabel(font_size="300sp", font_style="H1")) return nt_message
def on_start_addWBuildIt(self, *a): w = self.worikiOnWidgetObj wName = w.text self.actionType = "addW %s" % wName dw = self.getWByName(wName) print("working on ", dw['obj']) obj = dw['obj'] self.settingUpWidget = dw if obj.settingsNeedIt() == False: print("no need for more steps ") self.sw.addWidgetOnScreen(dw) else: print("it need settings step !") #self.q1 = QueryPopup() #self.q1.size_hint = [.8,.97] bl = MDBoxLayout( orientation='vertical', adaptive_height=True, padding=3, spacing=3, ) bl.add_widget(DLabel(text="Set it up:")) bl.add_widget(DLabel(text="Widget settings:")) bl = obj.addSettingsDialogPart(bl) srcSett = False try: aoeuoeu = obj.wvfh srcSett = True except: pass if srcSett: bl.add_widget(DLabel(text="Source settings:")) bl = obj.wvfh.makeSourceSettingsPart(bl, self.gui.sen.sensorsList) print("prerun") #Clock.schedule_once(self.q1.run,0.1) #self.q1.run() print("postrun") print("0predissmiss") #self.q.dismiss() print("0postdissmiss") for c in self.gui.rl.ids.bl_setUpWid.children: self.gui.rl.ids.bl_setUpWid.remove_widget(c) self.gui.rl.ids.bl_setUpWid.clear_widgets() self.gui.rl.ids.bl_setUpWid.add_widget(bl) self.gui.screenChange("SettingUpWidget")
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 create_special_row(self): """Creates the last row, which contains the button to get the 'analysis' """ row = MDBoxLayout(spacing=dp(50)) button = MDFillRoundFlatButton( text='Get more info!', on_release=lambda x: self.show_confirmation_dialog()) button.text_color = (1, 1, 1, 1) button.font_name = 'fonts/Montserrat-Regular.ttf' button.md_bg_color = (0.91, 0.46, 0.07, 1) row.add_widget(Widget()) # To center the button row.add_widget(button) row.add_widget(Widget()) return row