def __init__(self, sys, data): super().__init__(sys, data) monnom, monip, self.own = data # ajout d'une image lisdir = os.listdir(bge.ppath + "images/") lisdir.sort() lisdir.reverse() img = lisdir.pop(0) nom = bge.ppath + "images/" + img print("IMAGEEEEE ", nom) self.img = bgui.Image(self, nom, size=[.1, .1], pos=[.0, .0], options=bgui.BGUI_DEFAULT | bgui.BGUI_CACHE) #self.img = bgui.Image(self, nom, size=[.1, .1], pos=[.0, .0], # options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE) # ajout de bouton self.btnfermeimage = bgui.FrameButton(self, text='X', size=[.02, .02], pos=[.02, .02], options=bgui.BGUI_DEFAULT) self.btnfermeimage.on_click = self.on_click_fermeimage
def __init__(self, sys, data): super().__init__(sys, data) monnom, monip, self.own = data # ajout d'une image self.img = bgui.Image(self, 'img.jpg', size=[.5, .4], pos=[.05, .5], options=bgui.BGUI_DEFAULT) # ajout d'un listbox self.block = bgui.ListBox(self, items=['banane', 'pomme', 'orange', 'poire'], size=[0.4, 0.6], pos=[0.6, 0.3]) # ajout d'etiquette self.lbl = bgui.Label(self, text="Liste des participants inscrits", pos=[0.6, 0.9], sub_theme='Large', options=bgui.BGUI_DEFAULT) # ajout de bouton self.btndemarre = bgui.FrameButton(self, text='Demarrer la simulation', size=[.25, .06], pos=[.6, .14], options=bgui.BGUI_DEFAULT) if bge.c.egoserveur != 1: self.btndemarre.frozen = 1 self.btndemarre.on_click = self.on_demarre_simulation
def __init__(self, parent, name, aspect=None, size=[1, 1], pos=[0, 0], sub_theme='', options=bgui.BGUI_DEFAULT): bgui.Widget.__init__(self, parent, name, aspect, size, pos, sub_theme, options) theme = self.theme[self.theme_section] if self.theme else None self.bg = bgui.Frame(self, 'background', size=[1, 1], pos=[0, 0], options=bgui.BGUI_DEFAULT) self.bg.colors = [(0, 0, 0, 1) for i in range(4)] self.win = bgui.Frame(self, 'win', size=[741, 450], pos=[0, 700], options=bgui.BGUI_THEMED | bgui.BGUI_CENTERED) self.win.img = bgui.Image(self.win, 'image', safepath('./data/textures/nt.png'), size=[731, 235], pos=[5, 210], options=bgui.BGUI_THEMED | bgui.BGUI_CENTERX | bgui.BGUI_CACHE) self.button = bgui.FrameButton(self.win, 'button', text='ENTER GAME', size=[110, 30], pos=[100, 120], options=bgui.BGUI_THEMED) # Setup an on_click callback for the image self.button.on_click = self.start_game blurb = "NOVUS TERRA : Alpha v0.2 : Thanks for waiting!" self.lbl = bgui.Label(self.win, 'label', text=blurb, pos=[100, 180], options=bgui.BGUI_THEMED) #tweener.singleton.add(self, 'color', '[*,*,*,1]', length=2.0) self.input = bgui.TextInput(self.win, 'input', "dynamic.cell", size=[160, 30], pos=[220, 120], pt_size=32, input_options=bgui.BGUI_INPUT_SELECT_ALL, options=bgui.BGUI_THEMED) #self.input.activate() self.input.on_enter_key = self.on_input_enter
def __init__(self, sys, data): super().__init__(sys, data) monnom,monip,self.own=data # ajout d'une image self.img = bgui.Image(self, 'splash.jpg', size=[.9, .7], pos=[.01, .3], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE) # ajout d'etiquette self.lbl = bgui.Label(self, text="Votre nom", pos=[0.1, 0.25], sub_theme='Large', options = bgui.BGUI_DEFAULT ) self.lbl = bgui.Label(self, text="IP du serveur", pos=[0.1, 0.15], sub_theme='Large', options = bgui.BGUI_DEFAULT) self.lbl = bgui.Label(self, text="IP du client", pos=[0.1, 0.05], sub_theme='Large', options = bgui.BGUI_DEFAULT) # ajout de bouton self.btnserveur = bgui.FrameButton(self, text='Creer un serveur', size=[.25, .06], pos=[.6, .14], options = bgui.BGUI_DEFAULT) self.btnserveur.on_click = self.on_click_serveur # un autre bouton self.btnclient = bgui.FrameButton(self, text='Creer un client', size=[.25, .06], pos=[.6, .03], options = bgui.BGUI_DEFAULT) self.btnclient.on_click = self.on_click_client # ajout de champs de texte self.inNom = bgui.TextInput(self, text=monnom, size=[.4, .04], pos=[.3, 0.24], input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT) self.inNom.activate() # on aurait pu utiliser un Label (statique) self.inIPcreeServeur = bgui.TextInput(self, text=monip, size=[.4, .04], pos=[.3, 0.14], input_options = bgui.BGUI_INPUT_SELECT_ALL, options = bgui.BGUI_DEFAULT) self.inIPcreeServeur.frozen=1 self.inIPconnecteClient= bgui.TextInput(self, text=monip, size=[.4, .04], pos=[.3, 0.04], options = bgui.BGUI_DEFAULT)
def __init__(self, viewport): # Initialize the system bgui.System.__init__(self, '../../themes/default') # viewport = [x, y, width, height] # Use a frame to store all of our widgets self.frame = bgui.Frame(self, border=0, size=viewport[2:], pos=viewport[:2]) self.frame.colors = [(0, 0, 0, 0)] * 4 # A themed frame self.win = bgui.Frame(self.frame, size=[0.6, 0.8], options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED) # Create an image to display self.win.img = bgui.Image(self.win, 'img.jpg', size=[.92, .7], pos=[.01, .24], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE) # A button self.button = bgui.FrameButton(self.win, text='Click Me!', size=[.14, .09], pos=[.815, .03], options = bgui.BGUI_DEFAULT) # Setup an on_click callback for the image self.button.on_click = self.on_img_click # Add a label self.lbl = bgui.Label(self.frame, text="I'm a label!", pos=[0, 0.9], sub_theme='Large', options = bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) # A couple of progress bars to demonstrate sub themes self.progress = bgui.ProgressBar(self.win, percent=0.0, size=[0.92, 0.06], pos=[.2, 0.17], sub_theme="Progress", options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) self.health = bgui.ProgressBar(self.win, percent=0.5, size=[0.92, 0.02], pos=[0, 0.14], sub_theme="Health", options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX) # A few TextInput widgets self.input = bgui.TextInput(self.win, text="I'm active.", font="myfont.otf", size=[.4, .04], pos=[.04, 0.02], input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT) self.input.activate() self.input.on_enter_key = self.on_input_enter self.input2 = bgui.TextInput(self.win, text="I select all when activated.", size=[.4, .04], pos=[.04, 0.08], input_options = bgui.BGUI_INPUT_SELECT_ALL, options = bgui.BGUI_DEFAULT) # A counter property used for the on_img_click() method self.counter = 0 # Create a keymap for keyboard input self.keymap = {getattr(bge.events, val): getattr(bgui, val) for val in dir(bge.events) if val.endswith('KEY') or val.startswith('PAD')} # Now setup the scene callback so we can draw bge.logic.getCurrentScene().post_draw.append(self.render)
def __init__(self): # Initialize the system bgui.System.__init__(self) self.clear_time = time.time() self.note_visible = False self.frame = bgui.Frame(self, aspect=(4 / 3), options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED) self.frame.visible = False # Create the note self.note = bgui.Frame(self, border=1, size=[.25, .25], pos=[0.7, -0.3], options=bgui.BGUI_DEFAULT) self.note.colors = [[0, 0, 1, 0.5]] * 4 self.note_hdr = bgui.Label(self.note, text="Notification:", pt_size=42, pos=[0.05, 0.8]) self.note_msg = bgui.Label(self.note, text="The button was clicked!", pos=[0.1, 0], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERY) # Create the button self.button = bgui.FrameButton(self, text='Click Me!', size=[0.4, 0.2], pos=[0.3, 0.4]) self.button.on_click = self.display_note # Create a keymap for keyboard input self.keymap = { getattr(bge.events, val): getattr(bgui, val) for val in dir(bge.events) if val.endswith('KEY') or val.startswith('PAD') }
def __init__(self, sys, data): super().__init__(sys, data) # Use a frame to store all of our widgets self.frame = bgui.Frame(self, border=0) self.frame.colors = [(0, 0, 0, 0) for i in range(4)] # A themed frame self.win = bgui.Frame(self, size=[0.6, 0.8], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED) # Create an image to display self.win.img = bgui.Image(self.win, 'img.jpg', size=[.92, .7], pos=[.01, .24], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX | bgui.BGUI_CACHE) # A button self.button = bgui.FrameButton(self.win, text='Click Me!', size=[.14, .09], pos=[.815, .03], options=bgui.BGUI_DEFAULT) self.audio_button = bgui.ImageButton(self.win, sub_theme='Audio', size=[0.05, 0.05], pos=[0.75, 0.05]) # Setup an on_click callback for the image self.button.on_click = self.on_img_click # Add a label self.lbl = bgui.Label(self, text="I'm a label!", pos=[0, 0.9], sub_theme='Large', options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) # A couple of progress bars to demonstrate sub themes self.progress = bgui.ProgressBar(self.win, percent=0.0, size=[0.92, 0.06], pos=[.2, 0.17], sub_theme="Progress", options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) self.health = bgui.ProgressBar(self.win, percent=0.5, size=[0.92, 0.02], pos=[0, 0.14], sub_theme="Health", options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) # A few TextInput widgets self.input = bgui.TextInput(self.win, text="I'm active.", font="myfont.otf", size=[.4, .04], pos=[.04, 0.02], input_options=bgui.BGUI_INPUT_NONE, options=bgui.BGUI_DEFAULT) self.input.activate() self.input.on_enter_key = self.on_input_enter self.input2 = bgui.TextInput(self.win, text="I select all when activated.", size=[.4, .04], pos=[.04, 0.08], input_options=bgui.BGUI_INPUT_SELECT_ALL, options=bgui.BGUI_DEFAULT) # A counter property used for the on_img_click() method self.counter = 0
def __init__(self, sys, data): super().__init__(sys, data, name='ActivityFrame') self.sleep_btn = bgui.FrameButton(self.frame, text='sleep', size=[0.1, 0.05], pos=[0.90, 0.95]) self.eat_btn = bgui.FrameButton(self.frame, text='eat', size=[0.1, 0.05], pos=[0.90, 0.90]) self.personal_btn = bgui.FrameButton(self.frame, text='personal', size=[0.1, 0.05], pos=[0.90, 0.85]) self.work_btn = bgui.FrameButton(self.frame, text='work', size=[0.1, 0.05], pos=[0.90, 0.80]) self.leisure_btn = bgui.FrameButton(self.frame, text='leisure', size=[0.1, 0.05], pos=[0.90, 0.75]) self.anomaly_btn = bgui.FrameButton(self.frame, text='anomaly', size=[0.1, 0.05], pos=[0.90, 0.70]) self.other_btn = bgui.FrameButton(self.frame, text='other', size=[0.1, 0.05], pos=[0.90, 0.65]) self.ok_btn = bgui.FrameButton(self.frame, text='Ok', size=[0.3, 0.1], pos=[0, 0.2], options=bgui.BGUI_CENTERX) self.cancel_btn = bgui.FrameButton(self.frame, text='Cancel', size=[0.3, 0.1], pos=[0, 0.1], options=bgui.BGUI_CENTERX) self.activity_duration_input = bgui.TextInput( self.frame, prefix="Activity Duration: ", text='0', pt_size=30, pos=[0, 0.4], size=[0.3, 0.05], options=bgui.BGUI_CENTERX) self.activity_duration_input.visible = False self.activity_duration = 0 # signals self.ok_btn.on_click = self.ok_btn_click self.cancel_btn.on_click = self.cancel_btn_click self.sleep_btn.on_click = self.set_activity_click self.eat_btn.on_click = self.set_activity_click self.personal_btn.on_click = self.set_activity_click self.work_btn.on_click = self.set_activity_click self.leisure_btn.on_click = self.set_activity_click self.anomaly_btn.on_click = self.set_activity_click self.other_btn.on_click = self.set_activity_click
def __init__(self): # Initialize the system bgui.System.__init__(self, './resources/GUI') # Use an invisible frame to store all of our widgets self.frame = bgui.Frame(self, 'window', border=0, sub_theme='Root') # ----------------------------------------- # Create a main campaigns menu window # ----------------------------------------- self.campMenu = bgui.Frame(self, 'campaigns', size=[0.6, 0.8], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED) # Add the label bgui.Label(self.campMenu, 'campLabel', text="Select a Campaign", pos=[0.5, 0.9], sub_theme='Large', options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) # Create the campaingns buttons N = NCAMPS_PER_PAGE dy = 0.8 / (3.0 * N + 1.0) for i in range(N): button = bgui.FrameButton(self.campMenu, 'campButton{0}'.format(i), text='{0}:'.format(i), size=[0.9, 2.0 * dy], pos=[0.05, 0.9 - (3 + 3 * i) * dy], options=bgui.BGUI_DEFAULT) button.on_click = self._on_select_camp # Pages navigation self.campPag = 1 bgui.Label(self.campMenu, 'campPages', text="1 / 1", pos=[0.5, 0.05], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) button = bgui.FrameButton(self.campMenu, 'campPrev'.format(i), text='<', size=[0.08, 0.08], pos=[0.3, 0.025], options=bgui.BGUI_DEFAULT) button.on_click = self._on_prev_camp_page button = bgui.FrameButton(self.campMenu, 'campNext'.format(i), text='>', size=[0.08, 0.08], pos=[0.62, 0.025], options=bgui.BGUI_DEFAULT) button.on_click = self._on_next_camp_page # ----------------------------------------- # Create a missions menu window # ----------------------------------------- self.missMenu = bgui.Frame(self, 'missions', size=[0.6, 0.6], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED) # Add the label bgui.Label(self.missMenu, 'missLabel', text="Select a Mission", pos=[0.5, 0.9], sub_theme='Large', options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) # Create the missions buttons N = NMISSS_PER_PAGE dy = 0.8 / (3.0 * N + 1.0) for i in range(N): button = bgui.FrameButton(self.missMenu, 'missButton{0}'.format(i), text='{0}:'.format(i), size=[0.9, 2.0 * dy], pos=[0.05, 0.9 - (3 + 3 * i) * dy], options=bgui.BGUI_DEFAULT) button.on_click = self._on_select_miss # Pages navigation self.missPag = 1 bgui.Label(self.missMenu, 'missPages', text="1 / 1", pos=[0.5, 0.05], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) button = bgui.FrameButton(self.missMenu, 'missPrev'.format(i), text='<', size=[0.08, 0.08], pos=[0.3, 0.025], options=bgui.BGUI_DEFAULT) button.on_click = self._on_prev_miss_page button = bgui.FrameButton(self.missMenu, 'missNext'.format(i), text='>', size=[0.08, 0.08], pos=[0.62, 0.025], options=bgui.BGUI_DEFAULT) button.on_click = self._on_next_miss_page # Back to campaigns menu button button = bgui.FrameButton(self.missMenu, 'missBack'.format(i), text='Back', size=[0.15, 0.08], pos=[0.025, 0.025], options=bgui.BGUI_DEFAULT) button.on_click = self._on_miss_back # ----------------------------------------- # Create a progress bar window (hiden) # ----------------------------------------- """ p_bar_win = bgui.Frame(self, 'progress_bar_win', size=[0.8, 0.2], options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED) bgui.Label(p_bar_win, 'progress_bar_label', text="", pos=[0.5, 0.75], sub_theme='Small', options = bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) bgui.ProgressBar(p_bar_win, "progress_bar_pbar", percent=0.0, size=[0.95, 0.4], pos=[0.025, 0.15], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX) p_bar_win.visible = False """ # ----------------------------------------- # Create a keymap for keyboard input # ----------------------------------------- self.keymap = {} for val in dir(bge.events): if val.endswith('KEY') or val.startswith('PAD'): try: bgeVal = getattr(bge.events, val) bguiVal = getattr(bgui, val) self.keymap[bgeVal] = bguiVal except: continue # ----------------------------------------- # Setup the initial GUI # ----------------------------------------- self._activeCampaign = None self._activeMission = None # Initialize in the campaigns menu self.set_active_menu('campaigns') self._read_campaigns() self._setup_camp_GUI()
def __init__(self, sys, data): super().__init__(sys, data) monnom, monip, self.own = data self.params = [] #self.imgfond = bgui.Image(self, 'fond.jpg', size=[1, .6], pos=[0, 0.4], # options = bgui.BGUI_DEFAULT|bgui.BGUI_CACHE) # ajout d'une image self.img = bgui.Image(self, 'splash.jpg', size=[.4, .4], pos=[.05, .5], options=bgui.BGUI_DEFAULT | bgui.BGUI_CACHE) #PARAMS self.cadreParams = bgui.Frame(self, size=[.4, .4], pos=[.55, 0.5], border=3) self.cadreParamChamp = bgui.Frame(self.cadreParams, size=[.9, .15], pos=[.05, 0.75], border=1) self.cadreParamboutons = bgui.Frame(self.cadreParams, size=[.9, .15], pos=[.05, 0.55], border=1) self.cadreParamListe = bgui.Frame(self.cadreParams, size=[.9, .4], pos=[.05, 0.05], border=1) # ajout de champs de saisie des params self.inParam = bgui.TextInput(self.cadreParamChamp, text="test", size=[.9, .9], pos=[.05, 0.05], input_options=bgui.BGUI_INPUT_NONE, options=bgui.BGUI_DEFAULT) self.inParam.activate() # un autre bouton self.btnAjoutParam = bgui.FrameButton(self.cadreParamboutons, text='Ajoute', size=[.2, .9], pos=[.05, .05], options=bgui.BGUI_DEFAULT) self.btnAjoutParam.on_click = self.on_click_ajout_param # un autre bouton self.btnRetireParam = bgui.FrameButton(self.cadreParamboutons, text='Retire', size=[.2, .9], pos=[.3, .05], options=bgui.BGUI_DEFAULT) self.btnRetireParam.frozen = 1 self.btnRetireParam.on_click = self.on_click_retire_param # ajout d'un listbox pouyr afficher les params self.trouveItems() self.listParams = bgui.ListBox(self.cadreParamListe, items=self.params, size=[0.9, 0.9], pos=[0.05, 0.05]) self.listParams.on_click = self.clickliste # FIN PARAMS # ajout d'etiquette self.lbl = bgui.Label(self, text="Votre nom", pos=[0.1, 0.25], sub_theme='Large', options=bgui.BGUI_DEFAULT) self.lbl = bgui.Label(self, text="IP du serveur", pos=[0.1, 0.15], sub_theme='Large', options=bgui.BGUI_DEFAULT) self.lbl = bgui.Label(self, text="IP du client", pos=[0.1, 0.05], sub_theme='Large', options=bgui.BGUI_DEFAULT) #self.lblvider = bgui.Label(self, text="Vider la console", pos=[0.6, 0.25], # sub_theme='Large', options = bgui.BGUI_DEFAULT) # ajout de bouton self.btnvider = bgui.FrameButton(self, text='Vider la console', size=[.25, .06], pos=[0.6, 0.25], options=bgui.BGUI_DEFAULT) self.btnvider.on_click = self.videconsole # ajout de bouton self.btnserveur = bgui.FrameButton(self, text='Creer un serveur', size=[.25, .06], pos=[.6, .14], options=bgui.BGUI_DEFAULT) self.btnserveur.on_click = self.on_click_serveur # un autre bouton self.btnclient = bgui.FrameButton(self, text='Creer un client', size=[.25, .06], pos=[.6, .03], options=bgui.BGUI_DEFAULT) self.btnclient.on_click = self.on_click_client # ajout de champs de texte self.inNom = bgui.TextInput(self, text=monnom, size=[.4, .04], pos=[.3, 0.24], input_options=bgui.BGUI_INPUT_NONE, options=bgui.BGUI_DEFAULT) self.inNom.activate() # on aurait pu utiliser un Label (statique) self.inIPcreeServeur = bgui.TextInput( self, text=monip, size=[.4, .04], pos=[.3, 0.14], input_options=bgui.BGUI_INPUT_SELECT_ALL, options=bgui.BGUI_DEFAULT) self.inIPcreeServeur.frozen = 1 self.inIPconnecteClient = bgui.TextInput(self, text=monip, size=[.4, .04], pos=[.3, 0.04], options=bgui.BGUI_DEFAULT)
def test_memory_leak_frame_button(self): w = bgui.FrameButton(self.system) self.system = None gc.collect() self.assertListEqual(gc.garbage, [])