def show_dialog_add_lineup_entry(self): """ Show a dialog to ask the name of the new lineup_entry. :return: """ creation_time = datetime.now().strftime("%Y%m%d-%H%M%S") text = f"Concert_{creation_time}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) # mdlbl1 = MDLabel(text=str(CU.tfs.dic['EXPLANATION_WORKSPACE_PATH'].value)) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"Name of song" mdtf1.helper_text = f"{CU.tfs.dic['EXPLANATION_PLAYLIST_SONG_NAME'].value}" mdtf1.helper_text_mode = "on_focus" # content_obj.add_widget(mdlbl1) content_obj.add_widget(mdtf1) CU.show_input_dialog( title=f"Enter Name of New Songentry", content_obj=content_obj, size_hint=(.7, .4), text_button_ok="Add", ok_callback_set=lambda text_button, instance, *args, **kwargs: { self.add_lineup_entry(instance.text_field.text), self.refresh_list() })
def show_dialog_rename_playlist(self, playlist_rowview): """ Show a dialog to ask for the new name of the playlist. :param playlist_rowview: :return: """ text = f"{str(playlist_rowview.playlist_obj.file_path.stem)}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"Name of playlist" mdtf1.helper_text = f"{CU.tfs.dic['EXPLANATION_PLAYLIST_SONG_NAME'].value}" mdtf1.helper_text_mode = "on_focus" content_obj.add_widget(mdtf1) CU.show_input_dialog(title=f"Enter New Name for Playlist", content_obj=content_obj, size_hint=(.7, .4), text_button_ok="Update", text_button_cancel="Cancel", ok_callback_set=lambda *args, **kwargs: (self.rename_playlist(playlist_rowview, mdtf1.text ), self.refresh_list()))
def show_dialog_add_playlist(self): """ Show a dialog to ask the name of the new playlist. :return: """ creation_time = datetime.now().strftime("%Y%m%d-%H%M%S") text = f"Concert_{creation_time}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"Name of playlist" mdtf1.helper_text = f"{CU.tfs.dic['EXPLANATION_PLAYLIST_SONG_NAME'].value}" mdtf1.helper_text_mode = "on_focus" content_obj.add_widget(mdtf1) CU.show_input_dialog( title=f"Enter Name of New Playlist", content_obj=content_obj, size_hint=(.7, .4), text_button_ok="Add", text_button_cancel="Cancel", ok_callback_set=lambda *args, **kwargs: (self.add_playlist(mdtf1.text), self.refresh_list()))
def addDialogRow(self, bl, title, val): #bh = self.getDialogRow() #bh.add_widget(MDLabel(text="%s:"%title)) ti = MDTextField(text=str(val), ) ti.hint_text = "%s:" % title bl.add_widget(ti) #ti = MDTextField(text = str(val)) #bh.add_widget( ti ) #bl.add_widget( bh ) return bl, ti
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 on_start(self): # As a proposal, the actual (default)value of the tf_workspace_path-param is copied to the clipboard: workspace_path_proposal = CU.tfs.dic['tf_workspace_path'].default_value pyperclip.copy(str(workspace_path_proposal)) # In case the user did configure a customized path, that path will be filled in: text = "" if (CU.tfs.dic['tf_workspace_path'].default_value == CU.tfs.dic['tf_workspace_path'].value ) else f"{CU.tfs.dic['tf_workspace_path'].value}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) # mdlbl1 = MDLabel(text=str(CU.tfs.dic['EXPLANATION_WORKSPACE_PATH'].value)) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"{CU.tfs.dic['tf_workspace_path'].description}" mdtf1.helper_text = str(CU.tfs.dic['EXPLANATION_WORKSPACE_PATH'].value) mdtf1.helper_text_mode = "on_focus" # content_obj.add_widget(mdlbl1) content_obj.add_widget(mdtf1) CU.show_input_dialog( title= f"Enter Path to \"{CU.tfs.dic['WORKSPACE_NAME'].value}\"-Folder or to its Parent Folder", content_obj=content_obj, # hint_text=f"{CU.tfs.dic['tf_workspace_path'].description}", # size_hint=(.8, .4), text_button_ok="Load/Create", text_button_cancel="Cancel", ok_callback_set=lambda *args, **kwargs: (CU.tfs.dic['tf_workspace_path'].set_value(mdtf1.text), toast(str(CU.tfs.dic['tf_workspace_path'].value))), cancel_callback_set=lambda *args, **kwargs: toast( f"{CU.tfs.dic['WORKSPACE_NAME'].value} can still be changed anytime from the settings" ))
def import_file(self): if self.sm.ids.main_screen_id.ids.path_selected_label.text != "": self.sm.current = "export_screen" datafilename = self.sm.ids.main_screen_id.ids.path_selected_label.text if self.field_sep_tab: self.delim = '\t' else: self.delim = ',' f = open(datafilename, 'r', encoding='utf-8') reader = csv.reader(f, delimiter=self.delim) self.ncol = len(next(reader)) for i in range(self.ncol): id = "Field" + str(i) tf_name = MDTextField(id=id) tf_name.hint_text = "Field " + str(i) self.sm.ids.export_screen_id.ids.export_screen_box_layout_fields.add_widget( tf_name) self.dynamic_ids[id] = tf_name flat_btn = MDFlatButton(text="Export Deck", pos_hint={ 'center_x': .5, 'center_y': .5 }, on_press=self.exportDeck) flat_btn.text_color = rgba('ffffff') flat_btn.md_bg_color = rgba('2196f3') self.sm.ids.export_screen_id.ids.export_screen_box_layout_fields.add_widget( flat_btn) else: toast('Select file first')
def build(self): screen_manager = ScreenManager() self.loaded_values = [ 1, 0, 0, 0, 0, 0 ] # round num, cp, primary obj, 1st secondary, 2nd secondary, 3rd secondary self.update_values() self.theme_cls.primary_palette = "Gray" self.theme_cls.primary_hue = "800" # Game counters screen and backgrgound color self.counters = Screen(name="Counters") self.change_bg_color() screen_manager.add_widget(self.counters) # SCROLLVIEW self.scroll = ScrollView() self.counters.add_widget(self.scroll) # MENU self.menu_button = MDIconButton(icon='format-color-fill', on_release=self.menu_open) self.menu_button.pos_hint = {'center_x': .9, 'center_y': .1} self.menu_button.md_bg_color = (1, 1, 1, 1) items = [{ "text": "Ceramic White" }, { "text": "Loyal Angels Green" }, { "text": "Space Doggos Gray" }, { "text": "Codex Blue" }, { "text": "Vampire Angels Red" }, { "text": "Gray Nights" }, { "text": "Stubborn Fists Yellow" }] self.menu = MDDropdownMenu(caller=self.menu_button, items=items, callback=self.menu_callback, width_mult=5) self.counters.add_widget(self.menu_button) # MAIN GRID app_grid = GridLayout(cols=1, spacing=100, size_hint_y=None) app_grid.padding = [ Window.width / 40, Window.height / 20, Window.width / 40, Window.height / 4 ] # [left,top,right,bottom] app_grid.bind(minimum_height=app_grid.setter('height')) self.scroll.add_widget(app_grid) # ROUND COUNTER round_parent_grid = MDGridLayout() round_parent_grid.cols = 1 round_parent_grid.rows = 2 round_parent_grid.adaptive_height = True round_label = MDLabel(text='Round number:') round_label.halign = 'center' round_parent_grid.add_widget(round_label) app_grid.add_widget(round_parent_grid) grid_round = GridLayout() grid_round.cols = 3 increase_round = MDIconButton(icon="arrow-right-bold", on_press=self.increase_round) self.round_counter = MDLabel(text=str(self.loaded_values[0])) self.round_counter.halign = 'center' self.round_counter.valign = 'middle' decrease_round = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_round) grid_round.add_widget(decrease_round) grid_round.add_widget(self.round_counter) grid_round.add_widget(increase_round) round_parent_grid.add_widget(grid_round) # COMMAND POINTS cp_parent_grid = MDGridLayout() cp_parent_grid.cols = 1 cp_parent_grid.rows = 2 cp_parent_grid.adaptive_height = True cp_label = MDLabel(text='Command Points Left:') cp_label.halign = 'center' cp_parent_grid.add_widget(cp_label) app_grid.add_widget(cp_parent_grid) grid_cp = MDGridLayout() grid_cp.cols = 3 increase_cp = MDIconButton(icon="arrow-right-bold", on_press=self.increase_cp) self.cp_counter = MDLabel(text=str(self.loaded_values[1])) self.cp_counter.halign = 'center' self.cp_counter.valign = 'middle' decrease_cp = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_cp) grid_cp.add_widget(decrease_cp) grid_cp.add_widget(self.cp_counter) grid_cp.add_widget(increase_cp) cp_parent_grid.add_widget(grid_cp) # VP PRIMARY prim_parent_grid = MDGridLayout() prim_parent_grid.cols = 1 prim_parent_grid.rows = 2 prim_parent_grid.adaptive_height = True prim_label = MDLabel(text='Primary Objective Points:') prim_label.halign = 'center' prim_parent_grid.add_widget(prim_label) app_grid.add_widget(prim_parent_grid) grid_prim = MDGridLayout() grid_prim.cols = 3 increase_prim = MDIconButton(icon="arrow-right-bold", on_press=self.increase_prim) self.prim_counter = MDLabel(text=str(self.loaded_values[2])) self.prim_counter.halign = 'center' self.prim_counter.valign = 'middle' decrease_prim = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_prim) grid_prim.add_widget(decrease_prim) grid_prim.add_widget(self.prim_counter) grid_prim.add_widget(increase_prim) prim_parent_grid.add_widget(grid_prim) # VP SECONDARY 1 sec1_parent_grid = MDGridLayout() sec1_parent_grid.cols = 1 sec1_parent_grid.rows = 2 sec1_parent_grid.adaptive_height = True sec1_label = MDTextField() sec1_label.hint_text = '1st Secondary Objective Points:' sec1_label.multiline = False #sec1_label = MDLabel(text='1st Secondary Objective Points:') sec1_label.halign = 'center' sec1_parent_grid.add_widget(sec1_label) app_grid.add_widget(sec1_parent_grid) grid_sec1 = MDGridLayout() grid_sec1.cols = 3 increase_sec1 = MDIconButton(icon="arrow-right-bold", on_press=self.increase_sec1) self.sec1_counter = MDLabel(text=str(self.loaded_values[3])) self.sec1_counter.halign = 'center' self.sec1_counter.valign = 'middle' decrease_sec1 = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_sec1) grid_sec1.add_widget(decrease_sec1) grid_sec1.add_widget(self.sec1_counter) grid_sec1.add_widget(increase_sec1) sec1_parent_grid.add_widget(grid_sec1) # VP SECONDARY 2 sec2_parent_grid = MDGridLayout() sec2_parent_grid.cols = 1 sec2_parent_grid.rows = 2 sec2_parent_grid.adaptive_height = True sec2_label = MDTextField() sec2_label.hint_text = '2nd Secondary Objective Points:' sec2_label.multiline = False #sec2_label = MDLabel(text='2nd Secondary Objective Points:') sec2_label.halign = 'center' sec2_parent_grid.add_widget(sec2_label) app_grid.add_widget(sec2_parent_grid) grid_sec2 = MDGridLayout() grid_sec2.cols = 3 increase_sec2 = MDIconButton(icon="arrow-right-bold", on_press=self.increase_sec2) self.sec2_counter = MDLabel(text=str(self.loaded_values[4])) self.sec2_counter.halign = 'center' self.sec2_counter.valign = 'middle' decrease_sec2 = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_sec2) grid_sec2.add_widget(decrease_sec2) grid_sec2.add_widget(self.sec2_counter) grid_sec2.add_widget(increase_sec2) sec2_parent_grid.add_widget(grid_sec2) # VP SECONDARY 3 sec3_parent_grid = MDGridLayout() sec3_parent_grid.cols = 1 sec3_parent_grid.rows = 2 sec3_parent_grid.adaptive_height = True sec3_label = MDTextField() sec3_label.hint_text = '3rd Secondary Objective Points:' sec3_label.multiline = False #sec3_label = MDLabel(text='3rd Secondary Objective Points:') sec3_label.halign = 'center' sec3_parent_grid.add_widget(sec3_label) app_grid.add_widget(sec3_parent_grid) grid_sec3 = MDGridLayout() grid_sec3.cols = 3 increase_sec3 = MDIconButton(icon="arrow-right-bold", on_press=self.increase_sec3) self.sec3_counter = MDLabel(text=str(self.loaded_values[5])) self.sec3_counter.halign = 'center' self.sec3_counter.valign = 'middle' decrease_sec3 = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_sec3) grid_sec3.add_widget(decrease_sec3) grid_sec3.add_widget(self.sec3_counter) grid_sec3.add_widget(increase_sec3) sec3_parent_grid.add_widget(grid_sec3) # Empty grid to create space empty_grid = MDGridLayout() app_grid.add_widget(empty_grid) # Bottom grid for Score and Reset buttons bottom_grid = MDGridLayout() bottom_grid.cols = 2 app_grid.add_widget(bottom_grid) # SCORE TOAST score_button = MDFillRoundFlatIconButton(icon='flag-plus-outline', text="Show score", on_press=self.sum_up) button_anchor = AnchorLayout() button_anchor.anchor_y = 'bottom' button_anchor.add_widget(score_button) bottom_grid.add_widget(button_anchor) # RESET reset_button = MDFillRoundFlatIconButton(icon='backup-restore', text="Reset", on_press=self.reset_values) reset_button_anchor = AnchorLayout() reset_button_anchor.anchor_y = 'bottom' reset_button_anchor.add_widget(reset_button) bottom_grid.add_widget(reset_button_anchor) return screen_manager