Create Line Charts in tkinter Guis...!
Project description
tkchart - 1.0.5
you need to import package first
import tkchart
Mainly there are 2 objects.
- LineChart
- Line
To display data using LineChart you need to do 3 main tasks
- Create LineChart
- Create Line
- Display data
1 . Create LineChart
Create a LineChart
linechart = tkchart.LineChart()
-
Attributes & Types
master
: tkinter.widget (Frame, Canvas, Tk)
width
: int
height
: int
bar_size
: inty_sections_count
: int
x_sections_count
: int
y_labels_count
: int
x_labels_count
: inty_data
: str ,int, float
x_data
: str ,int, float
y_data_max
: int ,float
x_data_min_max
: touple(min ,max)
y_values_decimals
: int
x_values_decimals
: intsections_color
: str
y_values_color
: str
x_values_color
: str
y_data_text_color
: str
x_data_text_color
: str
bg_color
: str
chart_color
: str
bar_color
: strx_y_data_font
: tuple
x_y_values_font
: tuple
line_width_auto
: bool
line_width
: int -
Methods
1. configure
: use to change LineChart attributessupport **kwargs
width height bar_size y_sections_count x_sections_count y_labels_count x_labels_count y_data x_data y_data_max x_data_min_max y_values_decimals x_values_decimals sections_color y_values_color x_values_color y_data_text_color x_data_text_color bg_color chart_color bar_color x_y_data_font x_y_values_font line_width_auto line_width
2. show_data
: use to display data.support **kwargs
data line
3. place
: use to place same as tkinter place method..!support **kwargs
x y rely relx anchor
4. pack
: use to pack. same as tkinter pack method..!support **kwargs
pady padx before after side ipadx ipady ancho
5. grid
: use to grid. same as tkinter grid method..!support **kwargs
column columnspan ipadx ipady padx pady row rowspan sticky
6. place_forget
: use to place forget the chart7. pack_forget
: use to pack forget the chart8. grid_forget
: use to grid forget the chart9. place_back
: use to place chart in the old location after place forget10. pack_back
: use to pack chart in the old location after pack forget11. grid_back
: use to grid chart in the old location after grid forget12. hide_all
: use to hide all the linessupport **kwargs
state: Bool
13. hide
: use hide a specific linesupport **kwargs
line: tkchart.Line state: bool
linechart = tkchart.LineChart(master=root,
width=1000,
height=600,
bar_size=5
)
linechart = tkchart.LineChart(master=root,
width=1000,
height=600,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5
)
linechart = tkchart.LineChart(master=root, width=1000,
height=600,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5,
)
linechart = tkchart.LineChart(master=root, width=1000,
height=600,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5,
sections_color="#ffffff",
y_values_color="#ffffff",
x_values_color="#ffffff",
x_data_text_color="#00ffff",
y_data_text_color="#ff00ff",
bg_color="#202020",
chart_color="#101010",
bar_color="#909090"
)
linechart = tkchart.LineChart(master=root,
width=1000,
height=600,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5,
sections_color="#505050",
y_values_color="#bbbbbb",
x_values_color="#bbbbbb",
x_data_color="#00ffff",
y_data_color="#ff00ff",
bg_color="#202020",
chart_color="#101010",
bar_color="#cccccc",
x_y_data_font = ("Arial", 15,"bold"),
x_y_values_font = ("Arial", 10,"bold")
)
1 . Create Line
Create a Line
line = tkchart.Line()
-
Attributes & Types
master
: tkchart.LineChart
color
: str
size
: int -
Methods
1. configure
: use to change Line attributessize color
line = tkchart.Line(master=linechart,
color="#ffff00",
size=5)
line_width
is not a attributes of Line. Its a attribute of LineChart object..!
1 . Display Data
import tkinter
import tkchart
import random #for get random value
#create root
root = tkinter.Tk()
root.minsize(1200,800)
#create LineChart
linechart = tkchart.LineChart(master=root,
width=1000,
height=400,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5,
sections_color="#707070",
y_values_color="#bbbbbb",
x_values_color="#bbbbbb",
x_data_color="#00ff00",
y_data_color="#00ff00",
bg_color="#202020",
chart_color="#101010",
bar_color="#cccccc",
x_y_data_font = ("Arial", 15,"bold"),
x_y_values_font = ("Arial", 10,"bold"),
)
#place LineChart
linechart.place(x=50 ,y=150)
#Create Line
line = tkchart.Line(master=linechart,
color="#cccccc",
size=3)
displayed = 0
max_support = 50 #60-50
data = [0,100,200,300,400,500,600,700,800,900,1000]
start = (20,60)
def loop():
global displayed
global start
linechart.show_data(data=[random.choice(data)], line=line)
displayed+=1
if displayed>40:
start = (start[0]+1,start[1]+1)
linechart.configure(x_data_min_max=((start[0],start[1])))
root.after(250,loop)
#calling to loop
loop()
root.mainloop()
output
click to play
For more details
Github.com : tkchart
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.