#๐Ÿ”’ need help with fixing my dropdown menu

95 messages ยท Page 1 of 1 (latest)

dull houndBOT
#

@quick tapir

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lapis frigate
#

!paste

dull houndBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

lapis frigate
#

could you paste the entire code file and send the link please?

#

and also you mention a qss file, im not sure what i should name that

quick tapir
#

let me explain qss is like css but for pyside6

#

hold on im getting all the info together so i can explain it fully

tight hatch
#

The highlight is precisely 125 pixels wide

lapis frigate
#

its 167 on my screen

quick tapir
#

ok im sending over some more images too.

tight hatch
#

Okay, fine, the button and menu are 320 raw px (160 non-retina), the highlight is 250 (125 non retina)

quick tapir
#

i will send code for this and code for the first image i was able to isolate the issue somehow and get the bar to fully expand

tight hatch
#

interesting

#

What is that odd background behavior here?

austere abyss
#

can i just take a moment to let you all know that i love you very much

tight hatch
#

this looks like overlapped elements

quick tapir
#

thats what im trying to figure out too im trying to send the code but its too long so i need to split it

tight hatch
#

missing border radius on the selected block if it's the first item?

lapis frigate
#

use the pastebin

#

!paste

dull houndBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

tight hatch
#

Weird behavior though, css doesn't do that in browsers

quick tapir
#

oh snap soo helpful i love you

#

this is a desktop application

#

this code is the green dropdown i have more to send one second

#

this is the style for the dropdown

lapis frigate
#

ok i can see it on my end now

quick tapir
#

this is the pytton code for the button i'm trying to fix

tight hatch
#

the styelsheet didn't paste right?

#

I just see the python again...

quick tapir
lapis frigate
#

ok this looks like a stylesheet issue

#

give me a moment to make sense of it

quick tapir
#

there you go i sent over the python for each dropdown menu then the qss stylesheet for both menus. now my issue is i cant seem to get the bar to fully stretch

#

also i just want to express how appreciative i am for people stopping what there doing to help me out you have no idea how much that means to me

lapis frigate
#

your issue is the width: 100%. if i set it to width: 160px it looks fine

#

so i think its because the container isnt automatically growing either

#

the background not having border-radius applied is another issue...

quick tapir
#

so thats all i need to do then set it to 160?

tight hatch
#

Smells like there's a layer that's missing

#

what is a qmenu composed of

lapis frigate
#

i think the layout (QVBoxLayout) is missing style

quick tapir
#

hold on let me see if this works

lapis frigate
#

this makes me wish there was some kind of "inspect element" tool for this

quick tapir
#

sending the code for just the sidebar area one second

lapis frigate
#

hm so i get this now

#

what is the structure of the elements here?

#

QWidget -> QVBoxLayout -> QMenu / QPushButton?

quick tapir
#

this is entire sidebar

#

heres the structure of the elements in the sidebar section

QWidget (sidebar)
QVBoxLayout (sidebar_layout)
QWidget (sidebar_top_bar)
QHBoxLayout (sidebar_top_bar_layout)
QLabel (sidebar_label)
QSpacerItem (8px spacer)
QHBoxLayout (button_layout)
QPushButton (sidebar_button_1)
QSpacerItem (4px spacer)
QHBoxLayout (button_layout_2)
QPushButton (sidebar_button_2)
QSpacerItem (4px spacer)
QHBoxLayout (button_layout_3)
QPushButton (sidebar_dropdown_button)
QMenu (dropdown_menu)
QAction (for each frequency)
QSpacerItem (stretch)

lapis frigate
#

Warning: Unless otherwise specified, this property has no effect when set on widgets. If you want a widget with a fixed width, set the min-width and max-width to the same value.

quick tapir
#

i will look at that

lapis frigate
#

aha, getting better results already

quick tapir
#

what are you doing im over here pulling my hair out

lapis frigate
#

one second let me figure out how to fix the button width

quick tapir
#

okay i really really appreciate you

lapis frigate
#

look about right?

#

here is the qss


QPushButton {
    padding: 6px 12px;
    min-width: 160px; /* Set min and max width to desired size */
    max-width: 160px;
}

QMenu {
    background-color: #333333;
    border: 1px solid #555555;
    color: white;
    font-family: "Segoe UI";
    font-size: 10pt;
    border-radius: 4px;
    margin: 0;  /* Remove any margin around the menu */
    padding: 0;  /* Ensure no internal padding in the menu */
}

QMenu::item {
    padding: 6px 12px;  /* Ensuring consistent padding */
    border-radius: 4px;
    background-color: transparent;
    font-weight: normal;
    min-width: 160px;  /* Set min and max width to match button */
    max-width: 160px;
}

QMenu::item:selected {
    background-color: #5A9CF0;
    color: #ffffff;
}
#

i also removed the setFixedSize and setFixedWidth calls from the python code

#

basically the solution is min and max width

quick tapir
#

wow let me see

lapis frigate
#

since width itself seems to do nothing

quick tapir
#

i understand what you mean

#

i just don't understand what's going on. it didn't fix it

#

it looks better rounded though

#

not blaiming you im just llike wtf in general

lapis frigate
#

im guessing that using setFixedWidth will override the width for that widget, but it wont affect any child elements width that depend on it

quick tapir
#

humm

lapis frigate
#

looks like setting the width on the QMenu and using 100% on the items doesnt work either

#

so set min-width and max-width to 160px on the items themselves

quick tapir
#

nope but i sent over some testing code earlier that has the thing working for some reason

lapis frigate
#

let me catch up. can you send your current code and qss?

lapis frigate
quick tapir
#

this is the test code that's green i can send my code right now hold on

lapis frigate
#

its missing imports and things. can you send the entire file as a paste?

quick tapir
#

yep one moment

#

sorry got tied up

#

that is the qss stylesheet

dull houndBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.