Beispiel #1
0
def main() -> int:
    # root = Root()
    # main_window = MainWindow(title="Guide")
    # main_window.add(root)
    #
    # cruci_scheme = parse_file_name("brachiosauri.json")
    # print(cruci_scheme.cols)
    #
    # # guide = Guides(cruci_scheme.cols, Point(100, 100), 20, orientation=Guides.HORIZONTAL)
    # guide = Guides(cruci_scheme.rows, Point(100, 100), 20, orientation=Guides.VERTICAL)
    # root.set_child(guide)
    #
    # main_window.start_main()

    root = Root()
    main_window = MainWindow(title="Guide")
    main_window.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(.9,.9,.9,1))
    root.set_main_window(main_window)
    # container = _LineTestContainer()
    # container.translate(.5,.5)
    #
    # root.set_child(container)

    guides = BetterGuide([[], [1, 2], [15, 16, 3]], Orientation.HORIZONTAL, 20)

    guides.translate(100.5, 100.5)

    root.set_child(guides)

    main_window.start_main()
Beispiel #2
0
def main() -> int:
    main_window = MainWindow(title="table")

    root = Root(width=-1, height=-1)
    main_window.add(root)

    file_names=["al_parco.json", "brachiosauri.json", "monopattino.json", "mostro.json"]
    schemes = [parse_file_name("../data/" + name) for name in file_names]

    table_entries = [
        TableEntry(scheme.title, scheme.hard, len(scheme.rows), len(scheme.cols))
        for scheme in schemes
    ]

    table = ChooserTable(table_entries)

    table.translate(50, 50)

    table.skip = 1
    table.how_many = 10

    table.set_back_callback(lambda: root.set_min_size(200, 200))
    table.set_contents_callback(lambda x: print("{} selected".format(x)))
    table.font_size = 20
    root.set_child(table)

    main_window.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(.9,.9,.9,1))

    main_window.start_main()
Beispiel #3
0
def main():

    win = MainWindow("TextTest")
    root = Root(200, 200)
    root.set_main_window(win)

    root.set_child(TextArea(["questa è una prova", "funzioni anche quando ci sono due righe forzate?"]))

    win.start_main()
Beispiel #4
0
def main() -> int:
    main_window = MainWindow(title="prova")
    root = Root()
    main_window.add(root)
    navigator = Navigator()
    navigator.scale(.5, .5)
    container = UncheckedContainer()
    container.add(navigator)
    root.set_child(container)

    main_window.start_main()
Beispiel #5
0
def main() -> int:
    main_window = MainWindow(title="menu_test")
    root = Root()
    root.set_main_window(main_window)

    def create_callback(x: int):
        return lambda: print("Hi from", x)
    menu = BetterMainMenu("Test", ["ciao", "come", "stai"], [create_callback(x) for x in range(3)])
    root.set_child(menu)

    main_window.start_main()
    return 0
Beispiel #6
0
def main() -> int:
    mainWindow = MainWindow(title="Prova")
    root = Root()
    mainWindow.add(root)
    arr = Arrow(direction=Arrow.RIGHT)
    cont = UncheckedContainer()
    cont.add(arr)

    arr.translate(100,100)
    root.set_child(cont)

    mainWindow.start_main()
Beispiel #7
0
def main() -> int:
    mainWindow = MainWindow(title="Prova")
    root = Root()
    mainWindow.add(root)
    arr = Arrow(direction=Arrow.RIGHT)
    cont = UncheckedContainer()
    cont.add(arr)

    arr.translate(100, 100)
    root.set_child(cont)

    mainWindow.start_main()
Beispiel #8
0
def main() -> int:
    root = Root()
    main_window = MainWindow(title="Prova")
    main_window.add(root)

    crucipixel_model = parse_file_name("/home/giovanni/.app/monopattino.json")
    crucipixel_core = core.Crucipixel(crucipixel_model)
    crucipixel_core.make_move((MoveAtom(i, i, CrucipixelCellValue.SELECTED) for i in range(5)))
    grid = CrucipixelGrid(crucipixel_core)

    root.set_child(grid)

    main_window.start_main()
