Beispiel #1
0
    def __init__(self, alarm_access):
        """Initialize a Gtk.Box with all the intro part elements.

        Parameters
        ----------
        alarm_access: just_playback.Playback
            An access to the Playback instance used to play the end timer
            alarm.
        """

        Gtk.Box.__init__(self, spacing=6)
        self.instruction_label = Gtk.Label()
        self.instruction_label.set_label("Please enter a remaining time")
        self.instruction_label.set_xalign(1)  # align to the center

        self.menu_item_about = Gtk.MenuItem(label="About")
        self.menu_item_about.connect("activate", self.about_dialog)

        self.menu = Gtk.Menu()
        self.menu.append(self.menu_item_about)
        self.menu.show_all()

        self.param = Gtk.MenuButton(halign='end')
        self.param.set_popup(self.menu)
        self.param.set_direction(Gtk.ArrowType(4))

        adjustment_volume = Gtk.Adjustment(value=80,
                                           lower=0,
                                           upper=100,
                                           step_increment=1,
                                           page_increment=10,
                                           page_size=0)
        self.volume = Gtk.VolumeButton(halign='end')
        self.volume.set_adjustment(adjustment_volume)
        self.volume.connect("value-changed", self.param_volume)

        self.pack_start(self.instruction_label, True, True, 0)
        self.pack_start(self.volume, True, True, 0)
        self.pack_start(self.param, True, True, 0)

        self.alarm = alarm_access
