예제 #1
0
 def content(self):
     # fmt: off
     yield pyui.VStack(alignment=pyui.Alignment.LEADING)(
         pyui.HStack()(
             pyui.Toggle(self.items.all_complete, action=self.items.toggle_all),
             pyui.TextField(self.new_item, "What needs to be done?", action=self.add),
         ),
         pyui.ScrollView()(
             pyui.List(self.selected, builder=lambda item: (
                 pyui.HStack()(
                     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)
예제 #2
0
 def content(self):
     # fmt: off
     yield pyui.HStack()(
         pyui.TextField(self.current_text,
                        placeholder="Search icons",
                        action=self.search),
         pyui.Button("Search", action=self.search,
                     asset="button.primary").priority("high")).padding(10)
예제 #3
0
파일: demo.py 프로젝트: dnettoRaw/pyui
 def content(self):
     # fmt: off
     yield pyui.VStack()(pyui.HStack()(
         pyui.Text(self.timestamp.value.strftime("%H:%M:%S.%f")),
         pyui.Button(action=self.update_timestamp)(
             pyui.Image("images/python.svg").size(height=14),
             pyui.Text("Update"),
         ),
     ), )
예제 #4
0
파일: demo.py 프로젝트: dnettoRaw/pyui
 def content(self):
     # fmt: off
     yield pyui.HStack(alignment=pyui.Alignment.LEADING, spacing=20)(
         pyui.VStack(spacing=10, alignment=pyui.Alignment.LEADING)(
             pyui.ScrollView()(pyui.List(selection=self.selection)(
                 pyui.Text("First Row"),
                 pyui.ForEach(self.dynamic_items.value, lambda item:
                              (pyui.Text(item), )),
             ), ).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(),
     )
예제 #5
0
파일: demo.py 프로젝트: dnettoRaw/pyui
 def content(self):
     # fmt: off
     yield pyui.VStack(spacing=10)(
         pyui.Text("Bar Chart"),
         pyui.Spacer(),
         pyui.HStack(alignment=pyui.Alignment.TRAILING)(pyui.ForEach(
             self.bars.value, lambda height, idx:
             (pyui.Rectangle()
              (pyui.Text("{:.0f}%".format(height * 100.0)).color(
                  230, 230, 230).background(0, 0, 0, 160).
               padding(3).font(size=11).radius(2)).background(
                   random.randint(0, 255), random.randint(0, 255),
                   random.randint(0, 255)).size(height=height).animate(
                       pyui.spring(), 0.3, delay=0.03 * idx)))).priority(
                           pyui.Priority.HIGH),
         pyui.HStack()(
             pyui.Button("Fewer Bars", action=self.fewer_bars),
             pyui.Button("Randomize", action=self.randomize),
             pyui.Button("More Bars", action=self.more_bars),
         ),
     )
예제 #6
0
 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)
예제 #7
0
파일: demo.py 프로젝트: dnettoRaw/pyui
 def content(self):
     # fmt: off
     fg = pyui.Environment(
         "text").color if self.language.value else sdl2.SDL_Color(
             150, 150, 150)
     yield pyui.VStack(spacing=20)(
         pyui.HStack()(
             pyui.TextField(self.language, "Add a new language"),
             pyui.Button(action=self.new_language)(pyui.Text(
                 "Add {}".format(self.language.value)).color(fg), ).disable(
                     self.language.value == ""),
             pyui.Spacer(),
         ),
         pyui.ForEach(self.languages.value, lambda lang:
                      (DescriptionView(lang=lang))),
     )
예제 #8
0
    def __init__(self, surface, switch_context):
        self.surface = surface
        self.switch_context = switch_context

        # play soundtrack
        pygame.mixer.music.load(assets.HOME_SOUND)
        pygame.mixer.music.set_volume(0.2)
        pygame.mixer.music.play(-1)

        # create the interface
        self.desert_image = pyui.Image(surface, assets.DESERT_IMAGE, (0, 0),
                                       (1920, 1080))
        self.cannon_image = pyui.Image(surface, assets.CANNON_IMAGE,
                                       (520, 200), (880, 468))
        self.play_button = pyui.Button(surface, 'Play Cannons', (710, 750))
        self.escape_label = pyui.Label(surface, 'Press ESC to exit',
                                       (10, 1050),
                                       (assets.ABOVE_FONT, 20, colors.WHITE))