Example #1
0
    def __init__(self):
        self.table = Table(3, 1)
        radio_frame = create_vframe('Select A Gig')

        group = None
        for i, s in enumerate(sorted(GIG_CHOICES.keys())):

            btn = RadioButton (s, group)
            if i == 0:
                group = btn

            btn.child.multiline = True
            radio_frame.add_child (btn)

        group.activate()

        self.button = Button('SELECT GIG')

        self.doctor_button = Button('Go to Doctors surgery')



        self.radios = group.list

        self.table.add_child(0, 0, radio_frame)
        self.table.add_child(1, 0, self.button)
        self.table.add_child(2, 0, self.doctor_button)
Example #2
0
    def __init__(self, main_map):

        self.map = main_map
        self._clock = pygame.time.Clock()
        pygame.init()
        self.screen = screen = pygame.display.set_mode((1024, 760), pygame.DOUBLEBUF)
        pygame.display.set_caption('MCC - Mission Control Center')

        #Create the background
        #graph_tile = pygame.image.load('background.jpg').convert()
        #graph_rect = graph_tile.get_rect()
        #background = pygame.Surface(screen.get_size())
        #background.blit(graph_tile, graph_rect)

        #Display The Background
        #screen.blit(background, (0, 0))

        # Init GUI
        self.re = Renderer()
        self.re.screen = screen

        btn = Button("Click")
        btn.topleft = (10, 10)
        btn.connect_signal(Constants.SIG_CLICKED, self.success, btn)

        console = ScrolledWindow(1004, 100)
        console.topleft = (10, 650)
        console.child = self.label
        self.label.multiline = True
        self.re.add_widget(btn)
        self.re.add_widget(console)

        self.map_surface = pygame.Surface((604, 604))
        threading.Thread.__init__(self)
Example #3
0
    def __init__(self):
        self.table = Table(3, 1)

        radio_frame = create_vframe('Hi there...\nWhat do you want?')

        group = None
        for i, s in enumerate(sorted(DOCTOR_CHOICES.keys())):

            btn = RadioButton(s, group)
            if i == 0:
                group = btn

            btn.child.multiline = True
            radio_frame.add_child(btn)

        group.activate()

        self.button = Button('Tell doctor')

        self.radios = group.list

        self.stats = Label(player.player.get_stats_text())
        self.stats.multiline = True
        self.stats.align = ALIGN_LEFT

        self.table.add_child(0, 0, radio_frame)
        self.table.add_child(1, 0, self.button)
        self.table.add_child(2, 0, self.stats)

        # doesn't work for some reason...
        if 0:
            group.topleft = (640 - self.table.width, 0)
            radio_frame.topleft = (640 - self.table.width, 0)
            self.table.topleft = (640 - self.table.width, 0)
Example #4
0
  def __init__(self, driver, **kwargs) :
    AetherModule.__init__(self, driver, **kwargs)
    self.show_params = False

    #These need to be updated as they were moved from the top
    from ocempgui.widgets import Window,Button
    from ocempgui.widgets.Constants import SIG_CLICKED

    # parameter window stuff
    self.offscreen = pygame.Surface(self.dims)
    self.re = Renderer()
    self.re.screen = driver.screen
    self.param_window = Window('Parameters')
    self.param_window.opacity = 0

    def calib_f():
      driver.input.calibrate()

    calib = Button('Calibrate')
    calib.connect_signal(SIG_CLICKED,calib_f)
    button = Button('Close')
    button.connect_signal(SIG_CLICKED,self.toggle_params)

    # add custom widgets
    widgets = self.get_parameter_widgets()

    if driver.debug :
      from aether.core import Transform

      def change_sim_shape(btn) :
        btn.set_active(True)
        if self.person.active : shape = Transform.PERSON
        elif self.poly.active : shape = Transform.POLY
        else : shape = Transform.CIRCLE
        driver.input.sim_shadow_shape = shape

      self.circle = RadioButton("Circle")
      self.circle.active = True # circle is the default
      self.person = RadioButton("Person",self.circle)
      self.poly = RadioButton("Polygon",self.circle)

      self.circle.connect_signal(SIG_CLICKED,change_sim_shape,self.circle)
      self.person.connect_signal(SIG_CLICKED,change_sim_shape,self.person)
      self.poly.connect_signal(SIG_CLICKED,change_sim_shape,self.poly)
      widgets.append(self.circle)
      widgets.append(self.person)
      widgets.append(self.poly)

    else :
      widgets.append(calib)

    widgets.append(button)
    t = Table(len(widgets),1)
    for i,w in enumerate(widgets) :
      t.add_child(i,0,w)

    self.param_window.child = t
    self.re.add_widget(self.param_window)
Example #5
0
# Initialize pygame window
pygame.init ()
screen = pygame.display.set_mode ((200, 200));
screen.fill ((255, 200, 100))

# Create the Renderer to use for the UI elements.
re = Renderer ()

# Bind it to a part of the screen, which it will use to draw the widgets.
# Here we use the complete screen.
re.screen = screen

# Create a button, place it at x=10, y=30, bind a callback to its
# clicking action and add it to the Renderer instance.
button = Button ("Simple Button")
button.topleft = 10, 30
button.connect_signal (Constants.SIG_CLICKED, _count_clicks, button)
re.add_widget (button)

# Some variables we will need in the main loop for drawing a rect.
rnd = None
color = None
cnt = 100

