Пример #1
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)

        box = toga.Box()
        box.style.padding = 40
        box.style.update(alignment=CENTER)
        box.style.update(direction=COLUMN)

        # image from local path
        # load brutus.png from the package
        # We set the style width/height parameters for this one
        image_from_path = toga.Image('../resources/brutus.png')
        imageview_from_path = toga.ImageView(image_from_path)
        imageview_from_path.style.update(height=72)
        imageview_from_path.style.update(width=72)
        box.add(imageview_from_path)

        # image from remote URL
        # no style parameters - we let Pack determine how to allocate
        # the space
        image_from_url = toga.Image(
            'https://beeware.org/project/projects/libraries/toga/toga.png')
        imageview_from_url = toga.ImageView(image_from_url)
        box.add(imageview_from_url)

        self.main_window.content = box
        self.main_window.show()
Пример #2
0
def build(app):
    img_01 = toga.Image(path='icons/brutus-256.png')
    img_02 = toga.Image(
        path='https://dict.leo.org/img/leo/160x60/schriftzug-222990a1.png')

    image_view_01 = toga.ImageView(image=img_01)
    image_view_02 = toga.ImageView(image=img_02)
    box = toga.Box(style=CSS(flex=1))
    box.add(image_view_01)
    box.add(image_view_02)
    return box
Пример #3
0
 def switchButton(self, widget):
     print("Test:", self.imgLoaded, self.hideROI)
     if self.imgLoaded == False:
         return
     elif self.hideROI == True:
         self.Preview.image = toga.Image(self.ROIPath)
         widget.label = "Original"
         self.hideROI = False
         self.Preview.refresh()
     else:
         self.Preview.image = toga.Image(self.ImagePath)
         widget.label = "ROI      "
         self.hideROI = True
         self.Preview.refresh()
Пример #4
0
    def setupGUI(self):
        self.playerMatBG = toga.Image(path='resources/playmat.png')
        self.playerBagImage = toga.Image(path='resources/user.png')
        self.playerMatContainer = toga.ImageView(self.playerMatBG,
                                                 style=Pack(padding=0))
        self.playerBagContainer = toga.ImageView(self.playerBagImage,
                                                 style=Pack(padding=0,
                                                            width=25,
                                                            height=50))

        self.boxBasicDies = toga.Box(style=Pack(flex=1, direction=ROW))
        self.boxPlayerMat = toga.Box(
            children=[self.playerBagContainer, self.playerMatContainer],
            style=Pack(flex=1, direction=ROW, background_color=RED))
        self.main_window.content = toga.Box(children=[self.boxPlayerMat],
                                            style=Pack(direction=COLUMN))
Пример #5
0
 def send_report(self, e):
     uid = self.rep_inp.value
     if len(uid) >= 7:
         rep = Reporter(
             self.hook,
             self.profile_manager.prf_cfg['img_dir'] + "config.xml")
         res = rep.send_report(uid)
         if res:
             self._show_info("Thanks for Reporting!")
             self.rep_img.image = toga.Image("resources/logo.png")
             self.rep_inp.value = ""
         else:
             self._throw_error(
                 "Player with ID {} doesn't exist!".format(uid))
             self.rep_img.image = toga.Image("resources/logo.png")
             self.rep_inp.value = ""
Пример #6
0
    def generate(self, widget):
        if self.input.value:
            url = AVATAR_TYPES[self.avatar_type.value].format(self.input.value)
        else:
            url = AVATAR_TYPES[self.avatar_type.value].format('beeware')

        self.avatar.image = toga.Image(url)
Пример #7
0
    def startup(self):
        self.word_input = toga.PasswordInput(style=Pack(flex=1, padding=5))
        self.new_game = toga.Button('New Game',
                                    on_press=self.new_game_handler,
                                    style=Pack(width=100, padding=5))
        self.give_up = toga.Button('Give Up',
                                   on_press=self.give_up_handler,
                                   style=Pack(width=100, padding=5))
        self.start = toga.Button('Start',
                                 on_press=self.start_game_handler,
                                 style=Pack(width=50, padding=5))
        self.buttons_box = toga.Box(children=[
            self.new_game, self.give_up, self.word_input, self.start
        ])
        self.buttons_box.remove(self.word_input)
        print(self.buttons_box.children)

        self.tree_image = toga.ImageView(toga.Image(IMAGES[0]))
        self.tree_image.style.update(height=400)
        self.tree_image.style.update(width=400)

        start_box = toga.Box(children=[self.tree_image, self.buttons_box])
        # start_box.add(tree_image)
        # start_box.add(buttons_box)
        start_box.style.update(direction=COLUMN)
        start_box.style.update(alignment=CENTER)

        self.main_window = toga.MainWindow(title=self.name)

        self.main_window.content = start_box
        self.main_window.show()
