From 3557ef650278f839accbc94ebebe18e65726a6c0 Mon Sep 17 00:00:00 2001 From: KeithLin7024 Date: Wed, 31 Aug 2022 11:45:54 +0800 Subject: [PATCH] add inv mode --- src/Func.py | 49 +++++++++++++++++++++------- src/__pycache__/Func.cpython-39.pyc | Bin 6194 -> 7354 bytes src/__pycache__/ui.cpython-39.pyc | Bin 4448 -> 4503 bytes src/ui.py | 5 +++ 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/Func.py b/src/Func.py index cc69144..009f655 100644 --- a/src/Func.py +++ b/src/Func.py @@ -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): @@ -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() @@ -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 @@ -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) @@ -100,9 +107,11 @@ 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 = [ @@ -110,9 +119,7 @@ def __refresh(self) -> None: 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') @@ -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 diff --git a/src/__pycache__/Func.cpython-39.pyc b/src/__pycache__/Func.cpython-39.pyc index 8b346d9c767f6643901a908ea4846bd40cde57b1..a13c7090a7844588db8abf1485e4fb8d8ffb592b 100644 GIT binary patch delta 2783 zcmai0Ym6J!6~6b*j6ELPm4Sp(gd!4MfrJ8*R|up4L8x0$ThS;|CDb4MsH* zsUF?WGv}Uj?me%2?r&!Pu+z-N;|76W-`~yrt&ywd$1Fsze(~*yeXl)niDU=uE%qe* zCtoEh$qp@$bb94;I!x(J@fUW(XprJyF$9$JxFe^l3G$dxj^V_b| zOqylG=L!|Odd|)27AV7O?uM?6^UB8|aVAbcl~(#%&15DWEGwOUG3 zpPpZ9pgvd1l~38ZJ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Fpqo6BFn3bVDnbi#y)@uO5O4z9avju7)dLG z*i~k$7@;ph8>@uY8Rk+cm#rZ?`ogu0J69}b#eBw;4~?SyCfwhVN*ZDqxA)atX{PKe zxsvCrQ{{3&49dU4oo9T_^|GFmw*9rB8^XLGJ6_Q@X` z`e6KSCqIM+#Dhgf0wM|?G3&Xs(nn4R?%JhvFaU@?f`>$#Ha2yd%Kv~1J}P0N*Nf9C}>xVsP-Slj{? zS>vEq4X~c_s;bGy(IHbsuR?LRrD2_%wDq?Xarru%0Xt-C9~z5r3dds!Y@>oY*2_P} zdh-xe%&Fqqcb?nf|I};-H8)_*5xHp%G!U=i6v1iv7@Fm+*nmDkpHVp!+Xp#085`tc zf8hHkc4V0vnFR4Hg`6j-PknGpVrVO%xO9A-^QsS~cnS4%NH{aXaj&M5k+fN!^DfMJ zmv9=yade6}!OH}%5Cl99kQQw8Drx5kUa!pzs!1gnP+!5JNt@W3*+O>yBK9Dd)8JHe zpfuj)t&OkXXN`2VkvH-PSXHi=c#-*2T{C&(X5Wqh7^QLjJKXI$1!vlG>{K#T?_tnd zL6a_a640cGBLv;@MpG{=$gi3zP#)JNJ(k=lRTPx1T6LPjC0{7)o%i7`n`A&ns}nvJ@d*^i;7eIGk(ZZ?0SM|2@h0Dw-N?6{ov~!{G4^7%6wY7j 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: