Beispiel #1
0
 def _prepare_button_rows(self):
     bkw = {'size': (18, 1)}
     view_button_rows = [
         [
             Button('Clean & Add BPM', key='clean', **bkw),
             Button('View All Tags', key='all_tags', **bkw),
             Button('Edit', key='edit', **bkw),
             Button('Wiki Update', key='wiki_update', **bkw),
         ],
         [
             Button('Sync Ratings From...', key='sync_ratings::dst_album', **bkw),
             Button('Sync Ratings To...', key='sync_ratings::src_album', **bkw),
             Button('Copy Tags From...', key='copy_data', **bkw),
         ],
     ]
     edit_buttons = [Button('Review & Save Changes', key='save', **bkw), Button('Cancel', key='cancel', **bkw)]
     album_buttons = [
         Column(view_button_rows, key='col::view_buttons', visible=not self.editing, element_justification='center'),
         Column([edit_buttons], key='col::edit_buttons', visible=self.editing),
     ]
     open_button = Button(
         '\U0001f5c1',
         key='select_album',
         font=('Helvetica', 20),
         size=(10, 1),
         tooltip='Open',
         visible=not self.editing,
     )
     return [album_buttons, [open_button]]
Beispiel #2
0
 def as_all_tag_rows(self, editable: bool = True):
     cover = Column([[self.cover_image_thumbnail]],
                    key=f'col::{self.path_str}::cover')
     tag_rows, ele_binds = self.get_tag_rows(editable)
     tags = Column(tag_rows, key=f'col::{self.path_str}::tags')
     layout = [[HorizontalSeparator()],
               self.get_basic_info_row(),
               self.get_metadata_row(), [cover, tags]]
     return layout, ele_binds
Beispiel #3
0
 def _prepare_album_column(self, spinner: Spinner):
     spinner.update()
     album_data = [
         Column([[self.album_formatter.cover_image_thumbnail]], key='col::album_cover'),
         Column(self.album_formatter.get_album_data_rows(self.editing), key='col::album_data'),
     ]
     spinner.update()
     alb_col_rows = [album_data, [HorizontalSeparator()], *self._prepare_button_rows()]
     album_column = Column(
         alb_col_rows, vertical_alignment='top', element_justification='center', key='col::album_container'
     )
     return album_column
Beispiel #4
0
def ViewGUI():
    sg.theme('LightGreen')

    col1 = Column([
        [Frame('base function',[[Column([[
                        Text(r'VideoFile',size=(10,1)),
                        InputText(''*15, key="VideoFile"),
                        FileBrowse(target='VideoFile', size=(10,1)),
                        Button('start',key='start', size=(10,1)),
                        Button('stop',key='stop', size=(10,1)),
                        Button('Exit',key= 'exit', size=(10,1)),]],
                   size=(800,45), pad=(0, 0))]])],
        [Frame('videoplay',[[Column([[Image(filename='', key='image',)]],
                   size=(800,500), pad=(0, 0))
               ]])]
    ], pad=(0,0))


    col2 = Column([
        [Frame('results',
               [[Column(
                   [
                       [Image(filename='', key='image1', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))],
                       [Image(filename='', key='image2', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))],
                       [Image(filename='', key='image3', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))],
                       [Image(filename='', key='image4', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))],
                       [Image(filename='', key='image5', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))],
                   ]
               ,size=(400,560))
                 ]]
               )]
    ])

    layout = [[col1,col2]]
    # layout = [
    #     [sg.Text(r'机器视觉原型系统', size=(40,1), justification='center')],
    #     [sg.Text(r'VideoFile',size=(10,1)), sg.InputText(''*30, key="VideoFile"), sg.FileBrowse(size=(10,1)),
    #      sg.Button('start',key='start', size=(10,1)), sg.Button('stop',key='stop', size=(10,1)), sg.Button('end', key='end', size=(10,1)),
    #      sg.Button('Exit',key= 'exit', size=(10,1))],
    #     [sg.Image(filename='', key='image')],
    # ]

    window = sg.Window(
        '机器视觉',
        layout,
        location=(100,100),
        finalize=True
    )
    return window
