« first day (173 days earlier)      last day (580 days later) » 

15:25
@xlmaster sure.. probably with Object hast no attribute "Tk" or something.
the reason for this is simply that your object is not an instance of Tk it is an object with the bounded attribute root that is an instance of Tk.
oh wait no.. you never return from your init method. lol.. your mainloop will stop the execution of your script till the mainloop is finisch.
Where do I start here to explain what ? xD
So for starters..
28
A: Tkinter understanding mainloop

Bryan Oakleywhile 1: root.update() ... is (very!) roughly similar to: root.mainloop() The difference is, mainloop is the correct way to code and the infinite loop is subtly incorrect. I suspect, though, that the vast majority of the time, either will work. It's just that mainloop is a much cleaner s...

look what mainloop roughly does..
you can than understand why your script currently does not work.
when fixing this.. in the manner that you want to..
class UsrApp():
     def __init__(self):
          self.root=Tk()

    def mainloop(self):
        self.root.mainloop()

if __name__=='__main__':
       app = UsrApp()
       app.mainloop()
then to subclass your object you do as you did before, but using self
776
A: What is the purpose of the `self` parameter? Why is it needed?

Thomas WoutersThe reason you need to use self. is because Python does not use special syntax to refer to instance attributes. Python decided to do methods in a way that makes the instance to which the method belongs be passed automatically, but not received automatically: the first parameter of methods is the ...

class WdgtCheckButton(UsrApp):
    def __init__(self,wdgt_txt):
         tkinter.Checkbutton(master=self,text=wdgt_txt).pack()

if __name__=='__main__':
       app = WdgtCheckButton('first email adress')
       app.mainloop()
In case you wonder why app, the instance of WdgtCheckButton, has the method mainloop. You would need to research the topich inheritance.
that's a lot of useful information, even for me :o
Thank you
@NordineLotfi yea, took a while till I had have asked the right questions to get myself answers. So I think providing it is a huge help, but donno.
15:41
definitely a huge help
also made this version of the workaround I mentioned for fill (with tksvg): gist.github.com/secemp9/af1ab2466a5733683a956845396a1c3b
I made another one, but I didn't notice a silly error when I made this question yesterday: stackoverflow.com/questions/76167901/…
using itemconfig/itemconfigure also solved the incrementing object id when deleting the svg image on the canvas
@NordineLotfi go with something like acw did. Creating new items or creating new images leads to the same memory issue.
@NordineLotfi I think using excel here is a huge waste. Do something more lightways with a json file or something. It will be quicker, and more efficient.
@Thingamabobs but isn't that what I did? I used itemconfig like they did here: gist.github.com/secemp9/…
@Thingamabobs that's true. I did thought it was a waste, given replace/string formatting also would have worked, but didn't thought of using json instead. Good idea
@NordineLotfi in your question, acw mostly don't missinterpret questions :P
when looking at this bit of code:
self.svg_store.clear()
self.svg_store.append(tksvg.SvgImage(data=self.svg_string))
self.image_store.append(self.canvas.create_image(width / 2, height / 2, image=self.svg_store[0]))
you don't need to clear an empty list..
oh, forgot that :/
you store image reference and item id, separately
you could add the item id as attribute to the image for instance
or use a different approach you like
looking at this bit of code
def change_color(self, event):
    self.fill_color = "blue" if "red" in self.fill_color else "red"
    self.update_svg_store()
    self.canvas.itemconfig(self.image_store[0], image=self.svg_store[0])
you call update_svg.. where you create a new image and save this to the store
so you creating more instances of SvgImage
that's an issue
15:59
how can I handle it then? since I want to switch the fill option everytime the mouse hover on the svg image, but I need to recreate it using SvgImage...
@NordineLotfi fair point.. don't know yet :P
welp, maybe I could inherit the SvgImage class? but I don't know enough about inheritance to do that
I did look at the code used for it on github though. It's based on a stackoverflow answer: stackoverflow.com/a/64829808/12349101
@NordineLotfi that's not the answer to this problem at least.
and here is original code for the module I think: github.com/TkinterEP/python-tksvg/blob/master/tksvg/…
@Thingamabobs yeah, you're right :/
was just an idea, since as you mentioned, there also the problem of me recreating different instance of SvgImage
*Option may have any of the values accepted by the image create photo command. * tcl.tk/man/tcl/TkCmd/photo.html#M16
so what should be possible..
16:07
@Thingamabobs, I understand by myself only, the reason self is instance, and it has already root instance attribute of UsrApp class. Thanks for all above. That was great. It's already 4 months that I started coding, and maybe before I was Bachelor of Art and age 33 that makes hard to remember what you read before. I already got with this type of error and you helped previously. Now, I get into it little by little although I have a read a lot about it after [rveious error. Thanks @Thingamabobs
def change_color(self, event):
    self.fill_color = "blue" if "red" in self.fill_color else "red"
    img, id_ = self.image_store[0], image=self.svg_store[0]
    img.configure(data=self.svg_string)
    self.canvas.itemconfig(id_, image=img)
