Skip to content

Commit d9da684

Browse files
V1.5.1
1. The process of login and registration is optional, which speeds up the project development. 2. Divide Chinese into simplified Chinese and traditional Chinese. 3. Embedded video tutorial. 4. New control renaming function. 5. Modify and delete the control bug. 6. Reorganize all attribute names to make them easier to understand. 7. A lot of bugs have been modified 8. Complete the tutorial document.
1 parent 6ca49c6 commit d9da684

File tree

105 files changed

+2587
-1048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2587
-1048
lines changed

API_Manual.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
| Author | Honghaier |
66
| -------: | ---------- |
7-
| Version | V1.4.8 |
8-
| Last Update Date | 2021-06-12 |
7+
| Version | V1.5.1 |
8+
| Last Update Date | 2021-07-06 |
99
| Twitter: | honghaier_2020@Honghaier_game |
1010
| Email: | [email protected] |
11-
| QQ Group | 100180960 |
11+
| Twitter: | honghaier_2020@Honghaier_game |
1212

1313
WebSite:www.tkinterdesigner.com
1414

API_Manual_Cn.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
| Author | Honghaier |
66
| -------: | ---------- |
7-
| Version | V1.4.6 |
8-
| Last Update Date | 2021-06-12 |
9-
| Twitter: | honghaier_2020@Honghaier_game |
7+
| Version | V1.5.1 |
8+
| Last Update Date | 2021-07-06 |
9+
| Twitter: | honghaier_2020@honghaier_game |
1010
| Email: | [email protected] |
1111
| QQ Group | 100180960 |
1212

@@ -17,7 +17,7 @@ GitHub: https://github.com/honghaier-game/TKinterDesigner.git
1717

1818
## Fun.py是什么?
1919

20-
py是TkinterDesigner的函数库,它提供了访问UI控件及其属性的常用函数。同时,它还包含一些常用函数封装的函数。。
20+
Py是TkinterDesigner的函数库,它提供了访问UI控件及其属性的常用函数。同时,它还包含一些常用函数封装的函数。。
2121

2222
## Fun.py 包括哪些功能?
2323

Examples/CallTest/CallTest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import CallTest_cmd
55
import CallTest_sty
66
import Fun
7+
import os
78
import tkinter
89
from tkinter import *
910
import tkinter.ttk
@@ -13,14 +14,13 @@
1314
class CallTest:
1415
def __init__(self,root,isTKroot = True):
1516
uiName = self.__class__.__name__
16-
Fun.G_UIElementArray[uiName]={}
17-
Fun.G_UIElementUserDataArray[uiName]={}
1817
Fun.Register(uiName,'UIClass',self)
1918
self.root = root
2019
style = CallTest_sty.SetupStyle()
2120
if isTKroot == True:
2221
root.title("Form1")
2322
Fun.CenterDlg(uiName,root,500,400)
23+
root['background'] = '#efefef'
2424
Form_1= tkinter.Canvas(root,width = 10,height = 4)
2525
Form_1.place(x = 0,y = 0,width = 500,height = 400)
2626
Form_1.configure(bg = "#efefef")
@@ -29,9 +29,9 @@ def __init__(self,root,isTKroot = True):
2929
Fun.Register(uiName,'Form_1',Form_1)
3030
#Create the elements of root
3131
Button_2= tkinter.Button(root,text="调用注册",width = 10,height = 4)
32+
Fun.Register(uiName,'Button_2',Button_2)
3233
Button_2.place(x = 190,y = 139,width = 100,height = 28)
3334
Button_2.configure(command=lambda:CallTest_cmd.Button_2_onCommand(uiName,"Button_2"))
34-
Fun.Register(uiName,'Button_2',Button_2)
3535
#Inital all element's Data
3636
Fun.InitElementData(uiName)
3737
#Add Some Logic Code Here: (Keep This Line of comments)

Examples/CallTest/CallTest_cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
ElementBGArray={}
1111
ElementBGArray_Resize={}
1212
ElementBGArray_IM={}
13-
1413
def Button_2_onCommand(uiName,widgetName):
1514
topLevel = tkinter.Toplevel()
1615
topLevel.attributes("-toolwindow", 1)
1716
topLevel.wm_attributes("-topmost", 1)
1817
import RegDlg
1918
RegDlg.RegDlg(topLevel)
2019
tkinter.Tk.wait_window(topLevel)
21-
InputDataArray = RegDlg.Fun.G_UIInputDataArray
20+
InputDataArray = Fun.G_UIInputDataArray
2221
print(InputDataArray)
2322
print('个人简介:'+InputDataArray['Text_12'][0])
2423
print('姓名:'+InputDataArray['Entry_5'][0])
@@ -28,3 +27,4 @@ def Button_2_onCommand(uiName,widgetName):
2827
else:
2928
print('性别:女')
3029
print('邮箱:'+InputDataArray['Entry_10'][0])
30+