Пример #8
0
 def __init__(self):
     """Initialize box."""
     logo_path = Path(__file__).parent.parent / "resources" / "eddington_gui.png"
     logo = toga.Image(str(logo_path))
     super(HeaderBox, self).__init__(
         alignment=TOP,
         children=[
             toga.Label(
                 text=f"Version: {__version__}",
                 style=Pack(
                     font_size=SMALL_FONT_SIZE, font_family=HEADER_FONT_FAMILY
                 ),
             ),
             toga.Box(style=Pack(flex=1)),
             toga.ImageView(
                 image=logo, style=Pack(height=LOGO_SIZE, width=LOGO_SIZE)
             ),
             toga.Box(style=Pack(flex=1)),
             toga.Label(
                 text=f"Author: {__author__}",
                 style=Pack(
                     font_size=SMALL_FONT_SIZE, font_family=HEADER_FONT_FAMILY
                 ),
             ),
         ],
     )
Пример #9
0
    def create_display(self, state):
        self.state = state
        state.new_game()
        self.add(toga.Label("Name your castaways"))
        cast_box = toga.Box(style=Pack(direction=COLUMN))
        self.cast = []
        for cast in state.get_cast():
            info_box = toga.Box(style=Pack(direction=ROW))
            cast_box.add(info_box)
            left_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            right_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            info_box.add(left_box)
            info_box.add(right_box)

            img = cast['img']
            left_box.add(
                toga.widgets.imageview.ImageView(
                    toga.Image('resources/images/'+img),
                    style=Pack(width=48, height=48, direction=COLUMN)
                )
            )
            self.cast.append(
                toga.TextInput(initial=cast['name'], placeholder='Enter Name')
            )
            right_box.add(self.cast[-1])
        self.add(cast_box)
        button = toga.Button('Save', on_press=self.next, style=Pack(padding_bottom=0))
        self.add(button)
Пример #10
0
    def startup(self):
        # Controls

        self.index_stats_label = toga.Label('No tracks loaded, please index.',
                                            style=Pack(padding=10))

        self.reindex_button = toga.Button('Index Collection',
                                          on_press=self.re_index)
        self.reindex_button.style.padding = 10
        self.reindex_button.style.flex = 1

        self.mock_switch = toga.Switch('Enable mock Sender',
                                       on_toggle=self.mock_switch_handler)
        self.mock_switch.style.padding = 10
        self.mock_switch.style.flex = 1

        top_box = toga.Box(style=Pack(direction=ROW),
                           children=[self.reindex_button, self.mock_switch])

        # Cover Art Image Preview

        self.img = toga.Image(os.getcwd() + "/resources/testcard720.png")
        self.img_view = toga.ImageView(id='img_view',
                                       image=self.img,
                                       style=Pack(flex=1))

        self.img_label = toga.Label('Waiting for mock information...',
                                    style=Pack(padding=10))

        bottom_box = toga.Box(children=[self.img_label, self.img_view],
                              style=Pack(flex=1, direction=COLUMN))

        main_box = toga.Box(
            style=Pack(direction=COLUMN),
            children=[self.index_stats_label, top_box, bottom_box])

        self.main_window = toga.MainWindow(title=self.name, size=(400, 500))
        self.main_window.content = main_box
        self.main_window.show()

        self.cache_file = os.getcwd() + "/tracks.p"

        self.mapping = {
            "A": {
                "play": False,
                "updated_at": 0
            },
            "B": {
                "play": False,
                "updated_at": 0
            },
            "C": {
                "play": False,
                "updated_at": 0
            },
            "D": {
                "play": False,
                "updated_at": 0
            }
        }
Пример #11
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(660, 520))
        self.ScrollContainer = toga.ScrollContainer()

        main_box = toga.Box()
        plot_box = toga.Box()

        main_box.style.padding = 10
        main_box.style.update(alignment=CENTER)
        main_box.style.update(direction=COLUMN)

        button = toga.Button('Play',
                             on_press=self.playback,
                             style=Pack(width=100))

        GenerateSpectrum(self.filename)
        image_from_path = toga.Image('Figure_temp.png')
        imageview_from_path = toga.ImageView(image_from_path)
        imageview_from_path.style.update(height=480)
        imageview_from_path.style.update(width=640)
        plot_box.add(imageview_from_path)

        main_box.add(button)
        main_box.add(plot_box)

        self.main_window.content = main_box

        self.main_window.show()
Пример #12
0
    def create_display(self, state):
        super().__init__(style=Pack(padding=50, direction=COLUMN))
        self.add(toga.Label("Castaway Community"))
        cast_box = toga.Box(style=Pack(direction=COLUMN))
        # cast_scroll = toga.widgets.scrollcontainer.ScrollContainer(
        #     content=cast_box,
        #     style=Pack(height=200)
        # )
        for cast in state.get_cast():
            info_box = toga.Box(style=Pack(direction=ROW))
            cast_box.add(info_box)
            left_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            right_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            info_box.add(left_box)
            info_box.add(right_box)

            img = cast['img']
            left_box.add(toga.Label('Name: {}'.format(cast['name'])))
            left_box.add(
                toga.widgets.imageview.ImageView(
                    toga.Image('resources/images/'+img),
                    style=Pack(width=48, height=48, direction=COLUMN)
                )
            )
            right_box.add(toga.Label('Stats'))
            right_box.add(toga.Label('Age: {}'.format(cast['age'])))
        self.add(cast_box)
        super().create_display(state)
