#pyqt | Logs for 2019-02-05
Back
[04:42:42] -!- BPL has joined #pyqt
[05:59:38] -!- Belxjander has joined #pyqt
[10:56:20] -!- storgance has joined #pyqt
[11:03:44] <storgance> Hello, everyone. I am attempting to do some basic widget manipulation on PyQt5 using the sizeHint property along with SizePolicy. Here is what I have written thus far: https://pastebin.com . However, despite what I interpret from the documentation, the policy seems to be entirely ignored. The twist is that while this does not work on my Windows 10 machine, it appears to work on my friend's Linux machine. Is this a known bug
[11:04:15] -!- daegontaven has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
[11:05:05] <storgance> I should clarify: My goal is to have the blue widget be only a certain size and take the entire window, and the yellow widget to grow the same over top of it. My final goal is to have the yellow box just grow vertically, but that's besides the point right now.
[11:05:21] <storgance> *blue widget be at least a certain size
[11:05:51] -!- daegontaven has joined #pyqt
[11:06:50] <altendky> storgance: shouldn't the lambdas take a self parameter? and i can't say i'd be particularly surprised that trying to override methods without inheriting doesn't work. though i'm certainly not an expert at those mechanisms
[11:06:59] -!- nilshi has parted #pyqt
[11:07:55] <altendky> storgance: you want the widgets stacked on top of each other? the QStackedWidget or QStackedLayout might be of interest
[11:08:56] <altendky> storgance: i'm still not totally clear what your target is but i'm in linux here and i see a fixed size yellow box and then i can resize the window and the blue seems to follow
[11:09:25] <storgance> altendky: I don't believe the example I saw used a self parameter. I am not sure what you mean by the second part of that first message though. I am trying to emulate frame + pack on tkinter.
[11:09:45] <storgance> The yellow box is fixed size for you? hmm
[11:09:48] <altendky> storgance: i don't know tk well enough for that to help.
[11:11:10] -!- Siecje has joined #pyqt
[11:11:24] <altendky> storgance: do you want the blue to be a container that the yellow goes inside? or the yellow stacked in front of the blue? or...
[11:11:50] <storgance> My goal is: Have one widget (blue) be the size of the entire window and not get smaller than a certain size. Then, I would like a second widget (yellow), which is a child of the first widget, be a fixed width, but be the height of the entire window.
[11:11:51] <altendky> storgance: you don't have any layouts so this is a bit odd for qt, generally
[11:12:37] <altendky> storgance: why not just a horizontal layout with something on the left and something on the right?
[11:12:45] <storgance> Currently, the second, yellow widget is just growing on both x and y though, just as I wanted to see if there was some weird constraint I had
[11:13:19] <storgance> altendky: Does a horizontal layout let you have each widget grow in different manners?
[11:13:24] <altendky> storgance: sure
[11:14:01] <storgance> Hmm, okay. I will do that. But, do you think that will fix my issue with the yellow box not growing, and nothing having a minimum size on windows?
[11:16:16] <altendky> storgance: using layouts will address the yellow box not growing. presently it's just floating and is being given it's requested minimum (it seems, for me) because there's no layout encouraging it to take up more space. widgets not in layouts isn't a good place to start.
[11:16:52] <storgance> Ohhh, I see. Thank you, I will do that then. I appreciate the help.
[11:16:55] <altendky> storgance: i personally often use grid layouts regardless (as opposed to horizontal or vertical) because so often i end up adding more things and wanting the flexibility of the grid layout
[11:17:09] <altendky> storgance: but, at a minimum use a QHBoxLayout if you want columns
[11:17:17] <storgance> Is there any negative consequence to using grid?
[11:17:27] <storgance> Just extra space, misleading, ?
[11:17:31] <altendky> storgance: probably. not sure exactly what to point out though
[11:17:52] <storgance> Ok, thank you.
[11:17:56] <altendky> and it's not like it can't be changed later
[11:18:02] <storgance> true
[11:19:01] <altendky> storgance: i think the minimum window size is a bit tough, but i think i might have an example. for the yellow i would expect you end up with a fixed horizontal size policy, but no manually set size hint.
[11:19:18] <altendky> storgance: you want the right hand column to also have some minimum width?
[11:20:34] <storgance> I want the right hand column to grow by width
[11:20:48] <storgance> as opposed to the left hand column, which grows by height
[11:21:09] <storgance> the idea is that there's a list of chats on the left, and a chat window on the right. See Telegram Desktop for what I am attempting to emulate
[11:21:10] <altendky> storgance: won't they both grow vertically with a taller window?
[11:21:28] <storgance> Yes, sorry. The right hand column does grow in both directions
[11:21:47] <altendky> storgance: also, you may want a splitter layout so the user can adjust it
[11:22:07] <storgance> I haven't heard of that...I will look it up
[11:22:29] <altendky> http://doc.qt.io well, widget not layout but...
[11:23:02] <storgance> Ooo, I see. Thank you
[11:23:41] <altendky> storgance: http://doc.qt.io would probably be how you 'fix' the left column
[11:23:58] <altendky> mm, maybe
[11:26:54] <storgance> I thought stretchFactor stuff was about the growing ratio to adjacent widgets
[11:27:18] <altendky> storgance: right, i'm not confident on this point but i had in my head that 0 for left and 1 for right could be useful here maybe
[11:27:38] <altendky> storgance: i thought i had an example of this but i had rewritten it at some point without a splitter
[11:27:54] <storgance> Oh, true
[11:28:03] <storgance> dang
[11:28:39] <altendky> storgance: at least someone else thinks that might work https://stackoverflow.com
[11:30:26] <storgance> Cool, thank you
[11:31:10] <altendky> storgance: i probably wouldn't worry, at least for now, about enforcing a minimum window size. in some sense it's not even a nice thing to do to users. after that i think the only point left is getting a sensible initial left-column width.
[11:32:22] <storgance> Hmm...Perhaps. I just thought that if Telegram did it, I might wanna do it. But you have a point
[11:34:05] <altendky> storgance: i'd get something where you can see your various widgets and then look back at whether you want a minimum window size, and if so, if you can get there with just size policies on whatever widgets you want to drive that minimum size.
[11:35:11] <Avaris> if you want a minimum size, you need setMinimumSize. sizePolicy doesn't do anything for that
[11:35:31] <storgance> altendky: I suppose so.
[11:35:56] <Avaris> sizepolicy is to figure out a size between minimum and maximum sizes
[11:36:49] <storgance> Avaris: But the sizePolicy documentation is worded in such a way that it suggests it can do the same thing as setMinimumSize while also permitting for automatic growth (which is why I used it)
[11:37:10] <altendky> Avaris: is that specific to windows? i would have thought that setting the size policy to minimum or minimum expanding (assuming the widget has a non-zero size hint) would encourage a minimum size
[11:37:17] <storgance> https://doc.qt.io
[11:37:19] <altendky> well, windows -> top level widgets
[11:38:11] <Avaris> sorry, yes for windows.
[11:38:34] <storgance> Damn, that's annoying...thank you for that information
[11:39:43] <Avaris> size policy is for widgets inside layouts
[11:40:11] <storgance> I suppose what altendky stands up doubly then
[11:40:14] <altendky> https://github.com i do have setMinimumSize in my dialog.
[11:40:45] <Avaris> umm, setFixedSize is redundant there
[11:41:04] <altendky> Avaris: mostly what i remember about that code is that i was confused
[11:41:12] <Avaris> setFixedSize(size) == setMinimumSize(size) setMaximumSize(size)
[11:42:08] <altendky> Avaris: i think that may have forced the size and then i expand the limits by setting min/max so the user can still resize
[11:45:31] <storgance> Thank you both once again, and have a good day. I'll pop back in if I get stuck again)
[11:45:39] -!- storgance has quit [Quit: Page closed]
[11:45:41] <altendky> Avaris: so that's being called from right above when i either show or hide the 'details' section of the dialog. so i'm trying to actually change the window size to be bigger or smaller, but i also want to leave the limits on the size broader so the user can make the dialog somewhat bigger or smaller.
[11:46:12] <Avaris> i mean setFixedSize is literally setting both sizes in one go. so effectively, you're calling setMinimumSize or setMaximumSize twice where the first is immediately overridden
[11:47:08] <Avaris> oh, you're doing it to resize? that's a roundabout way of calling resize :)
[11:47:44] <altendky> Avaris: i did say i was confused. i don't recall if i tried resize. but yes, i'm not setting min/max to the same value so...
[11:55:58] <altendky> Avaris: yes, .resize() instead seems to do the same thing