Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tkinter slider

from tkinter import *
slider= Scale(root, from_=0, to=100)
slider.pack()
Comment

slider in tkinter figure

import random
import matplotlib
import tkinter as Tk
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

matplotlib.use('TkAgg')

root = Tk.Tk()
root.wm_title("Embedding in TK")
fig = plt.Figure()
canvas = FigureCanvasTkAgg(fig, root)
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

ax=fig.add_subplot(111)
fig.subplots_adjust(bottom=0.25)

y_values = [random.randrange(20, 40, 1) for _ in range(40)]
x_values = [i for i in range(40)]

ax.axis([0, 9, 20, 40])
ax.plot(x_values, y_values)

ax_time = fig.add_axes([0.12, 0.1, 0.78, 0.03])
s_time = Slider(ax_time, 'Time', 0, 30, valinit=0)


def update(val):
    pos = s_time.val
    ax.axis([pos, pos+10, 20, 40])
    fig.canvas.draw_idle()
s_time.on_changed(update)

Tk.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: remove keys from dict python 
Python :: pandas remove outliers for multiple columns 
Python :: python get last element of list 
Python :: python dict append value 
Python :: set value based on column 
Python :: login_required on class django 
Python :: python append to 2d array 
Python :: day name in python 
Python :: count number of spaces in string python 
Python :: how to update requirements.txt python 
Python :: find max length in string in pandas dataframe 
Python :: dataframe to dictionary 
Python :: append many items to list python 
Python :: pandas divide one column by another 
Python :: raise exception in python 
Python :: how to convert utf-16 file to utf-8 in python 
Python :: /bin/sh: 1: python: not found 
Python :: python code to generate fibonacci series 
Python :: list of seaborn color palette 
Python :: data series to datetime 
Python :: Select rows in pandas MultiIndex DataFrame 
Python :: how to make an ai 
Python :: sort a list of array python 
Python :: when button is clicked tkinter python 
Python :: python check if array is subset of another 
Python :: how to remove items from list in python 
Python :: python from float to decimal 
Python :: pandas add quantile columns 
Python :: max of three numbers in python 
Python :: Randint Random Library 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =