#pyqt | Logs for 2018-12-13

Back
[00:05:01] -!- TechSmurf has quit [Quit: Lost terminal]
[01:45:20] <TurBoss> Hello
[01:45:50] <TurBoss> I'm trying to add sorting capabilities to a QtableView
[01:46:50] <TurBoss> https://github.com
[02:04:07] -!- kallesbar has joined #pyqt
[03:09:27] -!- Lauxley has joined #pyqt
[03:37:29] -!- anqxyr has joined #pyqt
[03:42:17] -!- anqxyr has quit [Ping timeout: 250 seconds]
[03:46:48] kdas_ is now known as kushal
[04:01:59] -!- tijensse has joined #pyqt
[04:09:41] -!- BPL has joined #pyqt
[07:06:27] -!- mintograde has quit [Ping timeout: 246 seconds]
[08:45:43] -!- JT-Shop has quit [Remote host closed the connection]
[08:46:56] -!- JT-Shop has joined #pyqt
[09:06:38] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[09:07:01] -!- Belxjander has joined #pyqt
[10:21:54] <altendky> TurBoss: where's the QSortFilterProxyModel? Or what code are you having trouble with?
[10:36:00] <altendky> TurBoss: and is that file really meant to be directly run? (hint, it shouldn't be) it's got a #!
[10:37:32] <hazzy-m> altendky: No, that snuck in there with the header me thinks
[10:38:24] <altendky> hazzy-m: mostly that ought to not be in any python files, at least not project ones and especially not ones in packages
[10:40:23] <hazzy-m> altendky: yes, I used to put the shebang in all files until I learned better, so there are a lot that still have it
[10:40:43] <altendky> hazzy-m: as long as we understand :] my codebase looks the same still
[10:43:22] <hazzy-m> somewhat related, putting the license header in every file seems very un-DRY to me, so I have been removing them and just relying on the license in the root. What is your preference/opinion?
[10:44:17] <altendky> hazzy-m: https://github.com though that's completely improper per the gpl
[10:45:29] <hazzy-m> ah, I like that
[10:46:47] <altendky> hazzy-m: i don't remember where i got __copyright__ etc. not sure if they are any sort of actually common thing
[10:48:03] <altendky> but yeah, gpl says to put the actual license there. i forget how much of it
[10:49:35] <hazzy-m> ".. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found."
[10:50:13] <hazzy-m> according to GPL, so I think you can make a strong argument that what you are doing it sufficient
[10:54:48] <TurBoss> altendky: Hello
[10:55:15] <TurBoss> I need a QSortFilterProxyModel?
[10:56:11] <altendky> TurBoss: i think so. been awhile since i dealt with that stuff though. basically you want to present something other than your model (model contains data with structure, you want a different structure). also, i did it with a tree view, so there's a chance it's different with a table, though i think not.
[10:56:47] <altendky> https://stackoverflow.com
[10:56:56] <altendky> or maybe qstandarditemmodel provides sorting builtin, i dunno
[10:57:36] <TurBoss> ok
[10:57:42] <altendky> http://doc.qt.io
[10:57:48] <altendky> it's got something, says nothing about it
[10:57:54] <TurBoss> I'll try when arreive homr
[10:58:03] <TurBoss> *hoe
[10:58:05] <TurBoss> **home
[11:00:38] <TurBoss> thanks
[11:04:10] -!- TechSmurf has joined #pyqt
[11:39:23] -!- Dave_Elec has quit [Ping timeout: 250 seconds]
[11:40:50] -!- Dave_Elec has joined #pyqt
[11:57:00] -!- Dave_Elec has quit [Read error: Connection reset by peer]
[11:57:49] -!- Dave_Elec has joined #pyqt
[12:39:47] -!- Dave_Elec has quit [Ping timeout: 240 seconds]
[15:04:30] -!- Siecje has joined #pyqt
[15:48:02] -!- mintograde has joined #pyqt
[16:33:30] -!- diamondman has joined #pyqt
[16:38:12] <diamondman> I am making a python Qt5 program. Trying to use slots and actions with the designer, but I don't know how to teach the designer about slots in my MainWindow derived class. (I have also seen people suggest not using the UI to attach signals and instead write everything out. I am just trying to learn the most correct way of doing things.) I am sure there is a link explaining how to do it, but I can not find any resources
[16:38:12] <diamondman> explaining how to let the designer know about custom slots/signals so I can attach them to things in the UI.
[16:39:20] <altendky> diamondman: i can't say i know what's proper but i just do my connections in code. the .ui doesn't know about my code so it doesn't make a lot os sense to me to enter the data there.
[16:39:26] <altendky> *a lot of sense
[16:39:43] <altendky> diamondman: but, have you looked at how it's done in c++?
[16:40:56] <altendky> i probably should do up an example so i know...
[16:41:21] <diamondman> I am looking up how to do it in C++, but most people using C++ use qt creator, which automatically generates and links files, so no one really talks about how it works.
[16:41:33] <altendky> and interestingly, the designer page doesn't cover this? http://pyqt.sourceforge.net
[16:43:04] <diamondman> "Designer can only connect Qt signals and slots. It has no understanding of Python signals or callables."
[16:43:45] <altendky> diamondman: that's in the custom python widgets section
[16:46:34] <diamondman> yeah, it is just the clossest thing I can find in there. I feel like if I could tell qt designer that my mainwindow should be promoted to my main class (that inherits from MainWindow) that it would have some reference point to what is available in my custom class, but I can not promote the top of the tree. As it stands, I can't think of any way to teach Qt Designer about slots in Python Widgets/etc.
[16:47:32] <altendky> diamondman: how would that help it know what your custom class would have? but yeah, it appears to provide a list rather than letting you enter whatever you want
[16:47:57] <altendky> but really, self.ui.widget.signal.connect(self.blah) in the code isn't that bad i don't think
[16:49:58] <altendky> without this your .ui purely stands alone with no references to code (i think normally anyways)
[16:50:09] <Avaris> technically you can right click on somewhere on main window and define custom slots. then you can connect them in designer... but i have no idea what pyuic would do with them :)
[16:50:11] <diamondman> Well, if I was able to let the ui file know that the class would REALLY be a MainWindowForMyProgram or whatever instance instead of just a vanilla MainWindow instance, then it could potentially see the available slots in it... Not sure how that would work without a python parser in qt designer which I don't think is there. It feels like I would have to create some kind of qt metadata file describing the slots/actions I have
[16:51:03] <altendky> Avaris: thanks. i'll try that out
[16:51:13] <diamondman> woah there wee go... add sinals and slots
[16:51:39] <altendky> diamondman: sure, but this still introduces an extra connection between the two things
[16:52:01] <diamondman> extra?
[16:52:30] <diamondman> I will test it real quick to see if it calls the custom slot on my real MainWindow derived class
[16:53:11] <altendky> diamondman: yes, presently your .ui is entirely unrelated to your code. it stands totally alone. your code uses the .ui and is written to match it. add this and now both are written to match the other.
[16:53:17] <altendky> not the end of the world, but a distinct change
[16:54:16] <altendky> hmm, no extra code. just seems to work by magic
[16:54:47] <Avaris> it works?
[16:54:58] <altendky> and by magic i mean in setupUi maybe?
[16:55:13] <altendky> Avaris: yeah. add the signal via right click. connect it via the signal/slot editor. run
[16:55:23] <altendky> i'm using the loadUiTypes
[16:56:00] <altendky> you get an exception if you connect it to a non-existant slot name
[16:56:20] <Avaris> weird pyuic5.exe doesn't generate any code
[16:56:34] <Avaris> oh wait no it does
[16:56:35] <Avaris> cool
[16:56:46] * Avaris is blind
[16:56:56] <altendky> `self.actionSystem_Info.triggered['bool'].connect(MainWindow.open_system_info)`
[16:57:16] <altendky> picks the signal specifically too
[16:57:19] <altendky> `'bool'`
[16:58:26] <diamondman> I am using uic.loadUi('main_basic.ui', self), and it throws an error if the slot is not there. The keyboard shortcut I set to the action is not working... will test with a menu button
[16:59:04] <altendky> i really like having my ui load into a .ui attribute
[16:59:12] <altendky> namespacing the generated stuff is really nice
[16:59:44] <Avaris> too much extra typing :)
[17:00:13] <altendky> i mean normally we have `ok_button`... so `.ui.ok` is actually shorter
[17:00:41] <altendky> self.ui.ok.clicked.connect(self.ok)
[17:00:57] <Avaris> there is also a neat/weird/gotcha ability of uic. `connectSlotsByName`... if you define a slot `on_buttonName_clicked` it'll be automagically connected to the clicked signal
[17:01:33] <altendky> right :] magic that won't throw an error when you get it wrong
[17:01:39] <altendky> just won't be connected
[17:01:42] <diamondman> oh interesting point about the name spaces
[17:02:19] <altendky> diamondman: all my real code is up there as well but here's my example project. https://github.com
[17:02:51] <altendky> and i'm more and more liking my automatic compiling idea for `import mypackage.mywindow_ui` to hook and build it for you.
[17:03:12] <diamondman> altendky: Oh, you use that without having to use pyuic5 to preparse the ui file... That is nice
[17:03:26] <Avaris> build?
[17:03:43] <altendky> Avaris: https://github.com
[17:04:15] <altendky> Avaris: when your import ends with `_ui` it looks for a `.ui` file and if it exists it has uic create the .py then lets the import continue and find it.
[17:04:34] <altendky> Avaris: no manual step and you still get a real file to look at and for ide completion
[17:04:46] <altendky> though, i haven't actually used that anywhere yet
[17:04:56] <altendky> and i don't know how much trouble it'd have in various pyinstaller scenarios
[17:05:12] <Avaris> ugh, way to confuse developers :)
[17:05:29] <diamondman> Interesting idea nontheless
[17:06:07] <altendky> Avaris: i'm not convinced it's great, but is it really that bad? i mean lots of good things are bad until you hear about them.
[17:06:35] <altendky> and it's pretty simply. you import x_ui, it looks for x.ui and makes x_ui.py which then imports entirely normally
[17:07:07] <altendky> add a .gitignore line **/*_ui.py or whatever
[17:07:40] <Avaris> if you know about it, sure it's neat
[17:10:41] <Avaris> by that same logic, you might as well setup git hooks to auto compile ui to py and you can have actual files :)
[17:10:45] <altendky> once you build, it's there so no confusion when you look for it. and the file says not to edit it (thanks pyuic5) so if you do it's your own fault when it gets overwritten (but sure, could be confused). *shrug* doesn't seem massively worse than a lot of other things you need to know about any given project
[17:11:00] <altendky> Avaris: the import hook does make real files
[17:11:11] <Avaris> when you run
[17:11:19] <altendky> Avaris: and when would git do it?
[17:11:28] <Avaris> precommit?
[17:11:35] <altendky> needing to git something to be able to run doesn't seem better
[17:12:29] <altendky> i suppose the hooks could write a script that'd do the build and then you could call it manually if you wanted
[17:13:07] <diamondman> It is a 'magic' idea (which often is iffy), but so is the auto linking of functions handlers for widgets. It should be a thing that you import to enable so it does not make people cry
[17:13:19] <Avaris> or handle in the ide
[17:13:26] <altendky> diamondman: it's an explicit call to enable it, just a sec
[17:13:29] <diamondman> not everyone uses an ide
[17:14:02] <altendky> diamondman: https://github.com `basicpyqt5example.uiimporthook.install_ui_finder()`
[17:14:02] <Avaris> depends on the definition of ide. sublime text for example can do it
[17:14:59] <altendky> with c++ whatever, i'd add a build step because i'd already have umpteen others. with python i have no build steps. i just run. i don't like the idea of introducing a build step just for this
[17:15:10] <altendky> edit->run is nice
[17:15:38] <Avaris> you have a build step though, just pushing it to somewhere else
[17:16:12] <altendky> Avaris: but i don't have to trigger it (and i don't mean it's automatic in my ide i mean it's literally just part of running)
[17:16:27] <altendky> it doesn't matter how you run the code it will happen
[17:18:12] <altendky> alrighty, i'd have to put the registration in a test plugin
[17:18:36] <altendky> i'm not convinced this is great but the arguments against don't seem that terribly strong. *shrug*
[17:18:58] <Avaris> i'd be more ok if you put the _ui.py's in the repo :)
[17:19:25] <altendky> that's just asking for them to be wrong. though i would like to have an automatic secondary repo that does have any generated stuff
[17:19:27] <Avaris> without those, just looking at the repo is confusing at first glance (if you don't know that)
[17:19:51] <altendky> of course filled out by a build server so it's more likely to actually be accurate
[17:20:11] <altendky> though maybe a git hook would come into play here
[17:23:49] <diamondman> (also, I got the slot working with an action. So thanks for help on my initial question.)
[17:24:27] <altendky> Yeah, glad you both finally got me to see how that works
[17:24:43] <altendky> Even if I probably won't use it :]
[17:28:53] -!- Siecje has quit [Quit: Leaving.]
[17:40:49] -!- Lauxley has quit [Remote host closed the connection]
[19:42:49] -!- BPL has quit [Quit: Leaving]
[22:00:13] -!- kushal has quit [Remote host closed the connection]
[22:00:37] -!- kushal has joined #pyqt
[22:52:09] -!- swalladge has quit [Ping timeout: 246 seconds]
[23:28:28] -!- swalladge has joined #pyqt
[23:39:38] -!- mandeep has joined #pyqt