feat():initial version
This commit is contained in:
112
code_generator/backup/old/main.py
Normal file
112
code_generator/backup/old/main.py
Normal file
@@ -0,0 +1,112 @@
|
||||
# coding=utf-8
|
||||
import time
|
||||
import tkinter as tk
|
||||
from tkinter import Button, Checkbutton, Entry, Image, IntVar, Label, StringVar, scrolledtext, ttk, filedialog, messagebox
|
||||
from datetime import datetime
|
||||
from string import Template
|
||||
import tkinter_ui as gui
|
||||
import template as tmpl
|
||||
|
||||
|
||||
# 获取当前时间
|
||||
def Time(): #getCurrentTime
|
||||
current_time = time.strftime('[%Y-%m-%d %H:%M:%S]',time.localtime(time.time()))
|
||||
return current_time
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# #全局风格类型变量
|
||||
# entry_width = 30
|
||||
# short_entry_width = 15
|
||||
# font_pix = 15
|
||||
# font_type = "微软雅黑"
|
||||
# #window.geometry('1000x500+0+0')
|
||||
# #window.resizable(0,0)
|
||||
# #setWindowCenter(window, 700, 400) #窗口居中,传入窗口句柄和窗口宽高
|
||||
|
||||
#主窗口
|
||||
#实例化一个窗体
|
||||
window = gui.instantiate_the_window("Someip Service Code Generator") #窗口名
|
||||
note = gui.instantiate_the_note(window)
|
||||
#在窗体win中创建一个Notebook,并承载以下两个选项卡
|
||||
TabMain = gui.instantiate_the_tab(note, "Main") #选项卡1
|
||||
Tab2 = gui.instantiate_the_tab(note, "Tab2")
|
||||
|
||||
## 以下为Main选项卡
|
||||
# 第一组 :Create/Modify
|
||||
group_app = gui.instantiate_the_group(TabMain,"App") #创建Frame一组
|
||||
|
||||
|
||||
|
||||
#设置输入框控件,使用textvariable参数来接收变量
|
||||
# 定义输入框1
|
||||
label1 = Label(group_app, text='Run Config File Path')
|
||||
label1.grid(sticky="w", padx=15)
|
||||
entry1 = Entry(group_app, width=tmpl.entry_width, textvariable=tmpl.runConfigFilename)
|
||||
entry1.grid(row=0,column=1,sticky="w")
|
||||
entry1.config(state='normal') #'readonly'
|
||||
# Button(group_app, text='...', command=open_file).grid(row=0, column=2)
|
||||
# 定义输入框2
|
||||
label2 = Label(group_app, text='App name')
|
||||
label2.grid(sticky="w", padx=15)
|
||||
entry2 = Entry(group_app, width=tmpl.entry_width, textvariable=tmpl.appName)
|
||||
entry2.grid(row=1,column=1,sticky="w")
|
||||
# 定义输入框3
|
||||
label3 = Label(group_app, text='Service ID')
|
||||
label3.grid(sticky="w", padx=15)
|
||||
entry3 = Entry(group_app, width=tmpl.entry_width, textvariable=tmpl.serviceID)
|
||||
entry3.grid(row=2,column=1)
|
||||
entry3.config(state='readonly')
|
||||
# 定义输入框4
|
||||
label4 = Label(group_app, text='Instance ID')
|
||||
label4.grid(sticky="w", padx=15)
|
||||
entry4 = Entry(group_app, width=tmpl.ntry_width, textvariable=tmpl.instanceID)
|
||||
entry4.grid(row=3,column=1)
|
||||
entry4.config(state='readonly')
|
||||
|
||||
|
||||
# 设置复选框控件,使用variable参数来接收变量
|
||||
check0 = Checkbutton(window, text="use_tcp",variable = tmpl.use_tcp,onvalue=1,offvalue=0)
|
||||
check1 = Checkbutton(window, text="offer_F-F_method",variable = tmpl.offer_F_F_method,onvalue=1,offvalue=0, command=tmpl.entryState)
|
||||
check2 = Checkbutton(window, text="offer_R-R_method",variable = tmpl.offer_R_R_method,onvalue=1,offvalue=0, command=tmpl.entryState)
|
||||
check3 = Checkbutton(window, text="offer_setter",variable = tmpl.offer_setter,onvalue=1,offvalue=0, command=tmpl.entryState)
|
||||
check4 = Checkbutton(window, text="offer_getter",variable = tmpl.offer_getter,onvalue=1,offvalue=0, command=tmpl.entryState)
|
||||
check56 = Checkbutton(window, text="offer_event",variable = tmpl.offer_event,onvalue=1,offvalue=0, command=tmpl.entryState)
|
||||
check78 = Checkbutton(window, text="offer_field_notifier",variable = tmpl.offer_field_notifier,onvalue=1,offvalue=0, command=tmpl.entryState)
|
||||
|
||||
check0.grid(sticky="w")
|
||||
check1.grid(sticky="w")
|
||||
check2.grid(sticky="w")
|
||||
check3.grid(sticky="w")
|
||||
check4.grid(sticky="w")
|
||||
check56.grid(sticky="w")
|
||||
check78.grid(sticky="w")
|
||||
|
||||
# 设置各种服务类型的IDs,使用textvariable参数来接收变量
|
||||
idEntry1 = Entry(window, width=tmpl.entry_width, textvariable=tmpl.F_F_method_ids)
|
||||
idEntry2 = Entry(window, width=tmpl.entry_width, textvariable=tmpl.R_R_method_ids)
|
||||
idEntry3 = Entry(window, width=tmpl.entry_width, textvariable=tmpl.setter_ids)
|
||||
idEntry4 = Entry(window, width=tmpl.entry_width, textvariable=tmpl.getter_ids)
|
||||
idEntry5 = Entry(window, width=tmpl.short_entry_width, textvariable=tmpl.eventgroup_ids)
|
||||
idEntry6 = Entry(window, width=tmpl.short_entry_width, textvariable=tmpl.event_ids)
|
||||
idEntry7 = Entry(window, width=tmpl.short_entry_width, textvariable=tmpl.ield_eventgroup_ids)
|
||||
idEntry8 = Entry(window, width=tmpl.short_entry_width, textvariable=tmpl.field_event_ids)
|
||||
|
||||
idEntry1.grid_forget()
|
||||
idEntry2.grid_forget()
|
||||
idEntry3.grid_forget()
|
||||
idEntry4.grid_forget()
|
||||
idEntry5.grid_forget()
|
||||
idEntry6.grid_forget()
|
||||
idEntry7.grid_forget()
|
||||
idEntry8.grid_forget()
|
||||
|
||||
# 按钮
|
||||
button1 = Button(window, text="Generate", command=tmpl.generate)
|
||||
button1.grid(row=11, column=0, sticky="w", padx=15, pady=5)
|
||||
|
||||
button2 = Button(window, text='Exit',command=window.quit)
|
||||
button2.grid(row=11, column=1, sticky="e", padx=15, pady=5)
|
||||
|
||||
window.mainloop()
|
||||
Reference in New Issue
Block a user