def make_row_entry(grid: Gtk.Grid, entry_label: str,
                   label_cell_factory=make_label,
                   value_cell_factory=make_textview) -> GObject:
  label = make_label(entry_label)
  cell = value_cell_factory()
  grid.add(label)
  grid.attach_next_to(cell, label, side=Gtk.PositionType.RIGHT,
                      width=1, height=1)
  return cell
示例#2
0
    def _do_init(self, footer_area: Gtk.Grid) -> Gtk.Widget:
        self._widget = Gtk.Grid()

        frame = Gtk.Frame(margin=10, label_xalign=0.5)
        frame.show()
        self._widget.attach(frame, 0, 1, 1, 1)

        self._stack = Gtk.Stack()
        self._stack.show()
        frame.add(self._stack)

        _, self._individual_area = self.new_component(
            individual_cs.factory(model=self.presenter.individual_model))
        self._individual_area.show()
        self._stack.add_titled(self._individual_area,
                               name='Individual Fit',
                               title='Individual Fit')

        _, self._graphs_area = self.new_component(
            graphs_cs.factory(model=self.presenter.graphs_model))
        self._graphs_area.show()
        self._stack.add_titled(self._graphs_area,
                               name='Graphs',
                               title='Graphs')

        self._stack_switcher = Gtk.StackSwitcher(stack=self._stack)
        self._stack_switcher.show()
        frame.props.label_widget = self._stack_switcher

        self._stack.props.visible_child = self._individual_area

        _, footer_inner = self.new_component(
            results_footer_cs.factory(
                in_status=self.presenter.bn_footer_status,
                in_progress=self.presenter.bn_completion_progress,
                in_time_elapsed=self.presenter.bn_time_elapsed,
                in_time_remaining=self.presenter.bn_time_remaining,
                do_back=self.presenter.back,
                do_cancel=self.presenter.cancel,
                do_save=self.presenter.save,
            ))
        footer_inner.show()
        footer_area.add(footer_inner)

        self._confirm_cancel_dialog = None
        self._confirm_discard_dialog = None
        self._save_dialog_cid = None

        self.presenter.view_ready()

        return self._widget
示例#3
0
    def _do_init(self, footer_area: Gtk.Grid) -> Gtk.Widget:
        self._widget = Gtk.Grid(margin=10, column_spacing=10, row_spacing=10)

        image_source_lbl = Gtk.Label('Image source:')
        self._widget.attach(image_source_lbl, 0, 0, 1, 1)

        self._image_source_combobox = Gtk.ComboBoxText(hexpand=True, halign=Gtk.Align.START)
        self._widget.attach(self._image_source_combobox, 1, 0, 1, 1)

        self._populate_combobox()

        self._widget.attach(
            Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, hexpand=True),
            0, 1, 2, 1
        )

        _, configurator_area = self.new_component(
            configurator_cs.factory(
                in_acquirer=self.presenter.bn_acquirer
            )
        )
        self._widget.attach(configurator_area, 0, 2, 2, 1)

        self.bn_selected_acquirer_type = GObjectPropertyBindable(
            g_obj=self._image_source_combobox,
            prop_name='active-id',
            transform_to=lambda e: e.name if e is not None else None,
            transform_from=lambda name: AcquirerType[name] if name is not None else None,
        )  # type: Bindable[Optional[str]]

        _, footer_inside = self.new_component(
            linear_navigator_footer_cs.factory(
                do_next=self.presenter.next_page
            )
        )
        footer_inside.show()
        footer_area.add(footer_inside)

        self.presenter.view_ready()

        self._widget.foreach(Gtk.Widget.show)

        return self._widget
