Beispiel #1
0
 def onGrep(self):
     from formrows import makeFormRow
     popup = Toplevel()
     popup.title('PyEdit - grep')
     var1 = makeFormRow(popup,
                        label='Directory root',
                        width=18,
                        browse=False)
     var2 = makeFormRow(popup,
                        label='Filename pattern',
                        width=18,
                        browse=False)
     var3 = makeFormRow(popup,
                        label='Search string',
                        width=18,
                        browse=False)
     var4 = makeFormRow(popup,
                        label='Content encoding',
                        width=18,
                        browse=False)
     var1.set('.')  # current dir
     var2.set('*.py')  # initial values
     var4.set(sys.getdefaultencoding())  # for file content, not filenames
     cb = lambda: self.onDoGrep(var1.get(), var2.get(), var3.get(),
                                var4.get())
     Button(popup, text='Go', command=cb).pack()
Beispiel #2
0
	def modify_formula(self):
		index = self.listbox.curselection()
		if len(index) != 1:
			showerror('Error', 'Select one item')
		else:
			win = Toplevel(self)
			win.title('Modify formula')
			win.geometry('+100+100')
			itemlabel = self.listbox.get(index)
			products = Formula(itemlabel).get_formula(parent=win)
			defaultnumproducts = 5
			new = []
			for i in range(defaultnumproducts):
				if products:
					var1 = makeFormRow(win, label='Enter the name of the product %d' % (i+1), input=products[0][0])
					var2 = makeFormRow(win, label='Enter the name of the quantity', input=products[0][1])
					new.append((var1, var2))
					products.pop(0)
				else:
					var1 = makeFormRow(win, label='Enter the name of the product %d' % (i+1))
					var2 = makeFormRow(win, label='Enter the name of the quantity')
					new.append((var1, var2))

			Button(win, text='OK', command=lambda: Formula(itemlabel).modify_formula(new, parent=win)).pack(side=LEFT, fill=X, expand=YES)
			Button(win, text='Cancel', command=win.destroy).pack(side=RIGHT, fill=X, expand=YES)
			win.bind('<Return>', lambda event: Formula(itemlabel).modify_formula(new, parent=win))
Beispiel #3
0
	def modify_product(self, products):
		index = self.listbox.curselection()
		if len(index) != 1:
			showerror('Error', 'Select one product')
		else:
			win = Toplevel(self)
			win.title('Modify product')
			win.geometry('+100+100')
			productlabel = self.listbox.get(index)
			product = Storage().fetch_products(productlabel)
			product = product.pop(0)
			productslist = [data[1] for data in products]

			var1 = makeFormRow(win, label='Enter the name of the product', input=product[1], focus=True)
			var2 = makeFormRow(win, label='Enter the quantity of the item[pieces/volume/wieght]', input=product[2])
			var3, ent3 = makeFormRow(win, label='Enter the purchase data of the item[YYYY-MM-DD]', input=product[3], date=True)
			var4, ent4= makeFormRow(win, label='Enter the expiration data of the item[YYYY-MM-DD]', input=product[4], date=True)

			new = [var1, var2, var3, var4]
			date_entries = [[var3, ent3], [var4, ent4]]

			Button(win, text='OK', command=lambda: Storage().modify_product(label=productlabel, products=productslist, new=new, index=index, listbox=self.listbox, products_to_use=self.products_to_use, parent=win)).pack(side=LEFT, expand=YES, fill=X)
			Button(win, text='Cancel', command=win.destroy).pack(side=RIGHT, expand=YES, fill=X)
			win.bind('<Return>', lambda event: Storage().modify_product(label=productlabel, products=productslist, new=new, index=index, listbox=self.listbox, products_to_use=self.products_to_use, parent=win))
			for var, ent in date_entries:
				ent.bind('<Double-Button-1>', lambda event, var=var: self.focusin(event, var))
Beispiel #4
0
def queryDialog():
    win = Toplevel()
    win.title('Enter Record')
    var1 = makeFormRow(win, label='column', browse=False)
    var2 = makeFormRow(win, label='condition', browse=False)
    Button(win, text='OK', command=win.destroy).pack()
    win.grab_set()
    win.focus_set()
    win.wait_window()
    return var1.get(), var2.get()
