#pyqt | Logs for 2019-03-01

Back
[03:33:15] -!- BPL has joined #pyqt
[04:35:36] -!- n1` has joined #pyqt
[05:46:07] -!- BPL has quit [Quit: Leaving]
[06:15:20] -!- mintograde has joined #pyqt
[06:29:56] -!- mintograde has quit [Ping timeout: 250 seconds]
[09:13:50] -!- Siecje has joined #pyqt
[10:30:48] -!- Meorge has quit [Ping timeout: 252 seconds]
[11:16:56] -!- Safa_[A_boy] has joined #pyqt
[11:18:33] <Safa_[A_boy]> Hello! I have a question. I have created several classes to read a specific binary file. One class: https://pastebin.com . How can I now add the needed properties to work with it from QML? (I mean pyqtProperties)
[11:20:47] -!- JanC has quit [Remote host closed the connection]
[11:37:12] -!- JanC has joined #pyqt
[11:45:51] <Siecje> You should be reading from the file in Python and just use QML as the presentation.
[12:02:43] -!- Lauxley has joined #pyqt
[12:05:20] -!- storgance has joined #pyqt
[12:06:29] <storgance> altendky: Hello. So...it appears that setting the size policy of AdjustToContents to QTextEdit and QTextBrowser seems to give the box a specific size which it, despite the name, does not resize from...
[12:09:14] <altendky> storgance: you want your window jumping around in size depending on the text in it?
[12:09:19] <storgance> Yep
[12:09:26] <altendky> storgance: that seems really annoying
[12:09:46] <storgance> Wait, the whole window? No
[12:10:04] <storgance> Just the size of the QTextBrowser widget
[12:10:20] <storgance> I want 1 line of text to only take 1 line of space.
[12:10:36] <altendky> storgance: this is for where the user enters a message?
[12:10:58] <storgance> For now, just where there's an unchangeable received message. I was going to work on that later
[12:12:02] <altendky> storgance: can you share code showing an issue?
[12:12:05] <storgance> https://i.imgur.com
[12:12:07] <storgance> Sure, one second
[12:12:29] <storgance> https://pastebin.com
[12:12:42] <altendky> storgance: you don't want to have the blank space within the blue line and beneath the )aaaaaaa?
[12:12:46] <altendky> err 0aaaaaa
[12:12:57] <storgance> Yep
[12:13:42] <storgance> I tried seeing if it was the QListView trying to make uniform sized or unchanging sized elements, but it's not
[12:14:05] <altendky> storgance: how do you know that?
[12:14:49] <storgance> I checked the member values for those properties and made sure they were set to change size as they wished
[12:15:23] <Safa_[A_boy]> Siecje, Yes, but to use QML, I need Qt properties, no? I need to modify these values as well, to write the file later on
[12:15:31] <storgance> Plus, the input box at the bottom is not in a QListView
[12:15:44] <altendky> Safa_[A_boy]: are pyqtProperties not giving you the qt properties you need?
[12:16:44] -!- kdas_ has quit [Quit: ZNC 1.7.1 - https://znc.in]
[12:16:50] <Safa_[A_boy]> altendky, oh. Sorry forgot to say that. I don't want to write properties for 10+ class members :)
[12:17:01] -!- kushal has joined #pyqt
[12:17:22] <altendky> Safa_[A_boy]: ah, so you are looking for a lazy (that can be good) way to get properties written for you?
[12:18:06] <altendky> Safa_[A_boy]: you can call pyqtProperty rather than use it as a decorator. or write a function you call to create each one
[12:18:19] <Safa_[A_boy]> Yes, after I've initiated the class members in __init__ (look at the pasted code)
[12:18:20] <altendky> Safa_[A_boy]: i have some code that adds them to attrs.org classes
[12:19:09] <altendky> Safa_[A_boy]: i'm not sure what i'm supposed to see. make pyqtProperties one way or another if you want to have qt properties
[12:20:13] <Safa_[A_boy]> I know how pyqtProperty works, and what functions it needs, and the possibility to use decorators. The idea is that I have many members that needs Qt properties defined, and I don't want to bloat the code for bridging stuff now. This is a class that should be used to read/write my file
[12:20:35] <Safa_[A_boy]> (The pasted one is only a member of another class, having 10+ members)
[12:20:40] <altendky> Safa_[A_boy]: ok, so write a function that creates the property and call it for each property you want
[12:20:59] <altendky> Safa_[A_boy]: and as i said i've done a thing that takes an attrs.org class and creates properties for each attribute
[12:21:53] <altendky> could share if you want, it's not a simple read and may be much more than you want.
[12:22:35] <Safa_[A_boy]> Please :)
[12:22:56] <altendky> Safa_[A_boy]: anyways, if you don't see the way forward, write two properties totally manually then look at them and write a function that takes whatever varies and returns the property you want. then you just `x = that_function()` for each property you want
[12:23:24] <altendky> Safa_[A_boy]: https://github.com
[12:23:52] <altendky> and some related tests where you can see some usage https://github.com
[12:24:21] <altendky> https://github.com and some actual usage
[12:24:42] <altendky> this is a component of my system for using attrs-defined classes as a qt model
[12:27:58] <storgance> Ok, so...filling the QTextBrowser with an insane about of text gives it a scrollbar that can't be used...hmm
[12:29:38] <altendky> storgance: maybe make another little example with just a listview and no special delegate and put some single line items in and some multiline items in and see if you can get it to act properly. also try just a qtextbrowser (with minimal fiddling) in a layout with a spacer about it or somesuch and see how it works
[12:54:20] <Safa_[A_boy]> altendky, Thank you very much! I'll look into it
[13:03:39] <storgance> This seems to be a very common problem people face...
[13:03:55] <storgance> it's strange how there's a property you can set that doesn't even work, though
[13:10:57] <storgance> Oh wow, that worked beautifully...
[13:12:48] <storgance> altendky: The solution I found https://pastebin.com
[13:12:56] <storgance> Comes from https://stackoverflow.com
[13:13:32] <altendky> storgance: first thought is you should sum top() and bottom() instead of top()*2
[13:14:47] <storgance> That works as well, just tested it
[13:15:22] <altendky> storgance: if the property really 'doesn't work' then there should be a bug about it. i'm guessing we more likely don't know what it is suposed to do
[13:16:15] <storgance> It seems strangely common enough of an issue people look up...I suppose I might be shoehorning it into what I think it should do by name.
[13:16:31] <altendky> storgance: can you link the docs for what you think isn't working?
[13:18:30] <storgance> https://doc.qt.io with the sizeAdjustPolicy AdjustToContents (https://doc.qt.io/qt-5/qabstractscrollarea.html#SizeAdjustPolicy-enum)
[13:19:48] <storgance> Supposedly it is to change to "viewport," but given the name AdjustToContents, it feels implied that viewport should just be a reflection of the contents
[13:20:32] <storgance> But it seems as though viewport actually is independent of the contents, somehow
[13:26:33] <altendky> storgance: first issue is that it's global, not vertical or horizontal. you would only want the vertical size to be driven.
[13:26:45] <altendky> so, that makes it not obviously useful aside from anything else
[13:27:10] <altendky> also, i forget what is the scroll area vs the viewport etc
[13:29:54] <altendky> storgance: where did you put the setFixedHeight code?
[13:29:57] <storgance> altendky: It is unable to grow horizontally due to other constraints, so that does not worry me
[13:30:05] <storgance> altendky: https://stackoverflow.com
[13:30:36] <altendky> storgance: but it still leaves in question whether that property makes sense to apply
[13:32:47] <altendky> storgance: note the point about needing to catch other signals potentially. does your code work as you resize horizontally? i would think the contents wouldn't change in that case yet the height should
[13:32:56] <altendky> *yet you would want the height to change
[13:34:35] <storgance> altendky: It does work when I resize the window horizontally
[13:38:26] <altendky> storgance: good deal, thanks for sharing the solution. can you share the full code so i can take a look?
[13:40:09] <storgance> altendky: https://pastebin.com
[13:41:23] <altendky> there's a little glitching for me.
[13:42:31] <altendky> as i resize the window wider there's one pixel where the widget is shorter but the list row looks to be the old taller height. and the other direction as a new line is added there's one pixel where there is a scrollbar
[13:42:36] <storgance> Yeah, when the mouse goes into the QListView, for some reason, it moves the QTextBrowser
[13:42:56] <altendky> i'm thinking it might be related to the widget's preferences for size not feeding back out when they change
[13:43:00] <storgance> And also, if you look closely, the QTextBrowser for some reason doesn't take up the entire widgth
[13:43:17] <storgance> *width
[13:43:30] -!- stee has quit [Quit: leaving]
[13:43:30] <altendky> and the message editing box is just tall
[13:43:33] <storgance> it doesn't fit within its spot correctly
[13:44:27] <storgance> altendky: That is true, I was going to work on reimplementing this fix for the QTextEdit box once I figure out why the QListView isn't placing the QTextBrowser in the right spot
[13:45:13] <altendky> i feel like i need a way to ask the list view to update when the widget picks a new size, but that also feels a bit backwards.
[13:47:02] <storgance> Hmm..
[13:47:25] <altendky> hmm, you are only setting the height when you fill_from_index. though, at present that should be called anytime you are to be painted...
[13:49:26] <storgance> Something about the delegate is off I think..though I don't remember the QLabels having issues, they might have been
[13:52:25] -!- Safa_[A_boy] has quit [Quit: Leaving]
[13:54:17] <altendky> ok. so there's a basic problem. the delegate sets the widget geometry. the widget shouldn't be setting it itself.
[13:54:33] <altendky> the list view should be using the size hint (and maybe size policy?) for help
[13:56:37] <storgance> Ohhh, I see
[13:57:05] <altendky> it doesn't fix all three issues, but i think it fixed one of them
[13:57:17] <altendky> there's never any space above the blue background anymore
[13:58:03] <altendky> we need to be able to indicate that our size hint has changed i think
[13:59:04] <storgance> So, should I be using the setGeometry call, changing the return value, or both?
[13:59:24] <altendky> storgance: i'm looking. i'm not quite sure what's the next tweak
[14:10:19] <altendky> storgance: i think it may play into heightForWidth but i'm not sure yet if the delegate can have that
[14:12:42] <altendky> ah, but there is https://doc.qt.io
[14:14:20] <storgance> For some reason, resizing the widget in both the widget and the delegate makes it work, but just the delegate in sizeHint does not work
[14:14:50] <altendky> storgance: you were seeing both the blank line at the end and the scrollbar issue?
[14:14:59] <altendky> *vertical scrollbar visible
[14:15:05] <storgance> No, no scrollbar
[14:15:19] <storgance> but without it in the widget, it's bouncing around twice before settling down
[14:15:25] <storgance> let me try and fix something real quick
[14:15:35] <altendky> it's much easier to see if you use the keyboard to resize
[14:27:11] <storgance> damnit
[14:30:41] <storgance> I just really don't understand why this is happening
[14:31:38] <altendky> storgance: i think the basic issue is that the size hint depends on the size... hence me looking at heightForWidth. and so when a size hint is requested, it responds and then is given another size at which point it wants to give out a new size hint...
[14:32:06] <altendky> so i have to try to figure out how to trigger one extra cycle cleanly or how to avoid the need somehow
[14:32:27] <altendky> i'll have to figure out the order of calls or something perhaps
[14:32:32] <altendky> to better understand how to solve it
[14:33:05] <altendky> there may also be an issue here related to me using one instance of the widget presently
[14:33:23] <altendky> though i think that's not the issue actually here, but one that could crop up soon
[14:35:31] <storgance> But it's more than just that....
[14:38:20] <storgance> Wait...what the
[14:38:25] <altendky> storgance: what more?
[14:40:13] <storgance> If I use that math to create the supposed height, then return a QSize(self.widget.sizeHint().width(), height-18), it doesn't move or anything. But then, just simply moving the mouse over the window causes it to freak out and add or remove a scrollbar
[14:40:40] <altendky> it's easy to get in a loop etc
[14:41:00] <storgance> Or well
[14:41:05] <altendky> and actually we probably ought to turn off the scroll bar because it popping up could change the decision about whether or not it's needed
[14:41:19] <storgance> I think it causes it to shrink by some amount...I don't know
[14:41:21] <altendky> err, whether or not the extra height is needed
[14:42:13] <storgance> Oh wait
[14:42:26] <storgance> I...that is so weird. It is some loop
[14:42:53] <storgance> Any exiting or entering of the cursor in respect to the QListVIew causes it to move along in 1 of 3 states
[14:43:14] <storgance> Correct size, correct size with a scrollbar, 18px too small
[14:44:17] <storgance> this is so strange..
[14:46:38] <storgance> https://pastebin.com Check this out. Like this, it is going from right size with a scroll bar to too big instantaneously, but then down to correct size upon mousing over.
[14:49:57] <altendky> i'm think the solution won't involve the widget forcing it's own height. i think the delegate needs a way to feed back what the widget wants to the view
[14:50:09] <altendky> the view decides what space the widget actually gets afaik
[14:50:19] <storgance> Oh my goodness...The things that happen if you put in more than one widget like this...
[14:50:26] <storgance> 'Hmm
[14:50:43] <altendky> why do you have two delegate classes?
[14:51:15] <storgance> I was trying to alter the sizehint to use that one equation
[14:51:36] <altendky> don't we want the widget to describe the size it wants?
[14:52:16] <storgance> Oh, we need to make a sizehint inside of the widget itself? I thought we wanted the delegate to do that
[14:52:50] <altendky> the delegate calls the widget's size hint
[14:53:38] <storgance> Oh, wait a second...
[14:53:41] <storgance> I see what you're saying
[15:05:45] <storgance> This is starting to get depressing
[15:12:15] <altendky> storgance: meh, it's the way it goes. we've both got something to learn here. until we figure out what, it's slow going
[15:12:58] <storgance> erm, while we're at it, how would I remove the border on the frame? I don't know how to access the QFrame it's put in
[15:14:00] <altendky> storgance: it inherits from frame, it doesn't have one. https://doc.qt.io
[15:14:19] <altendky> so setFrameStyle is my first guess
[15:14:50] <storgance> Damn, you're right
[15:20:14] <altendky> my message isn't going below four rows worth of height regardless
[15:28:33] <altendky> huh, the option.rect passed to the sizeHint
[15:31:07] <altendky> is always 256 wide for me...
[15:31:30] <altendky> but the one passed into paint changes
[15:32:19] <altendky> so we don't know the actual width until paint and so for the next size hint we can respond correctly. thus the single cycle delay
[15:34:03] <altendky> seems similar to what they see except they get 0, i get 256 https://www.qtcentre.org
[15:36:38] <altendky> or maybe https://bugreports.qt.io*%22%20OR%20description%20~%20%22qstyleditemdelegate%20sizehint%20width*%22%20ORDER%20BY%20lastViewed%20DESC
[15:36:52] <altendky> claims fixed in 5.12.0 alpha... but i haven't read it all yet
[15:41:49] <altendky> this is a mess and the 'fix' (i think?) is a total hack what with the + 2, but does this fix it for you? https://gist.github.com
[15:44:50] <altendky> storgance: ^^
[15:48:58] <altendky> err, i think that worked but is still wrong
[15:52:39] -!- Siecje has quit [Quit: Leaving.]
[15:53:55] <altendky> there's some startup issue with multiple of them
[15:54:01] <altendky> and no, not quite working yet
[15:58:04] <storgance> Just got back
[16:00:35] <storgance> Hmm...What if the issue is that they are ending up on top pretty much on top of each other?
[16:00:51] <storgance> Oh wait...hmm
[16:01:03] <altendky> storgance: i don't follow. when we try to calculate our size hint it is presently based off garbage it seems
[16:03:58] <storgance> Ok, it's doing different things per each time I run it now
[16:04:39] <storgance> I had to resize it like 5 times, but now It's almost right
[16:05:27] <storgance> I still feel like it's something with the delegate, maybe
[16:06:29] <storgance> They definitely are stacking on each other
[16:06:43] <altendky> storgance: do you disagree that the option.rect being passed to the delegate sizeHint is unrelated to the width of the view? or that that being wrong would certainly make sense as to why we aren't calculating the proper height?
[16:06:48] <storgance> Try full screening and un-fullscreening on it. It will "unstack" them a little
[16:07:05] <altendky> as soon as i resize at all they 'unstack'. it's a startup issue for me
[16:07:13] <storgance> Oh, it's not like that on windows
[16:07:14] <altendky> i've been digging on the initial problem
[16:11:22] <storgance> What in the world...?
[16:12:06] <storgance> It was really messed up the firs 3 times I ran it, but now it's working perfectly except for the initial part, like you said. I feel like I'm going crazy
[16:12:32] <storgance> *first
[16:13:20] <altendky> it also only seems to adjust the rows vertically when resized vertically
[16:13:31] <altendky> horizontal resizes aren't triggering vertical updates
[16:13:53] <storgance> Oh THAT'S why
[16:23:28] <altendky> heh https://github.com you have to setWordWrap(True) to get it to figure out vertical changes when you resize only horizontally
[16:24:02] <altendky> so, back to the single resize-step delay
[16:24:24] <storgance> Wait a second... altendky . I added printing self.widget to the sizeHint() print and self to the setGeometry() print
[16:24:51] <storgance> and all I did was start it, wait for it to load, then close it.
[16:25:05] <storgance> Looking at the addresses of the objects, I'm only seeing one address.
[16:25:29] <altendky> storgance: there should only be a single widget for each delegate you instantiate presently, that's intentional
[16:25:52] <altendky> it just gets filled with the appropriate data when needed
[16:26:01] <storgance> Oh, hmm.
[16:26:17] <altendky> say you had 20k messages in your log. you wouldn't want 20k widgets if you can only see 10 of them
[16:27:45] <altendky> so with either 1 or 3 rows, the last row won't size down below the four rows worth of text size
[16:27:49] <altendky> as another isssue
[16:27:57] <altendky> still want to fix that single-resize-step delay though
[16:30:22] <altendky> enabling that wrap mode sure triggers a lot more size hint calls etc
[16:31:09] <storgance> So strange that that's the call that does it, honestly. Makes sense, but strange
[16:41:58] <storgance> I should be able to come back in about 4 hours
[16:42:05] <storgance> Thank you for all your help, once again.
[16:42:07] -!- storgance has quit [Quit: Page closed]
[16:49:10] -!- mintograde has joined #pyqt
[18:08:23] -!- Lauxley has quit [Remote host closed the connection]
[18:52:20] <altendky> and before i break it... https://gist.github.com seems to work. the last key being the setattribute don't show on screen and show. the setGeometry call wasn't propagating its effect to the QTextDocument until after ... stuff ... so it always lagged by a resize event
[21:21:47] -!- cetchmoh has quit [Ping timeout: 240 seconds]
[21:34:17] -!- storgance has joined #pyqt
[21:34:30] <storgance> altendky: any luck? I just got back from my event
[21:35:03] <altendky> 18:52 <altendky> and before i break it... https://gist.github.com seems to work. the last key being the setattribute don't show on screen and show. the setGeometry call wasn't propagating its effect to the QTextDocument until after ... stuff ... so it always lagged by a resize event
[21:35:15] <altendky> I haven't gotten back to try to tidy it up yet
[21:39:08] <storgance> Hmmm..
[21:40:09] <altendky> There's a bunch of stuff that should come out easily.
[21:40:37] <altendky> I'm not sure about the wrong width getting passed in to the size hint in the delegate though
[21:41:03] <altendky> Seems odd. But maybe that changed when I enabled the wrap, I dunno
[21:43:40] <altendky> There may be some other way to trigger the proper updating of the layout and child widgets but I hadn't dug yet
[21:43:53] <altendky> storgance: does that code seem to work for you?
[21:46:15] <storgance> Oh wow! It does!
[21:46:20] <storgance> What was wrong with the initial state?
[21:46:52] <altendky> I think the wrap enable helped some?
[21:46:59] <altendky> And the show did the rest iirc
[21:47:06] <altendky> But who knows...
[21:47:36] <altendky> We'll see what I can simplify it down to
[21:48:21] <storgance> Oh, hmm
[21:52:50] <storgance> Thank you for everything again!
[21:53:02] <storgance> (crediting you in all my commits, ftr)
[21:53:23] <altendky> storgance: sure thing. I'll be needing some of this at some point
[21:53:43] <altendky> It'll be sitting there ready and tested by the time you're done with it :]
[21:55:31] <storgance> Woo!
[22:00:27] <altendky> back at my computer, i'll take a stab at tidying it up
[22:03:41] <altendky> ok, first issue, it doesn't exit when you close the visible window :]
[22:13:49] -!- storgance has quit [Ping timeout: 256 seconds]
[23:16:53] -!- mintograde has quit [Ping timeout: 258 seconds]
[23:38:45] <altendky> i don't like some of the implementation, but i don't know of any bugs anyways. https://gist.github.com
[23:41:32] -!- storgance has joined #pyqt
[23:41:44] <storgance> altendky: sorry, I'm back. Something came up
[23:42:00] <altendky> storgance: no problem, i was just tidying up and about to close up
[23:42:05] <altendky> 23:38 <altendky> i don't like some of the implementation, but i don't know of any bugs anyways. https://gist.github.com
[23:43:01] <altendky> i had forgotten to account for the (optional) scrollbar width in my calcs... exactly why i hate remembering what to add up. but i haven't found a function for getting the available space inside the frame. so, math it is for now :[
[23:44:24] <altendky> so if i don't .show() the widget, stuff doesn't update immediately and you get the one cycle delay we saw earlier. if you don't either parent the widget or .close() it, the program doesn't exit. if you parent the widget, you get constant calls to the delegate size hint...
[23:44:49] <altendky> so, .show() before doing our fill etc, then close() after. not a huge fan, but for now it seems to work
[23:48:33] <altendky> storgance: found any bugs yet?
[23:52:36] <storgance> Going fullscreen makes the last message the wrong size, and mousing over things removes the border on some frames
[23:53:33] <altendky> Mm ..
[23:53:48] <storgance> https://i.imgur.com
[23:53:55] <altendky> If you just realize to not quite full screen is it the same?
[23:54:57] <altendky> *just resize
[23:55:17] <altendky> Or is it only when actually maximized
[23:56:59] <storgance> https://i.imgur.com
[23:57:10] <storgance> It seems like it happens at around this specific size
[23:59:42] <storgance> It's like the hitbox isn't resizing with it