Skip to content

Commit

Permalink
version 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisal-D committed Jan 2, 2025
1 parent 0ef2da8 commit 7c2d090
Show file tree
Hide file tree
Showing 8 changed files with 652 additions and 37 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

[![Downloads](https://static.pepy.tech/badge/ctkchart)](https://pepy.tech/project/ctkchart) [![Downloads](https://static.pepy.tech/badge/ctkchart/month)](https://pepy.tech/project/ctkchart) [![Downloads](https://static.pepy.tech/badge/ctkchart/week)](https://pepy.tech/project/ctkchart)

<img src="https://drive.google.com/thumbnail?id=1rMILz6ODw-1UY4YhlYAFiRCFUluNcVpI&sz=w180">
<img src="https://drive.google.com/thumbnail?id=1jOltT5qBvLmKAdSU6zb9wjh3GYa6jRvD&sz=w180">

</div>

Expand Down Expand Up @@ -151,7 +151,7 @@ linechart = ctkchart.CTkLineChart()
| hide | hide a specific line | line: ``ctkchart.CTkLine``<br> state: ``bool`` |
| reset | reset line chart | - |
| cget | Get the value of the specified parameter. | attribute_name: ``str`` \| "\_\_all\_\_" |
|apply_line_changes | Applying changes made to a Line objects. | -
</div>
Expand Down Expand Up @@ -192,7 +192,7 @@ line = ctkchart.CTkLine()
|-------------------|----------------------------------------------------|------------------------------------------|
| configure | Change LineChart attributes | All attributes except for master |
| cget | Get the value of the specified parameter. | attribute_name: ``str`` \| "\_\_all\_\_" |
| reset | reset line object | - |
</div>
<br>
<br>
Expand Down
21 changes: 10 additions & 11 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[![Downloads](https://static.pepy.tech/badge/ctkchart)](https://pepy.tech/project/ctkchart) [![Downloads](https://static.pepy.tech/badge/ctkchart/month)](https://pepy.tech/project/ctkchart) [![Downloads](https://static.pepy.tech/badge/ctkchart/week)](https://pepy.tech/project/ctkchart)


<img src="https://drive.google.com/thumbnail?id=1rMILz6ODw-1UY4YhlYAFiRCFUluNcVpI&sz=w180">
<img src="https://drive.google.com/thumbnail?id=1jOltT5qBvLmKAdSU6zb9wjh3GYa6jRvD&sz=w180">

</div>

Expand Down Expand Up @@ -143,13 +143,12 @@ linechart = ctkchart.CTkLineChart()
| pack_forget | Pack 忘记折线图 | - |
| grid_forget | Grid 忘记折线图 | - |
| place_back | Place 忘记位置后重新显示旧位置的折线图 |
| pack_back | Pack 忘记位置后重新显示旧位置的折线图 | - |
| grid_back | Grid 忘记位置后重新显示旧位置的折线图 | - |
| pack_back | Pack 忘记位置后重新显示旧位置的折线图 | - |
| grid_back | Grid 忘记位置后重新显示旧位置的折线图 | - |
| hide_all | 隐藏所有折线 | state: ``bool`` |
| hide | 隐藏特定折线 | line: ``ctkchart.CTkLine``<br> state: ``bool`` |
| hide | 隐藏特定折线 | line: ``ctkchart.CTkLine``<br> state: ``bool`` |
| reset | 重置折线图 | - |
| cget | 获取指定参数的值。 | attribute_name: ``str`` \| "\_\_全部\_\_" |
| apply_line_changes | 应用对 Line 对象所做的更改。 | - |
| cget | 获取指定参数的值。 | attribute_name: ``str`` \| "\_\_all\_\_" |
</div>
Expand Down Expand Up @@ -185,11 +184,11 @@ line = ctkchart.CTkLine()
## 方法
| 方法 | 描述 | 支持的参数 |
| --------- | ---------------- | ---------------------------------------- |
| configure | 更改折线图属性 | 所有属性,除了 master |
| cget | 获取指定参数的值 | attribute_name: ``str`` \| "\_\_all\_\_" |
| 方法 | 描述 | 支持的参数 |
| --------- | ----------------|----------------------------------------|
| configure | 更改折线图属性 | 所有属性,除了 master |
| cget | 获取指定参数的值 | attribute_name: ``str`` \| "\_\_all\_\_" |
|reset | 重置线对象 | - |
</div>
<br>
<br>
Expand Down
36 changes: 32 additions & 4 deletions Tests/Main - Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def line_configure(**kwrgs):
row += 1
ctk.CTkFrame(master=frame ,height=2, width=1000, fg_color=("#EEEEEE", "#202020")).grid(row=row, columnspan=9)
row += 1
ctk.CTkLabel(text_color=("black", "white"), master=frame, text="Line Width : ").grid(row=row, column=1)
ctk.CTkButton(master=frame, text="{}".format("Auto"), width=90, height=30, command=lambda : line_chart_configure(line_width="auto")).grid(row=row, column=2, padx=10, pady=2)
ctk.CTkLabel(text_color=("black", "white"), master=frame, text="x axis point spacing : ").grid(row=row, column=1)
ctk.CTkButton(master=frame, text="{}".format("Auto"), width=90, height=30, command=lambda : line_chart_configure(x_axis_point_spacing="auto")).grid(row=row, column=2, padx=10, pady=2)
column = 3
for line_width in range(10, 40, 5):
ctk.CTkButton(master=frame, text="{}".format(line_width), width=90, height=30, command=lambda line_width_=line_width: line_chart_configure(line_width=line_width_)).grid(row=row, column=column, padx=10, pady=2)
for x_axis_point_spacing in range(10, 40, 5):
ctk.CTkButton(master=frame, text="{}".format(x_axis_point_spacing), width=90, height=30, command=lambda x_axis_point_spacing_=x_axis_point_spacing: line_chart_configure(x_axis_point_spacing=x_axis_point_spacing_)).grid(row=row, column=column, padx=10, pady=2)
column += 1

row += 1
Expand Down Expand Up @@ -546,5 +546,33 @@ def line_configure(**kwrgs):
ctk.CTkButton(master=frame, text="{}".format("#00FFFF"), width=90, height=30, command=lambda:line_configure(point_highlight_color="#00FFFF")).grid(row=row, column=column, padx=10, pady=2)


row += 1
ctk.CTkFrame(master=frame ,height=2, width=1000, fg_color=("#EEEEEE", "#202020")).grid(row=row, columnspan=9)
row += 1
ctk.CTkLabel(text_color=("black", "white"), master=frame, text="Fill : ").grid(row=row, column=1)
column = 2
ctk.CTkButton(master=frame, text="{}".format("enabled"), width=90, height=30, command=lambda:line_configure(fill="enabled")).grid(row=row, column=column, padx=10, pady=2)
column += 1
ctk.CTkButton(master=frame, text="{}".format("disabled"), width=90, height=30, command=lambda:line_configure(fill="disabled")).grid(row=row, column=column, padx=10, pady=2)
column += 1



row += 1
ctk.CTkFrame(master=frame ,height=2, width=1000, fg_color=("#EEEEEE", "#202020")).grid(row=row, columnspan=9)
row += 1
ctk.CTkLabel(text_color=("black", "white"), master=frame, text="Point Hightlight Color : ").grid(row=row, column=1)
column = 2
ctk.CTkButton(master=frame, text="{}".format("#FF0000"), width=90, height=30, command=lambda:line_configure(fill_color="#FF0000")).grid(row=row, column=column, padx=10, pady=2)
column += 1
ctk.CTkButton(master=frame, text="{}".format("00FF00"), width=90, height=30, command=lambda:line_configure(fill_color="#00FF00")).grid(row=row, column=column, padx=10, pady=2)
column += 1
ctk.CTkButton(master=frame, text="{}".format("#0000FF"), width=90, height=30, command=lambda:line_configure(fill_color="#0000FF")).grid(row=row, column=column, padx=10, pady=2)
column += 1
ctk.CTkButton(master=frame, text="{}".format("#FF00FF"), width=90, height=30, command=lambda:line_configure(fill_color="#FF00FF")).grid(row=row, column=column, padx=10, pady=2)
column += 1
ctk.CTkButton(master=frame, text="{}".format("#00FFFF"), width=90, height=30, command=lambda:line_configure(fill_color="#00FFFF")).grid(row=row, column=column, padx=10, pady=2)



root.mainloop()
71 changes: 69 additions & 2 deletions src/ctkchart/CTkLine.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ def __init__(self,
fill_color: Union[Tuple[str, str], str] = ("#bdc6ed", "#5d6db6"),
*args: any
) -> None:
"""
Initialize a CTkLine object.
Args:
master (any): The master object.
color (Union[Tuple[str, str], str]): The color of the line.
size (int): The size/thickness of the line.
style (str): The style of the line (e.g., 'normal', 'dashed', 'dotted').
style_type (Tuple[int, int]): The style type for dashed or dotted lines.
point_highlight (str): Whether point highlighting is enabled or disabled.
point_highlight_size (int): The size of points used for highlighting.
point_highlight_color (Union[Tuple[str, str], str]): The color of points used for highlighting.
fill (str): Whether fill for the line is enabled or disabled.
fill_color (Union[Tuple[str, str], str]): The color of the fill for the line.
"""

if master == None:
if len(args) != 0:
Expand Down Expand Up @@ -64,51 +79,101 @@ def configure(self,
fill: str = None,
fill_color: Union[Tuple[str, str], str] = None,
) -> None:
"""
Configure attributes of the CTkLine object.
Args:
color (Union[Tuple[str, str], str]): The color of the line.
size (int): The size/thickness of the line.
style (str): The style of the line (e.g., 'normal', 'dashed', 'dotted').
style_type (Tuple[int, int]): The style type for dashed or dotted lines.
point_highlight (str): Whether point highlighting is enabled or disabled.
point_highlight_size (int): The size of points used for highlighting.
point_highlight_color (Union[Tuple[str, str], str]): The color of points used for highlighting.
fill (str): Whether fill for the line is enabled or disabled.
fill_color (Union[Tuple[str, str], str]): The color of the fill for the line.
"""

changes_req = False

if color != None:
Validate._isValidColor(color, "color")
self.__color = color
changes_req = True

if size != None:
Validate._isInt(size, "size")
self.__size = size
changes_req = True

if style != None:
Validate._isValidLineStyle(style, "style")
self.__style = style
changes_req = True

if style_type != None:
Validate._isValidStyleType(style_type, "style_type")
self.__style_type = style_type
changes_req = True

if point_highlight != None:
Validate._isValidLineHighlight(point_highlight, "point_highlight")
self.__point_highlight = point_highlight
changes_req = True

if point_highlight_size != None:
Validate._isInt(point_highlight_size, "point_highlight_size")
self.__point_highlight_size = point_highlight_size

changes_req = True

if point_highlight_color != None:
Validate._isValidColor(point_highlight_color, "point_highlight_color")
self.__point_highlight_color = point_highlight_color
changes_req = True

if fill != None:
Validate._isValidLineFill(fill, "fill")
self.__fill = fill
changes_req = True

if fill_color != None:
Validate._isValidColor(fill_color, "fill_color")
self.__fill_color = fill_color
changes_req = True

if changes_req:
self.__master._CTkLineChart__apply_line_configuration()


def __reset(self) -> None:
"""
Reset the CTkLine object.
"""

self.__y_end = 0
self.__x_end = self.__master._CTkLineChart__x_axis_point_spacing* -1
self.__data = []


def reset(self) -> None:
"""
Reset the line.
"""
self.__reset()
self.__master._CTkLineChart__call_reshow_data()


def cget(self, attribute_name: str) -> any:
"""
Get the value of a CTkLine attribute.
Args:
attribute_name (str): Name of the attribute.
Returns:
any: Value of the attribute.
"""

if attribute_name == "master": return self.__master
if attribute_name == "color": return self.__color
if attribute_name == "size": return self.__size
Expand All @@ -132,4 +197,6 @@ def cget(self, attribute_name: str) -> any:
"point_highlight_color" : self.__point_highlight_color,
"fill" : self.__fill,
"fill_color" : self.__fill_color
}
}

Validate._invalidCget(attribute_name)
Loading

0 comments on commit 7c2d090

Please sign in to comment.