Beispiel #5
0
    def get_render_args(self) -> RenderArgs:
        try:
            layout = [[Menu(self.menu)]]
        except AttributeError:
            layout = []

        if self.__class__ is PlexView and not self._init_event:
            image = image_to_bytes(ICONS_DIR.joinpath('search.png'),
                                   size=(200, 200))
            button = Button('Search',
                            image_data=image,
                            image_size=(210, 210),
                            font=('Helvetica', 18),
                            bind_return_key=True)
            inner_layout = [[Image(key='spacer::2', pad=(0, 0))], [button],
                            [Image(key='spacer::1', pad=(0, 0))]]
            content = Column(
                inner_layout,
                vertical_alignment='center',
                justification='center',
                element_justification='center',
                expand_y=True,
                expand_x=True,
            )
            layout.append([content])

        kwargs = {'title': f'Plex Manager - {self.display_name}'}
        return layout, kwargs
Beispiel #6
0
 def as_info_rows(self,
                  editable: bool = True,
                  keys: Collection[str] = None):
     yield [HorizontalSeparator()]
     yield self.get_basic_info_row()
     yield [
         Column(self.get_info_rows(editable, keys),
                key=f'col::{self.path_str}::tags')
     ]
Beispiel #7
0
    def get_render_args(self) -> RenderArgs:
        full_layout, kwargs = super().get_render_args()
        ele_binds = {}
        options_frame = self.options.as_frame('apply_changes')
        if self.last_view and self.last_view.name != 'album':
            top_side_kwargs = dict(size=(6, 1), pad=(0, 0), font=('Helvetica', 20))
            edit_button = Button('\u2190 Edit', key='edit', visible=True, **top_side_kwargs)
            edit_col = Column([[edit_button]], key='col::edit', expand_x=True)
            right_spacer = Text(key='spacer::1', **top_side_kwargs)
            first_row = [edit_col, options_frame, right_spacer]
            self.binds['<Control-e>'] = 'edit'
        else:
            first_row = [options_frame]

        layout = [first_row, [Text()], [HSep(), Text('Common Album Changes'), HSep()], [Text()]]

        if diff_imgs := self.album_formatter.get_cover_image_diff(self.album_info):
            src_img_ele, new_img_ele = diff_imgs
            img_row = [src_img_ele, Text('\u2794', key='txt::cover::arrow', font=('Helvetica', 20)), new_img_ele]
            img_diff_col = Column([img_row], key='col::img_diff', justification='center')
            layout.extend([[img_diff_col], [HSep()]])
Beispiel #8
0
 def as_frame(self,
              submit_key: str = None,
              disable_all: bool = None,
              submit_row: int = None,
              **kwargs) -> Column:
     frame = Frame(self.title,
                   self.layout(submit_key, disable_all, submit_row),
                   key='frame::options')
     return Column([[frame]],
                   key='col::frame_options',
                   justification='center',
                   **kwargs)
Beispiel #9
0
def value_ele(value: Any,
              val_key: str,
              disabled: bool,
              list_width: int = 30,
              no_add: bool = False,
              **kwargs) -> Element:
    if isinstance(value, bool):
        val_ele = Checkbox('',
                           default=value,
                           key=val_key,
                           disabled=disabled,
                           pad=(0, 0),
                           **kwargs)
    elif isinstance(value, list):
        kwargs.setdefault('tooltip', 'Unselected items will not be saved')
        add_button = not no_add and val_key.startswith('val::')
        if not add_button:
            kwargs.setdefault('pad', (6, 0))
        val_ele = Listbox(
            value,
            default_values=value,
            key=val_key,
            disabled=disabled,
            size=(list_width, len(value)),
            no_scrollbar=True,
            select_mode='extended',  # extended, browse, single, multiple
            **kwargs,
        )
        if add_button:
            val_ele = Column(
                [[
                    val_ele,
                    Button('Add...',
                           key=val_key.replace('val::', 'add::', 1),
                           disabled=disabled,
                           pad=(0, 0))
                ]],
                key=f'col::{val_key}',
                pad=(0, 0),
                vertical_alignment='center',
                justification='center',
                expand_y=True,
                expand_x=True,
            )
    else:
        val_ele = ExtInput(value,
                           key=val_key,
                           disabled=disabled,
                           right_click_menu=SearchMenu(),
                           **kwargs)

    return val_ele