Пример #13
0
    def openButton(self, widget):
        path = self.main_window.open_file_dialog("Select an Image", ".",
                                                 ["jpg", "jpeg", "bmp"])
        self.detector.newImage(path)
        sudoku = self.detector.classifyDigits()
        self.solver.clearGrid()
        if sudoku is not None:
            print("detected")
            sudoku = sudoku[0]
            for i in range(9):
                for j in range(9):
                    if sudoku[i, j]:
                        self.grid[i][j].label = str(sudoku[i][j])
                        self.solver.setField(j, i, sudoku[i, j])
                    else:
                        self.grid[i][j].label = " "
                        self.solver.setField(j, i, 0)
            self.ImagePath = path
            self.Preview.image = toga.Image(path)
            self.Preview.refresh()
            self.ImgStatusLabel.text = "Switch to Sudoku"
            self.ImgStatusLabel.refresh()
            I = self.detector.getROI()
            print(I[0].shape)
            path = "/tmp/ROI.jpg"
            detector.saveImage(I[0], path)

            self.ROIPath = path
            self.imgLoaded = True
            return
        self.ImgStatusLabel.text = "Failed to detect grid"
Пример #14
0
    def load_async_pokemon(self, pokemon):
        thread = threading.Thread(target=self.load_pokemon, args=[pokemon])
        thread.start()
        thread.join()

        self.image_view.image = toga.Image(self.response_sprite)
        self.pokemon_name.text = self.response_name
        self.pokemon_description.text = self.response_description
Пример #15
0
    def setUp(self):
        # mock factory to return a mock button
        self.factory = MagicMock()
        self.factory.Image = MagicMock(return_value=MagicMock(
            spec=toga_dummy.widgets.image.Image))

        self.path = 'path/to/image.jpg'
        self.image = toga.Image(path=self.path, factory=self.factory)
Пример #16
0
    def setUp(self):
        super().setUp()

        # an App must have been created before calling image.bind
        # because it tries to resolve the image path against the app path.
        toga.App(formal_name='Image Test App',
                 app_id='org.beeware.test_image',
                 factory=toga_dummy.factory)
        self.path = 'path/to/image.jpg'
        self.image = toga.Image(path=self.path)
Пример #17
0
    def get_about_window(self):
        """Return the "About" native window.

        This is a Toga window with the DativeTop icon and the versions of
        DativeTop, Dative and the OLD displayed.

        TODO: it would be nice if the text could be center-aligned underneath
        the DativeTop icon. Unfortunately, I found it difficult to do this
        using Toga's box model and ``Pack`` layout engine.
        """
        if self._about_window:
            return self._about_window
        dativetop_label = toga.Label('DativeTop {}'.format(
            dtutils.get_dativetop_version()))
        dative_label = toga.Label('Dative {}'.format(
            dtutils.get_dative_version()))
        old_label = toga.Label('OLD {}'.format(
            dtutils.get_old_version()))
        image_from_path = toga.Image(c.OLD_LOGO_PNG_PATH)
        logo = toga.ImageView(image_from_path)
        logo.style.update(height=72)
        logo.style.update(width=72)
        logo.style.update(direction=COLUMN)
        text_box = toga.Box(
            children=[
                dativetop_label,
                dative_label,
                old_label,
            ]
        )
        text_box.style.update(direction=COLUMN)
        text_box.style.update(alignment=CENTER)
        text_box.style.update(padding_left=20)
        text_box.style.update(padding_top=20)
        outer_box = toga.Box(
            children=[
                logo,
                text_box,
            ]
        )
        outer_box.style.update(direction=COLUMN)
        outer_box.style.update(alignment=CENTER)
        outer_box.style.update(padding=10)
        about_window = toga.Window(
            title=' ',
            id='about DativeTop window',
            minimizable=False,
            # resizeable = False,  # messes up layout
            size=(300, 150),
            position=(500, 200),
        )
        about_window.content = outer_box
        self._about_window = about_window
        return self._about_window
Пример #18
0
 def make_button(self, game):
     self.game = game
     box = button = toga.Button(self.name, on_press=self.click_button)
     if self.image:
         box = toga.Box(style=Pack(direction=ROW))
         box.add(
             toga.widgets.imageview.ImageView(
                 toga.Image('resources/images/' + self.image),
                 style=Pack(width=48, height=48)))
         box.add(button)
     return box
