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_width2. show_data: use to display data.support **kwargs
data line3. place: use to place same as tkinter place method..!support **kwargs
x y rely relx anchor4. pack: use to pack. same as tkinter pack method..!support **kwargs
pady padx before after side ipadx ipady ancho5. grid: use to grid. same as tkinter grid method..!support **kwargs
column columnspan ipadx ipady padx pady row rowspan sticky6. 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: Bool13. 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.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tkchart-1.0.5.tar.gz.
File metadata
- Download URL: tkchart-1.0.5.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11cdd2fbe9859555a24c0bf9b0934ae6e47f2fc7e8e25de220cd2d9359900c9f
|
|
| MD5 |
3d0de397ebfc3dcdaa6270dd531adb5f
|
|
| BLAKE2b-256 |
46081fd004a1cd91c078103ff06722b7072a49738886c4db89139b9bd3658b97
|
File details
Details for the file tkchart-1.0.5-py3-none-any.whl.
File metadata
- Download URL: tkchart-1.0.5-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d3c4e6afbdd12dca9f979d2d03d3a7d912febd0773a74f794c8dcde81c73091
|
|
| MD5 |
34e8493e464ec01745fb2c49d9947bc1
|
|
| BLAKE2b-256 |
51ad94675551cdf02f200312575232b02d20e8ba340ed22e55b7aa27264d64b2
|