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 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