Beispiel #5
0
def packDialog():
    win = Toplevel()  # 行的顶层窗口
    win.title('Enter Pack Parameters')  # 有2行图文框,还带有"OK"按钮
    var1 = makeFormRow(win, label='Output file')
    var2 = makeFormRow(win, label='Files to pack', extend=True)
    Button(win, text='OK', command=win.destroy).pack()
    win.grab_set()
    win.focus_set()  # 动作:鼠标选取数据;键盘获得焦点;等待
    win.wait_window()  # 等到窗口销毁,否则立即返回
    return var1.get(), var2.get()  # 获取相关联的变量值
Beispiel #6
0
def packDialog():
    win = Toplevel()
    win.title('Enter Pack Parameters')
    var1 = makeFormRow(win, label='Output file')
    var2 = makeFormRow(win, label='Files to pack', extend=True)
    Button(win, text='OK', command=win.destroy).pack()
    win.grab_set()
    win.focus_set()
    win.wait_window()
    return var1.get(), var2.get()
Beispiel #7
0
def packDialog():                               # a new top-level window
    win = Toplevel()                            # with 2 row frames + ok button
    win.title('Enter Pack Parameters')
    var1 = makeFormRow(win, label='Output file')
    var2 = makeFormRow(win, label='Files to pack', extend=True) 
    Button(win, text='OK', command=win.destroy).pack()
    win.grab_set()                   
    win.focus_set()                  # go modal: mouse grab, keyboard focus, wait
    win.wait_window()                # wait till destroy; else returns now
    return var1.get(), var2.get()    # fetch linked var values
Beispiel #8
0
def packDialog():                               # a new top-level window
    win = Toplevel()                            # with 2 row frames + ok button
    win.title('Enter Pack Parameters')
    var1 = makeFormRow(win, label='Output file')
    var2 = makeFormRow(win, label='Files to pack', extend=True) 
    Button(win, text='OK', command=win.destroy).pack()
    win.grab_set()                   
    win.focus_set()                  # go modal: mouse grab, keyboard focus, wait
    win.wait_window()                # wait till destroy; else returns now
    return var1.get(), var2.get()    # fetch linked var values
Beispiel #9
0
def packDialog():
    win = Toplevel()  # окно верхнего уровня с 2 фреймами-рядами+кнопка Ок
    win.title('Enter Pack Parameters')
    var1 = makeFormRow(win, label='Output file')
    var2 = makeFormRow(win, label='Files to pack', extend=True)
    Button(win, text='Ok', command=win.destroy).pack()
    win.grab_set()  # модальный: захват мышь, фокус
    win.focus_set()
    win.wait_window()  # ожидание закрытия
    return var1.get(), var2.get()
Beispiel #10
0
 def onPickFont(self):
     from formrows import makeFormRow
     popup = Toplevel(self)
     popup.title('PyEdit - font')
     var1 = makeFormRow(popup, label='Family', browse=False)
     var2 = makeFormRow(popup, label='Size', browse=False)
     var3 = makeFormRow(popup, label='Style', browse=False)
     var2.set('12')
     var3.set('bold italic')
     Button(popup, text='Apply', command=
            lambda: self.onDoFont(var1.get(), var2.get(), var3.get())).pack()
Beispiel #11
0
    def onGrep(self):
        from formrows import makeFormRow

        popup = Toplevel()
        popup.title('PyEdit - Grep')
        var1 = makeFormRow(popup, label='Directory root', width=18, browse=False)
        var2 = makeFormRow(popup, label='Filename pattern', width=18, browse=False)
        var3 = makeFormRow(popup, label='Search string', width=18, browse=False)
        var4 = makeFormRow(popup, label='Content encoding', width=18, browse=False)
        var1.set('.')
        var2.set('*.py')
        var4.set(sys.getdefaultencoding())
        cb = lambda: self.onDoGrep(var1.get(), var2.get(), var3.get(), var4.get())
        Button(popup, text='Go', command=cb).pack()
