Skip to content

Commit

Permalink
add inv mode
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithLin724 committed Aug 31, 2022
1 parent e19744d commit 3557ef6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
49 changes: 38 additions & 11 deletions src/Func.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __link(self) -> None:
self.changeModeBnt.configure(command=self.__changeModeFunc)
self.clearInputBnt.configure(command=self.__clearInputFunc)
self.addInputBnt.configure(command=self.__addInputFunc)
self.invBnt.configure(command=self.__invModeFunc)
return

def __init__(self):
Expand All @@ -36,6 +37,7 @@ def __init__(self):
self.__showState = False
self.__poseMode = False # False -> True <-
self.__addInputStr = ('', '')
self.__invMode = False # True inv Mode

logging.basicConfig(level=logging.DEBUG, format=Func.DISPLAY_FORMAT)
self.__link()
Expand All @@ -51,14 +53,17 @@ def __addNumberFunc(self, numberID: int) -> None:
Args:
numberID (int): _description_
"""
invBit = lambda x: int(not bool(x))

logging.info(f"on click {numberID}")
self.__hexCodeBuilder[numberID - 1] = int(\
not bool(self.__hexCodeBuilder[numberID - 1]))

self.__hexCodeBuilder[numberID - 1] = invBit(
self.__hexCodeBuilder[numberID - 1])

self.__refreshPreView()

logging.info(
f"now Build is {self.__hexCodeBuilder } state:{self.segmentBntDict[numberID].state()}"
f"now Build is {self.__hexCodeBuilder } state:{self.segmentBntDict[numberID].instate(['selected'])}"
)
return

Expand All @@ -81,10 +86,12 @@ def __refreshPreView(self) -> None:
self.preViewText.configure(state='normal')

self.preViewText.delete(1.0, END)

tmpInvStr = self.__hexCodeBuilder if not self.__invMode \
else Func.__invList(self.__hexCodeBuilder)

tmpStr = ''.join(
map(
str, self.__hexCodeBuilder
if not self.__poseMode else self.__hexCodeBuilder[::-1]))
map(str, tmpInvStr if not self.__poseMode else tmpInvStr[::-1]))

self.preViewText.insert(1.0, tmpStr)

Expand All @@ -100,19 +107,19 @@ def __refresh(self) -> None:
self.outPutText.text.configure(state='normal')

self.outPutText.text.delete(1.0, END)
tmpInvDisplay = self.__listDisplayHexCode if not self.__invMode \
else [Func.__invList(elm) for elm in self.__listDisplayHexCode]

tmp = self.__listDisplayHexCode if not self.__poseMode \
else [elm[::-1] for elm in self.__listDisplayHexCode]
tmp = tmpInvDisplay if not self.__poseMode \
else [elm[::-1] for elm in tmpInvDisplay]

if (self.__addInputStr != ('', '')):
tmp = [
f'{self.__addInputStr[0]}{elm}{self.__addInputStr[1]}'
for elm in tmp
]

displayStr = '\n'.join(tmp)
# logging.info(displayStr)
self.outPutText.text.insert(1.0, displayStr)
self.outPutText.text.insert(1.0, index='\n'.join(tmp))

self.outPutText.text.configure(state='disabled')
logging.info('refresh')
Expand Down Expand Up @@ -187,3 +194,23 @@ def __clearInputFunc(self) -> None:

self.clearInputBnt.state(['!selected'])
return

def __invList(lst):

numList = lambda tmp: [int(not elm) for elm in tmp]

if type(lst) is list:

return numList(lst)

if type(lst) is str:

return ''.join(map(str, numList(list(map(int, list(lst))))))

def __invModeFunc(self):

self.__invMode = not self.__invMode
logging.info(f"invMode :{self.__invMode}")
self.__refreshPreView()
self.__refresh()
return
Binary file modified src/__pycache__/Func.cpython-39.pyc
Binary file not shown.
Binary file modified src/__pycache__/ui.cpython-39.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions src/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def __settingSegmentControl(self) -> None:
text=ui.MODE_STR[0],
bootstyle="warning-toolbutton")
self.changeModeBnt.pack()

self.invBnt = Checkbutton(self.__leftFrame,
text='Inverse',
bootstyle='warning-toolbutton')
self.invBnt.pack()
return

def __settingRightFrame(self) -> None:
Expand Down

0 comments on commit 3557ef6

Please sign in to comment.