def __init__(self, **params): gui.Table.__init__(self, **params) text_color = THECOLORS["yellow"] #(0, 0, 255) # Make a table row in the gui (like a row in HTML). self.tr() # Color transfer. self.td( gui.Label(" Color Transfer (c): ", color=text_color), align=1) self.td( gui.Switch(value=False, name='colorTransfer')) # Stickiness. self.td( gui.Label(" Fix stickiness (s): ", color=text_color), align=1) self.td( gui.Switch(value=True, name='fix_Stickiness')) # Gravity. self.td( gui.Label(" Gravity (g): ", color=text_color)) self.td( gui.HSlider(0,-3,3, size=20, width=100, height=16, name='gravity_factor')) # Freeze the cars. self.td( gui.Label(" Freeze (f): ", color=text_color)) # Form element (freeze_button). freeze_button = gui.Button("v=0") # Note: must invoke the method to be called WITHOUT parentheses. freeze_button.connect( gui.CLICK, self.stop_cars) self.td( freeze_button) # Just a help tip for starting a new demo. self.td( gui.Label(" New demo (0-9)", color=THECOLORS["green"]))
def __init__(self,settings, **params): # The framework GUI is just basically a HTML-like table # There are 2 columns right-aligned on the screen gui.Table.__init__(self,**params) self.form=gui.Form() fg = (255,255,255) # "Toggle menu" self.tr() self.td(gui.Label("F1: Toggle Menu",color=(255,0,0)),align=1,colspan=2) for slider in sliders: # "Slider title" self.tr() self.td(gui.Label(slider['text'],color=fg),align=1,colspan=2) # Create the slider self.tr() e = gui.HSlider(getattr(settings, slider['name']),slider['min'],slider['max'],size=20,width=100,height=16,name=slider['name']) self.td(e,colspan=2,align=1) # Add each of the checkboxes. for text, variable in checkboxes: self.tr() if variable == None: # Checkboxes that have no variable (i.e., None) are just labels. self.td(gui.Label(text, color=fg), align=1, colspan=2) else: # Add the label and then the switch/checkbox self.td(gui.Label(text, color=fg), align=1) self.td(gui.Switch(value=getattr(settings, variable),name=variable))
def __init__(self, **params): gui.Table.__init__(self, **params) self.time_label = gui.Label("Time: 0", color=BLACK) self.plancton_label = gui.Label("Plancton: 0", color=BLACK) self.male_fish_label = gui.Label("Male fish: 0", color=BLACK) self.female_fish_label = gui.Label("Female fish: 0", color=BLACK) self.predator_fish_label = gui.Label("Predators: 0", color=BLACK) self.ill_fish_label = gui.Label("Ill fish: 0", color=BLACK) self.speed_label = gui.Label("Speed ", color=BLACK) self.slider = gui.HSlider(0, -10, 10, step=1, size=20, width=100, height=16, name='speed') def fullscreen_changed(btn): pygame.display.toggle_fullscreen() def change_simmulation_speed(btn): from main import Speed Speed.set_sim_speed(btn.value) self.tr() self.td(gui.Label("Statistics", color=BLACK), colspan=2) self.tr() self.td(self.time_label, align=-1) self.tr() self.td(self.speed_label, align=-1) self.slider.connect(gui.CHANGE, change_simmulation_speed, self.slider) self.td(self.slider, align=-1) self.tr() self.td(self.plancton_label, align=-1) self.tr() self.td(self.male_fish_label, align=-1) self.tr() self.td(self.female_fish_label, align=-1) self.tr() self.td(self.predator_fish_label, align=-1) self.tr() self.td(self.ill_fish_label, align=-1) #e = gui.HSlider(2,1,5,size=20,width=100,height=16,name='size') #self.td(e) btn = gui.Switch(value=False, name='fullscreen') btn.connect(gui.CHANGE, fullscreen_changed, btn) self.tr() self.td(gui.Label("Full Screen: ", color=BLACK), align=-1) self.td(btn, align=-1)
def __init__(self, designer): gui.Table.__init__(self) config = designer.config def fullscreen(btn): pygame.display.toggle_fullscreen() def analyse(btn): designer.analyseform = True # TODO: this could/should be custom events def connect(btn): designer.connectform = True def execute(btn): designer.executeform = True def clear(btn): designer.clearform = True fg = config['uicolor'] self.tr() self.td(gui.Label(" DESIGNER ")) td_left = {'padding_left': 25} td_right = {'padding_right': 25} btn = gui.Switch(value=False, name='fullscreen') btn.connect(gui.CHANGE, fullscreen, btn) self.td(gui.Label("full ", color=fg), align=1, style=td_left) self.td(btn, align=-1, style=td_right) td_styleb = { 'padding_left': 5, 'padding_right': 5, 'padding_top': 5, 'padding_bottom': 5 } btn = gui.Button("clear") btn.connect(gui.CLICK, clear, btn) self.td(btn, style=td_styleb) """ btn = gui.Button("analyse") btn.connect(gui.CLICK, analyse, btn) self.td(btn, style=td_styleb) """ btn = gui.Button("connect") btn.connect(gui.CLICK, connect, btn) self.td(btn, style=td_styleb) btn = gui.Button("execute") btn.connect(gui.CLICK, execute, btn) self.td(btn, style=td_styleb)
def __init__(self, sim): gui.Table.__init__(self) config = sim.config def fullscreen(btn): pygame.display.toggle_fullscreen() def designer(btn): sim.designerform = True def restart(btn): sim.restartform = True def fps_update(slider): sim.fps = slider.value fg = config['uicolor'] self.tr() self.td(gui.Label(" SIMULATION ")) td_left = {'padding_left': 25} td_right = {'padding_right': 25} btn = gui.Switch(value=False, name='fullscreen') btn.connect(gui.CHANGE, fullscreen, btn) self.td(gui.Label("full ", color=fg), align=1, style=td_left) self.td(btn, align=-1, style=td_right) td_styleb = { 'padding_left': 5, 'padding_right': 5, 'padding_top': 5, 'padding_bottom': 5 } btn = gui.Button("designer") btn.connect(gui.CLICK, designer, btn) self.td(btn, style=td_styleb) btn = gui.Button("restart") btn.connect(gui.CLICK, restart, btn) self.td(btn, style=td_styleb) self.td(gui.Label("FPS:")) slider = gui.HSlider(value=sim.fps, min=25, max=config['fpsmax'], size=20, width=120, name='fps') self.td(slider) slider.connect(gui.CHANGE, fps_update, slider)
def __init__(self, parent_class, instance): self.instance = instance self.parent_class = parent_class self.depth = 0 self.parent = None self.color = "Red" self._target = None self.label = "Null" self.has_child = False self.drop_down_visible = True self.drop_down_box = pgui.Switch({'value':True}) self.drop_down_box.style.off = texture["gray_triangle_off"] self.drop_down_box.style.on = texture["gray_triangle_on"] self.arrow_check = pgui.Switch() self.arrow_check.value = False self.arrow = Arrow(self.instance, self.target, GREEN, 1) self.arrow.visible = False def change_visiblity_arrow(value): self.arrow.visible = not self.arrow_check.value self.arrow_check.connect(pgui.CLICK, change_visiblity_arrow, None) if instance is not None: self.instance.create(self.arrow) # self.arrow_check.style.off = texture["gray_triangle_off"] # self.arrow_check.style.on = texture["gray_triangle_on"] def change_visiblity(value): self.drop_down_visible = not self.drop_down_box.value self.parent_class.update() self.drop_down_box.connect(pgui.CLICK, change_visiblity, None) self.name_box = pgui.Label(self.label) self.name_box.set_font(font["ui_font_1"]) self.name_box.style.color = LIGHT_GRAY
def __init__(self, menu): self.menu = menu title = gui.Label("Options") table = gui.Table(height=200, width=400) table.tr() musicswitch = gui.Switch(menu.music) def msc(): menu.music = not menu.music musicswitch.connect(gui.CLICK, msc) table.td(gui.Label("Music")) table.td(musicswitch) sfxswitch = gui.Switch(menu.sfx) def ssc(): menu.sfx = not menu.sfx sfxswitch.connect(gui.CLICK, ssc) table.tr() table.td(gui.Label("SFX")) table.td(sfxswitch) gui.Dialog.__init__(self, title, table)
def create_attribute_field(ctx, solver, attribute): # create the control converter = attribute.converter name = attribute.name prop = attribute.prop default = attribute.default if converter == bool: field = gui.Switch(value=default) elif converter in (int, float, Decimal): field = gui.Input(value=default, size=10, align=1) else: field = gui.Input(value=default, size=10, align=-1) label = gui.Label(name) field.connect(gui.CHANGE, attr_changer, (ctx, solver, prop, field, converter)) return label, field
def buildMovers(self): focusedActor = self.script.controls['actor-group-focus'].value position = self.script.frames[0][focusedActor].position offscreen = type(position) is str positionButton = gui.Button(_("Move"), name='actor-button-move') positionButton.connect(gui.CLICK, self.changePositionAbsolutely) self.editablesDocumentRight.add(positionButton) self.editablesDocumentRight.add(gui.Label(_(" or start offscreen "))) positionSwitch = gui.Switch(value=offscreen, name='actor-switch-offscreen') positionSwitch.connect(gui.CLICK, self.changePosition) self.editablesDocumentRight.add(positionSwitch) self.spaceEditablesDocumentRight()
def __init__(self, n=None): main = gui.Table() gui.Dialog.__init__(self, gui.Label(lang.settings), main) liste = gui.List(200, 114) liste.value = themename themes = "themes" for dire in os.listdir(themes): liste.add(str(dire), value=dire) self.liste = liste liste = gui.Select() liste.value = cache["columns"] for x in (1, 2, 3, 4, 5): liste.add(str(x), value=x) self.columns = liste backupswitch = gui.Switch() backupswitch.value = cache["do_backup"] self.backup = backupswitch sizelist = gui.Select(value=thumbsize) sizelist.add(lang.none, 0) sizelist.add(lang.small, (420.0, 120.0)) sizelist.add(lang.medium, (630.0, 180.0)) sizelist.add(lang.large, (840.0, 240.0)) sizelist.add(lang.very_large, (1260.0, 360.0)) self.sizelist = sizelist main.td(gui.Label(lang.warning, color=(127, 0, 0)), colspan=2) main.tr() main.td(gui.Label(lang.theme_select)) main.td(gui.Label(lang.thumbsize)) main.tr() main.td(self.liste, rowspan=5) main.td(sizelist) main.tr() main.td(gui.Label(lang.world_columns), col=1, row=3) main.tr() main.td(self.columns, col=1, row=4) main.tr() main.td(gui.Label(lang.mk_backups), col=1, row=5) main.tr() main.td(backupswitch, col=1, row=6) self.open()
def __init__(self, disp): gui.Desktop.__init__(self) self.toggle_pause_btn = gui.Switch("Pause", height=50) # Setup the 'game' area where the action takes place self.gameArea = DrawingArea(disp.get_width(), self.gameAreaHeight) # Setup the gui area self.menuArea = gui.Container(height=disp.get_height() - self.gameAreaHeight) tbl = gui.Table(height=disp.get_height()) tbl.tr() tbl.td(self.gameArea) tbl.tr() tbl.td(self.menuArea) self.setup_menu() self.init(tbl, disp)
def __init__(self, noise_model, noise_value, rand_under): title = gui.Label("Simulation Preferences") ##Once a form is created, all the widgets that are added with a name ##are added to that form. ##:: self.value = gui.Form() self.noise = [0, 0, 5, 5] self.noise[noise_model] = noise_value self.prev_noise_model = noise_model t = gui.Table() t.tr() t.td(gui.Spacer(width=8, height=8)) t.tr() t.td(gui.Label("IR Sensor Noise", align=0)) t.tr() g = gui.Group(name="irnoise", value=noise_model) tt = gui.Table() g.connect(gui.CHANGE, self.switch_noise, (tt, g)) tt.tr() radio0 = gui.Radio(g, value=NO_NOISE) tt.td(radio0) tt.td(gui.Label(" None"), align=-1, width=300, colspan=3) tt.tr() radio2 = gui.Radio(g, value=SAMPLED_NOISE) tt.td(radio2) tt.td(gui.Label(" Sampled"), align=-1, width=300, colspan=3) tt.tr() radio3 = gui.Radio(g, value=GAUSSIAN_NOISE) tt.td(radio3) tt.td(gui.Label(" Gaussian"), align=-1) self.noise_slider1 = gui.HSlider(name="noise1", value=self.noise[GAUSSIAN_NOISE], min=1, max=9, size=20, width=80, height=16) self.noise_label1 = gui.Label("Noise Level " + str(self.noise_slider1.value)) self.noise_slider1.connect( gui.CHANGE, self.adjust_noise, (self.noise_slider1, self.noise_label1, GAUSSIAN_NOISE)) if noise_model == GAUSSIAN_NOISE: tt.add(self.noise_slider1, 2, 2) tt.add(self.noise_label1, 3, 2) tt.tr() radio4 = gui.Radio(g, value=ANGULAR_NOISE) tt.td(radio4) tt.td(gui.Label(" Angular"), align=-1) self.noise_slider2 = gui.HSlider(name="noise2", value=self.noise[ANGULAR_NOISE], min=1, max=9, size=20, width=80, height=16) self.noise_label2 = gui.Label("Noise Level " + str(self.noise_slider2.value)) self.noise_slider2.connect( gui.CHANGE, self.adjust_noise, (self.noise_slider2, self.noise_label2, ANGULAR_NOISE)) if noise_model == ANGULAR_NOISE: tt.add(self.noise_slider2, 2, 3) tt.add(self.noise_label2, 3, 3) t.td(tt, colspan=1) tt = gui.Table() tt.tr() tt.td(gui.Label("Extra Sensor Options"), colspan=2) tt.tr() tt.td(gui.Spacer(width=8, height=8)) tt.tr() tt.td(gui.Switch(name="randunder", value=rand_under)) tt.td(gui.Label(" Random under-reads")) tt.tr() tt.td(gui.Spacer(width=8, height=40)) t.td(tt, colspan=1) t.tr() t.td(gui.Spacer(width=8, height=8)) ##The okay button CLICK event is connected to the Dialog's ##send event method. It will send a gui.CHANGE event. ##:: t.tr() e = gui.Button("Okay") e.connect(gui.CLICK, self.send, gui.CHANGE) t.td(e) ## e = gui.Button("Cancel") e.connect(gui.CLICK, self.close, None) t.td(e) gui.Dialog.__init__(self, title, t)
def run(main=None): from omnitool.shared import lang, theme, exit_prog, __version__ from omnitool.pgu_override import Quitbutton pygame.display.init() pygame.display.set_caption("Planetoids & Terra Generator") if main == None: app = gui.Desktop(theme=theme) main = gui.Table() app.connect(gui.QUIT, exit_prog, None) else: main = gui.Table() app = gui.Dialog(gui.Label("Planetoids and Terra Generator"), main) main.td(gui.Label(lang.pt_name), align=-1) nameinput = gui.Input("Planetoids OT-V" + str(__version__), width=237) main.td(nameinput, colspan=2) main.tr() main.td(gui.Label(lang.pt_mode), align=-1) method = gui.Select(width=250) method.add(lang.pt_small, (1, 0)) method.add(lang.pt_medium, (2, 0)) method.add(lang.pt_large, (3, 0)) method.add(lang.pt_square, (4, 0)) method.add(lang.pt_both, (3, 1)) method.add(lang.pt_square_terra, (4, 2)) method.value = (3, 0) main.td(method, colspan=2) main.tr() main.td(gui.Label(lang.pt_start_sel), align=-1) time = gui.Select(width=250) time.add(lang.pt_morning, 2) time.add(lang.pt_day, 1) time.add(lang.pt_night, 3) time.add(lang.pt_bloodmoon, 4) time.value = 1 main.td(time, colspan=2) main.tr() main.td(gui.Spacer(1, 24)) main.tr() main.td(gui.Label(lang.pt_extras), align=-1, colspan=3) main.tr() main.td(gui.Label(lang.pt_sun), align=-1) darkness = gui.Switch() darkness.value = True main.td(darkness, colspan=2) main.tr() main.td(gui.Label(lang.pt_atlantis), align=-1) atlantis = gui.Switch() atlantis.value = False main.td(atlantis, colspan=2) main.tr() main.td(gui.Label(lang.pt_merchant), align=-1) merch = gui.Switch() merch.value = True main.td(merch, colspan=2) main.tr() main.td(gui.Label(lang.pt_lloot), align=-1) loot = gui.Switch() loot.value = False main.td(loot, colspan=2) main.tr() main.td(gui.Label("Hardmode:"), align=-1) hard = gui.Switch() hard.value = False main.td(hard, colspan=2) main.tr() main.td(gui.Label(lang.pt_mirror), align=-1) mirror = gui.Switch() mirror.value = False main.td(mirror, colspan=2) main.tr() # main.td(gui.Label(lang.pt_pre), align = -1) pre = gui.Switch() pre.value = False #main.td(pre, colspan = 2) #main.tr() main.td(gui.Spacer(1, 12)) main.tr() main.td(Quitbutton(app, lang.pt_start), colspan=3) main.tr() main.td(gui.Spacer(1, 12)) if app.__class__.__name__ == "Desktop": app.run(main) pygame.display.quit() return (nameinput.value, method.value, time.value, darkness.value, atlantis.value, merch.value, loot.value, hard.value, mirror.value, pre.value) else: app.open()
def __init__(self,**params): gui.Table.__init__(self,**params) def fullscreen_changed(btn): #pygame.display.toggle_fullscreen() print("TOGGLE FULLSCREEN") def stars_changed(slider): n = slider.value - len(stars) if n < 0: for i in range(n,0): stars.pop() else: for i in range(0,n): stars.append([random.randrange(-WIDTH*span,WIDTH*span), random.randrange(-HEIGHT*span,HEIGHT*span), random.randrange(1,dist)]) fg = (255,255,255) self.tr() self.td(gui.Label("Phil's Pygame GUI",color=fg),colspan=2) self.tr() self.td(gui.Label("Speed: ",color=fg),align=1) e = gui.HSlider(100,-500,500,size=20,width=100,height=16,name='speed') self.td(e) self.tr() self.td(gui.Label("Size: ",color=fg),align=1) e = gui.HSlider(2,1,5,size=20,width=100,height=16,name='size') self.td(e) self.tr() self.td(gui.Label("Quantity: ",color=fg),align=1) e = gui.HSlider(100,1,1000,size=20,width=100,height=16,name='quantity') e.connect(gui.CHANGE, stars_changed, e) self.td(e) self.tr() self.td(gui.Label("Color: ",color=fg),align=1) default = "#ffffff" color = gui.Color(default,width=64,height=10,name='color') color_d = ColorDialog(default) color.connect(gui.CLICK,color_d.open,None) self.td(color) def update_col(): color.value = color_d.value color_d.connect(gui.CHANGE,update_col) btn = gui.Switch(value=False,name='fullscreen') btn.connect(gui.CHANGE, fullscreen_changed, btn) self.tr() self.td(gui.Label("Full Screen: ",color=fg),align=1) self.td(btn) self.tr() self.td(gui.Label("Warp Speed: ",color=fg),align=1) self.td(gui.Switch(value=False,name='warp'))
def init_app(): global app app = _app() # colors_height = 64 ss = 8 #--- top x, y, h = 0, 0, 0 #menus e = gui.Menus(menus) e.rect.w, e.rect.h = e.resize() app.add(e, x, y) x, h = x + e.rect.w, max(h, e.rect.h) menus_height = e.rect.h #--- row x, y, h = 0, y + h, 0 #--- vspace y += ss #--- hspace x += ss #tools e = gui.Toolbox(tools, 1, 0, value='draw') #,"icons48") e.rect.w, e.rect.h = e.resize() def _set_mode(value): cmd_mode(value.value) e.connect(gui.CHANGE, _set_mode, e) app.add(e, x, y) #--- vspace y += ss #--- switchbox for saving. sx, sy = x, y + (max(h, e.rect.h)) savelabel = gui.Label("Save on") app.add(savelabel, sx, sy) savelabel2 = gui.Label("focus:") app.add(savelabel2, sx, sy + (ss * 2)) #--- vspace y += (ss * 5) sy += (ss * 5) save_activeevent_switch = gui.Switch(False) app.add(save_activeevent_switch, sx, sy) app.save_activeevent_switch = save_activeevent_switch x, h = x + e.rect.w, max(h, e.rect.h) toolbox_width = e.rect.w #--- hspace x += ss y -= ss * 6 #undo what was done above to the y val #tdraw #tdraw-calcs dw = app.screen_w - (toolbox_width + app.tiles.get_width() + ss * 4) dh = app.screen_h - (menus_height + colors_height + ss * 2) if dw / float(app.tile_w) > dh / float(app.tile_h): dw = dh / float(app.tile_h) * app.tile_w else: dh = dw / float(app.tile_w) * app.tile_h e = app.tdraw = tdraw(dw, dh) app.add(e, x, y) x, h = x + e.rect.w, max(h, e.rect.h) #--- hspace x += ss #tpicker e = app.tpicker = tpicker() e.rect.w, e.rect.h = e.resize() #--- right x = app.screen_w - e.rect.w - ss app.add(e, x, y) h = max(h, e.rect.h) #tpreview y = y + e.rect.h e = app.tpreview = tpreview() e.rect.w, e.rect.h = e.resize() app.add(e, x, y) #--- bottom x, y, h = 0, app.screen_h - colors_height, 0 #cpreview colors_width = toolbox_width + ss * 2 e = app.cpreview = cpreview(colors_width, colors_height) e.rect.w, e.rect.h = e.resize() app.add(e, x, y) x, h = x + e.rect.w, max(h, e.rect.h) #cpicker if os.path.isfile(cfg['palette']): pal = pygame.image.load(cfg['palette']) else: #default to EGA / NES palette pw, ph = 16, 6 pdata = [ (0, 0, 0, 255), (0, 0, 170, 255), (0, 170, 0, 255), (0, 170, 170, 255), (170, 0, 0, 255), (170, 0, 170, 255), (170, 85, 0, 255), (170, 170, 170, 255), (85, 85, 85, 255), (85, 85, 255, 255), (85, 255, 85, 255), (85, 255, 255, 255), (255, 85, 85, 255), (255, 85, 255, 255), (255, 255, 85, 255), (255, 255, 255, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255), (255, 255, 255, 255), (173, 243, 255, 255), (223, 214, 255, 255), (255, 190, 255, 255), (255, 176, 255, 255), (255, 177, 237, 255), (255, 191, 185, 255), (255, 217, 145, 255), (237, 246, 128, 255), (185, 255, 138, 255), (145, 255, 173, 255), (128, 255, 223, 255), (138, 255, 255, 255), (197, 197, 197, 255), (0, 0, 0, 255), (0, 0, 0, 255), (255, 255, 255, 255), (129, 200, 255, 255), (179, 171, 255, 255), (231, 146, 255, 255), (255, 132, 244, 255), (255, 133, 194, 255), (255, 148, 141, 255), (244, 173, 101, 255), (194, 202, 84, 255), (141, 227, 94, 255), (101, 240, 129, 255), (84, 240, 179, 255), (94, 225, 231, 255), (120, 120, 120, 255), (0, 0, 0, 255), (0, 0, 0, 255), (192, 192, 192, 255), (57, 128, 200, 255), (108, 99, 217, 255), (160, 74, 207, 255), (200, 61, 172, 255), (217, 61, 122, 255), (207, 76, 70, 255), (172, 102, 30, 255), (122, 130, 13, 255), (70, 155, 23, 255), (30, 169, 57, 255), (13, 168, 108, 255), (23, 153, 160, 255), (61, 61, 61, 255), (0, 0, 0, 255), (0, 0, 0, 255), (128, 128, 128, 255), (16, 87, 159, 255), (67, 58, 176, 255), (119, 34, 166, 255), (159, 20, 131, 255), (176, 20, 81, 255), (166, 35, 29, 255), (131, 61, 0, 255), (81, 89, 0, 255), (29, 114, 0, 255), (0, 128, 16, 255), (0, 127, 67, 255), (0, 112, 119, 255), (0, 0, 0, 255), (0, 0, 0, 255), (0, 0, 0, 255) ] pal = pygame.Surface((pw, ph), SWSURFACE, 32) n = 0 for py in range(0, ph): for px in range(0, pw): pal.set_at((px, py), pdata[n]) n += 1 e = app.cpicker = cpicker(app.screen_w - colors_width, colors_height, pal) e.rect.w, e.rect.h = e.resize() app.add(e, x, y) x, h = x + e.rect.w, max(h, e.rect.h) pygame.key.set_repeat(500, 30) app.screen.fill((255, 255, 255, 255))
font=font_normal, color=(230, 230, 230)) select_midi = pgui.Select(width=180, height=20) select_midi_fill(select_midi) select_midi.connect(pgui.CHANGE, on_select_midi) def on_switch_midi(_widget): global play_midi if (_widget.value): print 'Play MIDI on' play_midi = 1 else: print 'Play MIDI off' play_midi = 0 switch_midi = pgui.Switch() switch_midi.connect(pgui.CHANGE, on_switch_midi) if play_midi: switch_midi.value = 1 gui_cnt.add(select_midi_label, W - 30 - 630, 25 + 3) gui_cnt.add(switch_midi, W - 30 - 555, 25 + 3) gui_cnt.add(select_midi, W - 30 - 530, 25) # ---- Trommelbold serial out select box ------------------------------ def on_select_trbold_change(_widget): seq_stop() if _widget.value != 'None': print 'Select Trommelbold on port', _widget.value trbold.open(_widget.value) else:
def _buildSltCb(tt): slt = gui.Select() tt.td(slt) chkbox = gui.Switch() tt.td(chkbox) return (slt, chkbox)
def cb(): print("Clicked!") btn = gui.Button("Click Me!") btn.connect(gui.CLICK, cb) c.tr() c.td(gui.Label("Button")) c.td(btn, colspan=3) ## c.tr() c.td(gui.Label("Switch")) c.td(gui.Switch(False), colspan=3) c.tr() c.td(gui.Label("Checkbox")) ##Note how Groups are used for Radio buttons, Checkboxes, and Tools. ##:: g = gui.Group(value=[1, 3]) c.td(gui.Checkbox(g, value=1)) c.td(gui.Checkbox(g, value=2)) c.td(gui.Checkbox(g, value=3)) ## c.tr() c.td(gui.Label("Radio")) g = gui.Group() c.td(gui.Radio(g, value=1))
def __init__(self, settings, **params): # The framework GUI is just basically a HTML-like table. # There are 2 columns, and basically everything is right-aligned. gui.Table.__init__(self, **params) self.form = gui.Form() fg = (255, 255, 255) fg = (127, 127, 127) # "Hertz" self.tr() self.td(gui.Label("F1: Toggle Menu", color=(255, 0, 0)), align=1, colspan=2) self.tr() self.td(gui.Label("Hertz", color=fg), align=1, colspan=2) # Hertz slider self.tr() e = gui.HSlider(settings.hz, 5, 200, size=20, width=100, height=16, name='hz') self.td(e, colspan=2, align=1) # "Vel Iters" self.tr() self.td(gui.Label("Vel Iters", color=fg), align=1, colspan=2) # Velocity Iterations slider (min 1, max 500) self.tr() e = gui.HSlider(settings.velocityIterations, 1, 500, size=20, width=100, height=16, name='velIters') self.td(e, colspan=2, align=1) # "Pos Iters" self.tr() self.td(gui.Label("Pos Iters", color=fg), align=1, colspan=2) # Position Iterations slider (min 0, max 100) self.tr() e = gui.HSlider(settings.positionIterations, 0, 100, size=20, width=100, height=16, name='posIters') self.td(e, colspan=2, align=1) settings.slowMotion = 1.0 # Add each of the checkboxes. for text, variable in self.checkboxes: self.tr() if variable == None: # Checkboxes that have no variable (i.e., None) are just labels. self.td(gui.Label(text, color=fg), align=1, colspan=2) else: # Add the label and then the switch/checkbox self.td(gui.Label(text, color=fg), align=1) self.td( gui.Switch(value=getattr(settings, variable), name=variable))
def _create_show_grid_lines_checkbox(self): field = gui.Switch() label = gui.Label('Show grid lines?') field.connect(gui.CHANGE, self._on_show_grid_lines_change, field) return label, field
def setup_menu(this): global NewNx global NewNy NewNx = Visualize.Nx NewNy = Visualize.Ny #--------------------------- ACCURACY tbl = gui.Table(vpadding=2, hpadding=1) def open_file_browser(arg): d = gui.FileDialog() d.connect(gui.CHANGE, handle_file_browser_closed, d) d.open() def handle_file_browser_closed(dlg): if dlg.value: input_file.value = dlg.value global airfoil airfoil = dlg.value td_style = {'padding_right': 10} t = gui.Table() t.tr() t.td(gui.Label('Airfoil'), style=td_style) input_file = gui.Input() t.td(input_file, style=td_style) b = gui.Button("Browse...") t.td(b, style=td_style) b.connect(gui.CLICK, open_file_browser, None) tbl.add(t) #----------------------row 1 tbl1 = gui.Table(vpadding=2, hpadding=1) timeLabel2 = gui.Label("Accuracy") tbl1.td(timeLabel2) slider3 = gui.HSlider(1, min=1, max=2, size=20, height=16, width=120) def update_accuracy(): global NewNx global NewNy if slider3.value == 1: NewNx = 30 NewNy = 10 if slider3.value == 2: NewNx = 60 NewNy = 20 slider3.connect(gui.CHANGE, update_accuracy) tbl1.td(slider3) #---------------------------------------alpha timeLabel2 = gui.Label("Alpha") tbl1.td(timeLabel2) slider2 = gui.HSlider(value=Visualize.alpha, min=-10, max=10, size=20, height=16, width=120) def update_alpha(): Visualize.alpha = slider2.value slider2.connect(gui.CHANGE, update_alpha) tbl1.td(slider2) #--------------------------------------- def recompute_cb(): global airfoil global NewNx global NewNy Visualize.rebuild(NewNx, NewNy, Visualize.N, Visualize.alpha, airfoil) btn = gui.Button("Recompute flow", height=25) tbl1.td(btn) btn.connect(gui.CLICK, recompute_cb) #---------------------------------------gamepause tbl.add(tbl1) tbl.tr() #------------------------row2 def pause_cb(): if (this.engine.clock.paused): this.engine.resume() else: this.engine.pause() #---------------------------------------gamespeed tbl2 = gui.Table(vpadding=2, hpadding=1) timeLabel = gui.Label("Playback speed") tbl2.td(timeLabel) slider = gui.HSlider(value=1, min=1, max=100, size=20, height=16, width=120) def update_speed(): this.engine.clock.set_speed((slider.value / 5) * 3) slider.connect(gui.CHANGE, update_speed) tbl2.td(slider) #-------button speed btn = gui.Button("Toggle normal speed", height=25) btn.connect(gui.CLICK, pause_cb) tbl2.td(btn) tbl2.tr() #---------------------------------------particles timeLabel3 = gui.Label("N particles") tbl2.td(timeLabel3) slider4 = gui.HSlider(Visualize.number_of_particles, min=1, max=14, size=20, height=16, width=120) def update_particles(): Visualize.number_of_particles = slider4.value slider4.connect(gui.CHANGE, update_particles) tbl2.td(slider4) tbl2.tr() def gridswitch_changed(switch): if switch.value: Visualize.tunnel = True else: Visualize.tunnel = False gridswitch = gui.Switch(value=False, name='warp') gridswitch.connect(gui.CHANGE, gridswitch_changed, gridswitch) tbl2.td(gui.Label("New top secret wind tunnel:"), align=1) tbl2.td(gridswitch) tbl.add(tbl2) #---------------------row 3 #---------------------------------------about tbl3 = gui.Table() dlg = AboutDialog() def about_cb(): dlg.open() btn = gui.Button("About", height=5) tbl3.td(btn) btn.connect(gui.CLICK, about_cb) #tbl3.tr() tbl3.td( gui.Label("Hint: Press and hold mouse button to spray particles!", align=1, colspan=2)) tbl.td(tbl3) this.menuArea.add(tbl, 10, 0)
def make_gui(): global pb, font, textArea, lines font = pygame.font.SysFont("default", 18) fontBig = pygame.font.SysFont("default", 24) fontSub = pygame.font.SysFont("default", 20) theme = pgui.Theme('test_theme') # create GUI object gui = pgui.App(theme=theme) textArea = pygame.Rect(390, 20, 250, 320) # layout using document lo = pgui.Container(width=screenSize[0]) # create page label # lo.block(align=-1) #lo.br(8) #lo.tr() title = pgui.Label("Pygame GUI Test Page - PGU", font=fontBig) lo.add(title, 29, 13) # create progress bar label # progress bar pbl = pgui.Label('Progress Bar') lo.add(pbl, 354, 351) pb = pgui.ProgressBar(10, 0, 100, width=200) lo.add(pb, 354, 371) # create checkbuttons and add to gui cbt = pgui.Table() cb1 = pgui.Switch() cb1.connect(pgui.CHANGE, logCheckAction, (cb1, "Check Box 1")) cb1l = pgui.Label("Check Box 1") cbt.add(cb1) cbt.add(cb1l) cbt.tr() cb2 = pgui.Switch() cb2.connect(pgui.CHANGE, logCheckAction, (cb2, "Check Box 2")) cb2l = pgui.Label("Check Box 2") cbt.add(cb2) cbt.add(cb2l) cbt.tr() cb3 = pgui.Switch() cb3.connect(pgui.CHANGE, logCheckAction, (cb3, "Check Box 3")) cb3l = pgui.Label("Check Box 3") cbt.add(cb3) cbt.add(cb3l) lo.add(cbt, 52, 52) # create radio buttons, put in table, and add to gui rbt = pgui.Table() radio = pgui.Group() rb1 = pgui.Radio(radio, 1) rb1l = pgui.Label("Radio Button 1") rbt.add(rb1) rbt.add(rb1l) rbt.tr() rb2 = pgui.Radio(radio, 2) rb2l = pgui.Label("Radio Button 2") rbt.add(rb2) rbt.add(rb2l) rbt.tr() rb3 = pgui.Radio(radio, 3) rb3l = pgui.Label("Radio Button 3") rbt.add(rb3) rbt.add(rb3l) rbt.tr() lo.add(rbt, 210, 52) radio.connect(pgui.CHANGE, logRadioAction, (radio, "Radio Button 3")) # create txt box label txtl = pgui.Label("Text Box", font=fontSub) lo.add(txtl, 30, 127) # create text box txt = pgui.Input("next line of input", size=40) txt.connect(pgui.BLUR, logInputAction, txt) lo.add(txt, 28, 149) # add buttons, both regular and toggle btn1 = pgui.Button("Button 1") btn1.connect(pgui.CLICK, logButtonAction, ("Button 1 clicked")) lo.add(btn1, 36, 250) btn2 = pgui.Button("Button 2") btn2.connect(pgui.CLICK, logButtonAction, ("Button 2 clicked")) lo.add(btn2, 133, 250) btn3 = pgui.Button("Button 3") btn3.connect(pgui.CLICK, logButtonAction, ("Button 3 clicked")) lo.add(btn3, 230, 250) # create toggle button not avail label tbl = pgui.Label("Toggle Buttons Not Supported") lo.add(tbl, 36, 290) img = pgui.Image("clear.png") img.connect(pgui.CLICK, logImg) # iml = pgui.Label("Image Map Not Supported") lo.add(img, 36, 340) # create slider label sll = pgui.Label("Slider", font=fontSub) lo.add(sll, 36, 195) # create slider sl = pgui.HSlider(value=1, min=0, max=100, size=32, width=200, height=16) sl.connect(pgui.CHANGE, logSliderAction, sl) lo.add(sl, 53, 210) # , colspan=3) # make some insensitive btn2.disabled = True cb3.disabled = True # clear setup noise, and put initial content in lines = [] lines.append('top line of input') lines.append('second line of input') progBar(pb, lines) # update progress bar for above two items gui.init(lo) return gui
def gen_gui(self): from omnitool.shared import theme, lang, exit_prog from omnitool.pgu_override import Quitbutton pygame.display.init() pygame.display.set_caption("Maze World Generator") app = gui.Desktop(theme=theme) main = gui.Table(width=800) app.connect(gui.QUIT, exit_prog, None) main.td(gui.Label("Maze Blocks: ")) tileFrom = gui.List(300, 150) for tile in db.tiles: if db.tiles.index(tile) not in db.multitiles and db.tiles.index( tile) in clib.data: tileFrom.add(gui.Label(tile), value=db.tiles.index(tile)) main.td(tileFrom) # main.td(gui.Label("Light up maze?")) # polkaDotButton = (gui.Switch(False)) # main.td(polkaDotButton) main.tr() main.td(gui.Label("Maze BackWalls: ")) tileInto = gui.List(300, 150) for wall in db.walls: if db.walls.index(wall) in clib.walldata: tileInto.add(gui.Label(wall), value=db.walls.index(wall)) main.td(tileInto) # main.td(gui.Label("View generation?")) viewGenButton = (gui.Switch(False)) # main.td(viewGenButton) main.tr() main.td(gui.Label("World Size: ")) size = gui.List(110, 50) size.add("Tiny", value=3) size.add("Small", value=0) size.add("Medium", value=1) size.add("Large", value=2) main.td(size) main.td(gui.Label("Complexity: ")) scale = gui.List(110, 50) scale.add("Insane", value=3) scale.add("Medium", value=6) scale.add("Easy", value=9) main.td(scale) main.tr() main.td(Quitbutton(app, lang.pt_start), colspan=4) app.run(main) pygame.display.quit() self.tileFrom = clib.data[tileFrom.value] self.tileInto = clib.walldata[tileInto.value] self.size2 = size.value self.scale2 = scale.value self.viewGen = viewGenButton.value
def __init__(self, pSize, pApp, pDefCfg): tbl = gui.Table(width=pSize['w'], height=pSize['c_h']) ## tilt g = gui.Group() tbl2 = gui.Table() tbl2.tr() tbl2.td(gui.Label(_('Tilt / Z Correction')), colspan=2) tbl2.tr() tbl2.td(gui.Radio(g, value='off')) tbl2.td(gui.Label(_('Off'))) tbl2.tr() tbl2.td(gui.Radio(g, value='intelligent')) tbl2.td(gui.Label(_('Intelligent'))) tbl2.tr() tbl2.td(gui.Radio(g, value='continuous')) tbl2.td(gui.Label(_('Continuous'))) self.tiltGrp = g tiltTbl = gui.Table(width=pSize['w']/5) tiltTbl.tr() tiltTbl.td(tbl2, style={'border':1}) ## recoil recoilTbl = gui.Table(width=pSize['w']/3) recoilTbl.tr() recoilTbl.td(gui.Label(_('Recoil'))) self.recoilSl = gui.HSlider(value=0, min=0, max=250, size=25, step=10, width=pSize['s_w'], height=pSize['s_h']) recoilTbl.td(self.recoilSl) button = gui.Button(_('Test')) button.connect(gui.CLICK, pApp.recoil, None) self._testBtn = button recoilTbl.td(button) ## IR gain irTbl = gui.Table(width=pSize['w']/3) irTbl.tr() irTbl.td(gui.Label(_('IR Gain'))) self.irGainSl = gui.HSlider(value=1, min=1, max=5, size=10, width=pSize['s_w'], height=pSize['s_h']) irTbl.td(self.irGainSl) txt = gui.Input(size=5) self.irGainSl.connect(gui.CHANGE, _slChange, (self.irGainSl, txt)) txt.focusable = False self.irGainSl.send(gui.CHANGE) irTbl.td(txt) ### disable auto gain irTbl.tr() irTbl.td(gui.Spacer(10,5)) irTbl.tr() chkbox = gui.Switch() chkbox.connect(gui.CLICK, _ckbClicked, (chkbox, self.irGainSl)) irTbl.td(chkbox) irTbl.td(gui.Label(_('Disable Auto Gain')), colspan=2, align=-1) self.autoGainSw = chkbox ## device ID devTbl = gui.Table(width=pSize['w']/4) devTbl.tr() devTbl.td(gui.Label(_('Device ID:'))) self.devIdSlt = gui.Select() for x in xrange(0x1601,0x1609): self.devIdSlt.add('0x%x' % x, x) devTbl.td(self.devIdSlt) ## button assignments btnTbl = gui.Table() btnTbl.tr() btnTbl.td(gui.Label(_('Button Assignments')), colspan=5) btnTbl.tr() btnTbl.td(gui.Spacer(20,20)) btnTbl.tr() btnTbl.td(gui.Label("")) btnTbl.td(gui.Label(_('On Screen')+" ")) btnTbl.td(gui.Label(_('Enable Cal')+" ")) btnTbl.td(gui.Label(_('Off Screen')+" ")) btnTbl.td(gui.Label(_('Enable Cal')+" ")) btnTbl.tr() btnTbl.td(gui.Spacer(10,5)) ### TRIG btnTbl.tr() btnTbl.td(gui.Label(_('TRIG')+" ")) self.onActTrigSlt, self.onCalTrigCb = _buildSltCb(btnTbl) self.offActTrigSlt, self.offCalTrigCb = _buildSltCb(btnTbl) ### LEFT btnTbl.tr() btnTbl.td(gui.Label(_('LEFT')+" ")) self.onActLeftSlt, self.onCalLeftCb = _buildSltCb(btnTbl) self.offActLeftSlt, self.offCalLeftCb = _buildSltCb(btnTbl) ### RIGHT btnTbl.tr() btnTbl.td(gui.Label(_('RIGHT')+" ")) self.onActRightSlt, self.onCalRightCb = _buildSltCb(btnTbl) self.offActRightSlt, self.offCalRightCb = _buildSltCb(btnTbl) ## Cal Delay calTbl = gui.Table(width=pSize['w']/4) calTbl.tr() calTbl.td(gui.Label(_('Cal Delay (Secs)'))) self.calDlSl = gui.HSlider(value="3", min=3, max=10, size=10, width=pSize['s_w'], height=pSize['s_h']) calTbl.td(gui.Spacer(10,5)) calTbl.td(self.calDlSl) txt = gui.Input(size=5) self.calDlSl.connect(gui.CHANGE, _slChange, (self.calDlSl, txt)) txt.focusable = False self.calDlSl.send(gui.CHANGE) calTbl.td(gui.Spacer(10,5)) calTbl.td(txt) ## joystick / mouse self.mjGrp = gui.Group() jtkTbl = gui.Table(width=pSize['w']/3) jtkTbl.tr() rad = gui.Radio(self.mjGrp, value='joystick') rad.connect(gui.CLICK, self._changeDevType, True) jtkTbl.td(rad) jtkTbl.td(gui.Label(_('Emulate Joystick'))) rad = gui.Radio(self.mjGrp, value='mouse') rad.connect(gui.CLICK, self._changeDevType, False) jtkTbl.td(rad) jtkTbl.td(gui.Label(_('Emulate Mouse'))) self._curSel = None ## button save saveBtn = gui.Button(_('Save Configuration')) saveBtn.connect(gui.CLICK, pApp.save, None) self._saveBtn = saveBtn dcntBtn = gui.Button(_('Disconnect')) dcntBtn.connect(gui.CLICK, pApp.disconnect, None) ## button set defaults defBtn = gui.Button(_('Set Defaults')) defBtn.connect(gui.CLICK, self.setConfig, pDefCfg) # assemble window tbl.tr() tbl.td(tiltTbl) tbl.td(btnTbl) tbl.tr() tbl.td(recoilTbl) tbl.td(calTbl) tbl.tr() tbl.td(irTbl) tbl.td(jtkTbl) tbl.tr() tbl.td(devTbl) tbl.tr() tbl.td(defBtn) tbl.td(saveBtn) tbl.tr() tbl.td(dcntBtn, colspan=2) # Configuration self.widget = tbl
def GuiSetup(): global app global MotorMin, MotorMax global LSlider, RSlider, FSlider, ASlider global speedLbl, depLbl, preLbl, depInput global pSwitch, Pbox, Ibox, Dbox app = gui.Desktop() app.connect(gui.QUIT, app.quit, None) Main = gui.Table(width=900) Main.tr() # c.tr() makes a row # c.td(component) creates a cell # Top panel for displaying network status and emergancy options n = gui.Table() n.tr() n.td(gui.Label("Network: Status"), height=40) n.td(gui.Label(" ")) emergeButton = gui.Button("In Case of Emergency") emergeButton.connect(gui.CLICK, emergeClick) n.td(emergeButton) #Make sub tabels to be put into c that hold seperate elements. #tabel on the "west" side of the frame. w = gui.Table() w.tr() #Radio button group w.tr() w1 = gui.Table() w1.tr() w1.td(gui.Label("PID Controls"), colspan=5, height=50) w1.tr() pidSwitch = gui.Switch(value=False) pidSwitch.connect(gui.CLICK, arm_disarm_Component, 0) w1.td(pidSwitch) w1.td(gui.Label("Arm ")) w1.td(gui.Label(""), width=95, height=30) pidButton1 = gui.Button("Hover") pidButton1.connect(gui.CLICK, pidHover) w1.td(pidButton1, align=1) w.td(w1, align=-1) w.tr() w2 = gui.Table() w2.tr() depInput = gui.Input(size=6) w2.td(depInput, align=-1) w2.td(gui.Label("m "), align=-1, width=30, height=30) pidButton2 = gui.Button("Go to depth") pidButton2.connect(gui.CLICK, pidGoDepth) w2.td(pidButton2, align=1) w.td(w2, align=-1) #Sliders to control coeficients w.tr() w3 = gui.Table() #P w3.tr() #w3.td(gui.Label("Stable ")) Pbox = gui.Input(value="0", height=16, width=120) w3.td(Pbox) w3.td(gui.Label(" Quick"), align=-1) #I w3.tr() #w3.td(gui.Label("Stable ")) Ibox = gui.Input(value="0", height=16, width=120) w3.td(Ibox) w3.td(gui.Label(" Accurate"), align=-1) #D w3.tr() #w3.td(gui.Label("Cautious ")) Dbox = gui.Input(value="0", height=16, width=120) w3.td(Dbox) w3.td(gui.Label(" Responsive"), align=-1) w.td(w3, align=-1) #Restore PID defaults button w.tr() w4 = gui.Table() w4.tr() pidButton3 = gui.Button("Restore PID Defaults") pidButton3.connect(gui.CLICK, pidDefault) w4.td(pidButton3, valign=1) w4.td(gui.Label(""), height=30) ## w4.tr() ## pidButton4 = gui.Button("Auto-Calibrate") ## pidButton4.connect(gui.CLICK, pidCalibrate) ## w4.td(pidButton4) ## w4.td(gui.Label(""), height = 30) w.td(w4, align=-1) #Second panel under top panel for depth, pressure, and subsytems label w.tr() w5 = gui.Table() w5.tr() w5.td(gui.Label("Depth "), height=30, align=-1) depLbl = gui.Input("0", size=6) w5.td(depLbl, align=1) w5.td(gui.Label(" m")) w5.tr() w5.td(gui.Label("Pressure "), align=-1) preLbl = gui.Input("0", size=6) w5.td(preLbl, align=1) w5.td(gui.Label(" kPa")) w.td(w5, align=-1) #Soleniod controls w.tr() w.td(gui.Label("Solenoid Controls "), height=30, align=-1) w.tr() w6 = gui.Table() w6.tr() sol0 = gui.Switch(false) sol0.connect(gui.CLICK, fireSol, 0) w6.td(sol0) sol1 = gui.Switch(false) sol1.connect(gui.CLICK, fireSol, 1) w6.td(sol1) sol2 = gui.Switch(false) sol2.connect(gui.CLICK, fireSol, 2) w6.td(sol2) sol3 = gui.Switch(false) sol3.connect(gui.CLICK, fireSol, 3) w6.td(sol3) sol4 = gui.Switch(false) sol4.connect(gui.CLICK, fireSol, 4) w6.td(sol4) sol5 = gui.Switch(false) sol5.connect(gui.CLICK, fireSol, 5) w6.td(sol5) sol6 = gui.Switch(false) sol6.connect(gui.CLICK, fireSol, 6) w6.td(sol6) sol7 = gui.Switch(false) sol7.connect(gui.CLICK, fireSol, 7) w6.td(sol7) sol8 = gui.Switch(false) sol8.connect(gui.CLICK, fireSol, 8) w6.td(sol8) sol9 = gui.Switch(false) sol9.connect(gui.CLICK, fireSol, 9) w6.td(sol9) w.td(w6, align=0) w.tr() w.td(gui.Label("0 1 2 3 4 5 6 7 8 9"), height=30, align=0) # Center tabel that holds all the navigation data. c = gui.Table() #verticle sliders for motor bars and space for surface. c.tr() c1 = gui.Table() c1.tr() LSlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) RSlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) FSlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) ASlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) c1.td(LSlider, width=20, valign=1) c1.td(RSlider, width=20, valign=1) c1.td(gui.Label(" Surface "), height=180, width=240) c1.td(FSlider, width=20, valign=1) c1.td(ASlider, width=20, valign=1) c1.tr() c1.td(gui.Label("L")) c1.td(gui.Label("R")) c1.td(gui.Label("")) c1.td(gui.Label("F")) c1.td(gui.Label("A")) c.td(c1) # Motor duty cycle bar. c.tr() c2 = gui.Table() c2.tr() c2.td(gui.Label(" Motor Duty Cycle "), height=50, colspan=3, valign=1) c2.tr() c2.td(gui.Label("0 "), height=30) MotormaxS = gui.HSlider(value=25, min=0, max=127, size=20, height=16, width=120) MotormaxS.connect(gui.CHANGE, setMotorMax, MotormaxS) c2.td(MotormaxS) c2.td(gui.Label(" 100")) c.td(c2) #motor configuration graphic c.tr() c3 = gui.Table() c3.tr() c3.td(gui.Label(""), height=30) c3.tr() c3.td(gui.Label(" Motor Configuration ")) c3.tr() c3.td(gui.Label(" Surface "), height=150, width=150) c3.tr() c3.td(gui.Label(""), height=30) c.td(c3) #Radio Buttons for controling pitch and button for speed cycle. c.tr() c4 = gui.Table() c4.tr() pSwitch = gui.Switch(value=False) pSwitch.connect(gui.CLICK, arm_disarm_Component, 4) c4.td(pSwitch) c4.td(gui.Label("Pitch on")) c4.td(gui.Label(" ")) spdCycButton = gui.Button("Speed Cycle") spdCycButton.connect(gui.CLICK, speedCycle) c4.td(spdCycButton) c4.tr() speedLbl = gui.Input("1/1", size=4, align=1) c4.td(speedLbl, colspan=4, align=1) c.td(c4) # East tabel for hold all the subsystems functions. e = gui.Table(width=200) e.tr() e.td(gui.Label(" Subsystems "), height=50) e.tr() sysSelectGroup = gui.Group(value=0) disarmRadio = gui.Radio(sysSelectGroup, value=0) disarmRadio.connect(gui.CLICK, arm_disarm_Component, 5) e0 = gui.Table() e0.tr() e0.td(disarmRadio, width=20) e0.td(gui.Label("Disarm All")) e.td(e0) # Critter Getter functions. e.tr() e1 = gui.Table() e1.tr() e1a = gui.Table() e1a.tr() e1a.td(gui.Label("Critter Getter"), height=29, align=-1) e1a.td(gui.Label(), width=30) cgRadio = gui.Radio(sysSelectGroup, value=1) cgRadio.connect(gui.CLICK, arm_disarm_Component, 1) e1a.td(cgRadio) e1a.td(gui.Label("Arm ")) e1a.td(gui.Label(""), height=29, width=20) e1.td(e1a, align=-1) e1.tr() e1b = gui.Table() e1b.tr() e1b.td(gui.Label("Status: "), height=29, align=-1) critLbl = gui.Input(size=15) e1b.td(critLbl) e1.td(e1b, align=-1) e1.tr() e1b = gui.Table() e1b.tr() cgButton1 = gui.Button("Flush") cgButton2 = gui.Button("Extend") cgButton1.connect(gui.CLICK, operateWC, 1) cgButton2.connect(gui.CLICK, operateWC, 2) e1b.td(cgButton1) e1b.td(gui.Label(""), height=29) e1b.td(cgButton2) e1.td(e1b, align=-1) e.td(e1, height=120, align=-1) #Water Collecter functions. e.tr() e2 = gui.Table() e2.tr() e2a = gui.Table() e2a.tr() e2a.td(gui.Label("Water Collecter"), height=29, align=-1) e2a.td(gui.Label(), width=30) wcRadio = gui.Radio(sysSelectGroup, value=2) wcRadio.connect(gui.CLICK, arm_disarm_Component, 2) e2a.td(wcRadio) e2a.td(gui.Label("Arm ")) e2a.td(gui.Label(""), height=29, width=20) e2.td(e2a, align=-1) e2.tr() e2b = gui.Table() e2b.tr() e2b.td(gui.Label("Status: "), height=29, align=-1) wcLbl = gui.Input(size=15) e2b.td(wcLbl) e2.td(e2b, align=-1) e2.tr() e2c = gui.Table() e2c.tr() wcButton = gui.Button("Operate") e2c.td(wcButton, height=29) e2.td(e2c, align=-1) e.td(e2, height=120, align=-1) #Cap and trade functions. e.tr() e3 = gui.Table() e3.tr() #CandTarm_disarm = gui.Group(value = 2) e3a = gui.Table() e3a.tr() e3a.td(gui.Label("Cap and Trade"), height=29, align=-1) e3a.td(gui.Label(), width=30) ctRadio = gui.Radio(sysSelectGroup, value=3) ctRadio.connect(gui.CLICK, arm_disarm_Component, 3) e3a.td(ctRadio) e3a.td(gui.Label("Arm ")) e3a.td(gui.Label(""), height=29, width=20) e3.td(e3a, align=-1) e3.tr() e3b = gui.Table() e3b.tr() e3b.td(gui.Label("Status: "), height=29, align=-1) ctLbl = gui.Input(size=15) e3b.td(ctLbl) e3.td(e3b, align=-1) e3.tr() ctButton1 = gui.Button("Operate") e3.td(ctButton1, height=29, align=-1) e.td(e3, height=120, align=-1) #put it together. Main.tr() Main.td(n, colspan=3) Main.tr() Main.td(gui.Label(""), height=30) Main.tr() Main.td(w, valign=-1) Main.td(c, valign=-1) Main.td(e, valign=-1) Main.tr() Main.td(gui.Label(""), height=30) app.init(Main) #Main is main tabel.
def draw_gui_kinect(title, index, lo, x, y): title = gui.Label(title, font=fontBig) lo.add(title, x, y) w = widgets[index] radio_device_table = gui.Table() w['radio_device_group'] = gui.Group() w['radio_device_eras1'] = gui.Radio(w['radio_device_group'], 1) w['radio_device_eras2'] = gui.Radio(w['radio_device_group'], 2) w['radio_device_eras3'] = gui.Radio(w['radio_device_group'], 3) w['radio_device_eras4'] = gui.Radio(w['radio_device_group'], 4) w['radio_device_group'].connect(gui.CHANGE, activate_button_start_tango, index) w['radio_device_eras1_lbl'] = gui.Label(" eras-1 ", font=fontSub) w['radio_device_eras2_lbl'] = gui.Label(" eras-2 ", font=fontSub) w['radio_device_eras3_lbl'] = gui.Label(" eras-3 ", font=fontSub) w['radio_device_eras4_lbl'] = gui.Label(" eras-4 ", font=fontSub) radio_device_table.tr() radio_device_table.td(w['radio_device_eras1']) radio_device_table.td(w['radio_device_eras1_lbl']) radio_device_table.tr() radio_device_table.td(w['radio_device_eras2']) radio_device_table.td(w['radio_device_eras2_lbl']) radio_device_table.tr() radio_device_table.td(w['radio_device_eras3']) radio_device_table.td(w['radio_device_eras3_lbl']) radio_device_table.tr() radio_device_table.td(w['radio_device_eras4']) radio_device_table.td(w['radio_device_eras4_lbl']) lo.add(radio_device_table, x, y + 22) w['button_start_tango'] = gui.Button("Start", font=fontSub) w['button_start_tango'].connect(gui.CLICK, start_tango, index) lo.add(w['button_start_tango'], x, y + 95) table_display_depth_skeleton = gui.Table() w['cb_display_depth'] = gui.Switch(display_depth[index]) w['cb_display_depth'].connect(gui.CHANGE, toggle_display_depth, index) w['label_display_depth'] = gui.Label("depth", align=-1, font=fontSub) table_display_depth_skeleton.tr() table_display_depth_skeleton.td(w['cb_display_depth']) table_display_depth_skeleton.td(w['label_display_depth']) w['cb_display_skeleton'] = gui.Switch(display_skeleton[index]) w['cb_display_skeleton'].connect(gui.CHANGE, toggle_display_skeleton, index) w['label_display_skeleton'] = gui.Label("skeleton", align=-1, font=fontSub) table_display_depth_skeleton.tr() table_display_depth_skeleton.td(w['cb_display_skeleton']) table_display_depth_skeleton.td(w['label_display_skeleton']) lo.add(table_display_depth_skeleton, x, y + 120) w['device_slider'] = gui.VSlider(value=0, min=-27, max=27, size=32, width=16, height=220) w['device_slider'].connect(pygame.locals.MOUSEBUTTONUP, change_tilt, index) lo.add(w['device_slider'], x + 75, y + 20) lo.add(img_device[index], x + 95, y) lo.add(img_device_skeleton[index], x + 95, y) toggle_kinect_manager_gui(index)
def main(): """this function is called when the program starts. it initializes everything it needs, then runs in a loop until the function returns.""" global lines #Initialize Everything pygame.init() pygame.font.init() font = pygame.font.SysFont("default", 18) fontBig = pygame.font.SysFont("default", 24) fontSub = pygame.font.SysFont("default", 20) screen = pygame.display.set_mode(screenSize) pygame.display.set_caption('GUI Test - PGU') # create GUI object gui = pgui.App() textArea = pygame.Rect(370, 20, 250, 320) # layout using document lo = pgui.Container(width=350) # create page label #lo.block(align=-1) #lo.br(8) #lo.tr() title = pgui.Label("Pygame GUI Test Page - PGU", font=fontBig) lo.add(title, 29, 13) # create progress bar label # progress bar pbl = pgui.Label("Progress Bar Not Supported") lo.add(pbl, 354, 371) # create checkbuttons and add to gui cbt = pgui.Table() cb1 = pgui.Switch() cb1.connect(pgui.CHANGE, logCheckAction, (cb1, "Check Box 1")) cb1l = pgui.Label("Check Box 1") cbt.add(cb1) cbt.add(cb1l) cbt.tr() cb2 = pgui.Switch() cb2.connect(pgui.CHANGE, logCheckAction, (cb2, "Check Box 2")) cb2l = pgui.Label("Check Box 2") cbt.add(cb2) cbt.add(cb2l) cbt.tr() cb3 = pgui.Switch() cb3.connect(pgui.CHANGE, logCheckAction, (cb3, "Check Box 3")) cb3l = pgui.Label("Check Box 3") cbt.add(cb3) cbt.add(cb3l) lo.add(cbt, 52, 52) # create radio buttons, put in table, and add to gui rbt = pgui.Table() radio = pgui.Group() rb1 = pgui.Radio(radio, 1) rb1l = pgui.Label("Radio Button 1") rbt.add(rb1) rbt.add(rb1l) rbt.tr() rb2 = pgui.Radio(radio, 2) rb2l = pgui.Label("Radio Button 2") rbt.add(rb2) rbt.add(rb2l) rbt.tr() rb3 = pgui.Radio(radio, 3) rb3l = pgui.Label("Radio Button 3") rbt.add(rb3) rbt.add(rb3l) rbt.tr() lo.add(rbt, 210, 52) radio.connect(pgui.CHANGE, logRadioAction, (radio, "Radio Button 3")) # create txt box label txtl = pgui.Label("Text Box", font=fontSub) lo.add(txtl, 30, 127) # create text box txt = pgui.Input("next line of input", size=45) txt.connect(pgui.BLUR, logInputAction, txt) lo.add(txt, 28, 149) # add buttons, both regular and toggle btn1 = pgui.Button("Button 1") btn1.connect(pgui.CLICK, logButtonAction, ("Button 1 clicked")) lo.add(btn1, 36, 250) btn2 = pgui.Button("Button 2") btn2.connect(pgui.CLICK, logButtonAction, ("Button 2 clicked")) lo.add(btn2, 133, 250) btn3 = pgui.Button("Button 3") btn3.connect(pgui.CLICK, logButtonAction, ("Button 3 clicked")) lo.add(btn3, 230, 250) # create toggle button not avail label tbl = pgui.Label("Toggle Buttons Not Supported") lo.add(tbl, 36, 290) iml = pgui.Label("Image Map Not Supported") lo.add(iml, 36, 340) # create slider label sll = pgui.Label("Slider", font=fontSub) lo.add(sll, 36, 195) # create slider sl = pgui.HSlider(value=1, min=0, max=100, size=32, width=200, height=16) sl.connect(pgui.CHANGE, logSliderAction, sl) lo.add(sl, 53, 210) #, colspan=3) # make some insensitive btn2.style.disabled = True cb3.style.disabled = True # clear setup noise, and put initial content in lines = [] lines.append('top line of input') lines.append('second line of input') gui.init(lo) #Main Loop while 1: #Handle Input Events for event in pygame.event.get(): if event.type == QUIT: return elif event.type == KEYDOWN and event.key == K_ESCAPE: return # pass event to gui gui.event(event) # clear background, and draw clock-spinner screen.fill((250, 250, 250)) radius = 30 spinPos = 240, 362 sp2 = spinPos[0] + 1, spinPos[1] progressAngle = int(time.time() % 15 * 24 - 90) #60 pygame.draw.circle(screen, (180, 180, 180), spinPos, radius, 0) for angle in range(-90, progressAngle): a = angle * math.pi / 180 tgt = radius*math.cos(a)+spinPos[0], \ radius*math.sin(a)+spinPos[1] pygame.draw.line(screen, (254, 254, 254), spinPos, tgt, 2) pygame.draw.circle(screen, (0, 0, 0), spinPos, radius, 2) pygame.draw.circle(screen, (0, 0, 0), spinPos, radius + 1, 3) pygame.draw.circle(screen, (0, 0, 0), sp2, radius, 2) pygame.draw.circle(screen, (0, 0, 0), sp2, radius + 1, 3) pygame.draw.line(screen, (0, 0, 0), spinPos, tgt, 2) tgt = spinPos[0], spinPos[1] - radius pygame.draw.line(screen, (0, 0, 0), spinPos, tgt, 2) # Draw GUI gui.paint(screen) edText = "\n".join(lines) text.writepre(screen, font, textArea, (0, 0, 0), edText) pygame.display.flip()
def genGui(self): from omnitool import themename, Theme, lang, exit_prog theme = Theme(themename) class Quitbutton(gui.Button): def __init__(self, value="Finish"): gui.Button.__init__(self, value, width=60, height=40) try: self.connect(gui.CLICK, app.quit, None) except AttributeError: self.connect(gui.CLICK, app.close, None) pygame.display.init() pygame.display.set_caption("Header Modifier") app = gui.Desktop(theme=theme) main = gui.Table(width=300) app.connect(gui.QUIT, exit_prog, None) main.td(gui.Label("Spawn Point: ")) X = gui.Input(value=self.header["spawn"][0], size=5) Y = gui.Input(value=self.header["spawn"][1], size=4) main.td(X) main.td(Y) main.tr() main.td(gui.Label("Hardmode: ")) hardmode = gui.Switch(self.header["hardmode"]) main.td(hardmode) main.td(gui.Label("Day: ")) daytime = gui.Switch(self.header["is_day"]) main.td(daytime) main.tr() main.td(gui.Label("Eye of Cthulhu killed: ")) eoc = gui.Switch(self.header["bosses_slain"][0]) main.td(eoc) main.td(gui.Label("Eater of Worlds killed: ")) eow = gui.Switch(self.header["bosses_slain"][1]) main.td(eow) main.tr() main.td(gui.Label("Skeletron killed: ")) skelly = gui.Switch(self.header["bosses_slain"][2]) main.td(skelly) main.td(gui.Label("Saved Goblin Tinkerer: ")) tinkerbell = gui.Switch(self.header["npcs_saved"][0]) main.td(tinkerbell) main.tr() main.td(gui.Label("Saved Mechanic: ")) mech = gui.Switch(self.header["npcs_saved"][1]) main.td(mech) main.td(gui.Label("Saved Wizard: ")) wizziewizz = gui.Switch(self.header["npcs_saved"][2]) main.td(wizziewizz) main.tr() main.td(gui.Label("Bloodmoon: ")) bloodz = gui.Switch(self.header["is_bloodmoon"]) main.td(bloodz) main.td(gui.Label("World Name: ")) worldName = gui.Input(value=self.header["name"], size=8) main.td(worldName) main.tr() main.td(gui.Label("Invasion Type: ")) # invasion = gui.Select() #invasion.add("None",0) #invasion.add("Goblin Invasion",1) #invasion.add("Frost Legion",2) invType = gui.List(110, 50) invType.add("None", value=0) invType.add("Goblin Invasion", value=1) invType.add("Frost Legion", value=2) if invType.value == None: invType.value = 0 #main.td(invasion) main.td(invType) main.td(gui.Label("Invasion Amount (0-1000): ")) invSize = (gui.Input(value=self.header["gob_inv_size"], size=8)) main.td(invSize) main.tr() main.tr() main.td(Quitbutton(), colspan=4) app.run(main) pygame.display.quit() bosses = (int(eoc.value), int(eow.value), int(skelly.value)) npcSaved = (int(tinkerbell.value), int(mech.value), int(wizziewizz.value)) self.header["spawn"] = (int(X.value), int(Y.value)) self.header["hardmode"] = int(hardmode.value) self.header["is_day"] = int(daytime.value) self.header["bosses_slain"] = bosses self.header["is_bloodmoon"] = int(bloodz.value) self.header["name"] = worldName.value self.header["gob_inv_size"] = int(invSize.value) self.header["gob_inv_type"] = int(invType.value) self.header["npcs_saved"] = npcSaved
window = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) pygame.display.set_caption("DalekCam") screen = pygame.display.get_surface() pygame.joystick.init() #Set up the GUI fontBig = pygame.font.SysFont("default", 48) fg = (255, 255, 255) gui = pgui.App() lo = pgui.Container(width=1024, height=600) title = pgui.Label("Dalek Controller", color=fg, font=fontBig) lo.add(title, 700, 10) cbt = pgui.Table() cb1 = pgui.Switch() cb1.connect(pgui.CHANGE, headTrackState, (cb1, "Head Tracking")) cb1l = pgui.Label("Enable Head Tracking", color=fg) cbt.add(cb1) cbt.add(cb1l) cbt.tr() lo.add(cbt, 750, 60) #Choose MP3s t = pgui.Table() t.tr() td_style = {'padding_right': 10, 'color': fg} t.td(pgui.Label('Top Left Sound File:', color=fg), style=td_style) input_file_1 = pgui.Input() t.td(input_file_1, style=td_style) b = pgui.Button("Browse...")
def build(self): # Play Button # Pause Button # Rewind, Forward # Slider panel.Panel.build(self) theaterTable = gui.Table(height=geom['panel'].height, width=geom['panel'].width * 3 / 4) theaterTable.tr() rewindAllButton = gui.Button(gui.Image(images['media-first']), style={'padding': 5}) rewindButton = gui.Button(gui.Image(images['media-backward']), style={'padding': 5}) self.playButton = gui.Button(gui.Image(images['media-play']), style={'padding': 5}) forwardButton = gui.Button(gui.Image(images['media-forward']), style={'padding': 5}) forwardAllButton = gui.Button(gui.Image(images['media-last']), style={'padding': 5}) self.script.director.reset() self.progressSlider = gui.HSlider( **self.buildProgressSliderArguments()) self.progressSlider.connect(gui.CLICK, self.changeProgressBar) rewindAllButton.connect(gui.CLICK, self.director.rewindAll, self.updateProgressBar) rewindButton.connect(gui.CLICK, self.director.rewind, self.updateProgressBar) self.playButton.connect(gui.CLICK, self.playScript) forwardButton.connect(gui.CLICK, self.director.forward, self.updateProgressBar) forwardAllButton.connect(gui.CLICK, self.director.forwardAll, self.updateProgressBar) self.playButton.activated = False theaterTable.td(gui.Spacer(1, 1), align=0) theaterTable.td(rewindAllButton, align=0) theaterTable.td(rewindButton, align=0) theaterTable.td(self.playButton, align=0) theaterTable.td(forwardButton, align=0) theaterTable.td(forwardAllButton, align=0) theaterTable.td(gui.Spacer(1, 1), align=0) theaterTable.tr() theaterTable.td(self.progressSlider, colspan=7, align=0) theaterTable.tr() theaterTable.td(gui.Label(_("Subtitles: ")), colspan=2, align=1) subtitleSwitch = gui.Switch(value=hacks['subtitle'], name='theater-switch-subtitles') subtitleSwitch.connect(gui.CLICK, self.subtitleSwitchState) theaterTable.td(subtitleSwitch, colspan=1, align=-1) theaterTable.td(gui.Spacer(1, 1), colspan=1) theaterTable.td(gui.Label(_("Mute: ")), colspan=1, align=1) muteSwitch = gui.Switch(value=hacks['mute'], name='theater-switch-mute') muteSwitch.connect(gui.CLICK, self.muteSwitchState) theaterTable.td(muteSwitch, colspan=2, align=-1) theaterDocument = gui.Document(width=geom['panel'].width, height=geom['panel'].height, align=0) theaterDocument.add(theaterTable) self.add(theaterDocument, 0, 10)