def __init__(self, name, title, equipped, icon, client, hit, dam, arm, desc=""): self.client = client self.name = name self.title = title icon = Graphic(path=['icons', icon]) title = Label(self.title) stats = HorizontalContainer([ Label(str(dam), color=[255, 100, 100, 255]), Label(str(hit), color=[100, 100, 255, 255]), Label(str(arm), color=[100, 255, 100, 255]), ]) button_text = 'Equip ' if equipped: button_text = 'Remove' equip_button = Button(label=button_text, is_pressed=equipped, on_press=self.equip) use_button = OneTimeButton(label='Use', on_release=self.use) drop_button = OneTimeButton(label='Drop', on_release=self.confirm_drop) HorizontalContainer.__init__( self, [icon, title, stats, equip_button, use_button, drop_button], align=HALIGN_LEFT)
def constructMeneButtons(self): for mene in meneList: if mene.hp <= 0: disabled = True else: disabled = False if g.gameEngine.fightScreen.myMene.ID == mene.ID: ispressed = True self.selectMeneID = mene.ID else: ispressed = False button = Button("", on_press=self.updateWindow, disabled=disabled, width=TILESIZE * 2, height=TILESIZE * 2, argument=mene.ID, texture=g.gameEngine.resManager.meneSprites[ mene.spriteName]["portraitlarge"], is_pressed=ispressed, outline='menewindowbutton') nameLabel = Label(mene.name, bold=True, color=g.npcColor) lvlLabel = Label("Lvl: %s" % mene.level) hpBar = HpBar(height=20, width=64 * 2, maxhp=mene.maxhp, currenthp=mene.hp) self.meneCont.append( VerticalContainer(content=[button, nameLabel, lvlLabel, hpBar], padding=0)) self.meneButtons.append(button)
def __init__(self, name, title, icon, client, dam, hit, arm, gold, desc=""): self.client = client self.name = name self.title = title icon = Graphic(path=['icons', icon]) title = Label(self.title) gold = Label("%sg" % gold, color=[230, 244, 68, 255]) stats = HorizontalContainer([ Label(str(dam), color=[255, 100, 100, 255]), Label(str(hit), color=[100, 100, 255, 255]), Label(str(arm), color=[100, 255, 100, 255]), ]) take_button = OneTimeButton(label='Take', on_release=self.take) HorizontalContainer.__init__(self, [icon, title, gold, stats, take_button], align=HALIGN_LEFT)
def __init__(self,name,text,a=0): if text[0]=='>': color=g.greentextColor else: color=g.postColor if a>0: if a==ADMIN_MODERATOR: nameColor=g.modColor appendix='#Mod#' elif a==ADMIN_ADMIN: nameColor=g.adminColor appendix='#Admin#' else: nameColor=g.adminColor appendix='#Owner#' else: nameColor=g.nameColor appendix='' if appendix: horz=HorizontalContainer(content=[Label(name,bold=True,color=nameColor),Label(appendix+':',color=nameColor),Label(text,color=color)]) else: horz=HorizontalContainer(content=[Label(name+':',bold=True,color=nameColor),Label(text,color=color)]) Manager.__init__(self, Frame(horz), window=g.screen, batch=g.chatBubbleBatch, anchor=ANCHOR_BOTTOM_LEFT, is_movable=False, offset=(0,0), theme=g.chatTheme)
def __init__(self, name, level, hp, maxhp): self.nameLabel = Label(name, color=g.whiteColor, font_size=g.theme["font_size"] + 2, bold=True) self.levelLabel = Label('Lvl: ' + str(level), color=g.whiteColor, font_size=g.theme["font_size"] + 2, bold=True) self.hpBar = HpBar() Manager.__init__( self, VerticalContainer(content=[ HorizontalContainer( content=[self.nameLabel, None, self.levelLabel]), self.hpBar ], align=HALIGN_LEFT), window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_BOTTOM_LEFT, offset=(0, 0), theme=g.theme) self.hpBar.setHP(hp, maxhp)
def bagHoverTemplate(money, es): moneyTmp = money / 100.0 moneyCont = HorizontalContainer( content=[Label("%.2f" % moneyTmp), Graphic("euro")]) esCont = HorizontalContainer( content=[Label("%s" % es), Graphic('es_icon')]) return VerticalContainer(content=[esCont, moneyCont], align=HALIGN_RIGHT)
def __init__(self): g.postWindowOpened = True label1 = Label("Notifications", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') self.postCont = [] #self.menes = [{"name":"Hitler","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'americanbear'},{"name":"Stalin","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'lorslara'},{"name":"Ebin","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'squadlider'},{"name":"Mao","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'mongolbear'},{"name":"Uusi mene","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'mongol'},{"name":"Hintti","hp":50,"level":15,"power":60,"defense":50,"speed":70,'sprite':'uusimene'}] #self.selectedMene=self.menes[0]["name"] for c in g.mails: label = Label(c["s"], bold=True, color=g.guiNameColor, font_size=g.theme["font_size"] + 2) label1 = Label(c["t"][:16] + '...', color=g.whiteColor) deleteBtn = HighlightedButton("", on_release=self.deletemail, width=14, height=14, path='delete_alt', argument=c["id"]) openBtn = HighlightedButton("", on_release=self.openmail, width=20, height=21, path='mailopen', argument=c["id"]) self.postCont.append( VerticalContainer(content=[ HorizontalContainer(content=[openBtn, label, deleteBtn]), label1 ], align=HALIGN_LEFT)) self.vertCont = VerticalContainer(self.postCont, align=VALIGN_TOP) self.report = Document("", is_fixed_size=True, height=g.SCREEN_HEIGHT / 2, width=g.SCREEN_WIDTH / 5) self.scrollable = Scrollable(content=self.vertCont, height=g.SCREEN_HEIGHT / 2, width=g.SCREEN_WIDTH / 5) total = HorizontalContainer( content=[self.scrollable, self.report, closeBtn], align=VALIGN_TOP) Manager.__init__( self, Frame(total), window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme) if len(self.postCont) > 0: self.openmail(self.postCont[0]._content[0]._content[0].arg)
def initManager(self): self.mode = MODE_CONNECTING self.guiBatch = pyglet.graphics.Batch() self.statusText = Label("Connecting", color=(255, 255, 255, 255)) self.downloadText = Label("", color=(255, 255, 255, 255)) self.manager = Manager(VerticalContainer( [self.statusText, self.downloadText]), window=self.screen, batch=self.guiBatch, theme=theme)
def abilityHoverTemplate(args): cont = [] if 'name' in args: cont.append( Label(args['name'], bold=True, font_size=g.theme['font_size'] + 1)) if 'type' in args: cont.append(Label(args['type'])) if 'info' in args: cont.append( Label(args['info'].format(*args['args']), width=TILESIZE * 4, multiline=True, color=g.loginFontColor)) return VerticalContainer(cont, align=HALIGN_LEFT, padding=0)
def __init__(self, title, content=None, x=0, y=0, type=0): g.selectedWindowOpened = True cont = [] self.type = type cont.append(Label(title, color=g.loginFontColor)) for c in content: cont.append( HighlightedButton(c["text"], on_release=c["function"], width=120, height=24, path='empty', argument=c["argument"], align=HALIGN_LEFT)) frame = Frame(VerticalContainer(content=cont, padding=0, align=HALIGN_LEFT), path='frame_alternative') Manager.__init__(self, frame, window=g.screen, batch=g.selectWindowBatch, is_movable=False, offset=(0, 0), theme=g.theme) self.set_position(x, y - self.height)
def manager(self): self.managerList += [ Manager(HorizontalContainer( [OneTimeButton(label="Continuar", on_release=self.nextWindow)]), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_BOTTOM_RIGHT, offset=(-80, 5), is_movable=False) ] self.managerList += [ Manager(VerticalContainer([ Checkbox(label="El CPU Inicia ", on_press=self.setCPUStarts, is_pressed=self.CPUStarts), Checkbox(label="El CPU es blancas", on_press=self.setCPUPlayWhite, is_pressed=self.CPUPlayWhite), Label(""), Label("Enroque de negras"), Checkbox(label="Lado de la Reina ", on_press=self.setBlackQueenCastling, is_pressed=self.blackQueenCastling), Checkbox(label="Lado del Rey ", on_press=self.setBlackKingCastling, is_pressed=self.blackKingCastling), Label(""), Label("Enroque de blancas"), Checkbox(label="Lado de la Reina ", on_press=self.setWhiteQueenCastling, is_pressed=self.whiteQueenCastling), Checkbox(label="Lado del Rey ", on_press=self.setWhiteKingCastling, is_pressed=self.whiteKingCastling) ]), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_RIGHT, offset=(-50, -95), is_movable=False) ]
def LabelFactory(model ,path): binding = Binding(context=model, path=path) label = Label(path='label') binding.setter = lambda value: label.set_text(value) if label.is_loaded: binding.apply_binding() return label
def add_message(self, message): step = 40 for i in range(0, len(message), step): self.message_container.add( Label("> " + message[i:step], font_name='Lucida Grande')) step += 40 self.text_input.set_text("")
def __init__(self): self.coinsText = Label("Coins: 0") Manager.__init__(self, self.coinsText, window=g.gameEngine.window, batch=g.guiBatch, theme=g.theme, is_movable=False, anchor=ANCHOR_TOP, offset=(0,-25))
def submit_message(self, state): message = self.text_input.get_text() self.text_input.set_text("") if message[0] == "/": self.message_container.add( Label("> " + message, font_name='Lucida Grande', color=[200, 200, 255, 255])) self.client.command(message[1:].split(' ')) else: self.client.chat(message)
def __init__(self): g.ignoreWindowOpened = True label1 = Label("Ignore List", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') title = [label1, None, closeBtn] ignores = [] for c in ignoreList: ignores.append(c) ignores.sort() ignoreCont = [] for c in ignores: label = HighlightedButton(c, width=150, height=24, path='baroutline_btn', on_release=self.constructSelect, argument=c, align=HALIGN_LEFT, font_color=g.guiNameColor) ignoreCont.append(label) #label=Label(c,bold=True,color=g.nameColorLighter) #removeBtn = HighlightedButton("",on_release=self.removeIgnore,width=24,height=24,path='ignoreremove',argument=c) #ignoreCont.append(HorizontalContainer(content=[label,removeBtn])) addBtn = HighlightedButton("Ignore Player", on_release=addIgnorePopup, width=100, height=24) horzCont = HorizontalContainer(content=title) frame = Frame( VerticalContainer(content=[ horzCont, Scrollable(height=400, width=400, content=VerticalContainer(content=ignoreCont, align=HALIGN_LEFT, padding=0)), addBtn ])) Manager.__init__( self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme)
def initNameMene(self): def sendMeneName(event): self.menename = self.nameInput.get_text() if len(self.menename) > 0: self.saveBtn.disabled = True self.naming = True label = Label("Name Your Mene", color=g.postColor, font_size=18, bold=True) #meneTheme = Theme({g.spriteName: { # "image": { # "source": g.spriteName+'_front.png' # }, # "gui_color": [255,255,255,255] # } # },resources_path=g.dataPath+'/menes/' #) #picture = Graphic(g.spriteName,alternative=meneTheme) picture = Graphic( texture=g.gameEngine.resManager.meneSprites[g.spriteName]['front']) self.nameInput = TextInput(text="", padding=2, length=12, max_length=12, width=200, font_size=16) self.saveBtn = HighlightedButton(label="Save", on_release=sendMeneName, width=100, height=40, font_size=16) frame = Frame(VerticalContainer(content=[ label, picture, HorizontalContainer([self.nameInput, self.saveBtn]) ]), path='frame_npc_talk') self.meneMan = Manager(frame, window=self.screen, batch=g.guiBatch, theme=g.theme, offset=(0, 0), is_movable=False)
def __init__(self): g.reportWindowOpened = True getReport() label1 = Label("Send Ticket", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') horzCont = HorizontalContainer(content=[label1, None, closeBtn]) #self.infoLabel = Label("No reports founds") self.reportInput = TextInput(text="", padding=5, length=16, max_length=400, width=g.SCREEN_WIDTH / 3, height=g.SCREEN_HEIGHT / 3, multiline=True) clearBtn = HighlightedButton("Clear", on_release=self.clear, width=120, height=30) deleteBtn = HighlightedButton("Delete", on_release=self.remove, width=120, height=30) sendBtn = HighlightedButton("Send", on_release=self.send, width=120, height=30) buttons = HorizontalContainer(content=[clearBtn, deleteBtn, sendBtn]) frame = Frame( VerticalContainer(content=[horzCont, self.reportInput, buttons])) Manager.__init__(self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, theme=g.theme) frame.expand(g.SCREEN_WIDTH / 2, height=g.SCREEN_HEIGHT / 4 * 3)
def manager(self): Manager(Label(""), window=self, batch=self.batch, theme=getTheme()) Manager(Frame(self.document), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_TOP_RIGHT, offset=(-10, -75), is_movable=False) Manager(HorizontalContainer([ OneTimeButton(label="Guardar", on_release=self.saveGame), OneTimeButton(label="Volver", on_release=self.onclose) ]), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_BOTTOM_RIGHT, offset=(-50, 15), is_movable=False) self.document.set_text("")
def __init__(self, client, name, title, dialog): self.client = client self.name = name title = Label(title, font_size=12) dialog = pyglet.text.decode_text(dialog) document = Document(dialog, width=300, height=100) accept_button = OneTimeButton(label="Ok, I'll do it!", on_release=self.accept) reject_button = OneTimeButton(label="No, Thanks.", on_release=self.reject) text_container = VerticalContainer([title, document]) button_container = HorizontalContainer([accept_button, reject_button]) quest_container = VerticalContainer([text_container, button_container]) Manager.__init__(self, Frame(quest_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
def __init__(self, client, quests): self.client = client quest_list = [] for quest in quests: quest_title = Label(quest['title']) quest_container = HorizontalContainer([quest_title]) quest_list.append(quest_container) close_button = OneTimeButton(label="Close", on_release=self.close) quest_container = VerticalContainer(quest_list) button_container = HorizontalContainer([close_button]) questlog_container = VerticalContainer( [quest_container, button_container]) Manager.__init__(self, Frame(questlog_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
def __init__(self): g.adminWindowOpened = True label1=Label("Admin Menu",bold=True,color=g.loginFontColor) closeBtn = closeBtn =HighlightedButton("",on_release=self.delete,width=19,height=19,path='delete') adminSayBtn=HighlightedButton("Admin say",on_release=self.adminSay,width=120,height=25) muteBtn=HighlightedButton("Mute player",on_release=self.mutePlayer,width=120,height=25) unmuteBtn=HighlightedButton("Unmute player",on_release=self.unmutePlayer,width=120,height=25) teleportBtn=HighlightedButton("Teleport player",on_release=self.teleportPlayer,width=120,height=25) banBtn=HighlightedButton("Ban player",on_release=self.banPlayer,width=120,height=25) unbanBtn=HighlightedButton("Unban player",on_release=self.unbanPlayer,width=120,height=25) reportBtn=HighlightedButton("Reports",on_release=self.reports,width=120,height=25) #addBtn = HighlightedButton("",on_release=self.addFriend,width=24,height=24,path='friendadd') horzCont = HorizontalContainer(content=[label1,closeBtn]) frame = Frame(VerticalContainer(content=[horzCont,adminSayBtn,muteBtn,unmuteBtn,teleportBtn,banBtn,unbanBtn,reportBtn])) Manager.__init__(self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40,int(g.SCREEN_HEIGHT*g.WINDOW_POSY_RELATIVE)), theme=g.theme)
def create_ui_element(xe: Et, children: []): d = parse_attributes(**xe.attrib) if xe.tag == VerticalContainer.__name__: # align=HALIGN_CENTER, padding=5 return VerticalContainer(children, align=d.get('align', 0), padding=d.get('padding', 5)) if xe.tag == HorizontalContainer.__name__: # align=HALIGN_CENTER, padding=5 return HorizontalContainer(children, align=d.get('align', 0), padding=d.get('padding', 5)) elif xe.tag == Label.__name__: return Label(text=d.get('text'), bold=d.get('bold', False), italic=d.get('italic', False), font_name=d.get('font_name', None), font_size=d.get('font_size', None), color=d.get('color', None), path=d.get('path', None)) elif xe.tag == Button.__name__: return Button(**xe.attrib) else: raise NotImplemented()
def __init__(self): g.keybindingsWindowOpened = True self.resW = g.SCREEN_WIDTH self.resH = g.SCREEN_HEIGHT self.fullscreen = g.FULLSCREEN self.vsync = g.VSYNC self.screenSelected = g.SCREENSELECTED screens = pyglet.window.get_platform().get_default_display( ).get_screens() screenopts = [] for i in range(len(screens)): screenopts.append(str(i)) if int(self.screenSelected) >= 0 and int( self.screenSelected) < len(screens): screenopts.insert(0, str(self.screenSelected)) options = [] modes = pyglet.window.get_platform().get_default_display( ).get_default_screen().get_modes() for i in modes: if i.width >= 1024 and i.height >= 720: opt = str(int(i.width)) + ':' + str(int(i.height)) if opt not in options: options.append(opt) options.insert(0, str(g.SCREEN_WIDTH) + ':' + str(g.SCREEN_HEIGHT)) titleText = Label("Video Settings", color=g.loginFontColor, font_size=g.theme["font_size"] + 2) windowTypeInfo = Label("Window mode") if g.FULLSCREEN: windowType = Dropdown(['Fullscreen', 'Windowed'], on_select=self.selection) else: windowType = Dropdown(['Windowed', 'Fullscreen'], on_select=self.selection) horz = HorizontalContainer([windowTypeInfo, windowType]) resolutionInfo = Label("Resolution") resolutionType = Dropdown(options, on_select=self.resSelect) horz1 = HorizontalContainer([resolutionInfo, resolutionType]) vsyncBtn = Checkbox("VSync", on_press=self.vsyncSelect, is_pressed=self.vsync, align=HALIGN_LEFT) resolutionInfo = Label("Monitor") resolutionType = Dropdown(screenopts, on_select=self.screenSelect) horz3 = HorizontalContainer([resolutionInfo, resolutionType]) discardBtn = HighlightedButton(label="Discard", on_release=self.delete, width=120, height=30) saveBtn = HighlightedButton(label="Save", on_release=self.onSave, width=120, height=30) horzBtn = HorizontalContainer([discardBtn, saveBtn]) Manager.__init__(self, Frame( VerticalContainer([ titleText, horz, horz1, vsyncBtn, horz3, horzBtn ])), window=g.screen, batch=g.guiBatch, theme=g.theme, is_movable=False)
def __init__(self, name, text, actionType=0): g.npcTalkWindowOpened = True g.cursorRound = -1 self.name = name sendTalkToNpc(name) if actionType == NPC_ACTIONTYPE_SHOP: namecolor = g.npcColor postcolor = g.whiteColor path = 'frame_npc_talk_shop' else: namecolor = g.npcColorLighter postcolor = g.postColor path = 'frame_npc_talk' label1 = Label(name, color=namecolor, bold=True) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') horzCont = HorizontalContainer(content=[label1, None, closeBtn]) self.yourmoney = None w1 = int(300 * (g.SCREEN_WIDTH / 1920.)) + 50 h1 = int(500 * (g.SCREEN_HEIGHT / 1080.)) textArr = text.split('\n\n') realText = "" for c in textArr: if c[0] == '>': realText += '{color ' + str( g.greentextColor) + '}' + c + '\n\n' else: realText += '{color ' + str(postcolor) + '}' + c + '\n\n' realText = realText[:-2] document = pyglet.text.decode_attributed(realText) self.textArea = Document(document, width=w1, height=h1, background=False, font_size=g.chatTheme["font_size"], font_name=g.chatTheme["font"]) if actionType == NPC_ACTIONTYPE_HEAL: healButton = HighlightedButton("Heal my menes", on_release=self.healButton) okButton = HighlightedButton("Goodbye", on_release=self.delete) cont = VerticalContainer(content=[ horzCont, self.textArea, HorizontalContainer([healButton, okButton]) ]) elif actionType == NPC_ACTIONTYPE_SHOP: #TODO: When more items, do a loop that adds then dynamically instead of statically like this disabled = False if Items["es"]["cost"] > g.moneyAmount: # print "TAPAHTU" disabled = True self.esButton = AbilityButton( width=50, height=50, argument=Items["es"]["id"], disabled=disabled, on_press=buyItem, texture=g.gameEngine.resManager.items[Items["es"]["sprite"]], outline='abilityoutline', hover=onHover, hoveringType=HOVERING_ITEM, arguments={ 'name': Items["es"]["name"], 'info': Items["es"]["info"], "args": () }) nameLabel = Label(Items["es"]["name"], color=g.npcColor) esCost = Items["es"]["cost"] / 100.0 costLabel = Label("%.2f" % esCost) euroPicture = Graphic("euro") costCont = HorizontalContainer(content=[costLabel, euroPicture]) infoCont = VerticalContainer( content=[Spacer(), nameLabel, costCont], align=HALIGN_LEFT) itemCont = HorizontalContainer(content=[self.esButton, infoCont]) moneyTmp = g.moneyAmount / 100.0 self.yourmoney = Label('%.2f' % moneyTmp) yourmoneyCont = HorizontalContainer( content=[self.yourmoney, Graphic("euro")]) self.yourES = Label('%s' % g.esAmount) yourESCont = HorizontalContainer( content=[self.yourES, Graphic("es_icon")]) okButton = HighlightedButton("Goodbye", on_release=self.delete) cont = VerticalContainer(content=[ horzCont, self.textArea, itemCont, Spacer(0, 20), HorizontalContainer(content=[ Spacer(), VerticalContainer(content=[yourmoneyCont, yourESCont], align=HALIGN_RIGHT) ]), okButton ]) else: okButton = HighlightedButton("Goodbye", on_release=self.delete) cont = VerticalContainer( content=[horzCont, self.textArea, okButton]) frame = Frame(cont, path=path) Manager.__init__( self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme)
def __init__(self): g.friendWindowOpened = True label1 = Label("Friends List", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') onlineFriends = [] offlineFriends = [] for c in friendList: if c[1] == 1: onlineFriends.append(c[0]) else: offlineFriends.append(c[0]) onlineFriends.sort() offlineFriends.sort() friends = [] for c in onlineFriends: label = HighlightedButton(c, width=150, height=24, path='baroutline_btn', on_release=self.constructSelect, argument=c, align=HALIGN_LEFT, font_color=g.loginFontColor) friends.append(label) for c in offlineFriends: label = HighlightedButton(c, width=150, height=24, path='baroutline_btn', on_release=self.constructSelect, argument=c, align=HALIGN_LEFT, font_color=g.npcColorLighter) friends.append(label) addBtn = HighlightedButton("Add Friend", on_release=addFriendPopup, width=100, height=24) horzCont = HorizontalContainer(content=[label1, None, closeBtn]) frame = Frame( VerticalContainer(content=[ horzCont, Scrollable(height=400, width=400, content=VerticalContainer(content=friends, align=HALIGN_LEFT, padding=0)), addBtn ])) Manager.__init__( self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme)
def __init__(self, *, window, **kwargs): self.vertex_list = None batch = pyglet.graphics.Batch() controller.window = window controller.manager = self with open('theme/theme.json') as f: theme = Theme(load(f), resources_path='./theme') super().__init__(VerticalContainer([ Frame( Wrapper( VerticalContainer([ SectionHeader("Map Tablet to MIDI outputs"), HorizontalContainer([ Label("Controller tablet"), binding_devices.bind( Dropdown(controller.tablet_names), 'tablet'), ]), HorizontalContainer([ Label("Map pointer"), bind_tablet_key.bind( Dropdown(controller.tablet_cursor_names), 'cursor'), Label("with"), Label("active button"), bind_tablet_key.bind( Dropdown(controller.tablet_button_names), 'button'), Label("as:") ]), GridContainer([ [ bind_tablet_x.bind(Button("X"), 'enabled'), Label("to channel"), bind_tablet_x.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_tablet_x.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_tablet_x.widget( HorizontalContainer([ Label("for"), bind_tablet_x.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_tablet_x.bind(TextInput(), 'range_from'), Label("to"), bind_tablet_x.bind(TextInput(), 'range_to'), Label("threshold"), bind_tablet_x.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], [ bind_tablet_y.bind(Button("Y"), 'enabled'), Label("to channel"), bind_tablet_y.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_tablet_y.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_tablet_y.widget( HorizontalContainer([ Label("for"), bind_tablet_y.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_tablet_y.bind(TextInput(), 'range_from'), Label("to"), bind_tablet_y.bind(TextInput(), 'range_to'), Label("threshold"), bind_tablet_y.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], [ bind_tablet_p.bind(Button("Pressure"), 'enabled'), Label("to channel"), bind_tablet_p.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_tablet_p.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_tablet_p.widget( HorizontalContainer([ Label("for"), bind_tablet_p.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_tablet_p.bind(TextInput(), 'range_from'), Label("to"), bind_tablet_p.bind(TextInput(), 'range_to'), Label("threshold"), bind_tablet_p.bind( HorizontalSlider(min_value=0.0, max_value=1.0, steps=20), 'threshold'), ], ]), ]))), Frame( Wrapper( VerticalContainer([ SectionHeader("Map Mouse to MIDI outputs"), HorizontalContainer([ Label("Map mouse with active button"), bind_mouse_key.bind( Dropdown(controller.mouse_button_names), 'button'), Label("as:"), ]), GridContainer([ [ bind_mouse_x.bind(Button("X"), 'enabled'), Label("to channel"), bind_mouse_x.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_x.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_x.widget( HorizontalContainer([ Label("for"), bind_mouse_x.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_x.bind(TextInput(), 'range_from'), Label("to"), bind_mouse_x.bind(TextInput(), 'range_to'), Label("threshold"), bind_mouse_x.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], [ bind_mouse_y.bind(Button("Y"), 'enabled'), Label("to channel"), bind_mouse_y.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_y.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_y.widget( HorizontalContainer([ Label("for"), bind_mouse_y.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_y.bind(TextInput(), 'range_from'), Label("to"), bind_mouse_y.bind(TextInput(), 'range_to'), Label("threshold"), bind_mouse_y.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], ]), HorizontalContainer([ Label("Map mouse wheel as:"), ]), GridContainer([ [ bind_mouse_wheel_x.bind( Button("X"), 'enabled'), Label("to channel"), bind_mouse_wheel_x.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_wheel_x.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_wheel_x.widget( HorizontalContainer([ Label("for"), bind_mouse_wheel_x.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_wheel_x.bind( TextInput(), 'range_from'), Label("to"), bind_mouse_wheel_x.bind( TextInput(), 'range_to'), Label("step"), bind_mouse_wheel_x.bind(TextInput(), 'step'), Label("value"), bind_mouse_wheel_x.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'value'), bind_mouse_wheel_x.bind( Checkbox('pull back'), 'pull_back'), ], [ bind_mouse_wheel_y.bind( Button("Y"), 'enabled'), Label("to channel"), bind_mouse_wheel_y.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_wheel_y.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_wheel_y.widget( HorizontalContainer([ Label("for"), bind_mouse_wheel_y.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_wheel_y.bind( TextInput(), 'range_from'), Label("to"), bind_mouse_wheel_y.bind( TextInput(), 'range_to'), Label("step"), bind_mouse_wheel_y.bind(TextInput(), 'step'), Label("value"), bind_mouse_wheel_y.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'value'), bind_mouse_wheel_y.bind( Checkbox('pull back'), 'pull_back'), ], ]), ]))), HorizontalContainer([ binding_buttons.bind(Button(label="Tablet Input On"), 'tablet_on'), binding_buttons.bind(Button(label="Mouse Input On"), 'mouse_on'), Button(label="Fullscreen", on_press=controller.toggle_fullscreen), OneTimeButton('All Notes Off', on_release=controller.midi_all_notes_off), OneTimeButton('Hide', on_release=controller.toggle_gui) ]), Frame( Wrapper( VerticalContainer([ SectionHeader("Output Device"), GridContainer([ [ Label("Output MIDI port"), binding_devices.bind( Dropdown(controller.midi_ports), 'output_midi_port_name'), ], ]), HorizontalContainer([ binding_buttons.bind( Button(label="MIDI Output On"), 'midi_output_on'), binding_buttons.bind(Button(label="Log Output"), 'log_output_on'), binding_buttons.bind(Button(label="Log Input"), 'log_input_on'), ]), ]))), Frame( Wrapper( VerticalContainer([ SectionHeader("Status"), Label("Input:", bold=True), binding_labels.bind(Label("---"), 'touch_status'), binding_labels.bind(Label("---"), 'mouse_status'), Label("Output:", bold=True), binding_labels.bind(Label("---"), 'output_status'), ]))), ]), theme=theme, window=window, batch=batch, **kwargs) controller.start_listen_bindings() controller.update_widgets() @window.event def on_resize(width, height): controller.clear_scale_cache() controller.note_labels.clear() controller.calculate_grid() # if __debug__: # fps_display = pyglet.clock.ClockDisplay() @window.event def on_draw(): window.clear() if self.vertex_list: self.vertex_list.draw(pyglet.gl.GL_QUADS) if controller.gui_visible: batch.draw() for label in controller.note_labels: label.draw() # if __debug__: # fps_display.draw() @window.event def on_text(text): controller.on_keyboard_input(text)
"padding": [18, 18, 8, 6] } }, "image": { "source": "button.png", "frame": [6, 6, 3, 3], "padding": [12, 12, 4, 2] } } } }, resources_path='../theme/') def f(): print("\n hola mundo \n") # Set up a Manager Manager(VerticalContainer([ Label("Try (SHIFT+)TAB and ENTER"), FocusButton("Button 1", on_press=f()), FocusButton("Button 2"), FocusButton("Button 3") ]), window=window, batch=batch, theme=theme) pyglet.app.run()
def pingHoverTemplate(text): return Label("Ping: %.0f ms" % text)
from setup import * from pyglet_gui.manager import Manager from pyglet_gui.gui import Frame, Label from pyglet_gui.theme import Theme theme = Theme( { "font": "Lucida Grande", "font_size": 12, "text_color": [255, 255, 255, 255], "gui_color": [255, 0, 0, 255], "frame": { "image": { "source": "panel.png", "frame": [8, 8, 16, 16], "padding": [8, 8, 0, 0] } } }, resources_path='../theme/') Manager(Frame(Label('An example of a white label with a red frame')), window=window, batch=batch, theme=theme) pyglet.app.run()