def __main(self): self.top = Widget.NewTop() frame = Widget.Labelframe(self.top) label = Widget.Label(frame) entry = Widget.Entry(frame) button1 = Widget.Button(frame) Window.widg = self.top Window.Top("Preference settint") Window.widg = frame Window.Config(text=u"设置偏好") Window.Pack() Window.widg = label Window.Config(text=u"文件路径:") Window.Pack(side="left") Window.widg = entry self.__entry_var = Window.ConfigVar("textvariable") Window.Config(state=Tkconstants.DISABLED) Window.Pack(side="left") Window.widg = button1 command = basic.register_command(button1, self.__select_dir) Window.Config(text=u"打开文件", command=command) Window.Pack(side="left")
def ListWithScrollbar(cls, master): '''Sample usage: from com.ui import ROOT frame1 = Widget.Labelframe(ROOT,text = "sssss") frame1.rowconfigure(0,weight =1, minsize = 0) frame1.columnconfigure(0,weight =1, minsize = 0) Window.widg = frame1 Window.Pack(side = "top", fill="both", expand="yes", padx = "0.2c") (l,x,y) = Components.ListWithScrollbar(frame1) elems = ["Don't speculate, measure", "Waste not, want not", "Early to bed and early to rise makes a man healthy, wealthy, and wise", "Ask not what your country can do for you, ask what you can do for your country", "I shall return", "NOT", "A picture is worth a thousand words", "User interfaces are hard to build", "Thou shalt not steal", "A penny for your thoughts", "Fool me once, shame on you; fool me twice, shame on me", "Every cloud has a silver lining", "Where there's smoke there's fire", "It takes one to know one", "Curiosity killed the cat", "Take this job and shove it", "Up a creek without a paddle", "I'm mad as hell and I'm not going to take it any more", "An apple a day keeps the doctor away", "Don't look a gift horse in the mouth", "Measure twice, cut once"] l.insert(0,*elems) ROOT.mainloop() ''' lb = Widget.Listbox(master, width=20, height=10, setgrid=1) s_x = Widget.Scrollbar(master, orient=Tkconstants.HORIZONTAL, command=lb.xview) s_y = Widget.Scrollbar(master, orient=Tkconstants.VERTICAL, command=lb.yview) Window.widg = lb Window.Config(xscrollcommand=s_x.set, yscrollcommand=s_y.set) Window.Grid(row=0, column=0, rowspan=1, columnspan=1, sticky=Tkconstants.NSEW) Window.widg = s_y Window.Grid(row=0, column=1, rowspan=1, columnspan=1, sticky=Tkconstants.NSEW) Window.widg = s_x Window.Grid(row=1, column=0, rowspan=1, columnspan=1, sticky=Tkconstants.NSEW) return (lb, s_x, s_y)
def LabelWithEntryAndButton(cls, master, grid_tree): '''Sample usage from com.ui import ROOT frame1 = Widget.Labelframe(ROOT,text = "YYYY") Window.widg = frame1 Window.Pack(side = "top", fill="both", expand="yes", padx = "0.2c") grid_tree = [ [(u"用户名:", u"登录")], [(u"密码:", ""),(u"验证码:", "")], ] widgets = Components.LabelWithEntryAndButton(frame1, grid_tree) widgets[0][1].insert("end","hi handsome boy.") ROOT.mainloop() ''' result = [] rows = len(grid_tree) for row in range(rows): result.append([]) column = -1 groups = grid_tree[row] for lable_name, button_name in groups: column = column + 1 label = Widget.Label(master, text=lable_name) result[row].append(label) Window.widg = label Window.Grid(row, column, "w") column = column + 1 entry = Widget.Entry(master) result[row].append(entry) Window.widg = entry Window.Grid(row, column, "ew") if button_name: column = column + 1 button = Widget.Button(master, text=button_name) result[row].append(button) Window.widg = button Window.Grid(row, column, "e") return result
def __get_frame1(self): # text1.window_create("end", window = list1) # print basic.get_configuration_keys(frame1) text1.insert(0.0, "switch to client automation") Window.widg = text1 Window.Pack(expand="yes", fill="both", pady=2, padx="2m") Window.Config(width=88, height=10) Window.Bind('<Key>', set_selection) Window.Bind('<Key-Return>', set_textformatter) Window.Bind('<Key-Tab>', set_textkey) Window.widg = text2 Window.Pack(expand="yes", fill="both", pady=2, padx="2m") Window.Config(width=88, height=10) Window.widg = frame1 Window.Pack(expand="yes", side="left", fill="both", pady=2, padx="2m") Window.Config(text="frame1")
def TextWithScrollbar(cls, master): '''Sample usage: from com.ui import ROOT frame1 = Widget.Labelframe(ROOT,text = "XXXX") Window.widg = frame1 Window.Pack(side = "top", fill="both", expand="yes", padx = "0.2c") (t,x,y) = Components.TextWithScrollbar(frame1) t.insert("end","0.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\n") t.insert("end","1.sdf\n") ROOT.mainloop() ''' f = TkFont() # wrap-->设置当一行文本的长度超过width选项设置的宽度时,是否换行; "none"不自动换行, "char"按字符自动换行, "word"按单词自动换行 tx = Widget.Text(master, width=60, height=24, font=f.font, wrap="word", setgrid=1) s_x = Widget.Scrollbar(master, orient=Tkconstants.HORIZONTAL, command=tx.xview) s_y = Widget.Scrollbar(master, orient=Tkconstants.VERTICAL, command=tx.yview) Window.widg = s_y Window.Pack(side="right", fill="y") Window.widg = s_x Window.Pack(side="bottom", fill="x") Window.widg = tx Window.Config(xscrollcommand=s_x.set, yscrollcommand=s_y.set) Window.Pack(side="top", fill="both", expand="yes") return (tx, s_x, s_y)
def __get_frame2(self): global g Window.widg = x_scroll_1 Window.Config(orient="horizontal", command=list1.xview) Window.Pack(side="bottom", fill="x") Window.widg = y_scroll_1 Window.Config(orient="vertical", command=list1.yview) Window.Pack(side="right", fill="y") Window.widg = list1 Window.Config(selectmode=Tkconstants.SINGLE, xscrollcommand=x_scroll_1.set, yscrollcommand=y_scroll_1.set) g["list1_var"] = Window.ConfigVar("listvariable") Window.Pack(expand="yes", fill="both") Window.widg = frame2 Window.Pack(expand="yes", side="right", fill="both") Window.Config(text="frame2")
def __main(self): self.frame1 = Widget.Labelframe(ROOT) self.frame2 = Widget.Labelframe(ROOT) label_caseid = Widget.Label(self.frame1) entry_caseid = Widget.Entry(self.frame1) label_steps = Widget.Label(self.frame1) text_steps = Widget.Text(self.frame1) label_des_name = Widget.Label(self.frame1) text_des_name = Widget.Text(self.frame1) label_precommand = Widget.Label(self.frame1) text_precommand = Widget.Text(self.frame1) label_head = Widget.Label(self.frame1) text_head = Widget.Text(self.frame1) label_data = Widget.Label(self.frame1) text_data = Widget.Text(self.frame1) label_postcommand = Widget.Label(self.frame1) text_postcommand = Widget.Text(self.frame1) label_verify = Widget.Label(self.frame1) text_verify = Widget.Text(self.frame1) label_casetype = Widget.Label(self.frame1) text_casetype = Widget.Entry(self.frame1) label_author = Widget.Label(self.frame1) text_author = Widget.Entry(self.frame1) list_control = Widget.Listbox(self.frame2) text_conf={"width" : 40, "height" : 5} entry_conf = {"width":40} # frame1 Window.widg = label_caseid Window.Config(text = "TestCaseID:") Window.Grid(row=0, column=0,sticky="w") Window.widg = entry_caseid Window.Config(**entry_conf) Window.Grid(row=0, column=1,sticky="EW") Window.widg = label_casetype Window.Config(text = "CaseType:") Window.Grid(row=1, column=0,sticky="w") Window.widg = text_casetype Window.Config(**entry_conf) Window.Grid(row=1, column=1,sticky="EW") Window.widg = label_author Window.Config(text = "Tester:") Window.Grid(row=2, column=0,sticky="w") Window.widg = text_author Window.Config(**entry_conf) Window.Grid(row=2, column=1,sticky="EW") Window.widg = label_steps Window.Config(text = "Steps:") Window.Grid(row=3, column=0,sticky="w") Window.widg = text_steps Window.Config(**text_conf) Window.Grid(row=3, column=1,sticky="EW") Window.widg = label_des_name Window.Config(text = "Description:") Window.Grid(row=4, column=0,sticky="w") Window.widg = text_des_name Window.Config(**text_conf) Window.Grid(row=4, column=1,sticky="EW") Window.widg = label_precommand Window.Config(text = "PreCommand:") Window.Grid(row=5, column=0,sticky="w") Window.widg = text_precommand Window.Config(**text_conf) Window.Grid(row=5, column=1,sticky="EW") Window.widg = label_head Window.Config(text = "Head:") Window.Grid(row=6, column=0,sticky="w") Window.widg = text_head Window.Config(**text_conf) Window.Grid(row=6, column=1,sticky="EW") Window.widg = label_data Window.Config(text = "Data:") Window.Grid(row=7, column=0,sticky="w") Window.widg = text_data Window.Config(**text_conf) Window.Grid(row=7, column=1,sticky="EW") Window.widg = label_postcommand Window.Config(text = "PostCommand:") Window.Grid(row=8, column=0,sticky="w") Window.widg = text_postcommand Window.Config(**text_conf) Window.Grid(row=8, column=1,sticky="EW") Window.widg = label_verify Window.Config(text = "Verify:") Window.Grid(row=9, column=0,sticky="w") Window.widg = text_verify Window.Config(**text_conf) Window.Grid(row=9, column=1,sticky="EW") Window.widg = self.frame1 Window.Config(text = "Part1") Window.Pack(side="left",fill = Tkconstants.X) # frame2 Window.widg = list_control self.console_output = Window.ConfigVar("listvariable") Window.Pack(side = "top", fill = Tkconstants.BOTH, expand="yes") Window.widg = self.frame2 Window.Config(text = "Part3") Window.Pack(side = "left", fill = Tkconstants.BOTH, expand = Tkconstants.YES)
FROM: 2016年6月15日 ******************************************************************** ====================================================================== UI and Web Http automation frame for python. ''' import sc from com import basic from com.basic import MSG,FileDilog from com.ui import Window,Widget,ROOT,Tkconstants from com.suite import Components Window.widg = ROOT Window.Top(sc.TITLE, geometry="917x580+179+130", resizable_x=1,resizable_y=1) menubar = Widget.Menu(ROOT) Window.Config(menu = menubar) ROOT.option_add("*Menu.tearOff", 0) class Menu: def __init__(self,loop=False): self.__main() self.__navigator_ui = AiTest() basic.mainloop(ROOT, loop=loop) def __main(self): self.menus = {} Components.GenerateMenu(menubar, sc.MENUS, self.menus)
"WEB_type", "WEB_upload", "WEB_verify_attr", "WEB_verify_count", "WEB_verify_displayed", "WEB_verify_text", "WEB_verify_title", "WEB_verify_url", "WEB_wait", ], "tmp": "", } Window.widg = ROOT Window.Top("Demo tk", resizable_x=1, resizable_y=1) frame1 = Widget.Labelframe(ROOT) frame2 = Widget.Labelframe(ROOT) text1 = Widget.Text(frame1) text2 = Widget.Text(frame1) list1 = Widget.Listbox(frame2) x_scroll_1 = Widget.Scrollbar(frame2) y_scroll_1 = Widget.Scrollbar(frame2) menu0 = Widget.Menu(ROOT) ROOT.config(menu=menu0) ROOT.option_add("*Menu.tearOff", 0) menu_objs = {}