Calling defintions from inside a class
<p>I am currently having an issue with calling on definitions from inside a class, how do I fix the issue of <code>slideShow()</code> in line 32 not opening the slideshow sequence?</p>

<pre><code>import tkinter as tk
from itertools import cycle

root = ""
#create a splash screen, 80% of display screen size, centered,
#quickly diplaying a cycle of images, disapearing after 10 seconds

#lists the images that will be cycled
images = ["pic1.gif", "pic2.gif", "pic3.gif", "pic.gif", "pic5.gif", "pic6.gif"]
photos = cycle(tk.PhotoImage(file=image) for image in images)

class splashscreen():
  def slideShow():
     img = next(photos)
     displayCanvas.config(image=img)
     #after 0.05 seconds, begin the slideshow
     root.after(1, slideShow)

  #creates the canvas for the image to go on
  global root
  root = tk.Tk()
  root.overrideredirect(True)
  width = root.winfo_screenwidth()
  height = root.winfo_screenwidth()

  #sets the size of the splash screen, and its distance from the sides of the screen
  root.geometry('%dx%d+%d+%d' % (1536, 864, width/10, height/20))
  displayCanvas = tk.Label(root)
  displayCanvas.pack()

  #after 10 milliseconds, the slideshow will begin, and after 10 seconds, be destroyed 
  #this is the thing that isnt working
  root.after(10, lambda: slideShow())
  root.after(10000, root.destroy)
</code></pre>

<p>Why doesn't <code>slideshow()</code> open the <code>def slideShow()</code>? It says that name slideshow is undefined, how do I fix this issue so my code works?</p>

<p>You have to use <code>self.</code> inside class. </p>

<pre><code>def slideShow(self):
</code></pre>

<p>and </p>

<pre><code>root.after(1, self.slideShow)
</code></pre>

<p>But probably you have problem with second <code>after</code> too. You have to create instance of class <code>splashscreen</code></p>

<pre><code>my_slides = splashscreen()
</code></pre>

<p>and then you can use <code>splashscreen.slideShow</code></p>

<pre><code>root.after(10, splashscreen.slideShow)
</code></pre>

<p>You have mess in code so I'm not sure which part is inside class and which not.</p>

<hr>

<p>BTW: to make code more readable use <code>CamelCase</code> names for classes - <code>SplashScreen</code> - <code>lower_case</code> namese for variables and functions - <code>display_canvas</code>, <code>show_slide</code></p>

python tkinter