Beispiel #9
0
def main() -> int:
    root = Root()
    main_window = MainWindow(title="Prova")
    main_window.add(root)

    crucipixel_model = parse_file_name("/home/giovanni/.app/monopattino.json")
    crucipixel_core = core.Crucipixel(crucipixel_model)
    crucipixel_core.make_move(
        (MoveAtom(i, i, CrucipixelCellValue.SELECTED) for i in range(5)))
    grid = CrucipixelGrid(crucipixel_core)

    root.set_child(grid)

    main_window.start_main()
Beispiel #10
0
def main() -> int:

    win = MainWindow(title="CrucipixelGTK")
    win.connect("delete-event", lambda *args: Gtk.main_quit)
    win.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(.9,.9,.9,1))
    root = Root()
    root.set_min_size(500, 500)

    # from lightwidgets.events import MouseButton
    create_main_menu(root)()

    root.set_main_window(win)
    win.start_main()

    return 0
Beispiel #11
0
def main() -> int:
    main_window = MainWindow(title="Number test")
    root = Root(100, 100)
    root.set_main_window(main_window)
    root.set_child(
        Border(
            SetAlignment(
                EditorInput(),
                Alignment.VERTICAL_CENTER
            ),
            left=50, right=50
        )
    )

    main_window.start_main()
    return 0
Beispiel #12
0
def main() -> int:
    crucipixel_model = parse_file_name("../data/monopattino.json")
    crucipixel_core = core.Crucipixel(crucipixel_model)
    # cruci_core = core.Crucipixel(
    #     len(cruci_scheme.rows),
    #     len(cruci_scheme.cols),
    #     cruci_scheme.rows,
    #     cruci_scheme.cols
    # )
    complete = PuzzleScreen()
    complete.start_crucipixel(crucipixel_core)
    complete.start_selector()
    complete.start_navigator()

    main_area = MainWindow(title="Complete")
    root = Root()
    root.set_child(complete)
    main_area.add(root)
    main_area.start_main()
Beispiel #13
0
def main():
    main_window = MainWindow(title="button")
    root = Root(200, 200)
    root.set_main_window(main_window)
    button = BetterButton("Pulsante!", 20, origin=BetterButton.CENTER)
    disabled = BetterButton("Disable", 20, origin=BetterButton.CENTER)
    button.translate(100, 50)
    disabled.translate(100, 100)
    button.on_click_action = click_left_button_wrapper(lambda: print("Hi!"))
    def disabled_action():
        button.disabled = not button.disabled
        button.invalidate()
    disabled.on_click_action = click_left_button_wrapper(disabled_action)
    container = UncheckedContainer()
    container.add(button)
    container.add(disabled)
    root.set_child(container)

    main_window.start_main()
Beispiel #14
0
def main() -> int:
    # root = Root()
    # main_window = MainWindow(title="Guide")
    # main_window.add(root)
    #
    # cruci_scheme = parse_file_name("brachiosauri.json")
    # print(cruci_scheme.cols)
    #
    # # guide = Guides(cruci_scheme.cols, Point(100, 100), 20, orientation=Guides.HORIZONTAL)
    # guide = Guides(cruci_scheme.rows, Point(100, 100), 20, orientation=Guides.VERTICAL)
    # root.set_child(guide)
    #
    # main_window.start_main()

    root = Root()
    main_window = MainWindow(title="Guide")
    main_window.override_background_color(Gtk.StateFlags.NORMAL,
                                          Gdk.RGBA(.9, .9, .9, 1))
    root.set_main_window(main_window)
    # container = _LineTestContainer()
    # container.translate(.5,.5)
    #
    # root.set_child(container)

    guides = BetterGuide([[], [1, 2], [15, 16, 3]], Orientation.HORIZONTAL, 20)

    guides.translate(100.5, 100.5)

    root.set_child(guides)

    main_window.start_main()
