Esempio n. 1
0
class PeopleList(Frame):
    def __init__(self, master=None, title='', items=(('客户名称',36),('机构类型',10),('国别', 10),('营业执照编号',20),('注册资本',10)), next_func=None):
        Frame.__init__(self, master, relief=Tkinter.GROOVE )
        self.mutilistbox_items = items
        self.next_func = next_func
        self.next_func_button = None
        self.title = title
        self.create_widget()

    def create_widget(self):
        self.create_explain_label()
        self.create_mutilistbox(self.mutilistbox_items)
        self.create_button()
        self.pack_all()

    def create_explain_label(self):
        self.explain_label = Label(self, text=self.title)
        self.explain_label['width'] = 80
        self.explain_label['anchor'] = 'w'

    def refresh_mutilistbox(self):
        self.people_mutilistbox.delete(0, self.people_mutilistbox.size())
        self.add_item()

    def add_item(self):
        people_list = show_people_list()
        for p in people_list:
            self.people_mutilistbox.insert(Tkinter.END, p)

    def get_mutilistbox_choose(self):
        now = self.people_mutilistbox.curselection()
        if not now:
            return None
        else:
            return (const.people_information_list[int(now[0])], int(now[0]))

    def create_mutilistbox(self, mutilistbox_items):
        self.people_mutilistbox = MultiListbox(self, mutilistbox_items)
        self.people_mutilistbox['width'] = 200
        self.people_mutilistbox['height'] = 100
        self.refresh_mutilistbox()

    def create_button(self):
        self.add_people_button = Button(self, text='增加新客户')
        self.add_people_button['command'] = lambda: PeopleInformationToplevel(self)
        self.confirm_button = Button(self, text='刷新')
        self.confirm_button['command'] = self.refresh_mutilistbox
        if self.next_func:
            self.next_func_button = Button(self, text='填写申请')
            self.next_func_button['command'] = self.next_func

    def pack_all(self):
        self.explain_label.pack()
        self.people_mutilistbox.pack(fill=Tkinter.BOTH)
        self.confirm_button.pack(side=Tkinter.RIGHT)
        self.add_people_button.pack(side=Tkinter.RIGHT)
        if self.next_func_button:
            self.next_func_button.pack(side=Tkinter.LEFT)
Esempio n. 2
0
 def help(self):
   hwin = Toplevel(self.win)
   hwin.title('Help')
   npanel = LabelFrame(hwin, text='NAME table', padx=0, pady=0, width=100, height=100)
   nlist = MultiListbox(npanel, 'SINGLE', (('FIELD', 20), ('Type', 15), ('Null', 5), ('Key', 5), ('Default', 10), ('Extra', 20)))
   dname = self.execute("DESCRIBE NAME")
   rname = dname.fetchall()
   for r in rname:
     nlist.insert(END, r)
   nlist.pack(fill=Y)
   npanel.pack()
   
   ppanel = npanel = LabelFrame(hwin, text='PROPERTY table', padx=0, pady=0, width=100, height=100)
   plist = MultiListbox(ppanel, 'SINGLE', (('FIELD', 20), ('Type', 15), ('Null', 5), ('Key', 5), ('Default', 10), ('Extra', 20)))
   dprop = self.execute("DESCRIBE PROPERTY")
   rprop = dprop.fetchall()
   for r in rprop:
     plist.insert(END, r)
   plist.pack(fill=Y)
   ppanel.pack()
Esempio n. 3
0
 def __init__(self, name, prop, option, parent=None):
   self.win = Toplevel()
   self.win.title=('Duplicate Card Exists')
   Label(self.win, text=name).pack(side=TOP)
   ppanel = MultiListbox(self.win, 'SINGLE', (('Property Name', 20), ('Type Parameter', 35), ('Value Parameter', 35), ('Value', 55)))
   for p in prop:
     ppanel.insert(END, (p[0], p[1], p[2], p[3]))
   ppanel.pack(side=TOP, fill=BOTH)
   bpanel = Frame(self.win)
   Label(bpanel, text='What would you like to do?').pack(side=TOP, fill=X)
   self.var = StringVar()
   self.option = option
   Radiobutton(bpanel, text="Don't store this card", variable=self.var, value="Skip").pack(anchor=NW)
   Radiobutton(bpanel, text="Replace this card", variable=self.var, value="Replace").pack(anchor=NW)
   Radiobutton(bpanel, text="Merge with this card",variable=self.var, value="Merge").pack(anchor=NW)
   Radiobutton(bpanel, text="Cancel storing",variable=self.var, value="Cancel").pack(anchor=NW)
   Button(bpanel, text="OK", command= lambda: self.get()).pack(side=RIGHT)
   bpanel.pack(side=LEFT)
   self.var.set("Skip")
   self.win.focus_set()
   self.win.grab_set()
   self.win.wait_window()