@xlmaster You are welcome. I tend to forget things too when I don't use them. :P
@xlmaster BTW: self is not really an instance it is a reference to that instance, but don't want to be picky :P
get loose with the terms myself ^^
reference to value ? in python variables are labels like pointing to that object...You mean in that direction..)) I read about it, watched Ned Bl...I am ok with calling it as instance referncing. ) By time I feel like I am able to think more deeply about things that I tend to use occassionally while coding)
@Thingamabobs using configure is genius. I didn't thought of doing that XD
@xlmaster yes, sometimes it is helpful, but mostly just "nice to know". I feel like.. when working with stuff, I try to get the wizard out of the box and make him tell me his secrets. I feel more comfortable, but on the other hand.. there is a point I'm just not interested in knowing more.. like what happens in the carnal and what not.
so with this, and using json (and not using clear on an empty list) you think it's a bit better? (at least as a temporary workaround)
16:21
@NordineLotfi it's more efficient at least, so while using it you can gain more out of it. So I think it is an improvement. The main idea of building your own tksvg.canvas is.. I don't know.. to be honest.. you might be better subclassing it.. but you can always do your own, did it like that in the past as well. But I feel it tends to provide repetitive code.
Isn't there source code available for tksvg ? I really don't know to be honest, didn't looked at it.
@Thingamabobs yeah, you're right :) Thank you, I think I even managed to notice I didn't need itemconfig. I also managed to bind directly to the object returned by create_image, and it works now
@Thingamabobs yeah, I posted the two relevant links above: github.com/TkinterEP/python-tksvg and the stackoverflow answer that tksvg SvgImage class is based on: stackoverflow.com/a/64829808/12349101
16:37
@NordineLotfi great and even better ! :)
@NordineLotfi Cool, thanks
@Thingamabobs do you think I should keep the question i did without an accepted answer? Maybe you could post the answer you mentioned above (or I could self-answer if you prefer).
I'm guessing an official answer (eg: one that directly modify tksvg, or something similar) probably won't come until later, so don't know if it's a good idea to wait
@NordineLotfi I did not notice that it's still in the scope of your question. I think I can add it as answer, even though I have already upvoted acw. lol :P
@NordineLotfi please add your comment that you don't need to use itemconfig, for future visitors.
17:02
@Thingamabobs Thanks
@Thingamabobs sure thing
 
4 hours later…
20:35
I really do not understand, banning me from asking questions. In The age of ChatGPT :D
Bad that Thingmambobs has left
class UsrApp():
df=None
def __init__(self):
self.root=Tk()


#checkbutton instantiations
df=pd.read_json('Email_Addresses/emailaddresses.json')
for k,v in df.items():
self.checkbutton_create(k)

def checkbutton_create(self,txt):
self.wdgt_var = BooleanVar()


self.wdg_checkbutton=tkinter.Checkbutton(master=self.frm_checkbuttons,text=txt,variable=self.wdgt_var)
self.wdg_checkbutton.pack(side='left',expand=YES,fill=X)
every time I create checkbutton newly I add to that instance same variable self.wdgt_var, but after when I use get() method I am able to get only last instantiated checkbutton's value. How can I get around this, by giving variables as paramter? Then I will need to assign every time BooleanVar() to new method then send it...Is n't there another way, easier one. At the end I need to see what are the texts of checked values
21:02
@NordineLotfi Well, I don't use it much these days. But I am working on a self driving bus project which will have its UI for check-in presumably in tkinter
Chose tkinter only because I was lazy to design a whole webpage '^_^
What about you guys
@DelriusEuphoria that's great :D
does that mean you use pyqt more? I started playing around with it because of the webkit support
@DelriusEuphoria trying to clone this: excalidraw.com in tkinter. Made some progress I think (see backlog here)
aside from that, I made a bunch of tiny POC using tkinter on my gist.github...
@NordineLotfi Nope, it means I dont make GUIs anymore. Websites
:D
@NordineLotfi In a way that even others can chip in and make changes real time?
@DelriusEuphoria :O that's nice. I didn't yet try to make websites, so this is on my todo list
@DelriusEuphoria yeah. Also would be easier to understand the codebase and extend/modify it, compared to the original version (which use a bunch of reactjs/nodejs dependencies, and is honestly a pretty big codebase)
there also the fact it run in the browser, and by just having less than 100KB worth of elements on the canvas, the cpu spike at all time at 100%
and lastly local save support.
(those three reasons are mostly why I'm trying to do that)
it also use the MIT license, so this is easier to do too...
 
1 hour later…
22:36
Hmmm I see
Good luck with your project!!

« first day (173 days earlier)      last day (580 days later) »