Skip to content

Commit

Permalink
v5.6.0a2
Browse files Browse the repository at this point in the history
  • Loading branch information
latte72r committed Feb 3, 2021
1 parent 0841c43 commit 4d9cc62
Showing 1 changed file with 62 additions and 21 deletions.
83 changes: 62 additions & 21 deletions easy_turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def UPDATE_CONFIG():
"ask_save_new": True,
"user_document": True,
"auto_update": True}

CONFIG = DEFAULT_CONFIG
UPDATE_CONFIG()

Expand Down Expand Up @@ -109,8 +109,6 @@ def UPDATE_CONFIG():

# システムがLinuxの場合
elif SYSTEM == "Linux":
import subprocess
import getpass

FONT_TYPE1 = "FreeMono"
FONT_TYPE2 = "FreeSerif"
Expand All @@ -136,7 +134,7 @@ def UPDATE_CONFIG():
UPDATE_CONFIG()

if CONFIG["user_document"] is True:
user = getpass.getuser()
user = os.environ['USER']
if os.path.exists(os.path.join("/home/", user, "/ドキュメント/")) is True:
DOCUMENTS = os.path.join("/home/", user, "/ドキュメント/EasyTurtle/")
else:
Expand Down Expand Up @@ -164,12 +162,14 @@ def UPDATE_CONFIG():
messagebox.showerror("エラー", f"{SYSTEM}には対応していません。")


def EXPAND(num): return int(round(num * WIN_MAG))
def EXPAND(num):
"""画面を拡大"""
return int(round(num * WIN_MAG))


FONT = (FONT_TYPE1, EXPAND(12), "bold")

__version__ = (5, 6, "0a1")
__version__ = (5, 6, "0a2")


class EasyTurtle:
Expand Down Expand Up @@ -375,7 +375,7 @@ def back_up(self):

# 前回と違ければ追加
elif self.without_check(self.backed_up[-1]["body"]) != \
self.without_check(data["body"]):
self.without_check(data["body"]):
self.backed_up.append(data)

def undo_change(self, event=None):
Expand All @@ -389,24 +389,24 @@ def undo_change(self, event=None):

# バックアップがあり、変更されているとき
if (len(self.backed_up) > 0) and \
(self.without_check(self.backed_up[-1]["body"]) != \
self.without_check(data["body"])):
(self.without_check(self.backed_up[-1]["body"]) !=
self.without_check(data["body"])):
self.canceled_changes.append(data)
self.set_data(self.backed_up[-1])
self.backed_up = self.backed_up[:-1]

# バックアップが2つ以上あり、変更されているとき
elif (len(self.backed_up) > 1) and \
(self.without_check(self.backed_up[-2]["body"]) != \
(self.without_check(self.backed_up[-2]["body"]) !=
self.without_check(data["body"])):
self.canceled_changes.append(data)
self.set_data(self.backed_up[-2])
self.backed_up = self.backed_up[:-2]

# それ以外ならエラー音
else:
self.root.bell()
return 1
self.root.bell()
return 1

self.all_redraw()

Expand All @@ -421,14 +421,14 @@ def redo_change(self, event=None):

# キャンセルがあり、変更されているとき
if (len(self.canceled_changes) > 0) and \
(self.without_check(self.canceled_changes[-1]["body"]) != \
self.without_check(data["body"])):
(self.without_check(self.canceled_changes[-1]["body"]) !=
self.without_check(data["body"])):
self.set_data(self.canceled_changes[-1])
self.canceled_changes = self.canceled_changes[:-1]
# それ以外ならエラー音
else:
self.root.bell()
return 1
self.root.bell()
return 1

self.all_redraw()

Expand Down Expand Up @@ -779,7 +779,8 @@ def open_program(self, file=None):

# バックアップデータを設定
self.backed_up = data["backedup"] if "backedup" in data else []
self.canceled_changes = data["canceled"] if "canceled" in data else []
self.canceled_changes = data["canceled"] if "canceled" in data else [
]

# 追加位置を設定
addmode = data["addmode"] if "addmode" in data else 2
Expand Down Expand Up @@ -994,7 +995,7 @@ def check_update(self, event=None):
else:
self.ask_update_page(new_version)
except TypeError:
messagebox.showerror("エラー", "\
messagebox.showerror("エラー", "\
正規リリースでないため確認できません。")

def ask_update_msi(self, new_version, start=False):
Expand Down Expand Up @@ -1423,8 +1424,6 @@ def draw_cv(self):
EXPAND(42), EXPAND(HEIGHT), width=EXPAND(2))

# ウィジェットの説明を表示
self.bln1 = tk.BooleanVar()
self.bln1.set(self.check)
lab1 = tk.Label(self.cv, text=self.info, font=FONT, bg=self.background)
self.binder(lab1)
lab1.place(x=EXPAND(50), y=EXPAND(10))
Expand All @@ -1437,11 +1436,53 @@ def draw_cv(self):
self.lab4.place(x=EXPAND(5), y=EXPAND(HEIGHT//2-8))

# チェックボックスを表示
self.bln1 = tk.BooleanVar()
self.bln1.set(self.check)
chk1 = tk.Checkbutton(self.cv, variable=self.bln1,
cursor="hand2", bg=self.background,
font=(FONT_TYPE2, EXPAND(10)))
chk1.place(x=EXPAND(12), y=EXPAND(HEIGHT//2+8))
self.binder(chk1)
chk1.bind("<Shift-Button-1>", self.shift_check)
chk1.place(x=EXPAND(12), y=EXPAND(HEIGHT//2+8))

def shift_check(self, event):
"""Shift+右クリック"""
selected = self.p.get_selected()
sindex = self.p.widgets.index(self)
if len(selected) == 0:
return
elif len(selected) == 1:
dindex = self.p.widgets.index(selected[0])
if sindex < dindex:
self.range_check(sindex, dindex, exc=sindex)
else:
self.range_check(dindex, sindex, exc=sindex)
else:
lindex = None
for new in selected:
nindex = self.p.widgets.index(new)
if lindex is None:
if sindex < nindex:
self.range_check(sindex, nindex, exc=sindex)
return
elif lindex < sindex < nindex:
if (sindex - lindex) < (nindex - sindex):
self.range_check(lindex, sindex, exc=sindex)
else:
self.range_check(sindex, nindex, exc=sindex)
return
lindex = nindex
if sindex > lindex:
self.range_check(lindex, sindex, exc=sindex)

def range_check(self, first, last, exc=None):
"""指定範囲をチェック"""
for widget in self.p.widgets:
widget.bln1.set(False)
for widget in self.p.widgets[first: last + 1]:
widget.bln1.set(True)
if exc is not None:
self.p.widgets[exc].bln1.set(False)

def check_enabled(self):
"""有効・無効の表示"""
Expand Down

0 comments on commit 4d9cc62

Please sign in to comment.