Python gi.repository.Gtk 模块,Stack() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用gi.repository.Gtk.Stack()

项目:Vulnerabilities-spider    作者:muhammad-bouabid    | 项目源码 | 文件源码
def __init__(self, parent):
      Gtk.Dialog.__init__(self, "Something", parent,
          Gtk.DialogFlags.MODAL, buttons=(
          Gtk.STOCK_NEW, Gtk.ResponseType.OK,
          Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

      self.set_default_size(400, 600)

      box = self.get_content_area()

      label = Gtk.Label("Insert text you want to search for:")
      box.add(label)

#        self.entry = Gtk.Entry()
#        box.add(self.entry)

      self.main_area = Gtk.Stack()
      self.main_area.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)

      self.main_area.set_transition_duration(1000)

      self.entry = Gtk.Entry()
      self.main_area.add_titled(self.entry, "entry_name", "Entry Url")

      self.labelS = Gtk.Label()
      self.label_txt = """<big><i>you have choice to runn the scan directly or after setup the scanning process you want to follow on your target</i></big>"""
      self.labelS.set_markup(self.label_txt)
      self.labelS.set_line_wrap(True)
      self.main_area.add_titled(self.labelS, "label_name", "How Scan will Start")

      self.our_stackSwitcher = Gtk.StackSwitcher()
      self.our_stackSwitcher.set_stack(self.main_area)

      box.add(self.our_stackSwitcher)
      box.add(self.main_area)

      self.show_all()


#~~~~~~~~~~~~ History Dialog ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
项目:fpi    作者:solus-cold-storage    | 项目源码 | 文件源码
def build_contents(self):
        """ Build the main UI display regions """
        self.stack = Gtk.Stack()
        self.box.pack_start(self.stack, True, True, 0)

        button = Gtk.Button("Install")
        lab_disclaimer = Gtk.Label(
            "This is a third party package and is not officially supported"
            " by Solus")
        img_warn = Gtk.Image.new_from_icon_name(
            "dialog-warning-symbolic", Gtk.IconSize.BUTTON)
        self.abar.pack_start(img_warn)
        self.abar.pack_start(lab_disclaimer)
        self.abar.pack_end(button)
        button.get_style_context().add_class("destructive-action")

        # Details
        dumb = Gtk.Label("Details ...")
        self._fix_label(dumb)
        dumb.set_property("margin", 12)
        self.stack.add_titled(dumb, "desc", "Details")

        # Files
        dumb = Gtk.Label("Files ...")
        self._fix_label(dumb)
        dumb.set_property("margin", 12)
        self.stack.add_titled(dumb, "files", "Files")
项目:dri-config    作者:TingPing    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super().__init__(
            default_width=800,
            default_height=400,
            **kwargs
        )
        self.add_dialog = None


        action = Gio.SimpleAction.new('add-application', None)
        self.add_action(action)
        action.connect('activate', self.on_add_application)


        header = Gtk.HeaderBar(show_close_button=True, title=_('DRI Configuration'))
        add_btn = Gtk.Button.new_from_icon_name('list-add-symbolic', Gtk.IconSize.BUTTON)
        add_btn.props.action_name = 'win.add-application'
        header.pack_start(add_btn)
        header.show_all()
        self.set_titlebar(header)

        box = Gtk.Box(Gtk.Orientation.HORIZONTAL)
        sidebar = Gtk.StackSidebar()
        sw = Gtk.ScrolledWindow(child=sidebar, hscrollbar_policy=Gtk.PolicyType.NEVER)
        box.pack_start(sw, False, True, 0)

        stack = Gtk.Stack()
        # Just a basic mockup
        conf = dri.DRIConfig('/etc/drirc')
        device = conf.devices[0]
        for app in device.apps:
            # TODO: Group these by device
            pane = ApplicationPane(app, visible=True)
            stack.add_titled(pane, app.name, app.name)
        sidebar.props.stack = stack

        sw = Gtk.ScrolledWindow(child=stack)
        box.pack_start(sw, True, True, 0)
        box.show_all()
        self.add(box)
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def on_main_view_change(self, main_view: Gtk.Stack, somearg):
        from cloneentry import CloneToImageEntry
        from restoreentry import RestoreFromImageEntry

        current_view = main_view.get_visible_child()
        if not self.is_mounted():
            self.clone_button.set_sensitive(type(current_view) is not CloneToImageEntry)
            self.restore_button.set_sensitive(type(current_view) is not RestoreFromImageEntry)
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, sources: List[Dict[str, Any]], core: ApartCore, main_view: 'MainView'):
        Gtk.Stack.__init__(self)
        self.core = core
        self.sources = sources
        self.main_view = main_view
        self.updating = False

        self.connect('notify::visible-child', self.on_child_change)
        self.get_style_context().add_class('part-info')

        self.update_sources(sources)
        self.show_all()
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, core: ApartCore, z_options: List[str]):
        Gtk.Stack.__init__(self)
        self.set_transition_type(Gtk.StackTransitionType.NONE)
        self.set_transition_duration(settings.animation_duration_ms())
        self.new_clone = CloneToImageEntry(self, core, z_options)
        self.add_named(self.new_clone, name='new-clone')
        self.progress = ProgressAndHistoryView(core, z_options)
        self.add_named(self.progress, name='progress')
        self.new_restore = RestoreFromImageEntry(self, core, z_options)
        self.add_named(self.new_restore, name='new-restore')
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()

        self.set_name('ProcessorBox')
        self.set_valign(Gtk.Align.CENTER)
        self.set_halign(Gtk.Align.CENTER)
        self.set_hexpand(True)
        self.set_vexpand(True)
        self.set_orientation(Gtk.Orientation.VERTICAL)

        self._stack = Gtk.Stack()
        self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self._stack.set_transition_duration(300)
        self._stack.props.margin = ItemsProcessors.MARGIN

        self._switcher = Gtk.StackSwitcher()
        self._switcher.set_no_show_all(True)
        self._switcher.set_stack(self._stack)
        self._switcher.set_halign(Gtk.Align.CENTER)
        self._switcher.props.margin = ItemsProcessors.MARGIN
        self._switcher.show()

        self.add(self._switcher)
        self.add(self._stack)
        self.show_all()

        self._items = []
        self._timeout_id = 0
        self._show_switcher = True
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def _on_button_clicked(self, button):
        dialog = Gtk.Dialog()
        dialog.set_transient_for(self)

        gpaste_settings = GPaste.SettingsUiWidget()

        for child in gpaste_settings.get_children():
            if isinstance(child, Gtk.StackSwitcher):
                toplevel = dialog.get_toplevel()
                if not toplevel: continue

                gpaste_settings.remove(child)

                header_bar = Gtk.HeaderBar()
                header_bar.set_show_close_button(True)
                header_bar.set_title(None)
                header_bar.set_subtitle(None)
                header_bar.set_custom_title(child)

                toplevel.set_titlebar(header_bar)

            if isinstance(child, Gtk.Stack):
                child.set_transition_type(
                    Gtk.StackTransitionType.SLIDE_LEFT_RIGHT
                )
                child.set_transition_duration(self._transition_duration)

        content_area = dialog.get_content_area()
        content_area.add(gpaste_settings)

        dialog.show_all()
        dialog.run()
        dialog.destroy()
