diff --git a/Base64.bas b/Base64.bas index 548087a..f7cdd51 100644 --- a/Base64.bas +++ b/Base64.bas @@ -6,24 +6,29 @@ Option Explicit '外部直接调用此函数即可 Public Sub Base64Encode(ByRef pbAInput() As Byte, ByRef sOut As String, Optional ByRef sPrexSpace As String = "", Optional ByRef charsPerLine As Integer = 68) - Dim abOut() As Byte, i As Long, s As String + Dim abOut() As Byte, idx As Long, sBase64 As String + Dim lengthMod As Integer + Dim paddingCount As Integer Encode pbAInput, abOut - ByteArrayToString abOut, s - + ByteArrayToString abOut, sBase64 sOut = "" + If Len(sBase64) = 0 Then Exit Sub - If Len(s) = 0 Then Exit Sub + 'Base64要求长度为4的倍数,如果不够,则添加"=" + lengthMod = Len(sBase64) Mod 4 + paddingCount = 4 - lengthMod + sBase64 = sBase64 & String(paddingCount, "=") '转换为合适的换行模式 If charsPerLine > 0 Then - For i = 1 To Len(s) Step charsPerLine - sOut = sOut & sPrexSpace & Mid(s, i, charsPerLine) & vbCrLf + For idx = 1 To Len(sBase64) Step charsPerLine + sOut = sOut & sPrexSpace & Mid(sBase64, idx, charsPerLine) & vbCrLf Next - sOut = Mid(sOut, 1, Len(sOut) - 3) + sOut = Mid(sOut, 1, Len(sOut) - 3) '去掉上面语句添加的最后的回车换行 Else - sOut = s + sOut = sBase64 End If End Sub diff --git a/Readme.md b/Readme.md index 52f0813..41d90c5 100644 --- a/Readme.md +++ b/Readme.md @@ -211,6 +211,10 @@ Readme of english version refers to [Readme_EN.md](https://github.com/cdhigh/tki # 鐗堟湰鍘嗗彶 +* v1.7.1 + 1. Combobox鐨凜hange浜嬩欢鏄犲皠鍒癟kinter鐨凜omboboxSelected + 2. 澶氳Text鐨凜hange浜嬩欢鏄犲皠鍒癟kinter鐨凪odified + 3. 淇base64缂栫爜鐨勪竴涓皬bug锛屼箣鍓嶇殑鐗堟湰灏嗘湯灏惧~鍏呯殑=鍘绘帀浜嗭紝瀵艰嚧鏈変簺瑙g爜搴撴姤閿 * v1.7 1. 鎻掍欢鍚嶄粠 TkinterDesigner 鏇村悕涓 Vb6Tkinter 2. 澧炲姞鍦ㄧ嚎妫鏌ョ増鏈洿鏂板姛鑳 diff --git a/Vb6Tkinter.vbp b/Vb6Tkinter.vbp index 1686c78..484891e 100644 --- a/Vb6Tkinter.vbp +++ b/Vb6Tkinter.vbp @@ -54,17 +54,17 @@ Startup="(None)" HelpFile="" Title="Vb6Tkinter" ExeName32="Vb6Tkinter.dll" -Path32="Bin" +Path32="Release" Command32="" Name="Vb6Tkinter" HelpContextID="0" Description="VB6 Tkinter Designer" CompatibleMode="2" -CompatibleEXE32="Bin\Vb6Tkinter.dll" +CompatibleEXE32="Release\Vb6Tkinter.dll" VersionCompatible32="1" MajorVer=1 MinorVer=7 -RevisionVer=0 +RevisionVer=1 AutoIncrementVer=0 ServerSupportFiles=0 DllBaseAddress=&H1f390000 diff --git a/Vb6Tkinter.vbw b/Vb6Tkinter.vbw index c7e5553..6ddf60e 100644 --- a/Vb6Tkinter.vbw +++ b/Vb6Tkinter.vbw @@ -1,7 +1,7 @@ GridOcx = 125, 125, 851, 574, C, 175, 175, 1048, 606, C Common = 125, 125, 998, 556, C FileDlg = 150, 150, 981, 581, C -clsBaseControl = 100, 100, 931, 531, C +clsBaseControl = 100, 100, 931, 531, Z clsButton = 75, 75, 906, 506, C clsCanvas = 0, 0, 0, 0, C clsCheckbutton = 0, 0, 0, 0, C @@ -17,16 +17,16 @@ clsSerialization = 0, 0, 0, 0, C clsText = 0, 0, 879, 406, C cStrBuilder = 0, 0, 0, 0, C Dictionary = 0, 0, 0, 0, C -FrmMain = 25, 25, 898, 456, C, 50, 50, 923, 481, C +FrmMain = 25, 25, 898, 456, , 50, 50, 923, 481, C clsMenu = 0, 0, 0, 0, C clsMenuItem = 0, 0, 0, 0, C clsProgressBar = 0, 0, 0, 0, C -clsCombobox = 175, 175, 1054, 581, C -clsComboboxAdapter = 0, 0, 0, 0, C +clsCombobox = 175, 175, 1054, 581, +clsComboboxAdapter = 25, 25, 799, 474, clsTreeview = 200, 200, 1079, 606, C clsNotebook = 50, 50, 929, 456, C -MultiLanguage = 175, 175, 1054, 608, Z -Base64 = 0, 0, 0, 0, C +MultiLanguage = 175, 175, 1054, 608, +Base64 = 100, 100, 874, 549, clsForm = 125, 125, 956, 556, C clsStatusbar = 75, 75, 801, 497, C Resizer = 100, 100, 826, 549, C @@ -35,7 +35,7 @@ xpcmdbutton = 0, 0, 0, 0, C, 0, 0, 873, 431, C clsNotebookTab = 0, 0, 0, 0, C clsSeparator = 0, 0, 0, 0, C Connect = 25, 25, 904, 458, -frmEncodeAFile = 100, 100, 973, 531, C, 25, 25, 898, 456, C +frmEncodeAFile = 100, 100, 973, 531, , 25, 25, 898, 456, C http = 125, 125, 1004, 558, C modJson = 25, 25, 904, 458, C frmNewVer = 100, 100, 979, 533, C, 75, 75, 954, 508, C diff --git a/clsBaseControl.cls b/clsBaseControl.cls index c190668..2840857 100644 --- a/clsBaseControl.cls +++ b/clsBaseControl.cls @@ -44,7 +44,7 @@ End Sub '输出结构化代码 Public Sub toStringStructure(ByRef sOut As cStrBuilder, ByRef sCmdFunc As cStrBuilder, rel As Boolean, usettk As Boolean, Optional sOtherParams As String = "") - Dim s() As String, i As Long, extra As String, sStyle As String + Dim s() As String, I As Long, extra As String, sStyle As String Dim sTmp As String, dTmp As Double, sCmdName As String, sUnderlineCmd As String '如果需要变量绑定,则先创建对应的变量 @@ -186,32 +186,32 @@ Public Sub toStringStructure(ByRef sOut As cStrBuilder, ByRef sCmdFunc As cStrBu sTmp = Replace(sTmp, " ", "") s = Split(sTmp, ",") - For i = 0 To UBound(s) - s(i) = Trim(s(i)) - If s(i) = "" Then '专门处理自定义的这个事件,用控件变量监视器模拟 + For I = 0 To UBound(s) + s(I) = Trim(s(I)) + If s(I) = "" Then '专门处理自定义的这个事件,用控件变量监视器模拟 If (m_Type = "Combobox" Or m_Type = "Entry" Or m_Type = "Label") And (Len(Dic("textvariable")) > 0) Then sCmdName = m_Name & "_Change" sOut.Append Space(4) & Dic("textvariable") & ".trace('w', " & sCmdName & ")" sCmdFunc.Append CreateFuncDef(sCmdName, "*args") End If - ElseIf Left(s(i), 1) = "<" And Right(s(i), 1) = ">" Then + ElseIf Left(s(I), 1) = "<" And Right(s(I), 1) = ">" Then - sCmdName = m_Name & "_" & Replace(Replace(Replace(s(i), "<", ""), ">", ""), "-", "_") + sCmdName = m_Name & "_" & Replace(Replace(Replace(s(I), "<", ""), ">", ""), "-", "_") - sOut.Append Space(4) & m_Name & ".bind('" & s(i) & "', " & sCmdName & ")" + sOut.Append Space(4) & m_Name & ".bind('" & s(I) & "', " & sCmdName & ")" sCmdFunc.Append CreateFuncDef(sCmdName, "event") 'Python是大小写敏感的,对应快捷键也一样,如果设置的快捷键包含字母键,则将对应的大写/小写也一起绑定 - If Right(s(i), 3) >= "-a>" And Right(s(i), 3) <= "-z>" Then + If Right(s(I), 3) >= "-a>" And Right(s(I), 3) <= "-z>" Then - s(i) = Left(s(i), Len(s(i)) - 2) & UCase(Mid(s(i), Len(s(i)) - 1, 1)) & ">" '对应字母变大写 - sOut.Append Space(4) & m_Name & ".bind('" & s(i) & "', " & sCmdName & ")" + s(I) = Left(s(I), Len(s(I)) - 2) & UCase(Mid(s(I), Len(s(I)) - 1, 1)) & ">" '对应字母变大写 + sOut.Append Space(4) & m_Name & ".bind('" & s(I) & "', " & sCmdName & ")" - ElseIf Right(s(i), 3) >= "-A>" And Right(s(i), 3) <= "-Z>" Then + ElseIf Right(s(I), 3) >= "-A>" And Right(s(I), 3) <= "-Z>" Then - s(i) = Left(s(i), Len(s(i)) - 2) & LCase(Mid(s(i), Len(s(i)) - 1, 1)) & ">" '对应字母变小写 - sOut.Append Space(4) & m_Name & ".bind('" & s(i) & "', " & sCmdName & ")" + s(I) = Left(s(I), Len(s(I)) - 2) & LCase(Mid(s(I), Len(s(I)) - 1, 1)) & ">" '对应字母变小写 + sOut.Append Space(4) & m_Name & ".bind('" & s(I) & "', " & sCmdName & ")" End If End If @@ -223,7 +223,7 @@ End Sub '输出面向对象代码 Public Sub toStringOOP(ByRef sOut As cStrBuilder, ByRef sCmdFunc As cStrBuilder, rel As Boolean, usettk As Boolean, Optional sOtherParams As String = "") - Dim s() As String, i As Long, extra As String + Dim s() As String, I As Long, extra As String Dim sTmp As String, sStyle As String, sCmdName As String, sUnderlineCmd As String '如果需要变量绑定,则先创建对应的变量 @@ -353,31 +353,31 @@ Public Sub toStringOOP(ByRef sOut As cStrBuilder, ByRef sCmdFunc As cStrBuilder, sTmp = Replace(sTmp, " ", "") s = Split(sTmp, ",") - For i = 0 To UBound(s) - s(i) = Trim(s(i)) - If s(i) = "" Then '专门处理自定义的这个事件,用控件变量监视器模拟 + For I = 0 To UBound(s) + s(I) = Trim(s(I)) + If s(I) = "" Then '专门处理自定义的这个事件,用控件变量监视器模拟 If (m_Type = "Combobox" Or m_Type = "Entry" Or m_Type = "Label") And (Len(Dic("textvariable")) > 0) Then sCmdName = m_Name & "_Change" sOut.Append Space(8) & "self." & Dic("textvariable") & ".trace('w', self." & sCmdName & ")" sCmdFunc.Append CreateFuncDefOOP(sCmdName, "*args") End If - ElseIf Left(s(i), 1) = "<" And Right(s(i), 1) = ">" Then + ElseIf Left(s(I), 1) = "<" And Right(s(I), 1) = ">" Then - sCmdName = m_Name & "_" & Replace(Replace(Replace(s(i), "<", ""), ">", ""), "-", "_") + sCmdName = m_Name & "_" & Replace(Replace(Replace(s(I), "<", ""), ">", ""), "-", "_") - sOut.Append Space(8) & "self." & m_Name & ".bind('" & s(i) & "', self." & sCmdName & ")" + sOut.Append Space(8) & "self." & m_Name & ".bind('" & s(I) & "', self." & sCmdName & ")" sCmdFunc.Append CreateFuncDefOOP(sCmdName, "event") 'Python是大小写敏感的,对应快捷键也一样,如果设置的快捷键包含字母键,则将对应的大写/小写也一起绑定 - If Right(s(i), 3) >= "-a>" And Right(s(i), 3) <= "-z>" Then + If Right(s(I), 3) >= "-a>" And Right(s(I), 3) <= "-z>" Then - s(i) = Left(s(i), Len(s(i)) - 2) & UCase(Mid(s(i), Len(s(i)) - 1, 1)) & ">" '变大写 - sOut.Append Space(8) & "self." & m_Name & ".bind('" & s(i) & "', self." & sCmdName & ")" + s(I) = Left(s(I), Len(s(I)) - 2) & UCase(Mid(s(I), Len(s(I)) - 1, 1)) & ">" '变大写 + sOut.Append Space(8) & "self." & m_Name & ".bind('" & s(I) & "', self." & sCmdName & ")" - ElseIf Right(s(i), 3) >= "-A>" And Right(s(i), 3) <= "-Z>" Then + ElseIf Right(s(I), 3) >= "-A>" And Right(s(I), 3) <= "-Z>" Then - s(i) = Left(s(i), Len(s(i)) - 2) & LCase(Mid(s(i), Len(s(i)) - 1, 1)) & ">" '变小写 - sOut.Append Space(8) & "self." & m_Name & ".bind('" & s(i) & "', self." & sCmdName & ")" + s(I) = Left(s(I), Len(s(I)) - 2) & LCase(Mid(s(I), Len(s(I)) - 1, 1)) & ">" '变小写 + sOut.Append Space(8) & "self." & m_Name & ".bind('" & s(I) & "', self." & sCmdName & ")" End If End If @@ -534,6 +534,10 @@ Public Function GetBindCommandStr(dMethods As Dictionary) As String If InStr(1, s, "," & m_Name & "_MouseDown,") > 0 Then sOut.Append "" ElseIf m_Type = "Listbox" Then If InStr(1, s, "," & m_Name & "_Click,") > 0 Then sOut.Append "<>" + ElseIf m_Type = "Combobox" Then + If InStr(1, s, "," & m_Name & "_Change,") > 0 Then sOut.Append "<>" + ElseIf m_Type = "Text" Then + If InStr(1, s, "," & m_Name & "_Change,") > 0 Then sOut.Append "<>" ElseIf m_Type <> "Notebook" Then If InStr(1, s, "," & m_Name & "_Click,") > 0 Or InStr(1, s, "," & m_Name & "_MouseDown,") > 0 Then sOut.Append "" End If @@ -548,7 +552,9 @@ Public Function GetBindCommandStr(dMethods As Dictionary) As String If InStr(1, s, "," & m_Name & "_Enter,") > 0 Or InStr(1, s, "," & m_Name & "_MouseMove,") > 0 Then sOut.Append "" If InStr(1, s, "," & m_Name & "_Leave,") > 0 Then sOut.Append "" - If InStr(1, s, "," & m_Name & "_Change,") > 0 Then sOut.Append "" '这个事件由内部处理,不是标准tk事件 + If m_Type <> "Combobox" And m_Type <> "Text" And InStr(1, s, "," & m_Name & "_Change,") > 0 Then + sOut.Append "" '这个事件由内部处理,不是标准tk事件 + End If If m_Type = "Treeview" Then If InStr(1, s, "," & m_Name & "_NodeClick,") > 0 Then sOut.Append "<>" @@ -599,15 +605,15 @@ End Function '将用户选择的配置更新到对象中,参数为使用"|"分割的很多对属性/值对 Public Sub SetConfig(sAttrs As String) - Dim sa() As String, i As Long + Dim sa() As String, I As Long sa = Split(sAttrs, "|") Debug.Assert (UBound(sa) Mod 1 = 0) m_dic.RemoveAll - For i = 0 To UBound(sa) - 1 Step 2 - m_dic(sa(i)) = sa(i + 1) + For I = 0 To UBound(sa) - 1 Step 2 + m_dic(sa(I)) = sa(I + 1) Next End Sub @@ -803,6 +809,7 @@ End Sub '构建一个函数空骨架; FuncName: 函数名,Params: 参数,sbody: 函数体 Public Function CreateFuncDef(funcName As String, Optional sparams As String = "", Optional sbody As String = "") As String + Dim txtMod As String, widgetName As String If Len(funcName) = 0 Then Exit Function CreateFuncDef = "def " & funcName & "(" & sparams & "):" & vbCrLf If Len(sbody) Then @@ -812,13 +819,20 @@ Public Function CreateFuncDef(funcName As String, Optional sparams As String = " CreateFuncDef = CreateFuncDef & Space(4) & "print('" & funcName & "')" & vbCrLf #Else CreateFuncDef = CreateFuncDef & Space(4) & "#TODO, Please finish the function here!" & vbCrLf - CreateFuncDef = CreateFuncDef & Space(4) & "pass" & vbCrLf + txtMod = "_Modified" + If m_Type = "Text" And Right(funcName, Len(txtMod)) = txtMod Then + widgetName = Left(funcName, Len(funcName) - Len(txtMod)) + CreateFuncDef = CreateFuncDef & Space(4) & widgetName & ".edit_modified(False)" & vbCrLf + Else + CreateFuncDef = CreateFuncDef & Space(4) & "pass" & vbCrLf + End If #End If End If End Function '构建一个函数空骨架(面向对象代码); FuncName: 函数名,Params: 参数,sbody: 函数体 Public Function CreateFuncDefOOP(funcName As String, Optional sparams As String = "", Optional sbody As String = "") As String + Dim txtMod As String, widgetName As String If Len(funcName) = 0 Then Exit Function CreateFuncDefOOP = " def " & funcName & "(self" & IIf(Len(sparams), ", ", "") & sparams & "):" & vbCrLf If Len(sbody) Then @@ -828,7 +842,13 @@ Public Function CreateFuncDefOOP(funcName As String, Optional sparams As String CreateFuncDefOOP = CreateFuncDefOOP & Space(8) & "print('" & funcName & "')" & vbCrLf #Else CreateFuncDefOOP = CreateFuncDefOOP & Space(8) & "#TODO, Please finish the function here!" & vbCrLf - CreateFuncDefOOP = CreateFuncDefOOP & Space(8) & "pass" & vbCrLf + txtMod = "_Modified" + If m_Type = "Text" And Right(funcName, Len(txtMod)) = txtMod Then + widgetName = Left(funcName, Len(funcName) - Len(txtMod)) + CreateFuncDefOOP = CreateFuncDefOOP & Space(8) & "self." & widgetName & ".edit_modified(False)" & vbCrLf + Else + CreateFuncDefOOP = CreateFuncDefOOP & Space(8) & "pass" & vbCrLf + End If #End If End If End Function