Пример #19
0
 def change_image(self, id):
     self.logger.info("try to change image preview")
     uid = id.value
     try:
         img_name = self.prf_cfg["imgs"][uid]
         img_eth = self.prf_cfg["ethnics"][uid]
         img_path = self.prf_cfg["img_dir"] + "/" + img_eth + "/" + img_name
         self.rep_img.image = toga.Image(img_path)
         self.logger.info("change image preview to: {}".format(img_path))
     except Exception:
         self.logger.info("changing image preview failed!")
         return
Пример #20
0
 def update_qr(self):
     if self.qr_image._impl.native.Image is not None:
         self.qr_image._impl.native.Image.Dispose()
     if os.path.isfile(self.qr_temp_filename):
         os.remove(self.qr_temp_filename)
     try:
         with open(self.qr_temp_filename, 'wb+') as temp:
             qr = self.license_data.qr
             qr._img.save(temp, 'png')
     except Exception as e:
         print(f"Cannot update the qr code due to {e}")
     qr_toga_image = toga.Image(self.qr_temp_filename)
     self.qr_image.image = qr_toga_image
Пример #21
0
 def change_image(self, id):
     self.logger.info("try to change image preview")
     uid = id.value
     if len(uid) >= 7:
         try:
             img_path = XML_Parser().get_imgpath_from_uid(
                 self.profile_manager.prf_cfg['img_dir'] + "config.xml",
                 uid)
             img_path = self.profile_manager.prf_cfg[
                 'img_dir'] + img_path + ".png"
             self.rep_img.image = toga.Image(img_path)
             self.logger.info(
                 "change image preview to: {}".format(img_path))
         except Exception as e:
             self.logger.info("changing image preview failed!")
             self.logger.info(e)
             return
     return
Пример #22
0
 def __init__(self):
     """Initialize box."""
     logo_path = Path(
         __file__).parent.parent / "resources" / "eddington_gui.png"
     logo = toga.Image(str(logo_path))
     super().__init__(
         alignment=TOP,
         children=[
             toga.Box(style=Pack(flex=1)),
             toga.ImageView(
                 image=logo,
                 style=Pack(height=LOGO_SIZE,
                            width=LOGO_SIZE,
                            alignment=CENTER),
             ),
             toga.Box(style=Pack(flex=1)),
         ],
     )
Пример #23
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(720, 580))
        self.ScrollContainer = toga.ScrollContainer()

        plot_box = toga.Box()

        button = toga.Button('Play',
                             on_press=self.playback,
                             style=Pack(width=100))

        GenerateSpectrum(self.filename)
        image_from_path = toga.Image('Figure_temp.png')
        imageview_from_path = toga.ImageView(image_from_path)
        imageview_from_path.style.update(height=480)
        imageview_from_path.style.update(width=640)
        plot_box.add(imageview_from_path)

        self.things = toga.Group('File')

        cmdOpen = toga.Command(self.actionOpenFileDialog,
                               label='Open',
                               tooltip='Open Audio File',
                               group=self.things)

        self.commands.add(cmdOpen)

        # Label to show responses.
        self.label = toga.Label('Ready.')

        # Outermost box
        outer_box = toga.Box(children=[self.label, button, plot_box],
                             style=Pack(flex=1,
                                        direction=COLUMN,
                                        alignment=CENTER,
                                        padding=10))

        # Add the content on the main window
        self.main_window.content = outer_box

        self.main_window.show()
Пример #24
0
    def display_pics(self, final_characters):
        picture_box = toga.Box(style=Pack(direction=COLUMN))
        for i in range(1, 11):
            image_from_path = toga.Image('./resources/images/' + (
                final_characters[i - 1]['Name'].lower().replace(" ", "-") +
                ".jpg"))
            imageview_from_path = toga.ImageView(image_from_path,
                                                 style=Pack(direction=COLUMN,
                                                            alignment=CENTER,
                                                            padding=40,
                                                            width=150,
                                                            height=240,
                                                            flex=1))
            picture_box.add(imageview_from_path)

        if len(self.outer_box.children) > 3:
            self.outer_box.children[3] = picture_box
        else:
            self.outer_box.add(picture_box)

        self.scroller.content = self.outer_box
        self.main_window.show()
Пример #25
0
def build(app):

    container = toga.OptionContainer()

    box1 = toga.Box()

    button = toga.Button('Hello world', on_press=button_handler)
    button.style.padding = 50
    button.style.flex = 1

    label = toga.NumberInput(min_value=10.5,
                             max_value=50.6,
                             on_change=lambda app: print(app.value))
    label.text = 'Hola Mundo'

    selection = toga.Selection(items=['Casella', 'Pedro Infante', 'Camilo'],
                               on_select=lambda app: print(app.value))
    selection.items = ['321', '123', '456', '654', '789', '987']

    box1.add(button)
    box1.add(label)
    box1.add(selection)

    box2 = toga.Box()

    image = toga.Image('../../static/images/tiberius.svg')
    imageview = toga.ImageView(image)

    slider = toga.Slider(range=(30, 50), on_slide=lambda app: print(app.value))

    box2.add(imageview)
    box2.add(slider)

    container.add('Window 1', box1)
    container.add('Window 2', box2)

    return container