项目:cavalcade    作者:worron    | 项目源码 | 文件源码
def __init__(self, mainapp):
        super().__init__("settings.glade", ("window", "mainbox"))
        self.gui["window"].set_keep_above(True)

        # build stack
        stack = Gtk.Stack()
        stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        stack.set_transition_duration(500)

        # add visual page
        self.visualpage = VisualPage(mainapp, self.gui["window"])
        stack.add_titled(self.visualpage.gui["mainbox"], "visset", "Visual")

        # add cava page
        self.cavapage = CavaPage(mainapp)
        stack.add_titled(self.cavapage.gui["mainbox"], "cavaset", "CAVA")

        # add player page
        if mainapp.is_player_enabled:
            self.playerpage = PlayerPage(mainapp)
            stack.add_titled(self.playerpage.gui["mainbox"], "playset", "Player")

        # setup stack
        stack_switcher = Gtk.StackSwitcher(halign=Gtk.Align.CENTER)
        stack_switcher.set_stack(stack)

        self.gui["mainbox"].pack_start(stack_switcher, False, True, 0)
        self.gui["mainbox"].pack_start(stack, True, True, 0)

        # signals
        self.gui["window"].connect("delete-event", self.hide)
        self.visualpage.gui["hide_button"].connect("clicked", self.hide)
        self.visualpage.gui["exit_button"].connect("clicked", mainapp.close)