Examples/CallTest/Fun.py

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#This file does not support direct editing
1+
#此文件不支持直接编辑
22
#coding=utf-8
33
import os
44
from os.path import abspath, dirname
@@ -9,16 +9,30 @@
99
G_UIElementArray={}
1010
G_UIElementVariableArray={}
1111
G_UIInputDataArray={}
12+
G_UIElementAlias={}
13+
G_UIGroupDictionary={}
14+
G_UIStyleDictionary={}
1215
G_CurrentFilePath=None
1316
G_CutContent=None
1417
#注册一个控件,用于记录它:参数1:界面类名, 参数2:控件名称,参数3:控件。
15-
def Register(uiName,elementName,element):
18+
def Register(uiName,elementName,element,alias=None,groupName=None,styleName=None):
1619
if uiName not in G_UIElementArray:
1720
G_UIElementArray[uiName]={}
21+
G_UIElementAlias[uiName]={}
22+
G_UIGroupDictionary[uiName]={}
23+
G_UIStyleDictionary[uiName]={}
1824
G_UIElementArray[uiName][elementName]=element
25+
if alias:
26+
G_UIElementAlias[uiName][alias]=elementName
27+
if groupName:
28+
G_UIGroupDictionary[uiName][elementName]=groupName
29+
if styleName:
30+
G_UIStyleDictionary[uiName][elementName]=styleName
1931
#取得控件:参数1:界面类名, 参数2:控件名称。
2032
def GetElement(uiName,elementName):
21-
global G_UIElementArray
33+
if uiName in G_UIElementAlias:
34+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
35+
elementName = G_UIElementArray[uiName][elementName]
2236
if uiName in G_UIElementArray:
2337
if elementName in G_UIElementArray[uiName]:
2438
return G_UIElementArray[uiName][elementName]
@@ -42,18 +56,33 @@ def AddTKVariable(uiName,elementName,defaultValue = None):
4256
#设置控件的tkinter变量.参数1:界面类名, 参数2:控件名称,参数3:值。
4357
def SetTKVariable(uiName,elementName,value):
4458
if uiName in G_UIElementVariableArray:
59+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
60+
elementName = G_UIElementAlias[uiName][elementName]
4561
if elementName in G_UIElementVariableArray[uiName]:
4662
G_UIElementVariableArray[uiName][elementName].set(value)
63+
if elementName in G_UIGroupDictionary[uiName]:
64+
GroupName = G_UIGroupDictionary[uiName][elementName]
65+
if GroupName in G_UIElementVariableArray[uiName]:
66+
G_UIElementVariableArray[uiName][GroupName].set(value)
4767
#取得控件的tkinter变量.参数1:界面类名, 参数2:控件名称。
4868
def GetTKVariable(uiName,elementName):
4969
if uiName in G_UIElementVariableArray:
70+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
71+
elementName = G_UIElementAlias[uiName][elementName]
5072
if elementName in G_UIElementVariableArray[uiName]:
5173
return G_UIElementVariableArray[uiName][elementName].get()
74+
if elementName in G_UIGroupDictionary[uiName]:
75+
GroupName = G_UIGroupDictionary[uiName][elementName]
76+
if GroupName in G_UIElementVariableArray[uiName]:
77+
return G_UIElementVariableArray[uiName][GroupName].get()
78+
return None
5279
#为控件添加一个用户数据,参数dataname为数据名,datatype为数据类型,可以包括int、float、string、list、dictionary等,一般在设计软件中用鼠标右键操作控件,在弹出的“绑定数据”对话枉中设置,参数datavalue为数据值,而ismaptotext则是是否将数据直接反映到控件的text变量中。
5380
def AddUserData(uiName,elementName,dataName,datatype,datavalue,isMapToText):
5481
global G_UIElementUserDataArray
5582
if uiName not in G_UIElementUserDataArray:
5683
G_UIElementUserDataArray[uiName]={}
84+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
85+
elementName = G_UIElementAlias[uiName][elementName]
5786
if elementName not in G_UIElementUserDataArray[uiName]:
5887
G_UIElementUserDataArray[uiName][elementName]=[]
5988
G_UIElementUserDataArray[uiName][elementName].append([dataName,datatype,datavalue,isMapToText])
@@ -62,6 +91,8 @@ def SetUserData(uiName,elementName,dataName,datavalue):
6291
global G_UIElementArray
6392
global G_UIElementUserDataArray
6493
if uiName in G_UIElementUserDataArray:
94+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
95+
elementName = G_UIElementAlias[uiName][elementName]
6596
if elementName in G_UIElementUserDataArray[uiName]:
6697
for EBData in G_UIElementUserDataArray[uiName][elementName]:
6798
if EBData[0] == dataName:
@@ -73,6 +104,8 @@ def SetUserData(uiName,elementName,dataName,datavalue):
73104
def GetUserData(uiName,elementName,dataName):
74105
global G_UIElementUserDataArray
75106
if uiName in G_UIElementUserDataArray:
107+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
108+
elementName = G_UIElementAlias[uiName][elementName]
76109
if elementName in G_UIElementUserDataArray[uiName]:
77110
for EBData in G_UIElementUserDataArray[uiName][elementName]:
78111
if EBData[0] == dataName:
@@ -87,19 +120,24 @@ def GetUserData(uiName,elementName,dataName):
87120
def SetTKAttrib(uiName,elementName,AttribName,attribValue):
88121
global G_UIElementArray
89122
if uiName in G_UIElementArray:
123+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
124+
elementName = G_UIElementAlias[uiName][elementName]
90125
if AttribName in G_UIElementArray[uiName][elementName].configure().keys():
91126
G_UIElementArray[uiName][elementName][AttribName]=attribValue
92127
#获取控件的tkinter属性值。
93128
def GetTKAttrib(uiName,elementName,AttribName):
94129
global G_UIElementArray
95130
if uiName in G_UIElementArray:
131+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
132+
elementName = G_UIElementAlias[uiName][elementName]
96133
return G_UIElementArray[uiName][elementName].cget(AttribName)
97-
return None
98134
#设置控件的文本(label, button, entry and text)。
99135
def SetText(uiName,elementName,textValue):
100136
global G_UIElementArray
101137
global G_UIElementVariableArray
102138
showtext = str("%s"%textValue)
139+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
140+
elementName = G_UIElementAlias[uiName][elementName]
103141
if uiName in G_UIElementVariableArray:
104142
if elementName in G_UIElementVariableArray[uiName]:
105143
G_UIElementVariableArray[uiName][elementName].set(showtext)
@@ -115,6 +153,8 @@ def SetText(uiName,elementName,textValue):
115153
def GetText(uiName,elementName):
116154
global G_UIElementArray
117155
global G_UIElementVariableArray
156+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
157+
elementName = G_UIElementAlias[uiName][elementName]
118158
if uiName in G_UIElementVariableArray:
119159
if elementName in G_UIElementVariableArray[uiName]:
120160
return G_UIElementVariableArray[uiName][elementName].get()
@@ -130,6 +170,8 @@ def GetText(uiName,elementName):
130170
#设置控件的背景图片(Label,Button)。
131171
def SetImage(uiName,elementName,imagePath):
132172
global G_UIElementVariableArray
173+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
174+
elementName = G_UIElementAlias[uiName][elementName]
133175
if elementName.find('Label_') == 0 or elementName.find('Button_') == 0 :
134176
Control = GetElement(uiName,elementName)
135177
if Control != None:
@@ -153,6 +195,8 @@ def SetImage(uiName,elementName,imagePath):
153195
#获取控件的背景图像文件(标签、按钮)。
154196
def GetImage(uiName,elementName):
155197
global G_UIElementVariableArray
198+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
199+
elementName = G_UIElementAlias[uiName][elementName]
156200
if elementName.find('Label_') == 0 or elementName.find('Button_') == 0 :
157201
Control = GetElement(uiName,elementName)
158202
if Control != None:
@@ -164,6 +208,8 @@ def GetImage(uiName,elementName):
164208
return str("")
165209
#设置ListBox和ComboBox的选中项。
166210
def SetSelectIndex(uiName,elementName,index):
211+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
212+
elementName = G_UIElementAlias[uiName][elementName]
167213
Control = GetElement(uiName,elementName)
168214
if Control != None:
169215
if elementName.find('ComboBox_') == 0 :
@@ -172,6 +218,8 @@ def SetSelectIndex(uiName,elementName,index):
172218
Control.select_set(index)
173219
#取得ListBox和ComboBox的选中项。
174220
def GetSelectIndex(uiName,elementName):
221+
if uiName in G_UIElementAlias.keys() and elementName in G_UIElementAlias[uiName].keys():
222+
elementName = G_UIElementAlias[uiName][elementName]
175223
Control = GetElement(uiName,elementName)
176224
if Control != None:
177225
if elementName.find('ComboBox_') == 0 :
@@ -195,15 +243,17 @@ def InitElementStyle(uiName,Style):
195243
StyleArray = ReadStyleFile(Style+".py")
196244
global G_UIElementArray
197245
if uiName in G_UIElementArray:
246+
Root = GetElement(uiName,'root')
247+
TFormKey = '.TForm'
248+
if TFormKey in StyleArray:
249+
if 'background' in StyleArray[TFormKey]:
250+
Root['background'] = StyleArray[TFormKey]['background']
198251
for elementName in G_UIElementArray[uiName].keys():
199252
Widget = G_UIElementArray[uiName][elementName]
200253
try:
201254
if Widget.winfo_exists() == 1:
202255
WinClass = Widget.winfo_class()
203256
StyleName = ".T"+WinClass
204-
if StyleName == '.TLabel':
205-
Root = GetElement(uiName,'root')
206-
Root['background'] = StyleArray[StyleName]['background']
207257
for attribute in StyleArray[StyleName].keys():
208258
Widget[attribute] = StyleArray[StyleName][attribute]
209259
except BaseException:
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
1.13 KB
Binary file not shown.

Examples/Chat/.idea/Chat.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Chat/.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)