Пример #26
0
    def startup(self):
        """ Initialise the window """
        self.main_window = toga.MainWindow(
            title=self.name,
            size=(400,400)
        )

        self.scaleFactor = 0.3048

        logoImage = toga.Image('joke.png')
        logo = toga.ImageView(id='header', image=logoImage)
        headerBox = toga.Box(
            children=[logo],
            style=Pack(direction=ROW, padding=10, height=170)
        )

        # create input elements
        inputLabel = self.createLabel('Feet to Metres: ') # this never changes
        self.inputValue = self.createInput('feetVal', 'Feet...') # this does
        # create an array for the input elements
        inputElements = [inputLabel, self.inputValue]
        # package the input elements in a box
        inputBox = self.createBox(ROW, inputElements)

        # create action elements
        actionButton = self.createButton('CONVERT', self.convert)
        actionBox = self.createBox(ROW, [actionButton])

        self.result = self.createLabel('[Results]')
        resultBox = self.createBox(ROW, [self.result])

        # create main Box
        mainBox = self.createBox(COLUMN, [headerBox, inputBox, actionBox, resultBox])

        self.main_window.content = mainBox

        self.main_window.show()
Пример #27
0
    def startup(self):
        """
        Construct and show the Toga application.

        Usually, you would add your application to a main content box.
        We then create a main window (with a name matching the app), and
        show the main window.
        """
        self.logger.info("Starting Application\n------------------------------------------------")

        self.mode_info = {"Overwrite": "Overwrites already replaced faces",
                          "Preserve":  "Preserves already replaced faces",
                          "Generate": "Generates mapping from scratch."}
        os.makedirs(".config", exist_ok=True)
        self.cfg_path = ".config/cfg.json"
        self.logger.info("Loading cfg.json")
        self.config = self._load_config(self.cfg_path)
        for k, v in self.config["Profile"].items():
            if v:
                self.cur_prf = k
                break

        self.logger.info("Loading current profile")
        self.prf_cfg = self._load_config(".config/"+self.cur_prf+".json")
        self.logger.info("Creating GUI")
        self.main_box = toga.Box()
        self.logger.info("Created main box")

        # TOP Profiles
        prf_box = toga.Box()
        self.logger.info("Created prf_box")

        prf_inp = toga.TextInput()
        self.logger.info("Created prf_inp")

        self.prfsel_box = toga.Box()
        prf_lab = toga.Label(text="Create Profile: ")

        prfsel_lab = toga.Label(text="Select Profile: ")
        self.prfsel_lst = SourceSelection(items=list(self.config["Profile"].keys()), on_select=self._set_profile_status)
        self.prfsel_lst.value = self.cur_prf
        prfsel_btn = toga.Button(label="Delete", on_press=lambda e=None, c=self.prfsel_lst : self._delete_profile(c))
        prf_btn = toga.Button(label="Create", on_press=lambda e=None, d=prf_inp, c=self.prfsel_lst: self._create_profile(d, c))

        self.main_box.add(prf_box)
        prf_box.add(prf_lab)
        prf_box.add(prf_inp)
        prf_box.add(prf_btn)
        prf_lab.style.update(padding_top=7)
        prf_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)

        self.main_box.add(self.prfsel_box)
        self.prfsel_box.add(prfsel_lab)
        self.prfsel_box.add(self.prfsel_lst)
        self.prfsel_box.add(prfsel_btn)
        self.prfsel_lst.style.update(direction=ROW, padding=(0, 20), flex=0.5)
        prfsel_lab.style.update(padding_top=7)

        # MID Path selections
        dir_box = toga.Box()
        dir_lab = toga.Label(text="Select Image Directory: ")
        self.dir_inp = toga.TextInput(readonly=True, initial=self.prf_cfg['img_dir'])
        self.dir_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)

        self.dir_btn = toga.Button(label="...", on_press=self.action_select_folder_dialog, enabled=False)

        rtf_box = toga.Box()
        rtf_lab = toga.Label(text="RTF File: ")
        self.rtf_inp = toga.TextInput(readonly=True, initial=self.prf_cfg['rtf'])
        self.rtf_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)

        self.rtf_btn = toga.Button(label="...", on_press=self.action_open_file_dialog, enabled=False)

        self.main_box.add(dir_box)
        self.main_box.add(rtf_box)
        dir_box.add(dir_lab)
        dir_box.add(self.dir_inp)
        dir_box.add(self.dir_btn)
        rtf_box.add(rtf_lab)
        rtf_box.add(self.rtf_inp)
        rtf_box.add(self.rtf_btn)
        dir_lab.style.update(padding_top=7)
        rtf_lab.style.update(padding_top=7)

        gen_mode_box = toga.Box()
        self.genmde_lab = toga.Label(text="Mode: ")
        self.genmdeinfo_lab = toga.Label(text=self.mode_info["Generate"])
        self.genmde_lst = SourceSelection(items=list(self.mode_info.keys()), on_select=self.update_label)
        self.genmde_lst.value = "Generate"
        self.genmde_lst.style.update(direction=ROW, padding=(0, 20), flex=0.5)
        self.genmde_lab.style.update(padding_top=7)
        self.genmdeinfo_lab.style.update(padding_top=7)

        gen_mode_box.add(self.genmde_lab)
        gen_mode_box.add(self.genmde_lst)
        gen_mode_box.add(self.genmdeinfo_lab)
        self.main_box.add(gen_mode_box)
        # BOTTOM Generation
        gen_box = toga.Box()
        self.gen_btn = toga.Button(label="Replace Faces", on_press=self._replace_faces, enabled=False)
        self.gen_btn.style.update(padding_bottom=20)
        self.gen_lab = toga.Label(text="")

        self.gen_prg = toga.ProgressBar(max=110)
        gen_box.add(self.gen_btn)
        gen_box.add(self.gen_lab)
        gen_box.add(self.gen_prg)
        self.main_box.add(gen_box)
        self.gen_lab.style.update(padding_top=20)

        # Report bad image
        rep_box = toga.Box()
        self.rep_lab = toga.Label(text="Player UID: ")
        self.rep_inp = toga.TextInput(on_change=self.change_image)
        self.rep_img = toga.ImageView(toga.Image("resources/logo.png"))
        self.rep_img.style.update(height=180)
        self.rep_img.style.update(width=180)
        self.rep_btn = toga.Button(label="Report", on_press=self.send_report, enabled=False)

        rep_box.add(self.rep_lab)
        rep_box.add(self.rep_inp)
        rep_box.add(self.rep_img)
        rep_box.add(self.rep_btn)
        self.main_box.add(rep_box)
        self.rep_lab.style.update(padding_top=10)
        self.rep_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)


        # END configs
        rep_box.style.update(direction=ROW, padding=20)
        gen_mode_box.style.update(direction=ROW, padding=20)
        prf_box.style.update(direction=ROW, padding=20)
        self.prfsel_box.style.update(direction=ROW, padding=20)
        dir_box.style.update(direction=ROW, padding=20)
        rtf_box.style.update(direction=ROW, padding=20)
        gen_box.style.update(direction=COLUMN, padding=20, alignment='center')
        self.main_box.style.update(direction=COLUMN, padding=10, alignment='center')

        self.main_window = toga.MainWindow(title=self.formal_name, size=(1000, 600))
        self.main_window.content = self.main_box
        self.main_window.show()