Beispiel #12
0
def insert_record(parent):
    win = Toplevel()
    f1 = Frame(win)
    column = [col[0] for col in parent.cur.description]
    temp = []
    for name in column:
        temp.append(makeFormRow(f1, label=name, browse=False))
    f2 = Frame(win)
    Button(f2, text='Ok', command=ss).pack(expand=YES, fill=X)
    Button(f2, text='Cancel', command=win.destroy).pack(expand=YES, fill=X)
    f1.grid(row=0, column=1)
    f2.grid(row=0, column=2)
    win.geometry("+%d+%d" %
                 (parent.winfo_rootx() + 50, parent.winfo_rootx() + 50))
    win.grab_set()
    win.focus_set()
    win.wait_window()
    new_record = dict(zip(column, temp))
    global DATA
    DATA = 'INSERT'

    def ss():
        if new_record:
            clean(new_record, parent)
        win.destroy()
Beispiel #13
0
	def add_item(self):
		win = Toplevel(self)
		win.title('Add item')
		win.geometry('+100+100')
				
		var1 = makeFormRow(win, label='Enter the name of the item', focus=True)
		var2 = makeFormRow(win, label='Enter the price of the item')
		var3 = makeFormRow(win, label='Enter the category of the item')
		Button(win, text='Save', command=(lambda: Item().save_item(name=var1.get(), price=var2.get(), cat=var3.get(), parent=win, listbox=self.listbox, menu=self.master))).pack(side=LEFT, expand=YES, fill=X)
		Button(win, text='Cancel', command=win.destroy).pack(side=RIGHT, expand=YES, fill=X)
		win.bind('<Return>', lambda event: Item().save_item(name=var1.get(), price=var2.get(), cat=var3.get(), parent=win, listbox=self.listbox, menu=self.master))
		win.grab_set()
		win.focus_set()
		win.wait_window()
		self.grab_set()
		self.focus_set()
		self.wait_window()
Beispiel #14
0
 def onPickFont(self):
     """
     2.0 non-modal font spec dialog
     2.1: pass per-dialog inputs to callback, may be > 1 font dialog open
     """
     from formrows import makeFormRow
     popup = Toplevel(self)
     popup.title('SSMLtagEdit - font')
     var1 = makeFormRow(popup, label='Family', browse=False)
     var2 = makeFormRow(popup, label='Size', browse=False)
     var3 = makeFormRow(popup, label='Style', browse=False)
     var1.set('courier')
     var2.set('12')  # suggested vals
     var3.set('bold italic')  # see pick list for valid inputs
     Button(popup,
            text='Apply',
            command=lambda: self.onDoFont(var1.get(), var2.get(), var3.get(
            ))).pack()
Beispiel #15
0
def unpackDialog():                   
    win = Toplevel()
    win.title('Enter Unpack Parameters')
    var = makeFormRow(win, label='Input file', width=11)
    win.bind('<Key-Return>', lambda event: win.destroy())
    win.grab_set()
    win.focus_set()                  # make myself modal
    win.wait_window()                # till I'm destroyed on return
    return var.get()                 # or closed by wm action
Beispiel #16
0
def unpackDialog():
    win = Toplevel()
    win.title('Enter Unpack Parameters')
    var = makeFormRow(win, label='Input file', width=11)
    win.bind('<Key-Return>', lambda event: win.destroy())
    win.grab_set()
    win.focus_set()
    win.wait_window()
    return var.get()
Beispiel #17
0
def unpackDialog():                   
    win = Toplevel()
    win.title('Enter Unpack Parameters')
    var = makeFormRow(win, label='Input file', width=11)
    win.bind('<Key-Return>', lambda event: win.destroy())
    win.grab_set()
    win.focus_set()                  # make myself modal
    win.wait_window()                # till I'm destroyed on return
    return var.get()                 # or closed by wm action
Beispiel #18
0
def unpackDialog():
    win = Toplevel()
    win.title('Enter Unpack Parameters')
    var = makeFormRow(win, label='Input file', width=11)
    win.bind('<Key-Return>', lambda event: win.destroy())
    win.grab_set()
    win.focus_set()
    win.wait_window()
    return var.get()