while True:
    events = pygame.event.get ()
    for ev in events:
        if ev.type == pygame.QUIT:
            sys.exit ()
        # We could handle other events separately, too, but do not care.
Example #6
0
	def get_settings_window(self,title,pos,settings):
		window=Window(title)
		window.child=Table(2,1)
		window.topleft=pos
		window.depth=1

		def brightness_changed(scale,label):
			self.settings.brightness=scale.value
			label.text='%3.2f'%self.settings.brightness
		def brightness_toggle_changed(toggle):
			self.settings.brightness_enable=not toggle.active
		def contrast_changed(scale,label):
			self.settings.contrast=scale.value
			label.text='%3.2f'%self.settings.contrast
		def contrast_toggle_changed(toggle):
			self.settings.contrast_enable=not toggle.active
		def threshold_changed(scale,label):
			self.settings.threshold=scale.value
			label.text='%d'%self.settings.threshold
		def threshold_toggle_changed(toggle):
			self.settings.threshold_enable=not toggle.active
		def points_toggle_changed(toggle):
			self.settings.points_enable=not toggle.active

		#Setup the slider table
		slider_table=Table(4,4)
		window.child.add_child(0,0,slider_table)

		brightness_label=Label('Brightness:')
		brightness_toggle=ToggleButton('')
		brightness_value_label=Label('')
		brightness_scale=HScale(0,2,0.1)
		brightness_scale.connect_signal(SIG_VALCHANGED,brightness_changed,brightness_scale,brightness_value_label)
		brightness_toggle.connect_signal(SIG_CLICKED,brightness_toggle_changed,brightness_toggle)

		slider_table.add_child(0,0,brightness_label)
		slider_table.add_child(0,1,brightness_toggle)
		slider_table.add_child(0,2,brightness_scale)
		slider_table.add_child(0,3,brightness_value_label)

		brightness_toggle.active=True
		brightness_scale.value=self.settings.brightness

		contrast_label=Label('Contrast:')
		contrast_toggle=ToggleButton('')
		contrast_value_label=Label('')
		contrast_scale=HScale(0,2,0.1)
		contrast_scale.connect_signal(SIG_VALCHANGED,contrast_changed,contrast_scale,contrast_value_label)
		contrast_toggle.connect_signal(SIG_CLICKED,contrast_toggle_changed,contrast_toggle)

		slider_table.add_child(1,0,contrast_label)
		slider_table.add_child(1,1,contrast_toggle)
		slider_table.add_child(1,2,contrast_scale)
		slider_table.add_child(1,3,contrast_value_label)

		contrast_toggle.active=True
		contrast_scale.value=self.settings.contrast

		threshold_label=Label('Threshold:')
		threshold_toggle=ToggleButton('')
		threshold_value_label=Label('')
		threshold_scale=HScale(0,255,1)
		threshold_scale.connect_signal(SIG_VALCHANGED,threshold_changed,threshold_scale,threshold_value_label)
		threshold_toggle.connect_signal(SIG_CLICKED,threshold_toggle_changed,threshold_toggle)

		slider_table.add_child(2,0,threshold_label)
		slider_table.add_child(2,1,threshold_toggle)
		slider_table.add_child(2,2,threshold_scale)
		slider_table.add_child(2,3,threshold_value_label)

		threshold_toggle.active=True
		threshold_scale.value=self.settings.threshold

		points_label=Label('Transform:')
		points_toggle=ToggleButton('')
		points_toggle.connect_signal(SIG_CLICKED,points_toggle_changed,points_toggle)

		slider_table.add_child(3,0,points_label)
		slider_table.add_child(3,1,points_toggle)

		points_toggle.active=True
		points_toggle.active=True

		def reset_settings(brightness_scale,brightness_toggle,contrast_scale,contrast_toggle,threshold_scale,threshold_toggle,points_toggle,settings):
			settings.brightness=1.0
			settings.brightness_enable=True
			settings.contrast=1.0
			settings.contrast_enable=True
			settings.threshold=100
			settings.threshold_enable=True
			settings.points.clear()
			settings.points_enable=True

			brightness_scale.value=settings.brightness
			contrast_scale.value=settings.contrast
			threshold_scale.value=settings.threshold

			brightness_toggle.active=settings.brightness_enable
			contrast_toggle.active=settings.contrast_enable
			threshold_toggle.active=settings.threshold_enable
			points_toggle.active=settings.points_enable

		reset_button=Button('Reset')
		reset_button.connect_signal(SIG_CLICKED,reset_settings,brightness_scale,brightness_toggle,contrast_scale,contrast_toggle,threshold_scale,threshold_toggle,points_toggle,self.settings)

		window.child.add_child(1,0,reset_button)

		reset_settings(brightness_scale,brightness_toggle,contrast_scale,contrast_toggle,threshold_scale,threshold_toggle,points_toggle,self.settings)

		return window
Example #7
0
# Theme usage example.
from ocempgui.widgets import base, Renderer, Button, Label

# Load the theme.
base.GlobalStyle.load ("theme_example.rc")

# Create screen.
re = Renderer ()
re.create_screen (200, 100)
re.title = "Theme example"
re.color = (250, 250, 250)

# Create widgets.
button = Button ("Button")
button.topleft = 5, 5
label = Label ("Label")
label.topleft = 100, 5

re.add_widget (button, label)
re.start ()