Пример #28
0
    def startup(self):
        main_box = toga.Box(id="mainbox",
                            style=Pack(direction=COLUMN, padding=5))
        self.solver = solver()
        self.detector = detector()
        self.ImagePath = None
        self.ROIPath = None
        self.Preview = toga.ImageView(
            image=toga.Image("resources/blank_sudoku.jpg"))
        self.grid = []
        self.hideROI = True
        self.imgLoaded = False
        self.ImgStatusLabel = None

        for i in range(9):
            self.grid.append([])
            row = toga.Box(style=Pack(direction=ROW, padding=0))
            for j in range(9):
                self.grid[i].append(
                    toga.Button(label=" ",
                                id='{}{}'.format(i, j),
                                on_press=self.pressedButton,
                                style=Pack(flex=1, background_color="white")))
                row.add(self.grid[i][j])
                if (j + 1) % 3 == 0 and j < 8:
                    row.add(toga.Label(style=Pack(padding=0), text="\t"))
            main_box.add(row)
            if (i + 1) % 3 == 0 and i < 8:
                main_box.add(toga.Label(text="\t"))

        #adding solvebutton
        main_box.add(toga.Label(text="\t"))
        main_box.add(
            toga.Button(label="Get obvious Fields",
                        on_press=self.obviousButton))
        main_box.add(toga.Button(label="Solve", on_press=self.solveButton))

        selection_box = toga.Box(id="imagebox",
                                 style=Pack(direction=ROW, padding=10))
        selection_buttons = toga.Box(style=Pack(direction=COLUMN, padding=5))
        selection_buttons.add(
            toga.Button(label="Open   ", on_press=self.openButton))
        selection_buttons.add(
            toga.Button(label="ROI      ",
                        on_press=self.switchButton,
                        style=Pack(direction=COLUMN)))
        self.ImgStatusLabel = toga.Label(text="Select an Image")
        selection_buttons.add(toga.Label(text=""))
        selection_buttons.add(self.ImgStatusLabel)
        selection_box.add(selection_buttons)
        selection_box.add(self.Preview)

        option = toga.OptionContainer()
        option.add("Image", selection_box)
        option.add("Sudoku", main_box)

        #init window
        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = option

        self.main_window.show()
