def build(icon_path, title, subtitle, key): # space between icon and top border TOP_SEP = fillers.horizontal_filler(2, colors.WHITE) icon = sg.Image( filename=icon_path, background_color=colors.WHITE, ) content = build_card_content(title, subtitle) # space between content and button CONTENT_SEP = fillers.horizontal_filler(2, colors.WHITE) read_more = button.build(CARD_BUTTON_TEXT, key, CARD_BUTTON_FONT, CARD_BUTTON_SIZE) # space between the button and the bottom border BOTTOM_SEP = fillers.horizontal_filler(2, colors.WHITE) return sg.Column(layout=[[TOP_SEP], [icon], [content], [CONTENT_SEP], [read_more], [BOTTOM_SEP]], background_color=colors.WHITE, element_justification='c', vertical_alignment='c', pad=CARD_SPACE_AROUND)
def build(key, title, subtitle, content): """Returns a popup with the information given.""" ttitlebar = titlebar.build() # space between icon and top border TOP_SEP = fillers.horizontal_filler(2, colors.WHITE) icon = sg.Image( filename=paths.POPUP_ICON, background_color=colors.WHITE, ) popup_content = build_popup_content(title, subtitle, content) # space between content and buttons BOTTOM_CONTENT_SEP = fillers.horizontal_filler(2, colors.WHITE) buttons = build_buttons_section(key) # space between buttons and the bottom border BOTTOM_SEP = fillers.horizontal_filler(1, colors.WHITE) return sg.Window(title='', layout=[[ttitlebar], [TOP_SEP], [icon], [popup_content], [BOTTOM_CONTENT_SEP], [buttons], [BOTTOM_SEP]], no_titlebar=True, keep_on_top=True, element_justification='c', background_color=colors.WHITE)
def build_popup_content(title, subtitle, content): """Returns a container with the content for this popup. This is the part that changes between popups. """ title = sg.Text(text=title, background_color=colors.WHITE, text_color=colors.VIOLET, justification='c', font=POPUP_TITLE_FONT) subtitle = sg.Text(text=subtitle, background_color=colors.WHITE, text_color=colors.BLACK, justification='c', font=POPUP_SUBTITLE_FONT, size=SUBTITLE_SIZE) # space between subtitle and content TOP_CONTENT_SEP = fillers.horizontal_filler(1, colors.WHITE) content = sg.Text( text=content, background_color=colors.WHITE, text_color=colors.BLACK, justification='c', font=POPUP_CONTENT_FONT, ) return sg.Column( layout=[[title], [subtitle], [TOP_CONTENT_SEP], [content]], background_color=colors.WHITE, element_justification='c', vertical_alignment='c', )
def build(): """A pseudo title bar, with no buttons.""" container = sg.Column( layout=[[fillers.horizontal_filler(1, colors.LIGHT_GRAY)]], vertical_alignment='c', element_justification='r', expand_x=True, background_color=colors.LIGHT_GRAY, grab=True) return container
def build_buttons_section(key): """Returns a container with the two buttons in a popup""" analyse = button.build(POPUP_BUTTON1_TEXT, key, POPUP_BUTTON_FONT, POPUP_BUTTON_SIZE) # space between this buttons BUTTON_BOTTOM_SEP = fillers.horizontal_filler(1, colors.WHITE) cancel = button.build(POPUP_BUTTON2_TEXT, keys.RETURN_EVENT, POPUP_BUTTON_FONT, POPUP_BUTTON_SIZE) return sg.Column(layout=[[analyse], [BUTTON_BOTTOM_SEP], [cancel]], background_color=colors.WHITE, expand_x=True, element_justification='c')
def build(): """Returns a window used to get the output filepath of the analysis.""" ttitlebar = titlebar.build() hheading = heading.build(HEADING_TITLE, HEADING_SUBTITLE) inputs = build_input_field() ccontinue = button.build(CONTINUE_BUTTON_TEXT, '', CONTINUE_BUTTON_FONT, CONTINUE_BUTTON_SIZE) bottom_sep = fillers.horizontal_filler(2, colors.BACKGROUND) return sg.Window(title='', layout=[[ttitlebar], [hheading], [inputs], [ccontinue], [bottom_sep]], element_justification='c', keep_on_top=True, no_titlebar=True)
def build(cards, exit_button_text, key, button_size): """Builds a menu with the given cards and a button.""" ttitlebar = titlebar.build() hheading = heading.build(MAIN_WINDOW_TITLE, MAIN_WINDOW_SUBTITLE) exit_button = button.build(exit_button_text, key, BUTTON_FONT, button_size) # adds space between button and bottom border bottom_sep = fillers.horizontal_filler(1, colors.BACKGROUND) window = sg.Window(title='', layout=[[ttitlebar], [hheading], [cards], [exit_button], [bottom_sep]], no_titlebar=True, keep_on_top=True, element_justification='c') return window