Python Forum
Wont create Image from function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wont create Image from function
#11
For your issue with the image not loading, the problem is likely due to the new image being garbage collected because there's no reference to it. You can fix this by keeping a reference to the new image in your helloworld function. Regarding your other questions, destroying and creating widgets is one way to do it, but another approach could be to update the existing widget instead of destroying it. For example, you can change the label's image without destroying it. As for managing long files, yes, keeping each game's code in separate files is a good practice. You can use Python modules to organize your code better. For example, you can have each game's code in a separate file and import the necessary functions or classes into your main file. This keeps your main file clean and manageable. A proper coder would definitely modularize the code for maintainability.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Kivy] Create a function to store text fields and drop downs selection in KivyMD floxia 0 2,726 Dec-18-2022, 04:34 AM
Last Post: floxia
  simple tkinter question function call not opening image gr3yali3n 5 5,687 Aug-02-2022, 09:13 PM
Last Post: woooee
  Class function does not create command button Heyjoe 2 2,987 Aug-22-2020, 08:06 PM
Last Post: Heyjoe
  [PyQt] Create exe file including referenced image (*.png) files mart79 0 2,207 Jul-21-2020, 09:49 AM
Last Post: mart79
  Create image on a Toplevel using tkinter ViktorWong 3 9,587 Jun-13-2020, 03:21 PM
Last Post: deanhystad
  Refresh image in label after every 1s using simple function jenkins43 1 6,139 Jul-28-2019, 02:49 PM
Last Post: Larz60+
  Simple Button click on image file to create action? jpezz 4 9,029 Mar-27-2019, 10:08 PM
Last Post: jpezz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020