Пример #29
0
    def startup(self):

        self.button_hide = toga.Button(
            label='Hide label',
            style=Pack(padding=10, width=120),
            on_press=self.hide_label,
        )

        self.button_add = toga.Button(
            label='Add image',
            style=Pack(padding=10, width=120),
            on_press=self.add_image,
        )

        self.button_remove = toga.Button(
            label='Remove image',
            style=Pack(padding=10, width=120),
            on_press=self.remove_image,
            enabled=False,
        )

        self.button_insert = toga.Button(
            label='Insert image',
            style=Pack(padding=10, width=120),
            on_press=self.insert_image,
        )

        self.button_reparent = toga.Button(
            label='Reparent image',
            style=Pack(padding=10, width=120),
            on_press=self.reparent_image,
            enabled=False,
        )

        self.button_add_to_scroll = toga.Button(
            label='Add new label',
            style=Pack(padding=10, width=120),
            on_press=self.add_label,
        )

        self.scroll_box = toga.Box(children=[],
                                   style=Pack(direction=COLUMN,
                                              padding=10,
                                              flex=1))
        self.scroll_view = toga.ScrollContainer(content=self.scroll_box,
                                                style=Pack(width=120))

        image = toga.Image('resources/tiberius.png')
        self.image_view = toga.ImageView(image,
                                         style=Pack(padding=10,
                                                    width=60,
                                                    height=60))

        # this tests adding children during init, before we have an implementation
        self.button_box = toga.Box(
            children=[
                self.button_hide,
                self.button_add,
                self.button_insert,
                self.button_reparent,
                self.button_remove,
                self.button_add_to_scroll,
            ],
            style=Pack(direction=COLUMN),
        )

        self.box = toga.Box(children=[],
                            style=Pack(direction=ROW,
                                       padding=10,
                                       alignment=CENTER,
                                       flex=1))

        # this tests adding children when we already have an impl but no window or app
        self.box.add(self.button_box)
        self.box.add(self.scroll_view)

        # add a couple of labels to get us started
        self.labels = []
        for i in range(3):
            self.add_label()

        self.main_window = toga.MainWindow()
        self.main_window.content = self.box
        self.main_window.show()
