[Tkinter] I don't think I understand the basics of tkinter! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] I don't think I understand the basics of tkinter! (/thread-17321.html) |
I don't think I understand the basics of tkinter! - jpezz - Apr-06-2019 The documentation doesn't help! If I have (forget the variables except the ones I need help with and not all statements are shown): root = tk.Tk() root.geometry('%sx%s+%s+%s' % (Xsize, Ysize, Xoffset, Yoffset)) label=tk.Label(root, textvariable=time_str, font=label_font, bg=bg_color, fg=Number_Color.get(), relief='raised', bd=3) label.pack(fill='x', padx=5, pady=5) label.config(fg=Number_Color.get()) root.mainloop()Questions:
RE: I don't think I understand the basics of tkinter! - Yoriz - Apr-06-2019 I don't understand tkinter much either
RE: I don't think I understand the basics of tkinter! - jpezz - Apr-07-2019 Quote:11. i don't understand what your asking on this one sorry.If I have a background that's just a black field. Then I create a label. If I remove that label, will the background behind it be restored to the black color? Seems to be "yes" in Gnome system but not necessarily always in my target openbox system. I asked in another question about the ability to leave behind a label even though the creating program has terminated. I want to be able to do both at varying times. For #7, if I only have one instance of tk.Tk(), like root=tk.Tk() then every time I execute a command like root.geometry , then that would affect all labels, right? I don't want that. I want it to only affect one label.
RE: I don't think I understand the basics of tkinter! - Gribouillis - Apr-07-2019 You also need to understand that tkinter is not python/pythonic. It is only a wrapper around Tcl/Tk, an award winning software by John Ousterhout. Tk has its own philosophy, its own design and its own language. Tkinter is thus an hybrid python module combining two different approaches and cultures. You can perhaps learn a lot by reading Tcl/Tk literature. RE: I don't think I understand the basics of tkinter! - jpezz - Apr-07-2019 (Apr-07-2019, 05:46 PM)Gribouillis Wrote: You also need to understand that tkinter is not python/pythonic. It is only a wrapper around Tcl/Tk, an award winning software by John Ousterhout. Tk has its own philosophy, its own design and its own language. Tkinter is thus an hybrid python module combining two different approaches and cultures. You can perhaps learn a lot by reading Tcl/Tk literature.I have been reading the literature and I still don't understand. I wouldn't ask the question if I hadn't searched the net for answers, read the appropriate parts of the tkinter documentation or saw answers but just couldn't relate them to my situation. I'll bet I've been using the net longer than you have; I have an advanced degree in engineering and I do know how to find things. It's just that python and tkinter are new to me; I have a short time to implement this project; have spent a lot of time on it; I'm doing it as a volunteer and have concluded that the only way to do any of this is by adapting previously-written python programs written without any graphical output. RE: I don't think I understand the basics of tkinter! - joe_momma - Apr-08-2019 Knowledge is acquired bit by byte. I've read through your posts. I suggest Mark Lutz's book learning python(no tkinter in it), then his book programming python(lots of tkinter examples and explanations). Mark has an example of a photo edit gallery all in tkinter (pyphoto). Or john grayson's tkinter programming, super old but still relevant. RE: I don't think I understand the basics of tkinter! - jpezz - Apr-15-2019 (Apr-08-2019, 08:53 PM)joe_momma Wrote: Knowledge is acquired bit by byte. I've read through your posts. I suggest Mark Lutz's book learning python(no tkinter in it), then his book programming python(lots of tkinter examples and explanations). Mark has an example of a photo edit gallery all in tkinter (pyphoto). Or john grayson's tkinter programming, super old but still relevant.I found an easier way and I finished the work early. I just dumped any attempt to create multiple windows or worry about the other issues and simply used a main program with no tkinter opening multiple python tkinter programs, each of which controls a specific line of output on the screen. Some (like lines output) are persistent. Others, like data provided by the user, are constantly changing. I simply provide all the data in arguments to a Popen then, to update, I kill the appropriate process and restart it with the new data. I also figured out how to send multiple graphics next to one another. Simple! I found a font that contains the few graphics characters I need, then Popen the program with the font and text I want (widget position, text, font, font size and fg/bg colors are all passed parameters) and it outputs graphics perfectly lined up. I use signals to kill appropriate program (4 output & 4 user data) then create a new one. That's the difference between being an engineer and a software developer. It's done; it works; It's flexible; it's inelegant (so what!); it is inefficient (a quad core Raspberry Pi with nothing else to do means "so what #2"). Thanks for everyone's help. Without it, I wouldn't have thought "Why do I need to do these things?" and would have learned OOP, Python and Tkinter over the next six months but then I'd have missed my deadline. Finished a month early. But the code would have been a lot nicer and I would have learned something I won't. Then again, at my age and my ability these days to retain information, there would be no guarantee I wouldn't be asking the same questions again. I'm not being sarcastic. Just practical. And in my 8 discussions I have learned a lot and sped up the process considerably. |