Beispiel #10
0
    def get_render_args(self) -> RenderArgs:
        full_layout, kwargs = super().get_render_args()
        ele_binds = {}
        win_w, win_h = self._window_size
        max_h = win_h - 66

        with Spinner() as spinner:
            layout = [[]]
            albums, formatters = (self.src_album,
                                  self.dst_album), (self.src_formatter,
                                                    self.dst_formatter)
            for loc, album, formatter in zip(('src', 'dst'), albums,
                                             formatters):
                path_key = f'path::{loc}'
                path = ExtInput(album.path.as_posix(),
                                key=path_key,
                                disabled=True,
                                size=(150, 1),
                                tooltip='Click to change album')
                ele_binds[path_key] = {'<Button-1>': ':::album_clicked'}
                rows = [  # menu = 20px; 46 px from menu to 1st track's horizontal separator
                    [Text('Album Path:'), path],
                    [HorizontalSeparator()],
                    *chain.from_iterable(
                        tb.as_sync_rows()
                        for tb in spinner(formatter)),  # 86 px each
                ]
                col_w = (win_w - 159) // 2
                if (len(album) * 86) > max_h:
                    col_kwargs = dict(scrollable=True,
                                      vertical_scroll_only=True)
                    col_w -= 17
                else:
                    col_kwargs = {}

                layout[0].append(
                    Column(rows,
                           key=f'col::track_data::{loc}',
                           size=(col_w, max_h),
                           **col_kwargs))

        workflow = self.as_workflow(layout,
                                    back_tooltip='Cancel Changes',
                                    next_tooltip='Review & Save Changes')
        full_layout.append(workflow)

        return full_layout, kwargs, ele_binds
Beispiel #11
0
 def get_render_args(self) -> tuple[list[list[Element]], dict[str, Any]]:
     size = self.kwargs.pop('size', (None, None))
     before = self.before or (
         f'Found multiple {self.item_name}s{_prepare_source(self.source)} - which {self.item_name} should be used?'
     )
     choices = [[
         Radio(self.repr_func(item),
               'rad::choices',
               key=('choice', i),
               enable_events=True)
     ] for i, item in enumerate(self.items)]
     layout = [
         [Text(before, key='txt::before', size=size)],
         [
             Column(choices, key='col::choices'),
             Button('Submit', key='submit', disabled=True)
         ],
     ]
     return layout, {'title': self.title, **self.kwargs}
