#Help with Paginator (Page Groups)

1 messages · Page 1 of 1 (latest)

calm spruce
#

**Is it possible to start the paginator with the group selector menu disabled? **
I'm using the PageTest class from the paginator example cogs file. Specifically the /pagetest groups slash command. When instancing the Paginator using:

        paginator = pages.Paginator(
            pages=page_groups, 
            show_menu=False, 
            menu_placeholder=f"{self.categories[0]}"
            )
        await paginator.respond(ctx.interaction, ephemeral=False)

    if sum(pg.default is True for pg in self.page_groups) > 1:
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

starting with show_menu=True works (this is the default way the example was set up).

if I start with show_menu=True then update the paginator with show_menu=False it removes the menu fine. I am guessing this has something to do with the paginator.respond?:

        paginator = pages.Paginator(
            pages=page_groups, 
            show_menu=True, 
            menu_placeholder=f"{self.categories[0]}"
            )
        await paginator.respond(ctx.interaction, ephemeral=False)
        await asyncio.sleep(3)
        await paginator.update(show_disabled=True, show_menu=False)

I would really like to be able to start this without the menu showing as a plan to have a button spawn the menu

More Code:
https://pastebin.com/FWiapTC2

queen fractalBOT
real crown
#

This seems to be a bug in the ext.pages code here

queen fractalBOT
#

discord/ext/pages/pagination.py lines 412 to 422

if all(isinstance(pg, PageGroup) for pg in pages):
    self.page_groups = self.pages if show_menu else None
    if sum(pg.default is True for pg in self.page_groups) > 1:
        raise ValueError("Only one PageGroup can be set as the default.")
    for pg in self.page_groups:
        if pg.default:
            self.default_page_group = self.page_groups.index(pg)
            break
    self.pages: list[Page] = self.get_page_group_content(
        self.page_groups[self.default_page_group]
    )```
real crown
#

Im not sure why page groups relies on show_menu as shown in the 2nd line of the snipet.

#

You can try removing the if show_menu else None part otherwise you can hack around it by

paginator.children.pop(-1)

As this should remove the last item (which would be the select menu)
Just note this is very prone to breaking and is a hack around not a final solution

calm spruce
#

i might know what the problem is

#

did you catch the note about how i changed the self.pages type?

#

honestly i didn't know the proper python way to add my content to the page groups

#

the example has 2 groups, one used self.pages the other it created inside the /pagetest groups slash command

#

my self. pages looks like this:


self.pages = {0: [<discord.ext.pages.pagination.Page object at 0x0000023464375760>, <discord.ext.pages.pagination.Page object at 0x0000023464375820>, ...] 1: [<dis...], 2:[<dis...]}

...

def get_pages(self, x):
   return self.pages[x]

...

        page_groups = [
            pages.PageGroup(
                pages=self.get_pages(x),
                label=f"{self.categories[x]}",
                description=f"Page Group #{x}",
                custom_buttons=page_buttons,
                use_default_buttons=False,
                custom_view=view,
            ) for x in range(len(self.categories))
        ]
        paginator = pages.Paginator(
            pages=page_groups, 
            show_menu=True, 
            menu_placeholder=f"{self.categories[0]}",
            )

this is just the first way i thought to do it, is this creating problems?

real crown
#

This is a normal way to create page groups.

calm spruce
#

And thank you that works, any idea why my buttons are not showing up in the view? only shows after i change the selection manu

#

they have been added to the view before custom_view=view im assuming they are somehow overwritten

#

i can't add my buttons to the custom_buttons becuase the PageGroup custom buttons only accepts PaginatorButtons

#

nvm let me try adding in the acutal paginator and possibly change the default row

real crown
#

what if you add the custom_buttons to the view?

calm spruce
#

i did

queen fractalBOT
calm spruce
#

ill play around wit h #1287927419142930564 message

real crown
#

Sounds good!
Pages is useful but it has always had its obscure bugs. We have been avoiding rewriting it as it would be a breaking change.

calm spruce
#

Hey thanks alot for the help. I have many qustions about the paginator.. am i supposed to make a new thread for each question? @real crown (sorry if this isn't what you meant in your discord profile)