#pyqt | Logs for 2019-01-08

Back
[01:35:28] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[01:35:55] -!- Belxjander has joined #pyqt
[01:36:14] -!- Mrokii has quit [Ping timeout: 246 seconds]
[01:36:59] -!- Mrokii has joined #pyqt
[01:52:30] -!- Belxjander has quit [Ping timeout: 268 seconds]
[01:52:39] -!- Bjander has joined #pyqt
[01:53:15] Bjander is now known as Belxjander
[03:27:04] -!- kallesbar has joined #pyqt
[03:31:28] -!- JanC_ has joined #pyqt
[03:33:13] JanC is now known as Guest41406
[03:33:13] JanC_ is now known as JanC
[03:33:57] -!- Guest41406 has quit [Ping timeout: 252 seconds]
[03:45:50] -!- anqxyr has joined #pyqt
[03:57:40] -!- linuxson has joined #pyqt
[03:58:18] <linuxson> How would I go about running a separate method first before starting up my application? Order of operation:
[03:58:25] <linuxson> Start splash screen
[03:58:35] <linuxson> Check git version (remote)
[03:58:50] <linuxson> If update is available, clone into folder
[03:59:09] <linuxson> While cloning, show another window with loader bar
[03:59:24] <linuxson> When finished, close updater and start main application
[04:15:50] -!- Lauxley has joined #pyqt
[04:45:13] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[04:45:48] -!- Belxjander has joined #pyqt
[05:07:35] -!- linuxson has quit []
[05:19:02] -!- Lauxley has quit [Remote host closed the connection]
[06:05:32] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[06:06:17] -!- Belxjander has joined #pyqt
[06:13:28] -!- Belxjander has quit [Ping timeout: 250 seconds]
[06:17:09] -!- Belxjander has joined #pyqt
[06:50:18] -!- Belxjander has quit [Ping timeout: 250 seconds]
[06:51:17] -!- Belxjander has joined #pyqt
[07:09:05] -!- kallesbar has quit [Ping timeout: 244 seconds]
[07:09:29] -!- kallesbar has joined #pyqt
[07:10:48] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[07:11:16] -!- Belxjander has joined #pyqt
[08:00:31] -!- Belxjander has quit [Ping timeout: 260 seconds]
[08:01:25] -!- Belxjander has joined #pyqt
[08:05:48] -!- Bjander has joined #pyqt
[08:06:24] -!- Belxjander has quit [Ping timeout: 252 seconds]
[08:06:25] Bjander is now known as Belxjander
[08:42:41] -!- Bjander has joined #pyqt
[08:44:26] -!- Belxjander has quit [Ping timeout: 268 seconds]
[08:44:31] Bjander is now known as Belxjander
[09:10:42] -!- Belxjander has quit [Ping timeout: 250 seconds]
[09:18:48] -!- Belxjander has joined #pyqt
[09:23:58] -!- Belxjander has quit [Ping timeout: 246 seconds]
[10:58:53] <Mrokii> Does somebody know how to apply "QImageReader().supportedMimeTypes()" as a filter for a File-Dialog? If I use "['image/jpeg', 'image/png']" as a filter, only jpegs and pngs are shown, but when I use the "mimeTypes()"-thing mentioned before, all files are shown (so the filter doesn't seem to work).
[11:00:48] <altendky> Mrokii: what is the result of print(repr(QImageReader().supported mime types())) ?
[11:03:13] <altendky> Mrokii: also, are you using http://doc.qt.io or the regular http://doc.qt.io
[11:09:29] -!- AbleBacon has joined #pyqt
[11:09:52] <Mrokii> altendky: The output is this:
[11:09:54] <Mrokii> [PyQt5.QtCore.QByteArray(b'image/bmp'), PyQt5.QtCore.QByteArray(b'image/gif'), PyQt5.QtCore.QByteArray(b'image/jpeg'), PyQt5.QtCore.QByteArray(b'image/png'), PyQt5.QtCore.QByteArray(b'image/svg+xml'), PyQt5.QtCore.QByteArray(b'image/svg+xml-compressed'), PyQt5.QtCore.QByteArray(b'image/tiff'), PyQt5.QtCore.QByteArray(b'image/vnd.microsoft.icon'), PyQt5.QtCore.QByteArray(b'image/vnd.wap.wbmp'),
[11:09:56] <Mrokii> PyQt5.QtCore.QByteArray(b'image/webp'), PyQt5.QtCore.QByteArray(b'image/x-icns'), PyQt5.QtCore.QByteArray(b'image/x-portable-bitmap'), PyQt5.QtCore.QByteArray(b'image/x-portable-graymap'), PyQt5.QtCore.QByteArray(b'image/x-portable-pixmap'), PyQt5.QtCore.QByteArray(b'image/x-tga'), PyQt5.QtCore.QByteArray(b'image/x-xbitmap'), PyQt5.QtCore.QByteArray(b'image/x-xpixmap')]
[11:10:21] <Mrokii> And I am using setMimeTypeFilters (which works with "['image/jpeg', │ TurBoss
[11:10:33] <Mrokii> oops, wrong paste.
[11:11:06] <Mrokii> And I am using setMimeTypeFilters, (which works with "['image/jpeg', 'image/png']". Only showing jpegs and pngs then.
[11:13:14] <altendky> Mrokii: after setting with that, what does print(repr(the_dialog.mimeTypeFilters())) output?
[11:21:14] <Mrokii> altendky: Okay, that's weird. The output is "['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']"
[11:22:34] <Mrokii> The only thing I did was to change 'my_mime_filters = ["image/jpeg", "image/png"]' to 'my_mime_filters = QImageReader().supportedMimeTypes()'
[11:22:51] <altendky> Mrokii: sure, some conversion isn't doing what we want
[11:23:38] <altendky> Mrokii: [bytes(f).decode() for f in x]
[11:23:51] <Mrokii> altendky: I'll try, one moment.
[11:32:31] <Mrokii> altendky: Is "my_var = [bytes(f).decode() for f in QImageReader().supportedMimeTypes()]" correct? I am not sure, as I got "TypeError: 'bytes' object cannot be interpreted as an integer"
[11:34:00] <altendky> Mrokii: that line ran for me and got the (i think) desired output. what line gave you the TypeError?
[11:34:12] <Avaris> Mrokii: full traceback?
[11:34:24] <altendky> that is a better way to ask that question :|
[11:34:42] <altendky> Avaris: i forget, do you use qml/quick at all?
[11:34:47] <Avaris> nope
[11:41:26] <Mrokii> altendky, Avaris: Wait I did something wrong as it seems. The line with "decode" works now. Thanks. :)
[11:42:11] <altendky> Mrokii: this might be worth reporting on the maillist. it doesn't seem like proper behavior.
[11:44:46] <Mrokii> altendky: I'll need to investigate further.
[11:45:16] <altendky> Mrokii: getting a mime type list from qt and giving it directly back to qt... ought to work i'd think :]
[11:46:11] <Avaris> might not be. one returns a bytearray list, other takes a stringlist
[11:46:24] <Mrokii> altendky: It does work now, as I said. it gives me this: ['image/bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/svg+xml', 'image/svg+xml-compressed', 'image/tiff', 'image/vnd.microsoft.icon', 'image/vnd.wap.wbmp', 'image/webp', 'image/x-icns', 'image/x-portable-bitmap', 'image/x-portable-graymap', 'image/x-portable-pixmap', 'image/x-tga', 'image/x-xbitmap', 'image/x-xpixmap']
[11:46:27] <Mrokii> >>> my_var = [bytes(f).decode() for f in QImageReader().supportedMimeTypes()]
[11:46:46] <Mrokii> Oops, too much copied once again.
[11:47:12] <altendky> Mrokii: right, i'm questioning whether this should be needed. but sure, Avaris has a good point as usual
[11:47:47] <Mrokii> I see the point.
[11:49:31] <Avaris> but an error would be nice I guess, instead of silently ignoring it
[11:49:40] <altendky> without the decode you get `TypeError: index 0 has type 'bytes' but 'str' is expected`. kinda seems like you should get an immediate failure from the QByteArray as well
[11:50:47] <Avaris> maybe pyqt is `str`ing before passing, which turns that into a weird string
[11:51:42] <altendky> str() in the comprehension gets you stuff like "b'image/bmp'" like you might expect
[11:51:56] <altendky> there's some chance qt isn't handling it properly
[11:53:44] <Avaris> i'm getting `TypeError: index 0 has type 'QByteArray' but 'str' is expected` if i do `f.setMimeTypeFilters(QtGui.QImageReader.supportedMimeTypes())`
[11:54:24] <Avaris> Mrokii: which pyqt version?
[11:55:12] * Avaris has 5.11.3
[11:55:43] <altendky> i get the error on 5.11.2. naughty me not verifying the report
[11:56:10] <altendky> the useful TypeError, that is
[11:58:34] <Mrokii> Avaris: I have 5.11.2 installed
[11:58:43] <altendky> i'm on linux
[11:58:47] <Mrokii> me too.
[11:58:54] <altendky> Mrokii: installed from pip?
[12:00:06] <Mrokii> altendky: I think I installed it via synaptic.
[12:00:54] <altendky> Mrokii: always work in a virtualenv or venv and install via the env's pip from pypi :] bit.ly/py-env
[12:01:16] <altendky> Mrokii: but maybe double check `python -c 'from PyQt5.Qt import QImageReader, QApplication, QFileDialog; app = QApplication([]); d = QFileDialog(); d.setMimeTypeFilters(QImageReader().supportedMimeTypes()); d.mimeTypeFilters()'`
[12:01:54] <Avaris> need to `print()` the last one :)
[12:01:56] <altendky> (for whatever you run to run python)
[12:02:08] <altendky> Avaris: true, but it'll fail before that :]
[12:02:18] <altendky> Mrokii: also `python -c 'import PyQt5; print(PyQt5.__file__)'`
[12:02:28] <altendky> again for however you run python
[12:03:03] <Avaris> python -c "from PyQt5 import QtCore; print(QtCore.PYQT_VERSION_STR)"
[12:03:59] <altendky> might this functionality relate more to sip?
[12:04:33] <Mrokii> Avaris: That last line gives me "5.11.3". Seems a bit weird that there are two different version-numbers.
[12:04:52] <altendky> Mrokii: what gave you 5.11.2?
[12:04:58] <Avaris> where did you get 5.11.2?
[12:05:22] <Mrokii> altendky: I've tried virtualenv quite some time ago and ran into trouble and gave up. But I will try again, thanks.
[12:06:33] <Mrokii> Avaris: Synaptic. As it was showing up there, I must have installed it from there I guess.
[12:06:46] <altendky> Mrokii: also `python -c 'import PyQt5; print(PyQt5.__file__)'`
[12:07:21] <altendky> Mrokii: do you install with pip? (either with sudo/root, bad, or --user, not great)
[12:07:28] <altendky> but that last command will tell us where it is
[12:08:06] <Avaris> hmm pyqt5.11.3 wraps qt5.11.2. maybe it was showing that
[12:08:57] <altendky> also, `sudo apt install virtualenv` `virtualenv -p python3 myvenv` `myvenv/bin/pip install pyqt5==5.11.3` `myvenv/bin/python -c 'from PyQt5.Qt import QImageReader, QApplication, QFileDialog; app = QApplication([]); d = QFileDialog(); d.setMimeTypeFilters(QImageReader().supportedMimeTypes()); print(d.mimeTypeFilters())'`
[12:15:12] <Mrokii> altendky: I once installed with pip (root) and I think that borked the system in some way. I am not sure what didn't work as expected with env. Just that I gave up about it.
[12:15:32] <altendky> Mrokii: also `python -c 'import PyQt5; print(PyQt5.__file__)'` :]
[12:15:52] <altendky> adjust for however you have have been running python
[12:16:52] <Mrokii> That last command gave me "/home/[my_username]/.local/lib/python3.6/site-packages/PyQt5/__init__.py".
[12:17:00] <Mrokii> Oh, btw, I am using all that stuff with Python3.
[12:17:05] <Mrokii> Not sure if that makes any difference.
[12:17:18] <altendky> Mrokii: that's a pip --user installed copy
[12:19:14] <Mrokii> altendky: Hm, weird. I thought I had installed it via Synaptic.
[12:19:25] <altendky> Mrokii: you certainly could have done that as well
[12:19:41] <altendky> env's provide a nice isolated environment away from everything else you've ever done :]
[12:20:13] <Mrokii> altendky: I see. So it may be that I have both versions installed, 5.11.2 and 5.11.3, just in different locations.
[12:20:21] <altendky> Mrokii: yes
[13:32:08] -!- anqxyr has quit [Ping timeout: 245 seconds]
[13:58:31] -!- kallesbar has quit [Quit: Konversation terminated!]
[14:31:28] <Mrokii> I think the mimetype-filters may not be quite the solution I like, though I guess the only alternative would be to use a namefilter. I'd like the user to see all usable files (all jpegs and pngs for example) in the filerequester. This works if I use a "nameFilter". But with "mimeTypes" one has to actually chose the jpeg-type in the filereqeust-window to see the jpegs in that folder.
[14:32:54] <Mrokii> I assume there's no way to change that behaviour, so the alternative would be to use a namefilter, including all possible file-endings. :-/
[14:33:22] <altendky> Mrokii: there's an SO for that
[14:33:41] <Mrokii> altendky: SO?
[14:33:48] <altendky> Mrokii: stack overflow (question)
[14:34:11] <Mrokii> altendky: Oh, okay. I will look there. Thanks.
[14:35:41] <altendky> maybe you can use .nameFilters() after to get the initial list then build the 'all supported' from that. *shrug* or maybe just building directly would be tidier
[14:36:58] <Mrokii> altendky: I had a similar idea but haven't checked if that's possible. The initial list doesn't contain the possible file-endings (though they're visible when looking at the mimetypes in the file-requester, so there might be a way to get them).
[14:37:45] <Avaris> use QImageReader.supportedImageFormats()?
[14:39:21] <Mrokii> Avaris: I haven't looked at ImageFormats yet, but I will. Thanks.
[14:40:15] <Mrokii> altendky: I think I did find something on SO, talking about QMimeType.suffixes, so that might be a way.
[14:40:59] <Avaris> ' '.join('*.{}'.format(bytes(f).decode()) for f in QtGui.QImageReader.supportedImageFormats())
[14:41:23] <Avaris> -> "*.png *.jpg *.jpeg ..."
[14:41:25] <altendky> it would be nice to have the names
[14:41:32] <Mrokii> Avaris: Thanks, I'll try. :)
[14:42:47] <Avaris> meh, "All images (*.png ...)"
[14:43:59] <altendky> Mrokii: `d.setMimeTypeFilters([bytes(f).decode() for f in QImageReader().supportedMimeTypes()]); print(d.nameFilters())` gets you the file format names. then add to it the all supported entry and an set it back in via setNameFilters
[14:44:22] <altendky> unless we can get the format names other ways
[14:45:23] <altendky> these two are a bit special, for example. `'compressed SVG image (*.svgz)', 'TIFF image (*.tif *.tiff)'`
[14:45:34] <altendky> compressed in the name, and two extensions in one for tiff
[14:45:43] <altendky> so the mime-type stuff seems to have some value
[14:46:21] <Avaris> the problem is those set different filters. i think the goal is to have single filter that shows all images
[14:46:46] <altendky> right, so take that pretty list and add to it the one you made based on supportedImageFormats for the 'all' entry
[14:47:19] <Avaris> i think one might override the other
[14:47:33] <altendky> Avaris: build a new list and set them all in
[14:47:38] <Mrokii> I just noticed that, in the file requester, with "QImageReader.supportedMimeTypes" there are for suffices for jpg-files. When using the extraction Avaris mentioned above, I get only two. So they seem to be incomplete indeed.
[14:48:22] <Avaris> Mrokii: huh? what's incomplete?
[14:48:33] <Avaris> altendky: one is mime filter, other name filter
[14:49:18] <altendky> Avaris: you set in via mime, read out via name, set in via name
[14:51:32] <altendky> https://gist.github.com
[14:51:44] <Avaris> Mrokii: ah ok I see what you mean. weird
[14:51:59] <altendky> though maybe check that supportedImageFormats has all the extensions from the supportedMimeTypes roundtrip
[14:52:21] <Mrokii> Avaris: I mean, the extraction from "supportedFileFormats". When I use that to get the suffices, there are two for jpegs ("jpeg" and "jpg"). But when I use "supportedMimeTypes", the file-requester shows me jpeg, jpg, jpe and jfif.
[14:52:56] <altendky> :] ok, so we have to build all from the mime types... does qt have some other ways to access this mime-type info?
[14:53:10] <altendky> so we don't have to parse the strings we get back from nameFilters()
[14:53:11] <Avaris> regexp
[14:53:50] <altendky> Avaris: the mime type info really is only accessible via setting them to a file dialog?
[14:53:50] <Avaris> or just foo.split('(')[1][:-1]
[14:54:39] <Mrokii> I haven't checked that solution from SO yet. Maybe that will work. I'll try to incorporate it.
[14:54:52] <Avaris> there is qmimetype i think
[14:55:14] <altendky> http://doc.qt.io and that but i'm still looking for getting the proper info based on the mime type string
[14:55:24] <altendky> or byte array i guess
[14:56:16] <Avaris> http://doc.qt.io
[14:56:59] <altendky> seems icky but maybe http://doc.qt.io ?
[14:57:09] <Mrokii> Avaris: Yes, QMimeType is mentioned on SO, in conjunction with "suffices". And there is a solution (albeit in c I think).
[14:57:12] <altendky> not sure how to get the QMimeType instance for say 'image/jpeg'
[14:57:21] <altendky> Mrokii: *suffixes
[14:57:35] <Avaris> altendky: nah that's a check, you need to get from the database
[14:57:40] <Mrokii> altendky: Sorry. English isn't my native language. :)
[14:57:52] <altendky> Mrokii: no problem, happened enough i figured i'd share :]
[14:58:04] <Avaris> http://doc.qt.io
[14:58:15] <Mrokii> altendky: Sure, always good to learn something new.
[14:58:43] <altendky> Avaris: quite so. so we should get the supported mime types, use that to create actual mime types, then generate the individual and all names
[14:58:45] <altendky> name filters
[15:07:46] <Avaris> https://dpaste.de
[15:08:02] <Avaris> seems like jumping a lot of hoops but meh :)
[15:08:47] <altendky> but it's not shoving it into a dialog and reading it back out like i did...
[15:11:32] <Avaris> also, for the record, i don't think i would (ever?) pick specific filters if you have all images there by default :)
[15:12:40] <Mrokii> altendky, Avaris: Thanks for all your help, I need to take a break though, too much Python for me today. :) I'll look at the solutions you provided.
[15:13:27] <altendky> Mrokii: go with Avaris'
[15:13:33] <Mrokii> Avaris: I don't understand your last sentence. Do you mean "specific filters" like for "jpeg"?
[15:13:38] <Mrokii> altendky: If you think so. :)
[15:14:30] <Avaris> i won't click on that combobox in file dialog to "hey show me only JPG files..."
[15:14:59] <Mrokii> Avaris: Yes, exactly. That's what irritated me as well.
[15:17:20] <Avaris> but... i won't mix files etc. i have ocd-ish habits when organizing folders/files usually :). so it might be different for others
[15:20:38] <Avaris> FWIW, `.globPatterns()` returns `*.`-ed versions already. instead of `.suffixes()`. simplifies a bit
[15:21:02] <altendky> is it tidy for the multiples?
[15:21:12] <Mrokii> Avaris: I see. Well, the reason I am doing all this is because of that memory-game of mine. The user can only choose a folder (not files), but for my purposes they should see all supported images within the selected folder. So getting all the suffixes as a namefilter was what I was looking for.
[15:21:14] <altendky> mm, i guess it's plural
[15:21:31] <Avaris> tidy? it's a list of `*.ext`s
[15:21:47] <altendky> Avaris: yeah, i ignored the trailing 's', sorry
[15:22:14] -!- BPL has joined #pyqt
[16:07:18] -!- mandeep has joined #pyqt
[17:01:12] rubenwardy is now known as CTF
[17:01:20] CTF is now known as rubenwardy
[17:01:29] -!- mintograde has joined #pyqt
[17:01:30] rubenwardy is now known as CTF5
[17:01:37] CTF5 is now known as rubenwardy
[17:31:58] -!- mandeep has quit [Remote host closed the connection]
[17:39:52] -!- mandeep has joined #pyqt
[18:17:10] -!- AbleBacon has quit [Quit: Leaving]
[19:30:40] -!- mandeep has quit [Remote host closed the connection]
[19:32:23] -!- mandeep has joined #pyqt
[19:53:29] rubenwardy is now known as CTF4
[19:53:34] CTF4 is now known as rubenwardy
[20:24:22] -!- BPL has quit [Quit: Leaving]
[23:35:12] -!- mintograde has quit [Ping timeout: 250 seconds]
[23:40:34] -!- mandeep has quit [Ping timeout: 244 seconds]