#pyqt | Logs for 2018-09-05

Back
[00:26:04] -!- mandeep has joined #pyqt
[00:39:18] -!- kdas_ has joined #pyqt
[00:40:07] -!- kushal has quit [Ping timeout: 256 seconds]
[00:41:47] -!- _AleX_ has quit [Ping timeout: 240 seconds]
[00:50:55] kdas_ is now known as kushal
[01:38:06] -!- nik90 has joined #pyqt
[02:29:40] -!- anqxyr has joined #pyqt
[02:51:01] -!- kallesbar has joined #pyqt
[05:07:15] -!- dodoo has joined #pyqt
[05:07:35] <dodoo> Hi
[05:08:18] <dodoo> i created an app with pyqt on osx, works fine, put it on windows, now the program has no borders e.g. window decoration. any ideas?
[05:15:58] -!- Flaghacker has joined #pyqt
[05:17:00] <Flaghacker> How do I remove child widgets from a layout? I tried widget.layout().removeItem(widget.layout().itemAt(0)), but the elements keep rendering even though widget.layout().count() decreases by one, and I tried widget.layout().itemAt(0).widget().setParent(None) but that appears to leak memory.
[05:17:47] <Flaghacker> Lookin it up for QT in general they say to do 'delete widget.layout().itemAt(0)', but that's of course not possible in python.
[05:21:11] <Flaghacker> And .deleteLater() hangs the entire application.
[05:23:20] <dodoo> Flaghacker: just a guess... del widegt.layout().itemAt(0)
[05:23:54] <dodoo> lol solved my problem, i had setGeometry(0,0 .... :)
[05:27:04] <Flaghacker> Doesn't do anything unfortunately, is it even possible to override del behaviour in python? Are there metamethods for it?
[05:27:58] <dodoo> yes def __del__(...
[05:28:33] <Flaghacker> No, that is called when an object is garbage collected, right?
[05:30:05] <Flaghacker> https://repl.it
[05:30:25] <Flaghacker> Yup it's one of those scary things you should never use, Java has one too.
[05:30:49] <Flaghacker> Because for `del list[5]` etc to work it would have to be a buildin
[06:01:48] -!- dodoo has quit [Ping timeout: 252 seconds]
[06:08:01] -!- mintograde has joined #pyqt
[06:51:24] <altendky> Flaghacker: __del__ may never be called so you really can't bank on it happening.
[06:52:04] <altendky> Flaghacker: del just deleted the name which may remove the last reference to the object which may trigger collection and calling __del__
[06:52:55] <altendky> Flaghacker: but I sure thought at some point I had removed a widget from a layout... Do you have an example that doesn't work that you can share?
[06:59:03] <Flaghacker> altendky, It's in the middle of a big app but I'll try to isolate an example.
[07:04:13] -!- mintograde has quit [Ping timeout: 245 seconds]
[07:04:57] <Flaghacker> altendky, https://pastebin.com
[07:05:03] <Flaghacker> That wasn't too difficult :)
[07:05:46] <Flaghacker> It seems that button1 doesn't respect the layout anumore, so you need to resize the window a bit to see it.
[07:07:49] <Flaghacker> Although .setParent(None) doesn't appear to leak any memory when I try it here.
[07:08:52] <altendky> Flaghacker: i didn't see anything funny here in linux. what os? what pyqt version?
[07:09:15] <altendky> https://usercontent.irccloud-cdn.com
[07:12:31] <altendky> Flaghacker: https://gist.github.com removing after two seconds makes it readjust for button 2 centered in the window/layout but button 1 still drawn https://usercontent.irccloud-cdn.com
[07:14:50] <altendky> https://gist.github.com seems to work cleanly
[07:14:51] <Flaghacker> Yeah so in the second case QT actually has time to layout, but button1 is still just as broken, right?
[07:15:53] <altendky> Flaghacker: hmm, your example was less obviuosly bad. i see now that the button1 was actually filling the whole window
[07:16:33] <Flaghacker> Yeah, you need to resize the window a bit.
[07:16:41] <altendky> Flaghacker: http://doc.qt.io "Removes the widget widget from the layout. After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout or to explicitly hide it if necessary."
[07:17:13] <altendky> Flaghacker: button1 in your example stuck to the window size for me. but no matter. the docs point out it is your responsibility to do more with the widget
[07:17:41] <altendky> Flaghacker: what did you observe as an issue with .setParent(None)?
[07:17:43] <Flaghacker> Ah okay, looks like it's the same for removeItem. Question is of course what to do then :)
[07:17:58] <altendky> Flaghacker: did my last example not work for you?
[07:18:38] <altendky> and actually, removing from the layout didn't even seem necessary. just .setParent(None) seems to work
[07:18:41] <Flaghacker> For .setParent(None) memory kept increasing, but I can't reproduce it in this small example. I'll try to reproduce it some more.
[07:19:11] <altendky> Flaghacker: fyi there's objgraph
[07:19:34] <Flaghacker> And I missed your last example, that does work, although I'm afraid I'll still be leaking memory that way.
[07:20:18] <altendky> Flaghacker: how are you checking that memory is increasing?
[07:20:23] <Flaghacker> I'll try objgraph, hopefully it can see trough the QT stuff.
[07:20:42] <altendky> Flaghacker: you should be checking about the references mostly
[07:20:54] <altendky> weakref also comes into play in these diagnostics
[07:21:44] <Flaghacker> Task manager :). It is _very_ consistent, 2000K per reset for my application. I knew about it originally because the UI starting responsing very slowly.
[07:22:07] <altendky> be wary of that
[07:22:20] <altendky> checking overall memory usage that is
[07:22:48] <altendky> python doesn't guarantee freeing memory to the os even if you do remove all references
[07:24:08] <Flaghacker> Yeah I know, but there certainly was a problem because the UI slowed down.
[07:27:36] <altendky> Flaghacker: maybe .deleteLater after it is out?
[07:28:38] <Flaghacker> See before I said "And .deleteLater() hangs the entire application." but now that isn't the case any more.
[07:28:57] <Flaghacker> It works and doesn't 'leak' momry.
[07:28:58] <altendky> i saw that. i didn't know if it was while it was still in the layout or something
[07:29:27] <Flaghacker> It works if it's not in the layout too.
[07:30:17] <Flaghacker> It's only for widgets though (are there other kinds of titems?) so now it's .widget().deleteLater()
[07:31:27] <Flaghacker> 'Inherited By:
[07:31:27] <Flaghacker> QLayout, QSpacerItem, and QWidgetItem' great
[07:32:21] <altendky> Flaghacker: when i need to work with items i keep my own python structure for them instead of navigating qt's usually
[07:32:38] <altendky> even have a class managing the combination
[07:33:02] <altendky> theres a good SO post on this memory stuff with pyqt but i can't find it
[07:33:36] <altendky> there it is. https://stackoverflow.com
[07:33:49] <altendky> mm, maybe
[07:35:38] <altendky> i thought there was one that said a bit more
[07:36:10] <Flaghacker> I read this a couple of days ago: http://enki-editor.org
[07:37:16] <Flaghacker> What do you mean about keeping structures yourself? You keep your own widgetList for layouts?
[07:37:48] <altendky> Flaghacker: sure. easier to iterate over, you have the actual thing rather than an 'item'.
[07:37:58] <altendky> Flaghacker: or use names for each thing if appropriate
[07:38:03] <altendky> Flaghacker: it depends
[07:38:28] <Flaghacker> Yeah definitely for lineedits, buttons etc I have actual variabes.
[07:38:43] <Flaghacker> It's just that sometimes I want to clear an entire layout.
[07:38:57] <altendky> sure. as i mentioned i might make a class for that then
[07:39:04] <altendky> let it manage the layout and contents
[07:39:08] <altendky> .clear()
[07:40:07] <Flaghacker> I've got this for now: https://pastebin.com I'll see if that holds up.
[07:40:19] -!- nitro25 has joined #pyqt
[08:22:21] -!- frispete has joined #pyqt
[08:25:54] -!- frispete_ has quit [Ping timeout: 252 seconds]
[08:27:22] -!- BPL has joined #pyqt
[08:40:45] -!- nik90 has quit [Ping timeout: 252 seconds]
[08:43:32] -!- nik90 has joined #pyqt
[08:49:26] -!- Siecje has joined #pyqt
[09:36:56] -!- mandeep has quit [Quit: Leaving]
[09:46:41] -!- mandeep has joined #pyqt
[10:31:47] -!- mandeep has quit [Quit: Leaving]
[11:21:37] -!- Flaghacker has quit [Quit: Leaving]
[11:50:39] -!- nik90 has quit [Quit: Konversation terminated!]
[14:03:48] -!- anqxyr has quit [Ping timeout: 245 seconds]
[14:43:57] -!- kallesbar has quit [Ping timeout: 252 seconds]
[14:52:16] -!- mandeep has joined #pyqt
[15:00:49] -!- mandeep has quit [Quit: Leaving]
[15:01:12] -!- mandeep has joined #pyqt
[15:26:13] -!- mandeep has quit [Quit: Leaving]
[15:49:27] -!- jthornton has quit [Read error: Connection reset by peer]
[15:49:27] -!- JT-Shop has quit [Read error: Connection reset by peer]
[15:52:21] -!- nitro25 has quit [Remote host closed the connection]
[15:53:01] -!- RackSmurf has joined #pyqt
[15:54:14] -!- RackSmurf has quit [Client Quit]
[15:55:11] -!- TechSmurf has joined #pyqt
[16:01:35] -!- _AleX_ has joined #pyqt
[16:23:13] -!- mintograde has joined #pyqt
[17:49:07] -!- Siecje has quit [Quit: Leaving.]
[19:09:47] -!- kushal has quit [Remote host closed the connection]
[19:13:34] -!- kushal has joined #pyqt
[19:14:16] -!- BPL has quit [Quit: Leaving]
[21:18:22] -!- stochastix has quit [Remote host closed the connection]
[21:19:37] -!- stochastix has joined #pyqt
[21:27:11] -!- argoneus has quit [Quit: No Ping reply in 180 seconds.]
[21:28:19] -!- argoneus has joined #pyqt
[23:15:53] -!- mintograde has quit [Ping timeout: 244 seconds]