Beispiel #15
0
def main():

    main_window = MainWindow("OrderedButtons test")
    root = Root(500, 500)
    ordered_buttons = EditorButtons()
    ordered_buttons.translate(100, 100)

    def wrap(action):
        def inner():
            action()
            ordered_buttons.invalidate()

        return inner

    ordered_buttons.set_undo_action(wrap(lambda: ordered_buttons.set_edit()))
    ordered_buttons.set_edit_action(wrap(lambda: ordered_buttons.set_undo()))

    ordered_buttons.set_quit_action(
        wrap(lambda: ordered_buttons.set_save_clickable(True)))
    ordered_buttons.set_save_action(
        wrap(lambda: ordered_buttons.set_save_clickable(False)))
    root.set_child(ordered_buttons)
    root.set_main_window(main_window)

    main_window.start_main()
Beispiel #16
0
def main():

    win = MainWindow("Help test")
    win.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(.9,.9,.9,1))
    root = Root(200, 200)

    root.set_main_window(win)
    root.set_child(HelpScreen())

    win.start_main()
Beispiel #17
0
def main() -> int:
    main_window = MainWindow(title="Number test")
    root = Root(100, 100)
    root.set_main_window(main_window)
    root.set_child(
        Border(SetAlignment(EditorInput(), Alignment.VERTICAL_CENTER),
               left=50,
               right=50))

    main_window.start_main()
    return 0
Beispiel #18
0
def main() -> int:
    root = Root()
    main_window = MainWindow(title="Guide")
    main_window.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(.9,.9,.9,1))
    root.set_main_window(main_window)

    root.set_child(BetterSelector(20))

    main_window.start_main()

    return 0
Beispiel #19
0
def main():
    main_window = MainWindow(title="Grid buttons")
    root = Root()
    root.set_main_window(main_window)
    root.set_min_size(100, 100)

    grid_buttons = OrderedButtons([["Save", "Edit"], ["Load"]])

    def action():
        grid_buttons.next_visible(0)

    grid_buttons.set_action(0, 0, click_left_button_wrapper(action))
    grid_buttons.set_action(0, 1, click_left_button_wrapper(action))

    root.set_child(
        SetAlignment(SetAlignment(grid_buttons, Alignment.RIGHT),
                     Alignment.VERTICAL_CENTER))

    main_window.start_main()
Beispiel #20
0
def main():
    main_window = MainWindow(title="Grid buttons")
    root = Root()
    root.set_main_window(main_window)
    root.set_min_size(100, 100)

    grid_buttons = OrderedButtons([["Save", "Edit"], ["Load"]])

    def action():
        grid_buttons.next_visible(0)
    grid_buttons.set_action(0, 0, click_left_button_wrapper(action))
    grid_buttons.set_action(0, 1, click_left_button_wrapper(action))

    root.set_child(SetAlignment(SetAlignment(grid_buttons, Alignment.RIGHT), Alignment.VERTICAL_CENTER))

    main_window.start_main()
Beispiel #21
0
def main() -> int:
    main_window = MainWindow(title="Test Overlay")
    # main_window.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(.9,.9,.9,1))
    # print(Gdk.RGBA)
    main_window.set_background_rgba(.9, .9, .9, 1)
    root = Root()
    root.set_main_window(main_window)
    root.set_min_size(200, 200)
    button_overlay = ButtonedTextOverlay("E con questo?" * 3)
    button_overlay.set_back_action(lambda: print("Back!"))
    button_overlay.set_ok_action(lambda: print("Ok!"))
    root.set_child(button_overlay)
    # text_overlay = TextOverlay("PUZZLE SOLVED")
    # text_overlay.on_click_action = lambda: print("Puzzle Solved!")
    # root.set_child(text_overlay)

    # root.set_min_size(100, 100)

    main_window.start_main()
    return 0
Beispiel #22
0
def main():

    win = MainWindow("TextTest")
    root = Root(200, 200)
    root.set_main_window(win)

    root.set_child(
        TextArea([
            "questa è una prova",
            "funzioni anche quando ci sono due righe forzate?"
        ]))

    win.start_main()
Beispiel #23
0
def main() -> int:
    main_window = MainWindow(title="menu_test")
    root = Root()
    root.set_main_window(main_window)

    def create_callback(x: int):
        return lambda: print("Hi from", x)

    menu = BetterMainMenu("Test", ["ciao", "come", "stai"],
                          [create_callback(x) for x in range(3)])
    root.set_child(menu)

    main_window.start_main()
    return 0
