I am trying to make a simple application launcher using Tkinter ( for the games that I have made using pygame). The code for the same is below.It runs in full screen mode(without any maximize or minimize buttons).
import Tkinter as tk
from Tkinter import *
import random
import os
import subprocess
def call(event,x):
print "begin"
if x==0:
p = subprocess.Popen("python C:\Users\Akshay\Desktop\i.py")
p.wait()
print "end"
root = tk.Tk()
root.geometry("1368x768+30+30")
root.overrideredirect(True)
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
games = ['Game1','Game2','Game3','Game4','Game5','Game6','Game7','Game8']
labels = range(8)
for i in range(8):
ct = [random.randrange(256) for x in range(3)]
brightness = int(round(0.299*ct[0] + 0.587*ct[1] + 0.114*ct[2]))
ct_hex = "%02x%02x%02x" % tuple(ct)
bg_colour = '#' + "".join(ct_hex)
l = tk.Label(root,
text=games[i],
fg='White' if brightness < 120 else 'Black',
bg=bg_colour)
l.place(x = 320, y = 30 + i*150, width=700, height=100)
l.bind('<Button-1>', lambda event, arg=i: call(event, arg))
root.mainloop()
There is no issue with this piece of code but I want a scroll bar at the right side or a way to scroll/move down using the arrow keys so that if I add more number of labels , they also become visible.
I tried to understand some code snippets from the internet and read the Tkinter documentations as well but didn't understood anything. Also tried to follow one more stackoverflow discussion and understood about the frame and canvas methods.
Python Tkinter scrollbar for frame
Frame , canvas and all is getting a bit complicated. I just want to keep it simple.Can something be added to the code snippet above to make the scroll thing work and all the labels become visible?
Something like the above but with a scroll bar!!