Beispiel #19
0
	def add_formula(self):
		index = self.listbox.curselection()
		if len(index) != 1:
			showerror('Error', 'Select one item to add formula')
		else:
			win = Toplevel(self)
			win.title('Add formula')
			win.geometry('+100+100')			
			defaultnumproducts = 5
			products = []
			itemlabel = self.listbox.get(index)
			for i in range(defaultnumproducts):
				var1 = makeFormRow(win, label='Enter the name of the product %d' % (i+1))
				var2 = makeFormRow(win, label='Enter the name of the quantity')
				products.append((var1, var2))

			Button(win, text='OK', command=lambda: Formula(itemlabel).add_formula(products, parent=win)).pack(side=LEFT, expand=YES, fill=X)
			Button(win, text='Cancel', command=win.destroy).pack(side=RIGHT, expand=YES, fill=X)
			win.bind('<Return>', lambda event: Formula(itemlabel).add_formula(products, parent=win))
Beispiel #20
0
def search(parent, user=None):
    temp = {}

    def validate():
        for var in [var1, var2, var3]:
            if var == var1:
                val = var.get()
                try:
                    if val != 0:
                        temp['InvoiceNo'] = val
                except Exception as err:
                    showerror('Type Error', err)
                    print(err)
            if var == var2:
                val = var.get()
                try:
                    if val != 0:
                        temp['CustomerID'] = val
                except Exception as err:
                    #print('Not tap')
                    showerror('Type Error', err)

            if var == var3:
                val = var.get()
                try:
                    if val.isspace():
                        temp['Country'] = val
                except Exception as err:
                    showerror('Type Error', err)
        if len(temp):
            global DATA
            if user:
                DATA = user
            else:
                DATA = 'SEARCH'
            clean(temp, parent=parent)
        win.destroy()

    win = Toplevel()
    f1 = Frame(win)
    var1 = makeFormRowInt(f1, label='InvoiceNo', browse=False)
    var2 = makeFormRowInt(f1, label='CustomerID', browse=False)
    var3 = makeFormRow(f1, label='Country', browse=False)
    f2 = Frame(win)
    Button(f2, text='Ok', command=validate).pack(expand=YES, fill=X)
    Button(f2, text='Cancel', command=win.destroy).pack(expand=YES, fill=X)
    f1.grid(row=0, column=1)
    f2.grid(row=0, column=2)
    win.geometry("+%d+%d" %
                 (parent.winfo_rootx() + 50, parent.winfo_rootx() + 50))
    win.grab_set()
    win.focus_set()
    win.wait_window()
Beispiel #21
0
	def modify_item(self):
		index = self.listbox.curselection()
		if len(index) != 1:
			showerror('Error', 'Select one item to modify')
		else:
			label = self.listbox.get(index)
			
			win = Toplevel(self)
			win.title('Modify item')
			win.geometry('+100+100')
			
			item = fetch_item(label, self.pos_settings)
			var1 = makeFormRow(win, label='Enter the new name of the item', input=item.name, focus=True)
			var2 = makeFormRow(win, label='Enter the new price of the item', input=item.price)
			var3 = makeFormRow(win, label='Enter the new category of the item', input=item.cat)
			Button(win, text='Save', command=(lambda: Item().modify_item(oldname= label, name=var1.get(), price=var2.get(), cat=var3.get(), index=index, parent=win, listbox=self.listbox, menu=self.master))).pack(side=LEFT, expand=YES, fill=X)
			Button(win, text='Cancel', command=win.destroy).pack(side=RIGHT, expand=YES, fill=X)

			win.bind('<Return>', lambda event: Item().modify_item(oldname= label, name=var1.get(), price=var2.get(), cat=var3.get(), index=index, parent=win, listbox=self.listbox, menu=self.master))
		self.grab_set()
		self.focus_set()
		self.wait_window()
