Skip to content

Instantly share code, notes, and snippets.

@novel-yet-trivial
novel-yet-trivial / DoubleScrolledFrame.py
Last active September 8, 2023 09:55
A frame for python tkinter with vertical and horizontal scrollbars that behaves like a normal Frame. Tested with python 2 and 3 on linux.
try:
import tkinter as tk
from tkinter import ttk
except ImportError:
import Tkinter as tk
import ttk
class DoubleScrolledFrame:
"""
try: #python3 imports
import tkinter as tk
except ImportError: #python3 failed, try python2 imports
import Tkinter as tk
class Main(tk.Frame):
def __init__(self, master=None, **kwargs):
tk.Frame.__init__(self, master, **kwargs)
lbl = tk.Label(self, text="this is the main frame")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
try:
import tkinter as tk
except ImportError:
import Tkinter as tk
from PIL import Image, ImageTk
from itertools import count, cycle
"""
An example of how to show one tkinter window after another.
This program will show a password entry dialog. If the ppassword is correct,
it will close the dialog and open the main body of the program.
"""
import tkinter as tk
class MainApp(tk.Tk):
import tkinter as tk
class menu:
def __init__(self):
self.game = tk.Tk()
self.game.geometry('200x200')
self.var = tk.StringVar()
#~ self.var = tk.StringVar(master=self.game) # this solves the problem
ent = tk.OptionMenu(self.game, self.var, 'one', 'two', 'three', 'four')
#!/usr/bin/env python
#
# unit.py
#
# Copyright September 2015
#
# Documentation is like sex.
# When it's good, it's very good.
# When it's bad, it's better than nothing.
# When it lies to you, it may be a while before you realize something's wrong.
@novel-yet-trivial
novel-yet-trivial / multicolumnlistbox.py
Last active July 28, 2020 04:51
A multicolumn Listbox made by packing normal listboxes together with a common scrollbar.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
from itertools import cycle
@novel-yet-trivial
novel-yet-trivial / VerticalScrolledFrame.py
Last active April 15, 2024 18:15
A vertical scrolled frame for python tkinter that behaves like a normal Frame. Tested with python 2 and 3, windows and linux.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
try:
import tkinter as tk
except ImportError:
import Tkinter as tk
class VerticalScrolledFrame:
"""