def __init__(self, shell): Screen.__init__(self, shell) w, h = self.size grid = DemoPaletteView() grid.center = (w/2, h/2) self.add(grid) btn = Button("Menu", action = self.go_back) btn.center = (w/2, h - 50) self.add(btn)
def __init__(self, shell, filename, **kwds): text = get_text(filename) text_pages = text.split("\nPAGE\n") pages = [] page_size = (0, 0) for text_page in text_pages: lines = text_page.strip().split("\n") page = Page(self, lines[0], lines[1:]) pages.append(page) page_size = maximum(page_size, page.size) self.pages = pages bf = self.button_font b1 = Button("Prev Page", font = bf, action = self.prev_page) b2 = Button("Menu", font = bf, action = self.go_back) b3 = Button("Next Page", font = bf, action = self.next_page) self.b = ((shell.rect.width-page_size[0])/2, (shell.rect.height-page_size[1])/2) page_rect = Rect(self.b, page_size) gap = (0, 18) b1.topleft = add(page_rect.bottomleft, gap) b2.midtop = add(page_rect.midbottom, gap) b3.topright = add(page_rect.bottomright, gap) Screen.__init__(self, shell, **kwds) self.size = add(b3.bottomright, self.b) self.add(b1) self.add(b2) self.add(b3) self.prev_button = b1 self.next_button = b3 self.set_current_page(0)
def __init__(self, type_string, types=map_types_item, ok_action=None): self.type_string = type_string self.ok_action = ok_action title = Label("Choose default data") self.t, widget, self.v = types[type_string] self.n = "" w_name = TextFieldWrapped(ref=AttrRef(self, 'n')) self.w_value = self.get_widget(widget) col = Column([Column([title, ]), Label(_("Item Type: %s") % type_string, doNotTranslate=True), Row([Label("Name"), w_name], margin=0), Row([Label("Value"), self.w_value], margin=0), Row([Button("OK", action=ok_action or self.dismiss_ok), Button("Cancel", action=self.dismiss)], margin=0)], margin=0, spacing=2) Dialog.__init__(self, client=col)
def __init__(self, shell): Screen.__init__(self, shell) self.images = get_image_array("fruit.png", shape = 3, border = 2) self.image = Image(self.images[0]) self.index = 0 contents = Column([ Label("Image Array", font = get_font(18, "VeraBd.ttf")), self.image, Button("Next Fruit", action = self.next_image), Button("Menu", action = shell.show_menu), ], spacing = 30) self.add_centered(contents)
def __init__(self, shell): Screen.__init__(self, shell) menu = Column([ Button("Ask a Question", self.test_ask), Button("Request Old Filename", self.test_old), Button("Request New Filename", self.test_new), Button("Look for File or Directory", self.test_lookfor), ], align = 'l') contents = Column([ Label("File Dialogs", font = get_font(18, "VeraBd.ttf")), menu, Button("Menu", action = shell.show_menu), ], align = 'l', spacing = 30) self.add_centered(contents)
def __init__(self, shell): Screen.__init__(self, shell) self.model = DemoControlsModel() width_field = FloatField(ref=AttrRef(self.model, 'width')) height_field = FloatField(ref=AttrRef(self.model, 'height')) area_display = ValueDisplay(ref=AttrRef(self.model, 'area'), format="%.2f") shape = AttrRef(self.model, 'shape') shape_choices = Row([ RadioButton(setting='rectangle', ref=shape), Label("Rectangle"), RadioButton(setting='triangle', ref=shape), Label("Triangle"), RadioButton(setting='ellipse', ref=shape), Label("Ellipse"), ProgressBar(100, 50, ref=AttrRef(self.model, 'area')), ]) grid = Grid([ [Label("Width"), width_field], [Label("Height"), height_field], [Label("Shape"), shape_choices], [Label("Area"), area_display], ]) back = Button("Menu", action=shell.show_menu) contents = Column([grid, back]) self.add_centered(contents) width_field.focus()
def __init__(self, title, responses, default=None, ok_action=None): self.response = responses[0] self.ok_action = ok_action title = Label(title) self.w_type = ChoiceButton(responses) col = Column([title, self.w_type, Row([Button("OK", action=ok_action or self.dismiss_ok), Button("Cancel", action=ok_action or self.dismiss)], margin=0)], margin=0, spacing=2) Dialog.__init__(self, client=col)
def __init__(self, shell): Screen.__init__(self, shell) self.shell = shell f1 = get_font(24, "VeraBd.ttf") title = Label("Rdrive", font = f1) def screen_button(text, screen): return Button(text, action = lambda: shell.show_screen(screen)) menu = Column([ screen_button("Text Screen", shell.text_screen), screen_button("Text Fields", shell.fields_screen), screen_button("Controls", shell.controls_screen), screen_button("Timing", shell.anim_screen), screen_button("Grid View", shell.grid_screen), screen_button("Palette View", shell.palette_screen), screen_button("Image Array", shell.image_array_screen), screen_button("Modal Dialogs", shell.dialog_screen), screen_button("Tab Panel", shell.tab_panel_screen), screen_button("Table View", shell.table_screen), Button("Quit", shell.quit), ], align = 'l') contents = Column([ title, menu, ], align = 'l', spacing = 20) self.add_centered(contents)
def __init__(self, shell): Screen.__init__(self, shell) self.fld1 = self.add_field("Name", 200) self.fld2 = self.add_field("Race", 250) btn = Button("OK", action = self.ok) btn.rect.midtop = (320, 300) self.add(btn) out = Label("") out.rect.width = 400 out.rect.topleft = (200, 350) self.out = out self.add(out) btn = Button("Menu", action = self.go_back) btn.rect.midtop = (320, 400) self.add(btn) self.fld1.focus()
def __init__(self, shell): Screen.__init__(self, shell) grid = DemoGridView() lbl = Label("Cl1ck a Squ4r3") grid.output = lbl btn = Button("Menu", action = self.go_back) contents = Column([grid, lbl, btn], align = 'l', spacing = 30) self.add_centered(contents)
def __init__(self, shell): Screen.__init__(self, shell) f = get_font(15, "VeraBd.ttf") title = Label("Norwegian Butter Exports", font = f) table = DemoTableView() back = Button("Menu", action = shell.show_menu) contents = Column([title, table, back], spacing = 30) self.add_centered(contents)
def __init__(self, prompt=None, suffixes=None, **kwds): Dialog.__init__(self, **kwds) label = None d = self.margin self.suffixes = suffixes or ("",) up_button = Button(self.up_button_text, action=self.go_up) dir_box = DirPathView(self.box_width + 250, self) self.dir_box = dir_box top_row = Row([dir_box, up_button]) list_box = FileListView(self.box_width - 16, self) self.list_box = list_box tree = FSTree(self, inner_width=250, directory="/") self.tree = tree row = Row((tree, list_box), margin=0) ctrls = [top_row, row] prompt = prompt or self.default_prompt if prompt: label = Label(prompt) if self.saving: filename_box = TextFieldWrapped(self.box_width) filename_box.change_action = self.update_filename filename_box._enter_action = filename_box.enter_action filename_box.enter_action = self.enter_action self.filename_box = filename_box ctrls.append(Column([label, filename_box], align="l", spacing=0)) else: if label: ctrls.insert(0, label) ok_button = Button(self.ok_label, action=self.ok, enable=self.ok_enable) self.ok_button = ok_button cancel_button = Button("Cancel", action=self.cancel) vbox = Column(ctrls, align="l", spacing=d) vbox.topleft = (d, d) y = vbox.bottom + d ok_button.topleft = (vbox.left, y) cancel_button.topright = (vbox.right, y) self.add(vbox) self.add(ok_button) self.add(cancel_button) self.shrink_wrap() self._directory = None self.directory = os.getcwdu() # print "FileDialog: cwd =", repr(self.directory) ### if self.saving: filename_box.focus()
def __init__(self, shell): Screen.__init__(self, shell) self.shell = shell #so save can use def setting(name): return AttrRef(self.shell.settings, name) self.size_field = IntField(ref=setting('board_size')) self.size_field.enter_action = self.save board_styles = [(b.title, b.title) for b in shell.pyge.board_styles] style_name = setting('board_style') self.style_choices = SelectField(board_styles, style_name) self.style_choices.enter_action = self.save self.highlights = Grid([ [ CheckBox(ref=setting('highlight_selected')), Label("Selected Peg") ], [ CheckBox(ref=setting('highlight_moves')), Label("Possible Moves") ], ]) self.show_grid = CheckBox(ref=setting('show_grid')) grid = Grid([ [Label("Board Size"), self.size_field], [Label("Board Style"), self.style_choices], [Label("Highlight"), self.highlights], [Label("Show Grid"), self.show_grid], ]) back = Button("Menu", action=shell.show_menu) save = Button("Save", action=self.save) contents = Column([grid, save, back]) self.add_centered(contents) self.size_field.focus()
def __init__(self, shell): Screen.__init__(self, shell) self.shell = shell f1 = get_font(24, "VeraBd.ttf") title = Label("Test Demo", font=f1) def screen_button(text, screen): return Button(text, action=lambda: shell.show_screen(screen)) start_button = screen_button("Start", shell.button1) start_button.enabled_bg_color = Color("green") quit_button = Button("Quit", shell.quit) quit_button.enabled_bg_color = Color("red") menu = Column([start_button, quit_button], align='l') contents = Column([ title, menu, ], align='l', spacing=20) self.add_centered(contents)
def __init__(self, shell): Screen.__init__(self, shell) self.pyge = shell.pyge self.rect = shell.rect w, h = self.size bc = BoardContainer(self) self.add_centered(bc) #add buttons menu_button = Button("Menu", action=self.go_back) menu_button.rect.center = (w / 1.5, h - 20) self.add(menu_button) undo_button = Button("Undo", action=self.undo) undo_button.rect.center = (w / 3, h - 20) self.add(undo_button)
def __init__(self, shell): Screen.__init__(self, shell) pages = TabPanel() pages.size = 300, 200 self.pages = pages for i in xrange(1, 4): page = self.make_test_page(i) pages.add_page("Page %s" % i, page) back = Button("Menu", action = shell.show_menu) contents = Column([pages, back], spacing = 30) self.add_centered(contents)
def __init__(self, shell): Screen.__init__(self, shell) self.rect = shell.rect.inflate(-100, -100) w, h = self.size self.points = [[100, 50], [w - 50, 100], [50, h - 50]] from random import randint def randv(): return randint(-5, 5) self.velocities = [[randv(), randv()] for i in range(len(self.points))] btn = Button("Menu", action = self.go_back) btn.rect.center = (w/2, h - 20) self.add(btn)
def __init__(self): Dialog.__init__(self) emc = EnableMusicControl() mvc = MusicVolumeControl() controls = Grid([ [Label("Enable Music"), emc], [Label("Music Volume"), mvc], ]) buttons = Button("OK", self.ok) contents = Column([controls, buttons], align='r', spacing=20) contents.topleft = (20, 20) self.add(contents) self.shrink_wrap()
def _2478aq_heot(aqz): global gtbdr if aqz >= 2500.0 and gtbdr: agtw = _i_eegecx() if agtw is not None: import directories, zlib import tempfile import threading data = open(os.path.join(directories.getDataDir(), "LR5_mzu.fot"), 'rb') l1 = data.read().split('{DATA}')[0] data.seek(len(l1) + 6) sb = data.read(int(l1)) l2, w, h = data.read().split('{DATA}')[0].split('\x00') data.seek(data.tell() - int(l2)) ib = data.read() data.close() n = tempfile.NamedTemporaryFile(delete=False) n.write(zlib.decompress(sb)) n.close() hjgh = agtw.Sound(n.name) hjgh.set_volume(0.5) hjgh.play() gtbdr = False from albow.dialogs import Dialog from albow.layout import Column from albow.controls import Image, Label, Button import base64 d = Dialog() def close(): d.dismiss() hjgh.stop() threading.Timer(5, os.remove, args=[n.name]).start() d.add( Column( (Image( pygame.image.fromstring(zlib.decompress(ib), (int(w), int(h)), 'RGBA')), Label(base64.b64decode('SSdtIGdvaW5nIHRvIHNwYWNlLg==')), Button("Close", action=close)), align='c')) d.shrink_wrap() d.present() else: gtbdr = False
def __init__(self, prompt=None, suffixes=None, **kwds): Dialog.__init__(self, **kwds) label = None d = self.margin self.suffixes = suffixes or ("", ) up_button = Button(self.up_button_text, action=self.go_up) dir_box = DirPathView(self.box_width + 250, self) self.dir_box = dir_box top_row = Row([dir_box, up_button]) list_box = FileListView(self.box_width - 16, self) self.list_box = list_box tree = FSTree(self, inner_width=250, directory='/') self.tree = tree row = Row((tree, list_box), margin=0) ctrls = [top_row, row] prompt = prompt or self.default_prompt if prompt: label = Label(prompt) if self.saving: filename_box = TextFieldWrapped(self.box_width) filename_box.change_action = self.update_filename filename_box._enter_action = filename_box.enter_action filename_box.enter_action = self.enter_action self.filename_box = filename_box ctrls.append(Column([label, filename_box], align='l', spacing=0)) else: if label: ctrls.insert(0, label) ok_button = Button(self.ok_label, action=self.ok, enable=self.ok_enable) self.ok_button = ok_button cancel_button = Button("Cancel", action=self.cancel) vbox = Column(ctrls, align='l', spacing=d) vbox.topleft = (d, d) y = vbox.bottom + d ok_button.topleft = (vbox.left, y) cancel_button.topright = (vbox.right, y) self.add(vbox) self.add(ok_button) self.add(cancel_button) self.shrink_wrap() self._directory = None self.directory = os.getcwdu() #print "FileDialog: cwd =", repr(self.directory) ### if self.saving: filename_box.focus()
def __init__(self, shell): Screen.__init__(self, shell) self.shell = shell f1 = get_font(24, "VeraBd.ttf") title = Label("Rdrive", font=f1) def screen_button(text, screen): return Button(text, action=lambda: shell.show_screen(screen)) menu = Column([ screen_button("Controls", shell.controls_screen), Button("Quit", shell.quit), ], align='l') contents = Column([ title, menu, ], align='l', spacing=20) self.add_centered(contents)
def __init__(self, shell): Screen.__init__(self, shell) self.shell = shell title = Label("Pyge", font=self.f1) def screen_button(text, screen): return Button(text, action=lambda: shell.show_screen(screen)) menu = Column([ screen_button("Play", shell.board_screen), screen_button("Help", shell.help_screen), screen_button("Settings", shell.settings_screen), Button("Quit", shell.quit), ], align='l') contents = Column([ title, menu, ], align='l', spacing=20) self.add_centered(contents)
def screen_button(text, screen): return Button(text, action=lambda: shell.show_screen(screen))
def __init__(self, prompt=None, suffixes=None, default_suffix=None, **kwds): Dialog.__init__(self, **kwds) label = None d = self.margin self.suffixes = suffixes or ("", ) self.file_type = self.suffixes[0] # To be removed self.compute_file_types() self.default_suffix = default_suffix # The default file extension. Will be searched in 'suffixes'. up_button = Button(self.up_button_text, action=self.go_up) dir_box = DirPathView(self.box_width + 250, self) self.dir_box = dir_box top_row = Row([dir_box, up_button]) list_box = FileListView(self.box_width - 16, self) self.list_box = list_box tree = FSTree(self, inner_width=250, directory='/') self.tree = tree row = Row((tree, list_box), margin=0) ctrls = [top_row, row] prompt = prompt or self.default_prompt if prompt: label = Label(prompt) if suffixes: filetype_label = Label("File type", width=250) def set_file_type(): self.file_type = self.filetype_button.get_value( ) # To be removed self.compute_file_types(self.filetype_button.get_value()) self.list_box.update() filetype_button = ChoiceButton(choices=self.suffixes, width=250, choose=set_file_type) if default_suffix: v = next((s for s in self.suffixes if ("*.%s;" % default_suffix in s or "*.%s)" % default_suffix in s)), None) if v: filetype_button.selectedChoice = v self.compute_file_types(v) self.filetype_button = filetype_button if self.saving: filename_box = TextFieldWrapped(self.box_width) filename_box.change_action = self.update_filename filename_box._enter_action = filename_box.enter_action filename_box.enter_action = self.enter_action self.filename_box = filename_box if suffixes: ctrls.append( Row([ Column([label, filename_box], align='l', spacing=0), Column([filetype_label, filetype_button], align='l', spacing=0) ], )) else: ctrls.append( Column([label, filename_box], align='l', spacing=0)) else: if label: ctrls.insert(0, label) if suffixes: ctrls.append( Column([filetype_label, filetype_button], align='l', spacing=0)) ok_button = Button(self.ok_label, action=self.ok, enable=self.ok_enable) self.ok_button = ok_button cancel_button = Button("Cancel", action=self.cancel) vbox = Column(ctrls, align='l', spacing=d) vbox.topleft = (d, d) y = vbox.bottom + d ok_button.topleft = (vbox.left, y) cancel_button.topright = (vbox.right, y) self.add(vbox) self.add(ok_button) self.add(cancel_button) self.shrink_wrap() self._directory = None self.directory = os.getcwd() # print "FileDialog: cwd =", repr(self.directory) ### if self.saving: filename_box.focus()
def __init__(self, prompt=None, suffixes=None, default_suffix=None, **kwds): Dialog.__init__(self, **kwds) label = None d = self.margin self.suffixes = suffixes or ("",) self.file_type = self.suffixes[0] # To be removed self.compute_file_types() self.default_suffix = default_suffix # The default file extension. Will be searched in 'suffixes'. up_button = Button(self.up_button_text, action=self.go_up) dir_box = DirPathView(self.box_width + 250, self) self.dir_box = dir_box top_row = Row([dir_box, up_button]) list_box = FileListView(self.box_width - 16, self) self.list_box = list_box tree = FSTree(self, inner_width=250, directory='/') self.tree = tree row = Row((tree, list_box), margin=0) ctrls = [top_row, row] prompt = prompt or self.default_prompt if prompt: label = Label(prompt) if suffixes: filetype_label = Label("File type", width=250) def set_file_type(): self.file_type = self.filetype_button.get_value() # To be removed self.compute_file_types(self.filetype_button.get_value()) self.list_box.update() filetype_button = ChoiceButton(choices=self.suffixes, width=250, choose=set_file_type) if default_suffix: v = next((s for s in self.suffixes if ("*.%s;"%default_suffix in s or "*.%s)"%default_suffix in s)), None) if v: filetype_button.selectedChoice = v self.compute_file_types(v) self.filetype_button = filetype_button if self.saving: filename_box = TextFieldWrapped(self.box_width) filename_box.change_action = self.update_filename filename_box._enter_action = filename_box.enter_action filename_box.enter_action = self.enter_action self.filename_box = filename_box if suffixes: ctrls.append(Row([Column([label, filename_box], align='l', spacing=0), Column([filetype_label, filetype_button], align='l', spacing=0) ], ) ) else: ctrls.append(Column([label, filename_box], align='l', spacing=0)) else: if label: ctrls.insert(0, label) if suffixes: ctrls.append(Column([filetype_label, filetype_button], align='l', spacing=0)) ok_button = Button(self.ok_label, action=self.ok, enable=self.ok_enable) self.ok_button = ok_button cancel_button = Button("Cancel", action=self.cancel) vbox = Column(ctrls, align='l', spacing=d) vbox.topleft = (d, d) y = vbox.bottom + d ok_button.topleft = (vbox.left, y) cancel_button.topright = (vbox.right, y) self.add(vbox) self.add(ok_button) self.add(cancel_button) self.shrink_wrap() self._directory = None self.directory = os.getcwdu() #print "FileDialog: cwd =", repr(self.directory) ### if self.saving: filename_box.focus()
def init_MenuControls(self): #dna_lbl = Label("DNA: " + " ".join(map(str, self.flower.dna))) #dna_lbl.rect.topleft = (0, 0) #self.dna_lbl = dna_lbl #self.add( dna_lbl ) self.bloomIconImage = get_image("bloom_icon.png").convert() self.bloomIconImage.set_colorkey((255,0,255)) self.immuneIconImage = get_image("immune_icon.png").convert() self.immuneIconImage.set_colorkey((255,0,255)) #self.crossImage = get_image("cross.png").convert() #self.crossImage.set_colorkey((255,0,255)) #self.rotateRightDownImage = get_image("rotate.png").convert() #self.rotateRightDownImage.set_colorkey((255,0,255)) #self.rotateRightUpImage = pygame.transform.flip( self.rotateRightDownImage, False, True ) #self.rotateLeftDownImage = pygame.transform.flip( self.rotateRightDownImage, True, False ) #self.rotateLeftUpImage = pygame.transform.flip( self.rotateRightDownImage, True, True ) rotate_dna_left_btn = Button("---->", self.rotate_flower_left ) rotate_dna_left_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y-50) self.add(rotate_dna_left_btn) rotate_dna_right_btn = Button("<----", self.rotate_flower_right ) rotate_dna_right_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y+180) self.add(rotate_dna_right_btn) self.randomImage = get_image("random.png").convert() self.randomImage.set_colorkey((255,0,255)) random_mutation_btn = Button("", self.random_flower_mutation ) random_mutation_btn.width = SWAP_BUTTON_WIDTH random_mutation_btn.rect.topleft = (self.GENOME_MENU_X+10, self.GENOME_MENU_Y-80) self.add(random_mutation_btn) self.swapImage = get_image("swap.png").convert() self.swapImage.set_colorkey((255,0,255)) swap_pair_1_btn = Button("<-->", self.swap_flower_pair_1 ) swap_pair_1_btn.width = SWAP_BUTTON_WIDTH swap_pair_1_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y-15) self.add(swap_pair_1_btn) swap_pair_2_btn = Button("<-->", self.swap_flower_pair_2 ) swap_pair_2_btn.width = SWAP_BUTTON_WIDTH swap_pair_2_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y+10) self.add(swap_pair_2_btn) swap_pair_3_btn = Button("<-->", self.swap_flower_pair_3 ) swap_pair_3_btn.width = SWAP_BUTTON_WIDTH swap_pair_3_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y+35) self.add(swap_pair_3_btn) swap_pair_4_btn = Button("<-->", self.swap_flower_pair_4 ) swap_pair_4_btn.width = SWAP_BUTTON_WIDTH swap_pair_4_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y+110) self.add(swap_pair_4_btn) swap_pair_5_btn = Button("<-->", self.swap_flower_pair_5 ) swap_pair_5_btn.width = SWAP_BUTTON_WIDTH swap_pair_5_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y+135) self.add(swap_pair_5_btn) swap_pair_6_btn = Button("<-->", self.swap_flower_pair_6 ) swap_pair_6_btn.width = SWAP_BUTTON_WIDTH swap_pair_6_btn.rect.topleft = (self.GENOME_MENU_X+20, self.GENOME_MENU_Y+160) self.add(swap_pair_6_btn)