Beispiel #22
0
	def add_product(self, products):
		win = Toplevel(self)
		win.title('Add product')
		win.geometry('+100+100')

		var1 = makeFormRow(win, label='Enter the name of the product', focus=True)
		var2 = makeFormRow(win, label='Enter the quantity of the item[pieces/volume/wieght]')
		var3, ent3 = makeFormRow(win, label='Enter the purchase data of the item[YYYY-MM-DD]', date=True)
		var4, ent4 = makeFormRow(win, label='Enter the expiration data of the item[YYYY-MM-DD]', date=True)

		date_entries = [[var3, ent3], [var4, ent4]]

		Button(win, text='Save', command=(lambda: Storage().add_product(name=var1.get(), quantity=var2.get(), pur_data=var3.get(), exp_data=var4.get(), products=products, parent=win, listbox=self.listbox))).pack(side=LEFT, expand=YES, fill=X)
		Button(win, text='Cancel', command=win.destroy).pack(side=RIGHT, expand=YES, fill=X)
		win.bind('<Return>', lambda event: Storage().add_product(name=var1.get(), quantity=var2.get(), pur_data=var3.get(), exp_data=var4.get(), products=products, parent=win, listbox=self.listbox))
		for var, ent in date_entries:
			ent.bind('<Double-Button-1>', lambda event, var=var: self.focusin(event, var))
		win.grab_set()
		win.focus_set()
		win.wait_window()
		self.grab_set()
		self.focus_set()
		self.wait_window()
Beispiel #23
0
	def sell(self): #all data in Item, Formula, Storage instances are strings
		def add(label, amount, pay, unit_price, sign, tp):
			label = label['text'][:-1]
			i = int(amount.get()) #get current quantity
			i += sign # add or subtract this item
			formula = Formula(label).get_formula(silence=True)
			avaiable = Storage().check_product(formula, name, self.products_to_use, sign)
			if avaiable:
				self.bills[bill_index][name] += 1
				price = round(unit_price * i, 2) #new price #better round in progress
				amount.set(i) #set new amount
				pay.set(price) #set new price to pay
				temp = round(tp.get() + sign * unit_price, 2) #new total price[tp] for bill #better round in progress
				tp.set(temp) #set new tp
			
		def subtract(label, amount, pay, unit_price, sign, tp):
			label = label['text'][:-1]
			i = int(amount.get()) #get current quantity
			if i == 0:
				price = unit_price * i
				amount.set(i)
				pay.set(price)
				temp = round(tp.get() + price, 2) #better round in progress
				tp.set(temp)
			else:
				i += sign 
				formula = Formula(label).get_formula(silence=True)
				avaiable = Storage().check_product(formula, name, self.products_to_use, sign)
				self.bills[bill_index][name] -= 1
				price = unit_price * i 
				amount.set(i) 
				pay.set(price) 
				temp = round(tp.get() + price, 2)  #better round in progress
				tp.set(temp) 

		bill_index = self.bill_num.get()
		if list(self.bills[bill_index].keys()) == []:
			showerror('Error', 'Add items to bill')
			return False
		win = Toplevel(self)
		win.title('Summary Bill' + str(bill_index))
		win.geometry('+90+90')
		total = Label(win, text="Total:")
		tp = DoubleVar()
		total_price = Entry(win, textvariable=tp)
		order = []
		changes = []
		price_all = []
		try:
			for name in self.bills[bill_index]:
				item = Item(name).get_item()
				summary = [name, self.bills[bill_index][name], float(item.price)] #[name, quantity, unit_price]
				label, amount, pay, row = makeFormRow(win, label=summary[0], unit_price=summary[2], input=summary[1], extended=True, width=20)
				Button(row, text='+', command=lambda label=label, amount=amount, pay=pay, unit_price=summary[2], tp=tp: add(label, amount, pay, unit_price, 1, tp), relief=RIDGE).pack(side=LEFT)
				Button(row, text='-', command=lambda label=label, amount=amount, pay=pay, unit_price=summary[2], tp=tp: subtract(label, amount, pay, unit_price, -1, tp), relief=RIDGE).pack(side=LEFT)
				order.append(summary)
				changes.append(amount)
				price_all.append(pay)
		except SyntaxError:
			showerror('Error', "Check if items price is a number")
		total_price_label = sum(list(map(lambda x: x.get(), price_all)))
		tp.set(round(total_price_label, 2)) #better round in progress
		total_price.pack(side=RIGHT)
		total.pack(side=RIGHT)
		Button(win, text='Submit', command=lambda: self.submit_sell(win, order, changes)).pack(side=LEFT, fill=X)
		Button(win, text='Cancel', command=win.destroy).pack(side=LEFT, fill=X)
		win.grab_set()
		win.focus_set()
		win.wait_window()