Esempio n. 4
0
class PeopleList(Frame):
    def __init__(self,
                 master=None,
                 title='',
                 items=(('客户名称', 36), ('机构类型', 10), ('国别', 10), ('营业执照编号', 20),
                        ('注册资本', 10)),
                 next_func=None):
        Frame.__init__(self, master, relief=Tkinter.GROOVE)
        self.mutilistbox_items = items
        self.next_func = next_func
        self.next_func_button = None
        self.title = title
        self.create_widget()

    def create_widget(self):
        self.create_explain_label()
        self.create_mutilistbox(self.mutilistbox_items)
        self.create_button()
        self.pack_all()

    def create_explain_label(self):
        self.explain_label = Label(self, text=self.title)
        self.explain_label['width'] = 80
        self.explain_label['anchor'] = 'w'

    def refresh_mutilistbox(self):
        self.people_mutilistbox.delete(0, self.people_mutilistbox.size())
        self.add_item()

    def add_item(self):
        people_list = show_people_list()
        for p in people_list:
            self.people_mutilistbox.insert(Tkinter.END, p)

    def get_mutilistbox_choose(self):
        now = self.people_mutilistbox.curselection()
        if not now:
            return None
        else:
            return (const.people_information_list[int(now[0])], int(now[0]))

    def create_mutilistbox(self, mutilistbox_items):
        self.people_mutilistbox = MultiListbox(self, mutilistbox_items)
        self.people_mutilistbox['width'] = 200
        self.people_mutilistbox['height'] = 100
        self.refresh_mutilistbox()

    def create_button(self):
        self.add_people_button = Button(self, text='增加新客户')
        self.add_people_button['command'] = lambda: PeopleInformationToplevel(
            self)
        self.confirm_button = Button(self, text='刷新')
        self.confirm_button['command'] = self.refresh_mutilistbox
        if self.next_func:
            self.next_func_button = Button(self, text='填写申请')
            self.next_func_button['command'] = self.next_func

    def pack_all(self):
        self.explain_label.pack()
        self.people_mutilistbox.pack(fill=Tkinter.BOTH)
        self.confirm_button.pack(side=Tkinter.RIGHT)
        self.add_people_button.pack(side=Tkinter.RIGHT)
        if self.next_func_button:
            self.next_func_button.pack(side=Tkinter.LEFT)
Esempio n. 5
0
class Program(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent
        self.initUI()

    def initUI(self):

        self.parent.title("Typesetting")

        self.min_margin = 10
        self.max_margin = 100
        self.margin_value = self.min_margin
        self.words = []

        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        fileMenu = Menu(menubar)
        fileMenu.add_command(label="Open", command=self.openfile)
        fileMenu.add_command(label="Clear", command=self.clear)
        fileMenu.add_separator()
        fileMenu.add_command(label="Exit", command=self.onExit)
        menubar.add_cascade(label="File", menu=fileMenu)

        grid = Frame(self.parent)
        left_grid = Frame(grid)
        w_list_label = Label(left_grid,text="Lista de palabras")
        w_list_label.pack(side=TOP)
        self.w_list = MultiListbox(left_grid,(("Palabra",20),("Longitud",10)))
        self.w_list.pack(side=BOTTOM,fill=BOTH,expand=TRUE)
        left_grid.pack(side=LEFT,fill=BOTH,expand=TRUE)


        right_grid = Frame(grid)
        up_grid = Frame(right_grid)
        margin_label = Label(up_grid,text="Margen")
        margin_label.pack(side=LEFT,expand=TRUE)
        self.margin_scale = Scale(up_grid,orient=HORIZONTAL,showvalue=0,\
            variable=self.margin_value,from_=self.min_margin,to=self.max_margin,
            command=self.refresh_margin)
        self.margin_scale.pack(side=LEFT)
        self.margin_spinbox = Spinbox(up_grid,\
            textvariable=self.margin_value,from_=self.min_margin,to=self.max_margin)
        self.margin_spinbox.pack(side=LEFT)
        typeset_btn = Button(up_grid, text ="Typeset", command =self.typeset)
        typeset_btn.pack(side=RIGHT)
        up_grid.pack(side=TOP)

        self.text = Text(right_grid)
        self.text.pack(side=BOTTOM,fill=BOTH,expand=TRUE)
        right_grid.pack(side=RIGHT,fill=BOTH)
        grid.pack(fill=BOTH, expand=YES)


    def onExit(self):
        self.quit()

    def openfile(self):
        filename = askopenfilename(parent=self.parent)
        lines = [line.rstrip('\n') for line in open(filename,'r')]
        self.words = []
        for line in lines:
           self.words.extend(line.split(' '))

        for word in self.words:
            self.insert_list(word)

    def refresh_margin(self,value):
        self.margin_value=value

    def get_margin(self):
        return int(self.margin_value)

    def typeset(self):
        try:
            self.clear_text()
            text = typeset(self.words,self.get_margin())
            self.insert_text(text)
        except IOError as e:
            tkMessageBox.showwarning(
            "Exception",
            e )

    def clear_text(self):
        self.text.delete("%d.%d"%(0,0),END)

    def insert_text(self,texto):
        self.text.insert(INSERT,texto)

    def clear_list(self):
        self.w_list.delete(0,END)
        pass

    def insert_list(self,word):
        self.w_list.insert(END,(word,len(word)))
        pass

    def clear(self):
        self.clear_list()
        self.clear_text()