Beispiel #24
0
def main():
    win = MainWindow("Test zoom")
    root = Root(200, 200)
    zoom = Zoom()
    zoom.plus_action = lambda: print("I'm a plus")
    zoom.minus_action = lambda: print("I'm a minus")
    root.set_main_window(win)
    root.set_child(
        SetAlignment(
            SetAlignment(
                zoom,
                Alignment.TOP
            ),
            Alignment.LEFT
        )
    )

    win.start_main()
Beispiel #25
0
def main():
    main_window = MainWindow(title="button")
    root = Root(200, 200)
    root.set_main_window(main_window)
    button = BetterButton("Pulsante!", 20, origin=BetterButton.CENTER)
    disabled = BetterButton("Disable", 20, origin=BetterButton.CENTER)
    button.translate(100, 50)
    disabled.translate(100, 100)
    button.on_click_action = click_left_button_wrapper(lambda: print("Hi!"))

    def disabled_action():
        button.disabled = not button.disabled
        button.invalidate()

    disabled.on_click_action = click_left_button_wrapper(disabled_action)
    container = UncheckedContainer()
    container.add(button)
    container.add(disabled)
    root.set_child(container)

    main_window.start_main()
Beispiel #26
0
            ext = context.text_extents(bline)
            length = math.ceil(ext[2])
            if length > width:
                char_width = math.ceil(length / len(bline))
                max_chars = math.floor(width / char_width)
                for l in split_every(bline, max_chars):
                    lines.append(l)
            else:
                lines.append(bline)

        context.set_font_size(self.font_size)
        context.rectangle(.5, .5, self.width - 1, self.height - 1)
        if not self.background_color is None:
            context.set_source_rgb(*self.background_color)
            context.fill_preserve()
        context.set_source_rgb(0, 0, 0)
        context.stroke()
        context.move_to(.5, txt_height + .5)
        for i, line in enumerate(lines):
            context.move_to(.5, txt_height * (i + 1) + .5)
            context.show_text(line)


if __name__ == '__main__':
    main_win = MainWindow(title="Debug test")
    root = Root(100, 100)
    main_win.add(root)
    debug = WidgetDebug(70, 50)
    debug.translate(10, 10)
    root.set_child(debug)
    main_win.start_main()
Beispiel #27
0
            length = math.ceil(ext[2])
            if length > width:
                char_width = math.ceil(length/len(bline))
                max_chars = math.floor(width / char_width)
                for l in split_every(bline,max_chars):
                    lines.append(l)
            else:
                lines.append(bline)
                
        context.set_font_size(self.font_size)
        context.rectangle(.5, .5,
                          self.width - 1,
                          self.height - 1)
        if not self.background_color is None:
            context.set_source_rgb(*self.background_color)
            context.fill_preserve()
        context.set_source_rgb(0,0,0)
        context.stroke()
        context.move_to(.5,txt_height + .5)
        for i,line in enumerate(lines):
            context.move_to(.5, txt_height * (i+1) + .5)
            context.show_text(line)

if __name__ == '__main__':
    main_win = MainWindow(title="Debug test")
    root = Root(100, 100)
    main_win.add(root)
    debug = WidgetDebug(70,50)
    debug.translate(10,10)
    root.set_child(debug)
    main_win.start_main()
Beispiel #28
0
    def on_mouse_up(self, w, e):
        self.selected = False
        self._deltaP = None
        return True

    def on_mouse_move(self, w, e):
        if self.selected:
            self.centerP = Point(e.x, e.y) - self._deltaP
            w.invalidate()
        return True


if __name__ == '__main__':
    main = MainWindow("Animated donut")
    root = Root(600, 600)
    root.set_main_window(main)
    #     main.add(root)and
    donut = Donut(Point(200, 200), 50, 150)
    circle = Circle(100)
    circle.translate(200, 200)
    #     button = Button("I'm a button", 100, 50)
    #     button.translate(50,50)
    cont_b = UncheckedContainer()
    text = BorderedString("ciao io sono una scritta,    e ho tanti spazi",
                          font_size=20)
    text.translate(20, 50)
    cont_b.add(text)
    cont = UncheckedContainer()
    cont.add(donut)
    root.child = cont