Пример #30
0
class SettingsGui(Window):

    COLUMN_WIDTH_LEFT = 210
    COLUMN_WIDTH_RIGHT = 350
    BUTTON_WIDTH = 180
    IMAGE_WIDTH = 70

    SECTION_PADDING = 15
    ELEMENT_PADDING = 10
    SUBELEMENT_PADDING = 3
    COLUMN_PADDING = 10

    faceholder = toga.Image(FACEHOLDER_PATH)

    def __init__(self, **kwargs) -> None:
        super().__init__(
            title="Maestral Settings",
            resizeable=False,
            minimizable=False,
            release_on_close=False,
            **kwargs,
        )

        # ==== account info section ====================================================

        self.profile_pic_view = toga.ImageView(
            self.faceholder,
            style=Pack(
                width=SettingsGui.IMAGE_WIDTH,
                height=SettingsGui.IMAGE_WIDTH,
                background_color=TRANSPARENT,
            ),
        )
        apply_round_clipping(self.profile_pic_view)

        self.profile_pic_view_spacer = toga.Box(style=Pack(
            width=SettingsGui.COLUMN_WIDTH_LEFT - SettingsGui.IMAGE_WIDTH,
            direction=ROW,
            background_color=TRANSPARENT,
        ))

        self.label_name = Label(
            "Account Name (Company Name)",
            style=Pack(
                font_size=17,
                padding_bottom=SettingsGui.ELEMENT_PADDING - 4,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )
        self.label_email = Label(
            "[email protected], Business",
            style=Pack(
                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                font_size=12,
            ),
        )
        self.label_usage = Label(
            "10.5 % from 1,005 TB used",
            style=Pack(
                padding_bottom=SettingsGui.ELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                font_size=12,
            ),
        )
        self.btn_unlink = toga.Button(
            "Unlink this Dropbox...",
            style=Pack(width=SettingsGui.BUTTON_WIDTH))

        account_info_box = toga.Box(
            children=[
                self.profile_pic_view_spacer,
                self.profile_pic_view,
                toga.Box(
                    children=[
                        self.label_name,
                        self.label_email,
                        self.label_usage,
                        self.btn_unlink,
                    ],
                    style=Pack(direction=COLUMN,
                               padding_left=SettingsGui.COLUMN_PADDING),
                ),
            ],
            style=Pack(direction=ROW),
        )

        # ==== sync settings section ===================================================

        self._label_select_folders = Label(
            "Selective sync:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.btn_select_folders = toga.Button(
            label="Select files and folders...",
            style=Pack(padding_left=SettingsGui.COLUMN_PADDING,
                       width=SettingsGui.BUTTON_WIDTH),
        )

        self._label_dbx_location = Label(
            "Local Dropbox folder:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.combobox_dbx_location = FileSelectionButton(
            initial=get_home_dir(),
            select_files=False,
            select_folders=True,
            style=Pack(padding_left=SettingsGui.COLUMN_PADDING,
                       width=SettingsGui.BUTTON_WIDTH),
        )

        dropbox_settings_box = toga.Box(
            children=[
                toga.Box(
                    children=[
                        self._label_select_folders, self.btn_select_folders
                    ],
                    style=Pack(alignment=CENTER,
                               padding_bottom=SettingsGui.ELEMENT_PADDING),
                ),
                toga.Box(
                    children=[
                        self._label_dbx_location, self.combobox_dbx_location
                    ],
                    style=Pack(alignment=CENTER),
                ),
            ],
            style=Pack(direction=COLUMN),
        )

        # ==== system settings section =================================================

        self._label_update_interval = Label(
            "Check for updates:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.combobox_update_interval = toga.Selection(
            items=["Daily", "Weekly", "Monthly", "Never"],
            style=Pack(padding_left=SettingsGui.COLUMN_PADDING,
                       width=SettingsGui.BUTTON_WIDTH),
        )

        self._label_system_settings = Label(
            "System settings:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.checkbox_autostart = Switch(
            label="Start Maestral on login",
            style=Pack(
                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )
        self.checkbox_notifications = Switch(
            label="Enable notifications on file changes",
            style=Pack(
                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )

        children = [
            toga.Box(
                children=[
                    self._label_update_interval, self.combobox_update_interval
                ],
                style=Pack(alignment=CENTER,
                           padding_bottom=SettingsGui.ELEMENT_PADDING),
            ),
            toga.Box(children=[
                self._label_system_settings,
                toga.Box(
                    children=[
                        self.checkbox_autostart,
                        self.checkbox_notifications,
                    ],
                    style=Pack(
                        alignment=TOP,
                        direction=COLUMN,
                        padding_left=SettingsGui.COLUMN_PADDING,
                    ),
                ),
            ], ),
        ]

        if FROZEN:
            # add UI to install command line interface
            self._label_cli_tool = Label(
                "Command line tool:",
                style=Pack(text_align=RIGHT,
                           width=SettingsGui.COLUMN_WIDTH_LEFT),
            )

            self.label_cli_tool_info = Label(
                "Install the 'maestral' command line tool to /usr/local/bin.",
                style=Pack(
                    color=GRAY,
                    font_size=12,
                    width=SettingsGui.COLUMN_WIDTH_RIGHT,
                    padding_left=SettingsGui.COLUMN_PADDING,
                ),
            )

            self.btn_cli_tool = toga.Button(
                "Install",
                style=Pack(
                    width=SettingsGui.BUTTON_WIDTH / 2,
                    padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                    padding_left=SettingsGui.COLUMN_PADDING,
                ),
            )

            children.append(
                toga.Box(
                    children=[
                        self._label_cli_tool,
                        self.btn_cli_tool,
                    ],
                    style=Pack(alignment=CENTER,
                               padding_top=SettingsGui.ELEMENT_PADDING),
                ))
            children.append(
                toga.Box(
                    children=[
                        Label(
                            " ",
                            style=Pack(text_align=RIGHT,
                                       width=SettingsGui.COLUMN_WIDTH_LEFT),
                        ),
                        self.label_cli_tool_info,
                    ],
                    style=Pack(alignment=CENTER,
                               padding_top=SettingsGui.SUBELEMENT_PADDING),
                ))

        maestral_settings_box = toga.Box(
            children=children,
            style=Pack(direction=COLUMN),
        )

        # ==== about section ===========================================================

        about_box = toga.Box(
            children=[
                Label(
                    "About Maestral:",
                    style=Pack(text_align=RIGHT,
                               width=SettingsGui.COLUMN_WIDTH_LEFT),
                ),
                toga.Box(
                    children=[
                        Label(
                            f"GUI v{__version__}, daemon v{__daemon_version__}",
                            style=Pack(
                                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                            ),
                        ),
                        LinkLabel(
                            text=__url__,
                            url=__url__,
                            style=Pack(
                                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                            ),
                        ),
                        Label(
                            f"© 2018 - {year}, {__author__}.",
                            style=Pack(color=GRAY,
                                       width=SettingsGui.COLUMN_WIDTH_RIGHT),
                        ),
                    ],
                    style=Pack(direction=COLUMN,
                               padding_left=SettingsGui.COLUMN_PADDING),
                ),
            ],
            style=Pack(direction=ROW),
        )

        main_box = toga.Box(
            children=[
                account_info_box,
                toga.Divider(style=Pack(padding=SettingsGui.SECTION_PADDING)),
                dropbox_settings_box,
                toga.Divider(style=Pack(padding=SettingsGui.SECTION_PADDING)),
                maestral_settings_box,
                toga.Divider(style=Pack(padding=SettingsGui.SECTION_PADDING)),
                about_box,
            ],
            style=Pack(
                direction=COLUMN,
                padding=30,
                width=SettingsGui.COLUMN_WIDTH_LEFT +
                SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )

        self.content = main_box