Beispiel #12
0
    def get_render_args(self) -> tuple[list[list[Element]], dict[str, Any]]:
        choices = []
        for title, image in self.images.items():  # type: str, PILImage
            try:
                image = image.copy()
                image.thumbnail(self.img_size)
            except Exception:
                self.log.error(f'Unable to render image={title!r}:',
                               exc_info=True)
                data = None
            else:
                bio = BytesIO()
                image.save(bio, format='PNG')
                data = bio.getvalue()

            button_text = '\n'.join(
                wrap(title,
                     break_long_words=False,
                     break_on_hyphens=False,
                     tabsize=4,
                     width=30))
            choices.append([
                Radio(button_text,
                      'rad::choices',
                      key=('choice', title),
                      enable_events=True),
                Image(data=data,
                      key=f'img::{title}',
                      enable_events=True,
                      size=self.img_size)
            ])

        images_shown = max(
            1, min(self.window.get_screen_size()[1] // 270, len(self.images)))
        content_col = Column(choices,
                             key='col::choices',
                             scrollable=True,
                             vertical_scroll_only=True,
                             size=(500, images_shown * 270))
        layout = [[content_col, Button('Submit', key='submit', disabled=True)]]
        return layout, {'title': self.title, **self.kwargs}
Beispiel #13
0
    def as_diff_rows(self,
                     new_track_info: TrackInfo,
                     title_case: bool = False,
                     add_genre: bool = False):
        yield [HorizontalSeparator()]
        new_name = new_track_info.expected_name(self.track)
        if self.track.path.name != new_name:
            yield from get_a_to_b('File Rename:', self.track.path.name,
                                  new_name, self.path_str, 'file_name')
        else:
            yield [
                Text('File:'),
                ExtInput(self.track.path.name,
                         disabled=True,
                         key=f'src::{self.path_str}::file_name'),
                Text('(no change)'),
            ]

        if diff_rows := self.get_diff_rows(new_track_info, title_case,
                                           add_genre):
            yield [Column(diff_rows, key=f'col::{self.path_str}::diff')]
Beispiel #14
0
    def get_render_args(self) -> RenderArgs:
        full_layout, kwargs = super().get_render_args()
        with Spinner() as spinner:
            album_path = self.album.path.as_posix()
            layout = [
                [Text('Album Path:'), ExtInput(album_path, disabled=True, size=(150, 1), path=album_path)],
                [HorizontalSeparator()]
            ]
            album_column = self._prepare_album_column(spinner)
            track_column = self._prepare_track_column(spinner)
            data_col = Column([[album_column, track_column]], key='col::all_data', justification='center', pad=(0, 0))
            layout.append([data_col])

        workflow = self.as_workflow(
            layout,
            back_tooltip='Cancel Changes' if self.editing else 'View previous album',
            next_tooltip='Review & Save Changes' if self.editing else 'View next album',
            back_visible=bool(self.editing or self._album_index),
            next_visible=bool(self.editing or self._album_index < len(self._albums) - 1),
        )
        full_layout.append(workflow)

        return full_layout, kwargs
Beispiel #15
0
                    resize_text_column(rows_with_text)  # noqa
                if self.align_checkboxes:
                    if box_rows := [
                            r for r in row_set
                            if r and all(isinstance(e, Checkbox) for e in r)
                    ]:
                        self.log.info(
                            f'Processing checkboxes into grid: {box_rows}')
                        make_checkbox_grid(box_rows)  # noqa

        if not layout and len(columns) == 1:
            layout = columns[0]
        else:
            column_objects = [
                Column(column,
                       key=f'col::options::{i}',
                       pad=(0, 0),
                       expand_x=True) for i, column in enumerate(columns)
            ]
            layout.append(column_objects)

        return layout

    def layout(self,
               submit_key: str = None,
               disable_all: bool = None,
               submit_row: int = None) -> list[list[Element]]:
        if disable_all is None:
            disable_all = self.disable_on_parsed and self.parsed
        self.log.debug(
            f'Building option layout with {self.parsed=!r} {submit_key=!r} {disable_all=!r}'
        )
Beispiel #16
0
    print("Here")
    window['-COMPLETED_GOALS_LIST-'].update(complete_goals_titles)


# ----- sublayouts -----#

# layout for the login page by Johan yeye kewl ;3
layoutthing = [
    [Text(" " *48), Button("Enter", font=('Courier', 10))]
]

# ---Login Column---#
bottom_right_column = Column([
    [Text("Username", size=(10, 2), font=('Courier', 12))],
    [InputText(key="-USERNAME-", size=(37, 5), background_color='#E0DEDE', font=('Courier', 10))],
    [Text("Password", size=(10, 2), font=('Courier', 12))],
    [InputText(key="-PASSWORD-", size=(37, 5), password_char='*', background_color='#E0DEDE', font=('Courier', 10))],
    [Column(layoutthing)]
])

# ---Login PAGE---#
bot_page = [
    [Text('\n\n\nTrack your progress, \nWith Cats!', size=(30, 10), font=('Courier', 20, 'bold'), justification='center'), bottom_right_column],
]

login_page_layout = [
    [Image(r'half_cat.png')],
    [Frame('', bot_page, background_color=sg.theme_input_background_color(), border_width=0)]
]

# layout for the info bar at top
Beispiel #17
0
def show_main():
    METER_REASON_CANCELLED = "cancelled"
    # METER_REASON_CLOSED = "closed"
    # METER_REASON_REACHED_MAX = "finished"
    METER_OK = True
    # METER_STOPPED = False

    menu_def = [
        # ["File", ["Save", "Load", "Exit"]],
        ["File", ["Exit"]],
        [
            "Commands",
            [
                "Extract",
                "Load",
                "Merge",
                "Catalog",
                ["Get", "List", "Purge", "Upload"],
                "Transform",
            ],
        ],
        ["Help", ["About", "Help"]],
    ]

    col1 = Column(
        [
            # Logon frame
            [
                Frame(
                    "Logon information",
                    [[
                        Text(),
                        Column([
                            [
                                Text("ION File:", size=(14, 1)),
                                Input(key="-ION-FILE-"),
                                FileBrowse(),
                            ],
                            [
                                Text("M3 Company/Div:"),
                                Input(key="-M3-COMPANY-", size=(5, 1)),
                                Input(key="-M3-DIV-", size=(7, 1)),
                            ],
                        ]),
                    ]],
                )
            ],
            # Information frame
            [
                Frame(
                    "Input Data",
                    [[
                        Text(),
                        Column([
                            [
                                Text("URL:", size=(14, 1)),
                                Input(key="-ION-URL-"),
                            ],
                            [
                                Text("Program:", size=(14, 1)),
                                sg.Input(
                                    size=(10, 1),
                                    enable_events=True,
                                    key="-ION-FILTER-",
                                ),
                            ],
                            [
                                Text(justification="r", size=(14, 1)),
                                sg.Listbox(
                                    programs,
                                    size=(10, 5),
                                    enable_events=False,
                                    key="-ION-Program-",
                                    select_mode="single",
                                ),
                            ],
                            [
                                Text("Method:", size=(14, 1)),
                                Input(key="-ION-METHOD-"),
                            ],
                            [
                                Text("Input File:", size=(14, 1)),
                                Input(key="-INPUT-FILE-"),
                                FileBrowse(),
                            ],
                            [
                                Text("Output File:", size=(14, 1)),
                                Input(key="-OUTPUT-FILE-"),
                                FileBrowse(),
                            ],
                            [
                                Text("Begin on line:", size=(14, 1)),
                                Input(key="-ION-BEGIN-", enable_events=True),
                            ],
                            [
                                Text("End on line:", size=(14, 1)),
                                Input(key="-ION-END-", enable_events=True),
                            ],
                        ], ),
                    ]],
                )
            ],
        ], )

    layout = [
        [sg.Menu(menu_def, tearoff=True, pad=(200, 1))],
        [col1],
        [Button("Execute"), Button("Cancel")],
    ]

    window = sg.Window("QuickdataLoad - Main",
                       layout=layout,
                       icon=icon_image,
                       margins=(10, 10))
    settings = load_settings(SETTINGS_FILE, DEFAULT_SETTINGS)

    window_extract_active = False

    # Event Loop
    while True:
        event, values = window.read(10)

        if not notifications.empty():
            e, m = notifications.get()
            sg.popup(m, icon=icon_image)

        if event in (None, sg.WIN_CLOSED, "Cancel"):
            break

        if event in ("-ION-BEGIN-", "-ION-END-"):
            if values[event] and values[event][-1] not in ("0123456789"):
                sg.popup_quick_message(
                    "Please enter a valid row number",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )

        if values["-ION-FILTER-"] != "":
            search = values["-ION-FILTER-"]
            filtered_programs = [x for x in programs if search in x]
            window["-ION-Program-"].update(filtered_programs)
        else:
            window["-ION-Program-"].update(programs)

        if event == "Execute":

            url = values["-ION-URL-"]
            ionfile = values["-ION-FILE-"]
            programs_list = values["-ION-Program-"]
            method = values["-ION-METHOD-"]
            inputfile = values["-INPUT-FILE-"]
            outputfile = values["-OUTPUT-FILE-"]

            if values["-ION-BEGIN-"]:
                start = int(values["-ION-BEGIN-"])
            else:
                start = 0

            if values["-ION-END-"]:
                end = int(values["-ION-END-"])
            else:
                end = None

            if validators.url(url) != True:
                sg.popup_quick_message(
                    "You have to provide a valid URL",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )
                METER_OK = False
            elif infor.filehandling.checkfile_exists(ionfile) != True:
                sg.popup_quick_message(
                    "You have to provide a valid ionfile",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )
                METER_OK = False
            elif not programs_list:
                sg.popup_quick_message(
                    "You have to provide a program",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )
                METER_OK = False
            elif not method:
                sg.popup_quick_message(
                    "You have to provide atleast one method",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )
                METER_OK = False
            elif not outputfile:
                sg.popup_quick_message(
                    "You have to provide output file path",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )
                METER_OK = False
            elif not infor.filehandling.checkfile_exists(inputfile):
                sg.popup_quick_message(
                    "Input File not found",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )
                METER_OK = False
            elif end is not None and end < start:
                sg.popup_quick_message(
                    "Begin value must be greater then End value",
                    keep_on_top=True,
                    text_color="red",
                    no_titlebar=True,
                )
                METER_OK = False
            else:
                METER_OK = True
                dataframe = pd.read_excel(inputfile, dtype=str)
                program = programs_list[0]

            if METER_OK:

                infor.main_load(
                    url,
                    ionfile,
                    program,
                    method,
                    dataframe,
                    outputfile,
                    start,
                    end,
                    on_progress,
                )

        if event == "Save":
            save_settings(True, SETTINGS_FILE, settings, values)

        if event == "Load":
            settings = load_settings(SETTINGS_FILE, DEFAULT_SETTINGS)
            fill_form_with_settings(window, settings)

        if event == "About":
            open_about()

        if event == "Help":
            open_help()

        if event in (sg.WIN_CLOSED, "Exit"):
            break

        # Command Windows

        if event == "Extract" and not window_extract_active:
            window_extract_active = True
            window.Hide()

            def TextLabel(text):
                return sg.Text(text + ":", justification="r", size=(12, 1))

            column = Column([
                [
                    Frame(
                        "Input Data",
                        [[
                            Text(),
                            Column([
                                [
                                    TextLabel("Program"),
                                    sg.Input(
                                        size=(10, 1),
                                        enable_events=True,
                                        key="-FILTER-",
                                    ),
                                ],
                                [
                                    Text(justification="r", size=(12, 1)),
                                    sg.Listbox(
                                        programs,
                                        size=(10, 5),
                                        enable_events=False,
                                        key="-PROGRAM-",
                                        select_mode="multiple",
                                    ),
                                ],
                                [
                                    TextLabel("Output Folder"),
                                    sg.Input(key="-OUTPUT-FOLDER-"),
                                    sg.FolderBrowse(target="-OUTPUT-FOLDER-"),
                                ],
                            ], ),
                        ]],
                    )
                ],
            ], )

            layout_extract = [[column], [Button("Execute"), Button("Cancel")]]
            window_extract = sg.Window(
                "QuickdataLoad  - Extract",
                layout=layout_extract,
                icon=icon_image,
                margins=(10, 10),
            )

            while True:
                event, values = window_extract.read()

                if event == sg.WIN_CLOSED or event == "Cancel":
                    window_extract.Close()
                    window_extract_active = False
                    break

                if values["-FILTER-"] != "":
                    search = values["-FILTER-"]
                    filtered_programs = [x for x in programs if search in x]
                    window_extract["-PROGRAM-"].update(filtered_programs)
                else:
                    window_extract["-PROGRAM-"].update(programs)

                if event == "Execute":
                    try:
                        programs_list = values["-PROGRAM-"]
                        output_folder = values["-OUTPUT-FOLDER-"]

                        if validators.length(programs_list,
                                             1) and validators.length(
                                                 output_folder, 1):
                            for program in programs_list:
                                output_path = output_folder + os.sep + program
                                excelexport.generate_api_template_file(
                                    program, output_path)
                            sg.popup("Template(s) generated!", icon=icon_image)
                        else:
                            sg.popup_ok("Please, check the form values!",
                                        icon=icon_image)
                    except Exception as e:
                        infor.logger.exception(e)
                        sg.popup_ok(
                            "Something went wrong! Please check the error logs!",
                            icon=icon_image,
                        )

        if event == "Transform" and not window_extract_active:

            window_transform_active = True
            window.Hide()

            def TextLabel(text):
                return sg.Text(text + ":", justification="r", size=(15, 1))

            column = Column([
                [
                    Frame(
                        "Input Data",
                        [[
                            Text(),
                            Column([
                                [
                                    TextLabel("Mapping File"),
                                    Input(key="-MAPPING-FILE-"),
                                    FileBrowse(),
                                ],
                                [
                                    TextLabel("Main Sheet"),
                                    Input(key="-MAIN-SHEET-"),
                                ],
                                [
                                    TextLabel("Input File"),
                                    Input(key="-INPUT-FILE-"),
                                    FileBrowse(),
                                ],
                                [
                                    TextLabel("Output Folder"),
                                    sg.Input(key="-OUTPUT-FOLDER-"),
                                    sg.FolderBrowse(target="-OUTPUT-FOLDER-"),
                                ],
                            ], ),
                        ]],
                    )
                ],
            ], )

            layout_transform = [[column],
                                [Button("Execute"),
                                 Button("Cancel")]]
            window_transform = sg.Window(
                "QuickdataLoad  - Transform",
                icon=icon_image,
                layout=layout_transform,
                margins=(10, 10),
            )

            while True:
                event, values = window_transform.read(10)

                if not notifications.empty():
                    e, m = notifications.get()
                    sg.popup(m, icon=icon_image)

                if event == sg.WIN_CLOSED or event == "Cancel":
                    window_transform.Close()
                    window_transform_active = False
                    break

                if event == "Execute":

                    try:
                        mapping_file = values["-MAPPING-FILE-"]
                        main_sheet = values["-MAIN-SHEET-"]
                        input_file = values["-INPUT-FILE-"]
                        output_folder = values["-OUTPUT-FOLDER-"]

                        if (validators.length(mapping_file, 1)
                                and validators.length(main_sheet, 1)
                                and validators.length(input_file, 1)
                                and validators.length(output_folder, 1)):

                            output_file_name = "output_" + path_leaf(
                                input_file)
                            output_file = output_folder + os.sep + output_file_name
                            threading.Thread(
                                target=transform,
                                args=(
                                    mapping_file,
                                    main_sheet,
                                    input_file,
                                    output_file,
                                    notifications,
                                ),
                            ).start()
                            sg.popup(
                                "Transformation file result will generated at: \n"
                                + output_file,
                                icon=icon_image,
                            )
                        else:
                            sg.popup_ok("Please, check the form values!",
                                        icon=icon_image)
                    except Exception as e:
                        infor.logger.exception(e)
                        sg.popup_ok(
                            "Something went wrong! Please check the error logs!",
                            icon=icon_image,
                        )

        window.UnHide()

    window.close()
Beispiel #18
0

# The tab 1, 2, 3 layouts - what goes inside the tab
tab_main_layout = [[
    main_graph,
    Column([[
        Button(
            button_text="",
            button_color=[PRIMARY, PRIMARY],
            key="GRAPH-BOX",
            image_filename="assets/img/box-unactivated.png",
            image_size=[35, 35],
            border_width=0,
        )
    ],
            [
                Button(
                    button_text="",
                    button_color=[PRIMARY, PRIMARY],
                    key="GRAPH-WALL",
                    image_filename="assets/img/brick-unactivated.png",
                    image_size=[35, 35],
                    border_width=0,
                )
            ]],
           metadata="unactivated",
           background_color=[PRIMARY])
]]

tab_colors_layout = [[colors_graph]]
tab_border_layout = [[borders_graph]]
Beispiel #19
0
          tooltip="Milliseconds to beep for",
          size=(5, 5))
],
        [
            Slider(range=(37, 32767),
                   orientation='h',
                   default_value=10000,
                   key="Beep",
                   tooltip="Current frequency")
        ],
        [
            Button("-", key="Lower", tooltip="Lower frequency", size=(1, 1)),
            Button("+", key="Raise", tooltip="Raise frequency", size=(1, 1))
        ]]

