#pyqt | Logs for 2018-11-06

Back
[02:50:42] -!- anqxyr has joined #pyqt
[03:12:24] -!- Mrokii_ has joined #pyqt
[03:14:27] -!- Mrokii has quit [Ping timeout: 240 seconds]
[03:14:27] Mrokii_ is now known as Mrokii
[04:00:43] -!- kallesbar has joined #pyqt
[04:34:22] -!- anqxyr has quit [Remote host closed the connection]
[04:34:51] -!- anqxyr has joined #pyqt
[04:35:13] -!- JanC_ has joined #pyqt
[04:37:35] -!- JanC has quit [Read error: Connection reset by peer]
[05:41:49] -!- mintograde has joined #pyqt
[06:37:43] -!- mintograde has quit [Ping timeout: 268 seconds]
[07:02:47] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[07:03:14] -!- Belxjander has joined #pyqt
[07:16:31] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[07:16:54] -!- Belxjander has joined #pyqt
[09:16:41] -!- malh has joined #pyqt
[09:25:35] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[09:26:43] -!- Belxjander has joined #pyqt
[09:36:36] -!- Siecje has joined #pyqt
[10:20:56] <Mrokii> So... I have another problem. Big surprise...
[10:23:47] <Mrokii> It may not be the best design, but I have created some clickable images (realised via a class derived from QLabel). This class emits a signal that invokes a function in the MainWindow-class. This part works. However, in this invoked class it seems I can't get access to MainWindow-properties (like GUI-elements for example).
[10:25:19] <Mrokii> It seems that, through calling it via an emit-signal from the qlabel-instance is run in the context of said instance, thus not knowing about the Mainwindow-class it's positioned in.
[10:26:25] <altendky> Mrokii: probably best to share code
[10:26:47] <altendky> and you mean you have connected the signal to a method in the MainWindow class?
[10:26:57] <altendky> hopefully an instance of the MainWindow class?
[10:31:39] <Mrokii> altendky: Yes, it's an instance of the MainWindow class.
[10:31:57] <altendky> Mrokii: then it will have self like any other method?
[10:32:03] <altendky> Mrokii: are you getting an error?
[10:33:44] <Mrokii> yes, when I try to access "self" I get "NameError: name 'self' is not defined"
[10:34:06] <altendky> Mrokii: then you wrote the method definition wrong
[10:34:17] <altendky> Mrokii: you missed self in the parameter list
[10:36:35] JanC_ is now known as JanC
[10:37:19] <Mrokii> altendky: I do have "self" in the paraemter list, but when I use that in the parameter list (like so: self.card_clicked.emit(self, self.my_path, self.my_row, self.my_col)
[10:37:24] <Mrokii> ...
[10:37:36] <altendky> Mrokii: no. can you share code?
[10:37:37] <Mrokii> then "self" refers to the Qlabel-class, not the MainWindow-class
[10:37:47] <altendky> Mrokii: parameter list not argument list
[10:37:50] <Mrokii> I will try to. One moment.
[10:38:06] <altendky> Mrokii: `def the_slot(self, other, stuff)` rather than `def the_slot(other, stuff)`
[10:38:07] -!- malh has quit [Ping timeout: 256 seconds]
[10:39:13] <altendky> Mrokii: the external signature gets the self removed when the class is constructed. i'm not sure if it's literally this but it's at least similar. so you can think of it as in init doing `self.the_slot = functools.partial(self.the_slot, self)`
[10:39:50] <altendky> Mrokii: so `an_instance.the_slot` is holding onto `self` inside of itself and passes it to `TheClass.the_slot` for you
[10:40:05] <Mrokii> I will paste my code, one moment.
[10:42:22] <Mrokii> This is the relevant part of the qlabel-class: https://pastebin.com
[10:42:28] <altendky> Mrokii: https://repl.it (we'll see if this is relevant but i wanted to take a look myself)
[10:43:03] <Mrokii> Oh wait, there's something missing in that paste...
[10:43:09] <altendky> Mrokii: are you wanting to pass the label to the slot?
[10:43:21] <altendky> Mrokii: and really aren't you getting the exception in the slot?
[10:43:27] <altendky> Mrokii: can you just share full code and full output?
[10:45:06] <Mrokii> exception?
[10:45:09] <Mrokii> https://pastebin.com
[10:45:17] <Mrokii> This is the part of the Qlabel-class
[10:45:41] <Mrokii> and the called function in MainWindow is defined like this: "def on_img_clicked(my_object, card_path, my_r, my_c):
[10:45:43] <Mrokii> "
[10:46:14] <altendky> Mrokii: yes, you said you get a NameError. that's an exception
[10:46:46] <Mrokii> Oh yeah, I wasn't sure what exactly you were referring to, sorry.
[10:46:47] <altendky> Mrokii: 1) you aren't connecting to a method on an instance of MainWindow. you are connecting to the class itself.
[10:47:01] <altendky> Mrokii: 2) where is the slot which the exception refers to?
[10:47:16] <altendky> Mrokii: 3) do you want to be passing the label to the mainwindow?
[10:48:18] <Mrokii> Oh, okay, I made a mistake then, regarding 1)
[10:48:48] <altendky> Mrokii: presumably the window in some way creates the label. as such the window would connect the label to the window
[10:48:52] <altendky> normally
[10:50:36] <Mrokii> *sigh* I've been doing this for too long today... I am getting confused as it seems. Better to stop, I guess.
[10:51:00] <altendky> Mrokii: i bet we can get through it in not too long if you share the code
[10:51:06] <altendky> and full exception
[10:57:57] <Mrokii> This is how I created the main window: https://pastebin.com
[10:58:27] <altendky> Mrokii: as i said, the function definition doesn't contain self
[10:58:51] <Mrokii> and this is the stuff from before, the other class: https://pastebin.com
[10:59:00] <altendky> Mrokii: `def on_img_clicked(self, my_object, card_path, my_r, my_c)`
[10:59:34] <altendky> Mrokii: methods will get 'the object' as their first parameter no matter what you name it. by convention we name it self.
[10:59:58] <Mrokii> altendky: I think I have tried that and got some exception. One moment, I will try.
[11:00:22] <altendky> Mrokii: and you want to do the connection after line 12. `my_img_lbl.card_clicked.connect(self.on_img_clicked)`
[11:00:51] <Mrokii> altendky: I have extended the line as you suggested and got "TypeError: on_img_clicked() missing 1 required positional argument: 'my_c'
[11:01:13] <altendky> Mrokii: full code and full output...
[11:02:31] <Mrokii> It's just as before, with the one exception that the line def "on_img_clicked(my_object, card_path, my_r, my_c):" was changed to "def on_img_clicked(self, my_object, card_path, my_r, my_c):"
[11:03:12] <Mrokii> And then I get "TypeError: on_img_clicked() missing 1 required positional argument: 'my_c'" in the console. Nothing more.
[11:03:40] <Mrokii> I will try to change line 12 as you suggested and see what happens.
[11:03:47] <altendky> Mrokii: i have limited interest in trying to apply english diffs, sorry
[11:04:32] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[11:04:59] -!- Belxjander has joined #pyqt
[11:06:41] <Mrokii> Okay, once again: This is the qlabel-derived class: https://pastebin.com
[11:07:03] <altendky> Mrokii: as long as you snip stuff your exception line numbers won't be valid
[11:07:20] <Mrokii> And this is the MainWindow part: https://pastebin.com
[11:08:08] <Mrokii> Alright, one moment
[11:08:19] <altendky> Mrokii: go ahead and share the exceptoin
[11:08:26] <altendky> Mrokii: also, presumably you should get one for `self.card_clicked.connect(self.on_img_clicked)`
[11:11:50] <altendky> Mrokii: also, gist.github.com let's you share multiple files in one place (without ads)
[11:11:58] <Mrokii> This is the whole sourcecode: https://pastebin.com
[11:12:17] <Mrokii> And this is the exception I get at the moment: https://pastebin.com
[11:12:28] <Mrokii> I didn't know about gist.github. Will have a look, thanks.
[11:12:30] <altendky> Mrokii: yes. you see how that error makes sense?
[11:13:15] <Mrokii> well, I assume "self" in that case refers to the QMemCardWidget class.
[11:13:39] <Mrokii> I mean, its instance.
[11:13:53] <altendky> Mrokii: it refers to the instant for which you are running the __init__ yes. because it is inside the __init__ in that class and the first parameter's name was self
[11:14:04] <altendky> (and you didn't reassign it to reference something else)
[11:14:56] <altendky> Mrokii: the thing is that the label doesn't know the window it should be connecting to. and it probably doesn't need to. that's why i suggesting making the connection in the mainwindow. the window is creating the label and thus inherently knows about both so it is a good candidate for connecting them
[11:15:45] <altendky> Mrokii: it also leaves the label knowing only that it has a signal that one or more things may pay attention to. the listeners, or some third party sometimes, get to connect themselves
[11:19:04] <Mrokii> altendky: I will have to think about how to do that. My mind is a bit clogged at the moment, as I've been working on this thing for too long today.
[11:19:16] <Mrokii> altendky: But thanks for your help.
[11:19:31] <altendky> 11:00 <altendky> Mrokii: and you want to do the connection after line 12. `my_img_lbl.card_clicked.connect(self.on_img_clicked)
[11:19:35] <altendky> but... line number...
[11:20:20] <altendky> Mrokii: after line 840. so create the card and then connect it's signals
[11:20:36] <altendky> *its
[11:25:51] <Mrokii> Do I need to change something in QMemCardWidget as well?
[11:26:00] <altendky> Mrokii: stop trying to connect there
[11:27:36] <Mrokii> altendky: Okay, I got rid of the connect line in there...
[11:32:01] <Mrokii> altendky: Oh, wow, it seems to work!
[11:32:08] <Mrokii> altendky: I can't thank you enough!
[11:32:46] <Mrokii> That's what one gets when they have no real clue what they're actually doing. :-/ Seems I still have a lot to learn.
[11:35:24] <altendky> Mrokii: we all do, in time you just learn how much more there is...
[11:35:33] <altendky> (and occasionally are productive along the way)
[11:41:57] <Mrokii> altendky: I am quite often overwhelmed by everything already. Seems it never gets easier, really.
[11:42:35] <altendky> Mrokii: as long as you try to do something new, it stays hard. if you just write the same thing as last time in the same way, then it would get easy. :] but there's not much point in that usually.
[11:42:52] <Mrokii> Though at least this little app seems to work, at least on the most basic level. So that's a plus.
[11:44:43] <Mrokii> altendky: Yeah, that's the point, probably. Still, sometimes it's just overwhelming.
[11:45:08] <altendky> Mrokii: absolutely. that you do learn and learn how to deal with yourself.
[11:46:33] <Mrokii> Yeah, no other way ultimately. :/
[12:10:58] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[12:11:25] -!- Belxjander has joined #pyqt
[12:15:09] -!- Belxjander has quit [Client Quit]
[12:15:43] -!- Belxjander has joined #pyqt
[14:22:46] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[14:23:13] -!- Belxjander has joined #pyqt
[15:27:12] -!- necrose99_ has quit [Ping timeout: 252 seconds]
[16:12:36] -!- mintograde has joined #pyqt
[16:20:38] -!- Bjander has joined #pyqt
[16:23:42] -!- Belxjander has quit [Ping timeout: 252 seconds]
[16:23:44] Bjander is now known as Belxjander
[16:50:48] -!- TunaLobster has joined #pyqt
[16:58:05] -!- TunaLobster has quit [Quit: So long and thanks for all the fish]
[16:58:37] -!- anqxyr has quit [Read error: Connection reset by peer]
[17:01:23] -!- Siecje has parted #pyqt
[17:05:21] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[17:06:57] -!- Belxjander has joined #pyqt
[17:24:11] -!- necrose99 has joined #pyqt
[17:31:30] -!- kallesbar_ has joined #pyqt
[17:35:02] -!- necrose99 has quit [Ping timeout: 250 seconds]
[17:35:09] -!- kallesbar has quit [Ping timeout: 252 seconds]
[18:04:41] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[18:05:13] kallesbar_ is now known as kallesbar
[18:06:01] -!- Belxjander has joined #pyqt
[18:28:26] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[18:28:58] -!- Belxjander has joined #pyqt
[21:29:54] -!- mintograde has quit [Ping timeout: 244 seconds]
[22:00:17] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[22:00:43] -!- Belxjander has joined #pyqt
[22:36:56] -!- JT-Shop has joined #pyqt
[23:30:41] -!- kallesbar has quit [Quit: Konversation terminated!]
[23:41:25] -!- Belxjander has quit [Quit: AmigaOSv4.1.6+//PowerPC native]
[23:42:13] -!- Belxjander has joined #pyqt