Beispiel #1
0
    text = pyui.State(default="")

    async def built(self):
        async with httpx.AsyncClient() as client:
            params = {"type": "meat-and-filler", "format": "text", "paras": 2}
            r = await client.get("https://baconipsum.com/api/", params=params)
            self.text = r.text

    def content(self):
        # fmt: off
        yield pyui.VStack(alignment=pyui.Alignment.LEADING)(
            pyui.Text("Enter some text below:"),
            pyui.TextField(self.line, placeholder="Single line text"),
            pyui.TextField(self.lines,
                           placeholder="Two line text input").lines(2),
            pyui.TextField(
                self.text,
                placeholder="All the text").lines(None).priority("high"),
            pyui.HStack()(
                pyui.Spacer(),
                pyui.Button("Submit", asset="button.primary"),
            ),
        ).padding(20)
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("io.temp.TextTest")
    app.window("Text Tester", TextTest())
    app.run()
Beispiel #2
0
import pyui


class ProgressTest(pyui.View):
    current = pyui.State(default=50)

    def content(self):
        # fmt: off
        yield pyui.VStack()(
            pyui.Slider(self.current),
            pyui.ProgressBar(self.current),
            pyui.Text(self.current.value),
        ).padding(20)
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("io.temp.ProgressTest")
    app.window("Progress Test", ProgressTest(), width=640, height=200)
    app.run()
Beispiel #3
0
                        asset="button.primary").priority("high")).padding(10)
        # fmt: on


class IconsView(pyui.View):
    search_text = pyui.State(default="")

    def filtered_icons(self):
        search = self.search_text.value.lower()
        for name in pyui.Icon.data["icons"]:
            if search == "" or search in name:
                yield name

    def content(self):
        # fmt: off
        yield pyui.VStack(spacing=0)(
            SearchView(self.search_text),
            pyui.ScrollView()(pyui.Grid(size=100, flex=True)(pyui.ForEach(
                self.filtered_icons(), lambda name:
                (pyui.Rectangle(pyui.VStack()
                                (pyui.Icon(name, size=32), pyui.Text(name).
                                 font(size=11))).background(30, 30, 30).
                 padding(5)))).position(pyui.Position.TOP_LEADING)))
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("io.temp.IconViewer")
    app.window("Icon Viewer", IconsView())
    app.run()
Beispiel #4
0
import pyui


class PickerTest(pyui.View):
    text = pyui.State(default="")
    selected = pyui.State(default=0)

    def content(self):
        # fmt: off
        yield pyui.VStack()(pyui.TextField(self.text, placeholder="Some text"),
                            pyui.Picker(selection=self.selected)(
                                pyui.Text("Item One"),
                                pyui.Text("Item Two"),
                                pyui.Text("Item Three"),
                            )).padding(20)
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("io.temp.PickerTest")
    app.window("Picker Test", PickerTest())
    app.run()
Beispiel #5
0
                ), ).priority(pyui.Priority.HIGH),
                pyui.HStack()(
                    pyui.Spacer(),
                    pyui.Button("Clear", action=self.clear),
                    pyui.Button("+", action=self.create_row),
                ),
            ),
            pyui.Text("Selected rows: {}".format(self.selection.value)),
            pyui.Spacer(),
        )
        # fmt: on


class DemoView(pyui.View):
    def content(self):
        # fmt: off
        yield pyui.TabView()(
            TimestampView().padding(20).item("Time"),
            BarChartView().padding(20).item("Bar Chart"),
            ImageSizerView().padding(20).item("Image"),
            FormView().padding(20).item("Form"),
            ListView().padding(20).item("Lists"),
        )
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("io.temp.PyUI")
    app.window("PyUI Demo", DemoView())
    app.run()
Beispiel #6
0
                        pyui.Toggle(item.complete, label=item.text, action=(self.items.toggle, item))
                            .modify(ITEM_COMPLETE if item.complete else ITEM_ACTIVE),
                        pyui.Spacer(),
                        pyui.Button(action=(self.items.delete, item), asset=None)(
                            pyui.Icon("trash-alt")
                        ).font(size=12).padding(0)
                    )
                )),
            ).priority(pyui.Priority.HIGH),
            pyui.HStack(
                pyui.Text(self.remaining_text),
                pyui.Button(action=self.items.clear_complete, asset=None)(
                    pyui.Text("Clear Completed").color(60, 150, 255)
                ).padding(5).disable(not self.items.any_complete),
                pyui.Spacer(),
                # TODO: would be nice to pass SegmentedButton an enum?
                pyui.SegmentedButton(self.selected_filter)(
                    pyui.Text("All"),
                    pyui.Text("Active"),
                    pyui.Text("Completed"),
                ),
            )
        ).padding(20)
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("net.pyui.TodoMVC")
    app.window("TodoMVC", TodoMVC(), height=320)
    app.run()
Beispiel #7
0
            CalcButton(")", self.add, BTN_TOP),
            CalcButton("/", self.add, BTN_OPERATOR),
            CalcButton("7", self.add),
            CalcButton("8", self.add),
            CalcButton("9", self.add),
            CalcButton("*", self.add, BTN_OPERATOR),
            CalcButton("4", self.add),
            CalcButton("5", self.add),
            CalcButton("6", self.add),
            CalcButton("-", self.add, BTN_OPERATOR),
            CalcButton("1", self.add),
            CalcButton("2", self.add),
            CalcButton("3", self.add),
            CalcButton("+", self.add, BTN_OPERATOR),
            CalcButton("(…)", self.group),
            CalcButton("0", self.add),
            CalcButton(".", self.add),
            CalcButton("=", self.compute, BTN_OPERATOR),
        ))
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("io.temp.Calculator")
    app.window("Calculator",
               CalculatorView(),
               width=250,
               height=300,
               resize=True)
    app.run()
Beispiel #8
0
                                                    128).priority("high"),
                ),
                pyui.Slider(self.num, minimum=1,
                            maximum=10).disable(self.size_or_num.value == 1),
                pyui.HStack(
                    pyui.Text("Item size"),
                    pyui.Spacer(),
                    pyui.Text(self.size.value).color(128, 128,
                                                     128).priority("high"),
                ),
                pyui.Slider(self.size, minimum=50,
                            maximum=200).disable(self.size_or_num.value == 0),
                pyui.Toggle(self.flex, label="Adjust size to fit").disable(
                    self.size_or_num.value == 0),
            ).padding(10).size(width=300),
            ItemGridView(
                item_count=self.item_count.value,
                size=size,
                num=num,
                axis=self.axis.value,
                flex=self.flex.value,
            ),
        )
        # fmt: on


if __name__ == "__main__":
    app = pyui.Application("io.temp.GridTest")
    app.window("Grid Tester", GridTest())
    app.run()