Esempio n. 1
0
	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)
Esempio n. 2
0
    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
Esempio n. 3
0
    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, sys, data):
        super().__init__(sys, data)

        #Use a frame to store all of our widgets
        self.frame = bgui.Frame(self,
                                border=0,
                                options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
        self.frame.colors = [(0, 0, 0, 0) for i in range(4)]

        # Add a label for the title
        self.titlelbl = bgui.Label(self.frame,
                                   text=empty.getPropertyNames()[0],
                                   pos=[0.4, .95],
                                   sub_theme='Large',
                                   pt_size=50,
                                   options=bgui.BGUI_DEFAULT)

        self.timerlbl = bgui.Label(self.frame,
                                   text="0:00",
                                   pos=[0.1, .95],
                                   sub_theme='Large',
                                   pt_size=50,
                                   options=bgui.BGUI_DEFAULT)

        if 'pragmatic' not in empty.getPropertyNames():
            # Add a label for the figure
            self.figurelbl = bgui.Label(self.frame,
                                        text='Figure: ',
                                        pos=[.1, .9],
                                        sub_theme='Large',
                                        pt_size=50,
                                        options=bgui.BGUI_DEFAULT)
            # Add a label for the ground
            self.groundlbl = bgui.Label(self.frame,
                                        text='Ground: ',
                                        pos=[.7, .9],
                                        sub_theme='Large',
                                        pt_size=50,
                                        options=bgui.BGUI_DEFAULT)

            self.confirmlbl = bgui.Label(
                self.frame,
                text='Press Enter to Confirm this selection',
                pos=[0.3, .5],
                sub_theme='Large',
                color=(0, 1, 0, 1),
                outline_color=(1, 0, 0, 1),
                outline_size=2,
                pt_size=50,
                options=bgui.BGUI_DEFAULT)
            self.confirmlbl.visible = False

            if 'sfg' in empty.getPropertyNames():
                self.allselectedlbl = bgui.Label(
                    self.frame,
                    text=
                    'Press Enter to Confirm that you have selected all pairs in the scene',
                    pos=[0.1, .5],
                    sub_theme='Large',
                    color=(0, 1, 0, 1),
                    outline_color=(1, 0, 0, 1),
                    outline_size=2,
                    pt_size=50,
                    options=bgui.BGUI_DEFAULT)
                self.allselectedlbl.visible = False

            if "p" not in empty.getPropertyNames():
                # A label for the given preposition
                p = random_preposition_list[0]
                self.prepositionlbl = bgui.Label(self.frame,
                                                 text='Preposition: ' + p,
                                                 pos=[0, 0.9],
                                                 sub_theme='Large',
                                                 pt_size=50,
                                                 options=bgui.BGUI_DEFAULT
                                                 | bgui.BGUI_CENTERX)

            if "p" in empty.getPropertyNames():
                # A themed frame to store text input widget
                self.win = bgui.Frame(self.frame,
                                      size=[.6, .1],
                                      pos=[0, 0.1],
                                      border=0.2,
                                      options=bgui.BGUI_DEFAULT
                                      | bgui.BGUI_CENTERX)

                self.prepositionlbl = bgui.Label(self.frame,
                                                 text="",
                                                 pos=[0, 0.9],
                                                 sub_theme='Large',
                                                 pt_size=50,
                                                 options=bgui.BGUI_DEFAULT
                                                 | bgui.BGUI_CENTERX)

                # A TextInput widget
                self.input = bgui.TextInput(self.win,
                                            text="",
                                            input_options=bgui.BGUI_INPUT_NONE,
                                            pt_size=50,
                                            options=bgui.BGUI_DEFAULT)
                self.input.activate()
                self.input.on_enter_key = self.on_input_enter

        if 'pragmatic' in empty.getPropertyNames():
            # Add a label for the title
            self.instructionlbl0 = bgui.Label(
                self.frame,
                text=
                'Imagine you want the robot to bring you the highlighted object.',
                pos=[0.18, .9],
                sub_theme='Large',
                pt_size=50,
                options=bgui.BGUI_DEFAULT)
            self.instructionlbl1 = bgui.Label(
                self.frame,
                text='Provide the robot with a description of its location',
                pos=[0.21, .85],
                sub_theme='Large',
                pt_size=50,
                options=bgui.BGUI_DEFAULT)
            # A TextInput widget
            # A themed frame to store text input widget
            self.win = bgui.Frame(self.frame,
                                  size=[.6, .1],
                                  pos=[0, 0.1],
                                  border=0.2,
                                  options=bgui.BGUI_DEFAULT
                                  | bgui.BGUI_CENTERX)
            self.input = bgui.TextInput(self.win,
                                        text="",
                                        input_options=bgui.BGUI_INPUT_NONE,
                                        pt_size=50,
                                        options=bgui.BGUI_DEFAULT)
            self.input.activate()
            self.input.on_enter_key = self.on_input_enter

            if 'f' in empty.getPropertyNames():
                # Add a label for the figure
                self.figurelbl = bgui.Label(self.frame,
                                            text='Object: ',
                                            pos=[0, .8],
                                            sub_theme='Large',
                                            pt_size=50,
                                            options=bgui.BGUI_DEFAULT
                                            | bgui.BGUI_CENTERX)
Esempio n. 5
0
    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
Esempio n. 6
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
Esempio n. 7
0
    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)
Esempio n. 8
0
    def test_memory_leak_text_input(self):
        w = bgui.TextInput(self.system, text="Testing string")
        self.system = None

        gc.collect()
        self.assertListEqual(gc.garbage, [])