Beispiel #2
0
    def __init__(self, gui):
        window.__init__(self, gui)
        self.name = 'new_experiment_window'

        # User selection
        #self.cb = Gtk.ComboBoxText()
        #for user in gui.users:
        #	self.cb.append_text(user)
        #self.cb.set_active(0)

        self.user_list = [key for key in gui.users]
        self.num_users = len(gui.users)
        self.user_select_index = 0
        self.selected_user = self.user_list[0]
        self.user_indicator = Gtk.Label(self.user_list[0])

        next_user_button = Gtk.Button()
        arrow_next = Gtk.Arrow(Gtk.ArrowType(3))
        next_user_button.add(arrow_next)
        next_user_button.connect('clicked', self.arrow_clicked, 'next')

        prev_user_button = Gtk.Button()
        arrow_prev = Gtk.Arrow(Gtk.ArrowType(2))
        prev_user_button.add(arrow_prev)
        prev_user_button.connect('clicked', self.arrow_clicked, 'prev')

        self.user_box = Gtk.HBox()
        self.user_box.pack_start(prev_user_button, True, True, 0)
        self.user_box.pack_start(self.user_indicator, True, True, 0)
        self.user_box.pack_start(next_user_button, True, True, 0)
        self.user_label = Gtk.Label('User:'******'Num cycles:')

        # Light and dark times
        num_light_hours_adj = Gtk.Adjustment(value=0,
                                             lower=0,
                                             upper=24,
                                             step_incr=1)
        num_light_mins_adj = Gtk.Adjustment(value=0,
                                            lower=0,
                                            upper=60,
                                            step_incr=1)
        num_dark_hours_adj = Gtk.Adjustment(value=0,
                                            lower=0,
                                            upper=24,
                                            step_incr=1)
        num_dark_mins_adj = Gtk.Adjustment(value=0,
                                           lower=0,
                                           upper=60,
                                           step_incr=1)
        self.num_light_hours = Gtk.SpinButton()
        self.num_light_mins = Gtk.SpinButton()
        self.num_dark_hours = Gtk.SpinButton()
        self.num_dark_mins = Gtk.SpinButton()
        self.num_light_hours.set_adjustment(num_light_hours_adj)
        self.num_light_mins.set_adjustment(num_light_mins_adj)
        self.num_dark_hours.set_adjustment(num_dark_hours_adj)
        self.num_dark_mins.set_adjustment(num_dark_mins_adj)
        light_label = Gtk.Label('Light time:')
        num_light_hours_label = Gtk.Label('Hours,')
        num_light_mins_label = Gtk.Label('Minutes')
        dark_label = Gtk.Label('Dark time:')
        num_dark_hours_label = Gtk.Label('Hours,')
        num_dark_mins_label = Gtk.Label('Minutes')

        # Light level
        light_level_adj = Gtk.Adjustment(value=20,
                                         lower=0,
                                         upper=40,
                                         step_incr=2)
        self.light_level = Gtk.SpinButton()
        self.light_level.set_adjustment(light_level_adj)
        light_level_label = Gtk.Label('Light level (mW):')

        # Temperature
        temperature_adj = Gtk.Adjustment(value=20,
                                         lower=15,
                                         upper=25,
                                         step_incr=1)
        self.temperature = Gtk.SpinButton()
        self.temperature.set_adjustment(temperature_adj)
        temperature_label = Gtk.Label('Temperature:')
        temperature_units = Gtk.Label('Degrees Celsius')
        if get_num_running_experiments() == 0:
            self.set_temperature = True
            self.temperature.set_sensitive(True)
        else:
            self.set_temperature = False
            self.temperature.set_sensitive(False)

        # Buttons
        start_icon = Gtk.Image()
        start_icon.set_from_file(configs['START_ICON'])
        self.start_button = Gtk.Button()
        self.start_button.add(start_icon)
        self.start_button.connect('clicked', self.start_button_clicked)
        self.start_button.set_relief(Gtk.ReliefStyle.NONE)

        cancel_icon = Gtk.Image()
        cancel_icon.set_from_file(configs['CANCEL_ICON'])
        self.cancel_button = Gtk.Button()
        self.cancel_button.add(cancel_icon)
        self.cancel_button.connect('clicked', self.cancel_button_clicked)
        self.cancel_button.set_relief(Gtk.ReliefStyle.NONE)

        # Set margins for all widgets
        self.widgets = [
            self.user_label, self.num_cycles, num_cycles_label,
            self.num_light_hours, self.num_light_mins, self.num_dark_hours,
            self.num_dark_mins, num_light_hours_label, num_light_mins_label,
            num_dark_hours_label, num_dark_mins_label, self.light_level,
            light_level_label, self.temperature, temperature_label,
            temperature_units, self.start_button, self.cancel_button
        ]

        for widget in self.widgets:
            widget.set_margin_top(configs['MARGINS']['TOP'])
            widget.set_margin_bottom(configs['MARGINS']['BOTTOM'])
            widget.set_margin_left(configs['MARGINS']['LEFT'])
            widget.set_margin_right(configs['MARGINS']['RIGHT'])

        # Putting all widgets on the grid
        grid = Gtk.Grid()

        grid.attach(self.user_label, 0, 0, 1, 1)
        grid.attach(self.user_box, 1, 0, 2, 1)

        grid.attach(num_cycles_label, 0, 1, 1, 1)
        grid.attach(self.num_cycles, 1, 1, 1, 1)

        grid.attach(light_label, 0, 2, 1, 1)
        grid.attach(self.num_light_hours, 1, 2, 1, 1)
        grid.attach(num_light_hours_label, 2, 2, 1, 1)
        grid.attach(self.num_light_mins, 3, 2, 1, 1)
        grid.attach(num_light_mins_label, 4, 2, 1, 1)

        grid.attach(dark_label, 0, 3, 1, 1)
        grid.attach(self.num_dark_hours, 1, 3, 1, 1)
        grid.attach(num_dark_hours_label, 2, 3, 1, 1)
        grid.attach(self.num_dark_mins, 3, 3, 1, 1)
        grid.attach(num_dark_mins_label, 4, 3, 1, 1)

        grid.attach(light_level_label, 0, 4, 1, 1)
        grid.attach(self.light_level, 1, 4, 1, 1)

        grid.attach(temperature_label, 0, 5, 1, 1)
        grid.attach(self.temperature, 1, 5, 1, 1)
        grid.attach(temperature_units, 2, 5, 1, 1)

        # Vertical box (for buttons)
        vbox = Gtk.VBox()
        vbox.pack_start(self.start_button, True, True, 0)
        vbox.pack_start(self.cancel_button, True, True, 0)

        # Horizontal box (grid a vbox)
        box = Gtk.Box()
        box.pack_start(grid, True, True, 0)
        box.pack_start(vbox, True, True, 0)

        self.add(box)
        self.show_all()