项目:lightdm-settings    作者:linuxmint    | 项目源码 | 文件源码
def __init__(self, label, main_widget, alternative_widget=None):

        self.main_widget = main_widget
        self.alternative_widget = alternative_widget
        self.label = label
        self.stack = Gtk.Stack()
        self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        self.stack.set_transition_duration(1000)

        self.stack.add_named(main_widget, "main_widget")
        if alternative_widget is not None:
            self.stack.add_named(self.alternative_widget, "alternative_widget")

        Gtk.ListBoxRow.__init__(self)

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        hbox.set_border_width(5)
        hbox.set_margin_left(20)
        hbox.set_margin_right(20)
        self.add(hbox)

        grid = Gtk.Grid()
        grid.set_column_spacing(15)
        hbox.pack_start(grid, True, True, 0)

        self.description_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.description_box.props.hexpand = True
        self.description_box.props.halign = Gtk.Align.START
        self.description_box.props.valign = Gtk.Align.CENTER
        self.label.props.xalign = 0.0
        self.description_box.add(self.label)

        grid.attach(self.description_box, 0, 0, 1, 1)
        grid.attach_next_to(self.stack, self.description_box, Gtk.PositionType.RIGHT, 1, 1)
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, core: ApartCore, z_options: List[str]):
        Gtk.Stack.__init__(self)
        self.core = core
        self.z_options = z_options

        self.get_style_context().add_class('progress-view')
        self.next_notification = NotificationHelper()

        self.nothing_label = Gtk.Label('Select a partition to clone', xalign=0.5, vexpand=True)
        self.nothing_label.get_style_context().add_class('dim-label')
        self.add(self.nothing_label)

        self.content = Gtk.VBox(valign=Gtk.Align.START)
        self.add(self.content)

        self.running_jobs_label = Gtk.Label('Running', halign=Gtk.Align.START)
        self.running_jobs_label.get_style_context().add_class('section-title')
        self.content.add(self.running_jobs_label)

        # self.running_jobs: Dict[str, RunningJob] = {} <- not compatible with 3.5
        self.running_jobs = {}
        self.running_jobs_grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL,
                                          column_spacing=6,
                                          row_spacing=6)

        self.running_jobs_grid.get_style_context().add_class('jobs')
        self.content.add(self.running_jobs_grid)

        # self.finished_jobs: Dict[str, FinishedJob] = {} <- not compatible with 3.5
        self.finished_jobs = {}
        self.finished_jobs_label = Gtk.Label('History', halign=Gtk.Align.START)
        self.finished_jobs_label.get_style_context().add_class('section-title')
        self.content.add(self.finished_jobs_label)

        self.finished_jobs_grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL,
                                           column_spacing=6)
        self.finished_jobs_grid.get_style_context().add_class('finished-jobs')
        self.content.add(self.finished_jobs_grid)

        self.show_all()

        self.listener = MessageListener(message_predicate=lambda m: m['type'] in ['clone',
                                                                                  'restore',
                                                                                  'clone-failed',
                                                                                  'restore-failed'],
                                        on_message=lambda m: GLib.idle_add(self.on_job_message, m),
                                        listen_to=core)

        GLib.timeout_add(interval=1000, function=self.update_jobs)
        self.connect('destroy', self.save_history)
        GLib.idle_add(self.read_history)