示例#4
0
    def _do_init(self, footer_area: Gtk.Grid) -> Gtk.Widget:
        self._widget = Gtk.Grid(margin=20, row_spacing=10, column_spacing=10)

        # Label widgets
        inner_density_lbl = Gtk.Label('Inner density (kg/m³):', xalign=0)
        self._widget.attach(inner_density_lbl, 0, 0, 1, 1)

        outer_density_lbl = Gtk.Label('Outer density (kg/m³):', xalign=0)
        self._widget.attach(outer_density_lbl, 0, 1, 1, 1)

        needle_width_lbl = Gtk.Label('Needle diameter (mm):', xalign=0)
        self._widget.attach(needle_width_lbl, 0, 2, 1, 1)

        gravity_lbl = Gtk.Label('Gravity (m/s²):', xalign=0)
        self._widget.attach(gravity_lbl, 0, 3, 1, 1)

        # Input widgets
        self._inner_density_inp = FloatEntry(lower=0, width_chars=10)
        self._widget.attach_next_to(self._inner_density_inp, inner_density_lbl,
                                    Gtk.PositionType.RIGHT, 1, 1)

        self._outer_density_inp = FloatEntry(lower=0, width_chars=10)
        self._widget.attach_next_to(self._outer_density_inp, outer_density_lbl,
                                    Gtk.PositionType.RIGHT, 1, 1)

        self._needle_width_inp = FloatEntry(lower=0, width_chars=10)
        self._widget.attach_next_to(self._needle_width_inp, needle_width_lbl,
                                    Gtk.PositionType.RIGHT, 1, 1)

        self._gravity_inp = FloatEntry(lower=0, width_chars=10)
        self._widget.attach_next_to(self._gravity_inp, gravity_lbl,
                                    Gtk.PositionType.RIGHT, 1, 1)

        self._inner_density_err_msg_lbl = Gtk.Label(xalign=0)
        self._inner_density_err_msg_lbl.get_style_context().add_class(
            'error-text')
        self._widget.attach_next_to(self._inner_density_err_msg_lbl,
                                    self._inner_density_inp,
                                    Gtk.PositionType.RIGHT, 1, 1)

        self._outer_density_err_msg_lbl = Gtk.Label(xalign=0)
        self._outer_density_err_msg_lbl.get_style_context().add_class(
            'error-text')
        self._widget.attach_next_to(self._outer_density_err_msg_lbl,
                                    self._outer_density_inp,
                                    Gtk.PositionType.RIGHT, 1, 1)

        self._needle_width_err_msg_lbl = Gtk.Label(xalign=0)
        self._needle_width_err_msg_lbl.get_style_context().add_class(
            'error-text')
        self._widget.attach_next_to(self._needle_width_err_msg_lbl,
                                    self._needle_width_inp,
                                    Gtk.PositionType.RIGHT, 1, 1)

        self._gravity_err_msg_lbl = Gtk.Label(xalign=0)
        self._gravity_err_msg_lbl.get_style_context().add_class('error-text')
        self._widget.attach_next_to(self._gravity_err_msg_lbl,
                                    self._gravity_inp, Gtk.PositionType.RIGHT,
                                    1, 1)

        self._widget.show_all()

        self.bn_inner_density = GObjectPropertyBindable(
            g_obj=self._inner_density_inp,
            prop_name='value',
        )

        self.bn_outer_density = GObjectPropertyBindable(
            g_obj=self._outer_density_inp,
            prop_name='value',
        )

        self.bn_needle_width = GObjectPropertyBindable(
            g_obj=self._needle_width_inp,
            prop_name='value',
            # Needle width shown to user is in millimetres.
            transform_from=lambda x: x / 1000 if x is not None else None,
            transform_to=lambda x: x * 1000 if x is not None else None,
        )

        self.bn_gravity = GObjectPropertyBindable(
            g_obj=self._gravity_inp,
            prop_name='value',
        )

        _, footer_inside = self.new_component(
            linear_navigator_footer_cs.factory(
                do_back=self.presenter.prev_page,
                do_next=self.presenter.next_page,
            ))
        footer_inside.show()
        footer_area.add(footer_inside)

        self.presenter.view_ready()

        return self._widget