layout = [[Column(col1)]]

window = Window("Beep!").Layout(layout).Finalize()
window.Size = (310, 140)
while True:
    event, values = window.Read(timeout=10)

    if not event or event == "Quit":
        break
    elif event == "Raise":
        window.Element("Beep").Update(values["Beep"] + int(values["Step"]))
    elif event == "Lower":
        window.Element("Beep").Update(values["Beep"] - int(values["Step"]))

    elif event == "Beep!":
        print(values)
Beispiel #20
0
                 [
                     Text('Non-moral', size=(20, 1)),
                     Input('0', key='non-moral_result', size=(35, 1))
                 ]]
tab1_layout = [
    [Text('Enter text to annotate:')],
    [Multiline('', size=(88, 20), key='inputtext')], [Button('Analyze text')],
    [
        Text(
            '''The output in the first column is the estimated probability of the text being relevant to either a vice or virtue of the corresponding moral trait.
Since the system is trained on tweets, try not to analyze a long text!
The second column is the average rating for the words, based on human ratings of the Moral Foundation Dictionary words.
The range goes from 1 to 9:
1: words closely associated to harm, cheating, betrayal, subversion, degradation
9: words closely associated to care, fairness, loyalty, authority, sanctity''')
    ], [Column(output_values)]
]

#the second tab is for analyzing one or more files
tab2_layout = [
    [
        Text(
            '''Select one or more files to analyze. If you select a text file, the file results are calculated *per line*.
The output file will contain the input text lines, the 6 predictions and 5 averages, separated by tabs.
	
You can also select an Excel file; the results are calculated on the text in the first column, row by row.
Rrow A is considered a header and *is ignored*.
The results are put in the first available column, and a new file is saved.

The output will always be saved in "[old_filename]_MoralStrength", and the file will be overwritten silently!
Beispiel #21
0
window = sg.Window("Shortcuts", layout)
event, values = window.read()
sg.popup_scrolled(event, values)
window.close()

col2 = Column(
    [[
        Frame(
            "Accounts:",
            [[
                Column(
                    [[
                        Listbox(
                            ["Account " + str(i) for i in range(1, 16)],
                            key="-ACCT-LIST-",
                            size=(15, 20),
                            select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED,
                        ),
                    ]],
                    size=(150, 400),
                )
            ]],
        )
    ]],
    pad=(0, 0),
)

col1 = Column(
    [
        # Categories frame
        [
Beispiel #22
0
                [Text('Comparing ' + str(values['numFiles']) + ' files')])
            column = []
            for i in range(0, values['numFiles']):
                column.append([
                    Text(i + 1),
                    Input('Path', size=(49, 0)),
                    FileBrowse(file_types=(("Excel Workbook", "*.xlsx"),
                                           ("All Files", "*.*")))
                ])
                column.append([
                    Input('Sheet Name', size=(25, 0)),
                    Input('Indicator Name', size=(25, 0))
                ])
            layout2.append([
                Column(column,
                       scrollable=True,
                       vertical_scroll_only=True,
                       size=(450, 400))
            ])
            layout2.append([
                Button('Next', key='toLayout3'),
                Button('Cancel', key='exit')
            ])
            window.Close()
            window = Window('CompyrisonTool').Layout(layout2)
        except:
            Popup('Please enter a interger value')

    if (event == 'toLayout3'):
        fileList = list()
        fileItem = list()
        for i in range(0, len(values)):
Beispiel #23
0
''' tools main '''
from PySimpleGUI import Column, Window

from opencv.main import EnvProcess
from tool.agent import agent_gui, agent_gui_event
from tool.mask import mask_gui, mask_gui_event

TOOLS_GUI = Column([[mask_gui, agent_gui]])


def tools_events(event: str, values: dict, window: Window,
                 env_process: EnvProcess):
    ''' map all events of tools '''
    agent_gui_event(event, values, window, env_process)
    mask_gui_event(event, values, window, env_process)