#pyqt | Logs for 2018-09-08
Back
[01:24:34] -!- mintograde has quit [Ping timeout: 246 seconds]
[01:35:11] -!- BPL has quit [Read error: Connection reset by peer]
[03:31:49] -!- anqxyr has joined #pyqt
[05:41:26] -!- kallesbar has joined #pyqt
[08:02:41] -!- mintograde has joined #pyqt
[08:22:24] -!- frispete_ has joined #pyqt
[08:25:48] -!- frispete has quit [Ping timeout: 252 seconds]
[09:01:03] -!- BPL has joined #pyqt
[10:11:56] -!- mandeep has joined #pyqt
[11:59:20] -!- pennTeller has joined #pyqt
[12:00:09] <pennTeller> Guys can anybody show me how to properly subclass a Ui_MainWindow generated by pyuic5?
[12:00:25] <altendky> pennTeller: i don't :]
[12:00:43] <The-Compiler> pennTeller: there are some examples in the PyQt docs
[12:01:04] <altendky> pennTeller: this is how i use .ui files (well, it's my latest preference, i have all sorts of ways in existing code)
[12:01:05] <altendky> https://github.com
[12:02:16] <altendky> pennTeller: so UiBase ends up being a QMainWindow. then i have the Ui (Ui_MainWindow) as an attribute. then all my ui stuff (buttons, line edits, etc) are segregated into the .ui attribute of my mainwindow
[12:02:21] <altendky> and, no multiple inheritance
[12:06:32] <pennTeller> let me show you what I got so far
[12:08:03] <pennTeller> This doesn't work when I click on the submit_button nothing happens
[12:08:04] <pennTeller> https://pastebin.com
[12:09:56] <altendky> pennTeller: i'm not sure offhand. but as i recall the Ui_Mainwindow isn't actuallly a QMainWindow (might be wrong). if you share the .ui i could actually run it. gist.github.com is nice, especially for multiple files
[12:10:48] <altendky> pennTeller: but i'd expect at least a failure on .connectToDB()? have you been editing the generated file?
[12:11:43] <altendky> pennTeller: also, what os?
[12:11:55] <pennTeller> I'm on windows
[12:12:28] <altendky> pennTeller: and how do you run the program?
[12:12:28] <pennTeller> I have not edited the generated file at all
[12:12:36] <pennTeller> python Main.py
[12:12:49] <pennTeller> ^thats how I run it
[12:12:51] <altendky> pennTeller: iirc you don't get to print in that case. stdout isn't available
[12:13:04] <altendky> pennTeller: but to understand your code we need all of it
[12:13:25] <pennTeller> ok here it goes
[12:14:06] <pennTeller> this is the generated file from pyuic5 https://pastebin.com
[12:15:33] <pennTeller> and this is my "main" file (where I am subclassing) https://pastebin.com
[12:16:52] <altendky> pennTeller: that gives an attribute error. not a 'nothing happens when you click a button'
[12:17:05] <altendky> pennTeller: you are trying to connect in the __init__ before you have done setupUi
[12:17:20] <altendky> pennTeller: unless you have an issue with my structure, perhaps consider using it?
[12:18:03] <altendky> pennTeller: the main complaint about it is that there is no .py file so the ide can't provide completions of everything. i personally don't spend that much time connecting to the .ui so that isn't a big issue for me
[12:18:11] <pennTeller> the problem is I didn't understand exactly what you meant
[12:18:34] <altendky> pennTeller: alright. do you see that with what you shared you get an attribute error? i'll gist in a second
[12:18:48] <pennTeller> I have never heard of UIBase
[12:18:58] <altendky> pennTeller: it's a name i assign to in my code
[12:19:04] <altendky> pennTeller: did you see my code link?
[12:19:17] <altendky> pennTeller: https://gist.github.com so do you get this?
[12:19:18] <pennTeller> yes
[12:20:00] <pennTeller> I will give it a shot
[12:20:02] <pennTeller> :)
[12:20:27] <altendky> pennTeller: do you get the exception i shared? what i am observing is not consistent with your report that you get a gui showing
[12:21:08] <pennTeller> yes I am getting the same exception
[12:21:14] <pennTeller> sorry I think I sent a slightly modified version
[12:21:17] <pennTeller> let me resend please
[12:21:33] <altendky> pennTeller: run the exact files. then share them along with the exact output.
[12:22:11] <pennTeller> ok her goes the whole thing I was trying to clean it up for you
[12:22:36] <pennTeller> this is my fulle "main" file
[12:22:36] <pennTeller> https://pastebin.com
[12:23:28] <altendky> pennTeller: do you see 'got through' when you run your program?
[12:23:41] <pennTeller> yes!
[12:26:18] <altendky> pennTeller: well, i observe the issue anyways
[12:26:23] <altendky> not sure why yet
[12:27:29] <pennTeller> I've been fighting with it all morning lol driving me nuts
[12:29:55] <altendky> pennTeller: fyi, setupUi calls retranslateUi
[12:31:06] <altendky> pennTeller: and you should call the super init via `super().__init__()`
[12:31:30] <altendky> (still looking for the actual issue though)
[12:32:26] <altendky> oh, uh...
[12:32:52] <altendky> you create a MarioWindow (which inherits from Ui_MainWindow). then you also create a Ui_MainWindow() directly (so now you have two).
[12:33:10] <altendky> and you use the second one to setup on the first one and show the first one
[12:33:17] <altendky> pennTeller: that's a mess :]
[12:33:58] <altendky> hmm, a mess but still not fixed
[12:34:10] <pennTeller> yeah
[12:34:41] <pennTeller> sorry for the pain
[12:36:45] <altendky> pennTeller: stepping away for lunch. i'll let you know if i fix it later
[12:38:10] <pennTeller> altendky thank you very much man
[12:38:20] <pennTeller> I'll go eat too
[12:57:41] <altendky> pennTeller: also, everything should be in layouts. You don't want to just place everything wherever like that.
[13:22:07] -!- kallesbar has quit [Remote host closed the connection]
[13:22:33] -!- kallesbar has joined #pyqt
[13:27:51] <pennTeller> altendky I recently found out about that plus this is my first Qt program :p
[13:29:10] -!- mandeep has quit [Quit: Leaving]
[14:14:03] <BPL> guys, it's just me or the number of people at #pyqt is smaller than few months ago, maybe I'm wrong but I recall few months ago there was a scrollbar in my chat client and now there isn't :'D
[14:14:47] <BPL> guess many of them moved out to qt-pyside and they're not coming back? lol
[14:16:13] <altendky> BPL: you stopped asking as many questions?
[14:16:20] <altendky> BPL: oh, you mean the members list
[14:16:34] <altendky> BPL: that's because of the spam and all channels requiring authentication by default i think
[14:21:03] <altendky> pennTeller: ok, it was the multiple setupui calls
[14:21:46] <altendky> pennTeller: in __init__ you called setupUi then connected then you setupUi again which removed the reference to the first button whose click you had connected and replaced it with a new button that you didn't connect.
[14:22:43] <altendky> pennTeller: i deleted each file down to about 30 lines before i saw... :|
[14:26:43] <altendky> i wonder if there's a way to make .pyi files for .ui that could be associated with the dynamically loaded types.
[14:27:11] <altendky> or for that last 'ide completion' part do you really have to compile to a .py file and import that .py... :[
[14:36:51] <altendky> I suppose it wouldn't be too bad to do `ui = build_and_import_ui()` instead of my import hook 'magic'. Could optionally create an in memory only module when you don't want to write to disk (when deployed or some such in some cases)
[14:46:48] -!- mandeep has joined #pyqt
[14:50:58] -!- mandeep has quit [Ping timeout: 246 seconds]
[15:12:07] -!- mandeep has joined #pyqt
[15:13:30] <pennTeller> altendky thanks for the insight man, I will try to implement it now and report back in a few
[15:15:38] <pennTeller> altendky oh thanks man I got it working now! :D
[15:16:17] <altendky> pennTeller: good deal
[15:16:50] <pennTeller> altendky, many thanks and my apologies for the bad code
[15:58:56] <altendky> pennTeller: meh, I'm still figuring out the patterns I like. There are lots of choices each with their own drawbacks.
[17:14:19] -!- BPL has quit [Read error: Connection reset by peer]
[17:44:36] -!- pennTeller has quit [Quit: Hard work pays off in the future, laziness pays off now]
[17:50:12] -!- necrose99 has joined #pyqt
[18:05:39] -!- anqxyr has quit [Read error: Connection reset by peer]
[18:35:34] -!- necrose99_ has joined #pyqt
[18:39:24] -!- necrose99 has quit [Ping timeout: 252 seconds]
[18:49:13] -!- necrose99_ has quit [Ping timeout: 245 seconds]
[23:12:37] -!- stochastix has quit [Read error: Connection reset by peer]
[23:48:30] -!- mintograde has quit [Ping timeout: 252 seconds]