Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_tickscale_init(self):
TickScale(self.window, orient='vertical', style='my.Vertical.TScale',
tickinterval=0.2, from_=-1, to=1, showvalue=True,
digits=2, length=400, cursor='watch').pack()
self.window.update()
TickScale(self.window, orient='horizontal', from_=0, to=10,
tickinterval=0, tickpos='n', labelpos='s',
showvalue=False).pack()
self.window.update()
with self.assertRaises(ValueError):
TickScale(self.window, orient='vertical', tickpos='n')
with self.assertRaises(ValueError):
TickScale(self.window, orient='horizontal', tickpos='e')
with self.assertRaises(ValueError):
TickScale(self.window, labelpos='ne')
def test_tickscale_init(self):
TickScale(self.window, orient='vertical', style='my.Vertical.TScale',
tickinterval=0.2, from_=-1, to=1, showvalue=True,
digits=2, length=400, cursor='watch').pack()
self.window.update()
TickScale(self.window, orient='horizontal', from_=0, to=10,
tickinterval=0, tickpos='n', labelpos='s',
showvalue=False).pack()
self.window.update()
with self.assertRaises(ValueError):
TickScale(self.window, orient='vertical', tickpos='n')
with self.assertRaises(ValueError):
TickScale(self.window, orient='horizontal', tickpos='e')
with self.assertRaises(ValueError):
TickScale(self.window, labelpos='ne')
def test_tickscale_init(self):
TickScale(self.window, orient='vertical', style='my.Vertical.TScale',
tickinterval=0.2, from_=-1, to=1, showvalue=True,
digits=2, length=400, cursor='watch').pack()
self.window.update()
TickScale(self.window, orient='horizontal', from_=0, to=10,
tickinterval=0, tickpos='n', labelpos='s',
showvalue=False).pack()
self.window.update()
with self.assertRaises(ValueError):
TickScale(self.window, orient='vertical', tickpos='n')
with self.assertRaises(ValueError):
TickScale(self.window, orient='horizontal', tickpos='e')
with self.assertRaises(ValueError):
TickScale(self.window, labelpos='ne')
scale['orient'] = 'vertical'
self.window.update()
scale['tickpos'] = 'e'
self.window.update()
self.assertEqual(scale['tickpos'], 'e')
with self.assertRaises(ValueError):
scale.configure(orient='vertical', tickpos='n')
with self.assertRaises(ValueError):
scale.configure(orient='horizontal', tickpos='e')
with self.assertRaises(ValueError):
TickScale(self.window, labelpos='ne')
scale.configure(style='my.Vertical.TScale')
self.window.update()
scale.style.configure('my.Vertical.TScale', font='TkDefaultFont 20 italic',
sliderlength=50)
scale.x = 0
def cmd(value):
scale.x = 2 * float(value)
scale.configure(command=cmd)
self.window.update()
scale.configure(digits=1)
scale.set(10)
self.window.update()
def test_tickscale_methods(self):
scale = TickScale(self.window, from_=0, to=10, orient='horizontal')
scale.pack()
self.window.update()
self.assertEqual(scale.cget('digits'), -1)
self.assertEqual(scale['tickinterval'], 0)
self.assertEqual(scale['resolution'], 0)
self.assertTrue(scale.cget('showvalue'))
self.assertEqual(scale['from'], 0)
self.assertEqual(scale.cget('to'), 10)
keys = ttk.Scale(self.window).keys() + ['showvalue', 'tickinterval', 'digits']
self.assertEqual(sorted(scale.keys()), sorted(keys))
scale.config(from_=-1)
self.window.update()
self.assertEqual(scale['from'], -1)
tickinterval=0.2, from_=-1, to=1, showvalue=True,
digits=2, length=400, cursor='watch').pack()
self.window.update()
TickScale(self.window, orient='horizontal', from_=0, to=10,
tickinterval=0, tickpos='n', labelpos='s',
showvalue=False).pack()
self.window.update()
with self.assertRaises(ValueError):
TickScale(self.window, orient='vertical', tickpos='n')
with self.assertRaises(ValueError):
TickScale(self.window, orient='horizontal', tickpos='e')
with self.assertRaises(ValueError):
TickScale(self.window, labelpos='ne')
root = tk.Tk()
style = ttk.Style(root)
style.theme_use('clam')
style.configure('my.Vertical.TScale', sliderlength=50, background='white',
foreground='red')
style.configure('my.Horizontal.TScale', sliderlength=10,
font='TkDefaultFont 20 italic')
s1 = TickScale(root, orient='vertical', style='my.Vertical.TScale',
tickinterval=0.2, from_=-1, to=1, showvalue=True, digits=2,
length=400, labelpos='e')
s2 = TickScale(root, orient='horizontal', style='my.Horizontal.TScale',
from_=0, to=10, tickinterval=2, resolution=1,
showvalue=True, length=400)
s3 = TickScale(root, orient='horizontal', from_=0.25, to=1, tickinterval=0.1,
resolution=0.1)
s1.pack(fill='y')
s2.pack(fill='x')
s3.pack(fill='x')
root.mainloop()
# Copyright (c) Juliette Monsel 2017
# For license see LICENSE
from ttkwidgets import TickScale
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
style = ttk.Style(root)
style.theme_use('clam')
style.configure('my.Vertical.TScale', sliderlength=50, background='white',
foreground='red')
style.configure('my.Horizontal.TScale', sliderlength=10,
font='TkDefaultFont 20 italic')
s1 = TickScale(root, orient='vertical', style='my.Vertical.TScale',
tickinterval=0.2, from_=-1, to=1, showvalue=True, digits=2,
length=400, labelpos='e')
s2 = TickScale(root, orient='horizontal', style='my.Horizontal.TScale',
from_=0, to=10, tickinterval=2, resolution=1,
showvalue=True, length=400)
s3 = TickScale(root, orient='horizontal', from_=0.25, to=1, tickinterval=0.1,
resolution=0.1)
s1.pack(fill='y')
s2.pack(fill='x')
s3.pack(fill='x')
root.mainloop()
from ttkwidgets import TickScale
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
style = ttk.Style(root)
style.theme_use('clam')
style.configure('my.Vertical.TScale', sliderlength=50, background='white',
foreground='red')
style.configure('my.Horizontal.TScale', sliderlength=10,
font='TkDefaultFont 20 italic')
s1 = TickScale(root, orient='vertical', style='my.Vertical.TScale',
tickinterval=0.2, from_=-1, to=1, showvalue=True, digits=2,
length=400, labelpos='e')
s2 = TickScale(root, orient='horizontal', style='my.Horizontal.TScale',
from_=0, to=10, tickinterval=2, resolution=1,
showvalue=True, length=400)
s3 = TickScale(root, orient='horizontal', from_=0.25, to=1, tickinterval=0.1,
resolution=0.1)
s1.pack(fill='y')
s2.pack(fill='x')
s3.pack(fill='x')
root.mainloop()